1 /*
2  * Copyright (C) 2007, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.location;
18 
19 import android.app.PendingIntent;
20 import android.location.Address;
21 import android.location.Criteria;
22 import android.location.GeocoderParams;
23 import android.location.Geofence;
24 import android.location.GnssAntennaInfo;
25 import android.location.GnssCapabilities;
26 import android.location.GnssMeasurementCorrections;
27 import android.location.GnssMeasurementRequest;
28 import android.location.IGeocodeListener;
29 import android.location.IGnssAntennaInfoListener;
30 import android.location.IGnssMeasurementsListener;
31 import android.location.IGnssStatusListener;
32 import android.location.IGnssNavigationMessageListener;
33 import android.location.IGnssNmeaListener;
34 import android.location.ILocationCallback;
35 import android.location.ILocationListener;
36 import android.location.LastLocationRequest;
37 import android.location.Location;
38 import android.location.LocationRequest;
39 import android.location.LocationTime;
40 import android.location.provider.IProviderRequestListener;
41 import android.location.provider.ProviderProperties;
42 import android.os.Bundle;
43 import android.os.ICancellationSignal;
44 import android.os.PackageTagsList;
45 
46 /**
47  * System private API for talking with the location service.
48  *
49  * @hide
50  */
51 interface ILocationManager
52 {
getLastLocation(String provider, in LastLocationRequest request, String packageName, @nullable String attributionTag)53     @nullable Location getLastLocation(String provider, in LastLocationRequest request, String packageName, @nullable String attributionTag);
getCurrentLocation(String provider, in LocationRequest request, in ILocationCallback callback, String packageName, @nullable String attributionTag, String listenerId)54     @nullable ICancellationSignal getCurrentLocation(String provider, in LocationRequest request, in ILocationCallback callback, String packageName, @nullable String attributionTag, String listenerId);
55 
registerLocationListener(String provider, in LocationRequest request, in ILocationListener listener, String packageName, @nullable String attributionTag, String listenerId)56     void registerLocationListener(String provider, in LocationRequest request, in ILocationListener listener, String packageName, @nullable String attributionTag, String listenerId);
unregisterLocationListener(in ILocationListener listener)57     void unregisterLocationListener(in ILocationListener listener);
58 
registerLocationPendingIntent(String provider, in LocationRequest request, in PendingIntent pendingIntent, String packageName, @nullable String attributionTag)59     void registerLocationPendingIntent(String provider, in LocationRequest request, in PendingIntent pendingIntent, String packageName, @nullable String attributionTag);
unregisterLocationPendingIntent(in PendingIntent pendingIntent)60     void unregisterLocationPendingIntent(in PendingIntent pendingIntent);
61 
62     @EnforcePermission(allOf={"LOCATION_HARDWARE", "ACCESS_FINE_LOCATION"})
injectLocation(in Location location)63     void injectLocation(in Location location);
64 
requestListenerFlush(String provider, in ILocationListener listener, int requestCode)65     void requestListenerFlush(String provider, in ILocationListener listener, int requestCode);
requestPendingIntentFlush(String provider, in PendingIntent pendingIntent, int requestCode)66     void requestPendingIntentFlush(String provider, in PendingIntent pendingIntent, int requestCode);
67 
requestGeofence(in Geofence geofence, in PendingIntent intent, String packageName, String attributionTag)68     void requestGeofence(in Geofence geofence, in PendingIntent intent, String packageName, String attributionTag);
removeGeofence(in PendingIntent intent)69     void removeGeofence(in PendingIntent intent);
70 
geocoderIsPresent()71     boolean geocoderIsPresent();
getFromLocation(double latitude, double longitude, int maxResults, in GeocoderParams params, in IGeocodeListener listener)72     void getFromLocation(double latitude, double longitude, int maxResults,
73         in GeocoderParams params, in IGeocodeListener listener);
getFromLocationName(String locationName, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, int maxResults, in GeocoderParams params, in IGeocodeListener listener)74     void getFromLocationName(String locationName,
75         double lowerLeftLatitude, double lowerLeftLongitude,
76         double upperRightLatitude, double upperRightLongitude, int maxResults,
77         in GeocoderParams params, in IGeocodeListener listener);
78 
getGnssCapabilities()79     GnssCapabilities getGnssCapabilities();
getGnssYearOfHardware()80     int getGnssYearOfHardware();
getGnssHardwareModelName()81     String getGnssHardwareModelName();
82 
getGnssAntennaInfos()83     @nullable List<GnssAntennaInfo> getGnssAntennaInfos();
84 
registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, @nullable String attributionTag, String listenerId)85     void registerGnssStatusCallback(in IGnssStatusListener callback, String packageName, @nullable String attributionTag, String listenerId);
unregisterGnssStatusCallback(in IGnssStatusListener callback)86     void unregisterGnssStatusCallback(in IGnssStatusListener callback);
87 
registerGnssNmeaCallback(in IGnssNmeaListener callback, String packageName, @nullable String attributionTag, String listenerId)88     void registerGnssNmeaCallback(in IGnssNmeaListener callback, String packageName, @nullable String attributionTag, String listenerId);
unregisterGnssNmeaCallback(in IGnssNmeaListener callback)89     void unregisterGnssNmeaCallback(in IGnssNmeaListener callback);
90 
addGnssMeasurementsListener(in GnssMeasurementRequest request, in IGnssMeasurementsListener listener, String packageName, @nullable String attributionTag, String listenerId)91     void addGnssMeasurementsListener(in GnssMeasurementRequest request, in IGnssMeasurementsListener listener, String packageName, @nullable String attributionTag, String listenerId);
removeGnssMeasurementsListener(in IGnssMeasurementsListener listener)92     void removeGnssMeasurementsListener(in IGnssMeasurementsListener listener);
injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections)93     void injectGnssMeasurementCorrections(in GnssMeasurementCorrections corrections);
94 
addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, @nullable String attributionTag, String listenerId)95     void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, @nullable String attributionTag, String listenerId);
removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener)96     void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener);
97 
addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, @nullable String attributionTag, String listenerId)98     void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, @nullable String attributionTag, String listenerId);
removeGnssAntennaInfoListener(in IGnssAntennaInfoListener listener)99     void removeGnssAntennaInfoListener(in IGnssAntennaInfoListener listener);
100 
addProviderRequestListener(in IProviderRequestListener listener)101     void addProviderRequestListener(in IProviderRequestListener listener);
removeProviderRequestListener(in IProviderRequestListener listener)102     void removeProviderRequestListener(in IProviderRequestListener listener);
103 
getGnssBatchSize()104     int getGnssBatchSize();
startGnssBatch(long periodNanos, in ILocationListener listener, String packageName, @nullable String attributionTag, String listenerId)105     void startGnssBatch(long periodNanos, in ILocationListener listener, String packageName, @nullable String attributionTag, String listenerId);
flushGnssBatch()106     void flushGnssBatch();
stopGnssBatch()107     void stopGnssBatch();
108 
hasProvider(String provider)109     boolean hasProvider(String provider);
getAllProviders()110     List<String> getAllProviders();
getProviders(in Criteria criteria, boolean enabledOnly)111     List<String> getProviders(in Criteria criteria, boolean enabledOnly);
getBestProvider(in Criteria criteria, boolean enabledOnly)112     String getBestProvider(in Criteria criteria, boolean enabledOnly);
getProviderProperties(String provider)113     ProviderProperties getProviderProperties(String provider);
isProviderPackage(@ullable String provider, String packageName, @nullable String attributionTag)114     boolean isProviderPackage(@nullable String provider, String packageName, @nullable String attributionTag);
getProviderPackages(String provider)115     List<String> getProviderPackages(String provider);
116 
117     @EnforcePermission("LOCATION_HARDWARE")
setExtraLocationControllerPackage(String packageName)118     void setExtraLocationControllerPackage(String packageName);
getExtraLocationControllerPackage()119     String getExtraLocationControllerPackage();
120     @EnforcePermission("LOCATION_HARDWARE")
setExtraLocationControllerPackageEnabled(boolean enabled)121     void setExtraLocationControllerPackageEnabled(boolean enabled);
isExtraLocationControllerPackageEnabled()122     boolean isExtraLocationControllerPackageEnabled();
123 
isProviderEnabledForUser(String provider, int userId)124     boolean isProviderEnabledForUser(String provider, int userId);
isLocationEnabledForUser(int userId)125     boolean isLocationEnabledForUser(int userId);
setLocationEnabledForUser(boolean enabled, int userId)126     void setLocationEnabledForUser(boolean enabled, int userId);
127 
isAdasGnssLocationEnabledForUser(int userId)128     boolean isAdasGnssLocationEnabledForUser(int userId);
setAdasGnssLocationEnabledForUser(boolean enabled, int userId)129     void setAdasGnssLocationEnabledForUser(boolean enabled, int userId);
130 
131     @EnforcePermission("CONTROL_AUTOMOTIVE_GNSS")
isAutomotiveGnssSuspended()132     boolean isAutomotiveGnssSuspended();
133     @EnforcePermission("CONTROL_AUTOMOTIVE_GNSS")
setAutomotiveGnssSuspended(boolean suspended)134     void setAutomotiveGnssSuspended(boolean suspended);
135 
addTestProvider(String name, in ProviderProperties properties, in List<String> locationTags, String packageName, @nullable String attributionTag)136     void addTestProvider(String name, in ProviderProperties properties,
137         in List<String> locationTags, String packageName, @nullable String attributionTag);
removeTestProvider(String provider, String packageName, @nullable String attributionTag)138     void removeTestProvider(String provider, String packageName, @nullable String attributionTag);
setTestProviderLocation(String provider, in Location location, String packageName, @nullable String attributionTag)139     void setTestProviderLocation(String provider, in Location location, String packageName, @nullable String attributionTag);
setTestProviderEnabled(String provider, boolean enabled, String packageName, @nullable String attributionTag)140     void setTestProviderEnabled(String provider, boolean enabled, String packageName, @nullable String attributionTag);
141 
getGnssTimeMillis()142     LocationTime getGnssTimeMillis();
143 
sendExtraCommand(String provider, String command, inout Bundle extras)144     void sendExtraCommand(String provider, String command, inout Bundle extras);
145 
146     // used by gts tests to verify whitelists
getBackgroundThrottlingWhitelist()147     String[] getBackgroundThrottlingWhitelist();
getIgnoreSettingsAllowlist()148     PackageTagsList getIgnoreSettingsAllowlist();
getAdasAllowlist()149     PackageTagsList getAdasAllowlist();
150 }
151