1717package android .location ;
1818
1919import android .app .PendingIntent ;
20+ import android .content .Context ;
2021import android .content .Intent ;
2122import android .os .Bundle ;
2223import android .os .Looper ;
@@ -160,6 +161,8 @@ public class LocationManager {
160161 */
161162 public static final String EXTRA_GPS_ENABLED = "enabled" ;
162163
164+ private final Context mContext ;
165+
163166 // Map from LocationListeners to their associated ListenerTransport objects
164167 private HashMap <LocationListener ,ListenerTransport > mListeners =
165168 new HashMap <LocationListener ,ListenerTransport >();
@@ -260,8 +263,9 @@ private void _handleMessage(Message msg) {
260263 * right way to create an instance of this class is using the
261264 * factory Context.getSystemService.
262265 */
263- public LocationManager (ILocationManager service ) {
266+ public LocationManager (Context context , ILocationManager service ) {
264267 mService = service ;
268+ mContext = context ;
265269 }
266270
267271 private LocationProvider createProvider (String name , Bundle info ) {
@@ -657,7 +661,8 @@ private void _requestLocationUpdates(String provider, Criteria criteria, long mi
657661 transport = new ListenerTransport (listener , looper );
658662 }
659663 mListeners .put (listener , transport );
660- mService .requestLocationUpdates (provider , criteria , minTime , minDistance , singleShot , transport );
664+ mService .requestLocationUpdates (provider , criteria , minTime , minDistance ,
665+ singleShot , transport , mContext .getPackageName ());
661666 }
662667 } catch (RemoteException ex ) {
663668 Log .e (TAG , "requestLocationUpdates: DeadObjectException" , ex );
@@ -837,7 +842,8 @@ private void _requestLocationUpdates(String provider, Criteria criteria,
837842 }
838843
839844 try {
840- mService .requestLocationUpdatesPI (provider , criteria , minTime , minDistance , singleShot , intent );
845+ mService .requestLocationUpdatesPI (provider , criteria , minTime , minDistance , singleShot ,
846+ intent , mContext .getPackageName ());
841847 } catch (RemoteException ex ) {
842848 Log .e (TAG , "requestLocationUpdates: RemoteException" , ex );
843849 }
@@ -1005,7 +1011,7 @@ public void removeUpdates(LocationListener listener) {
10051011 try {
10061012 ListenerTransport transport = mListeners .remove (listener );
10071013 if (transport != null ) {
1008- mService .removeUpdates (transport );
1014+ mService .removeUpdates (transport , mContext . getPackageName () );
10091015 }
10101016 } catch (RemoteException ex ) {
10111017 Log .e (TAG , "removeUpdates: DeadObjectException" , ex );
@@ -1028,7 +1034,7 @@ public void removeUpdates(PendingIntent intent) {
10281034 Log .d (TAG , "removeUpdates: intent = " + intent );
10291035 }
10301036 try {
1031- mService .removeUpdatesPI (intent );
1037+ mService .removeUpdatesPI (intent , mContext . getPackageName () );
10321038 } catch (RemoteException ex ) {
10331039 Log .e (TAG , "removeUpdates: RemoteException" , ex );
10341040 }
@@ -1087,7 +1093,7 @@ public void addProximityAlert(double latitude, double longitude,
10871093 }
10881094 try {
10891095 mService .addProximityAlert (latitude , longitude , radius ,
1090- expiration , intent );
1096+ expiration , intent , mContext . getPackageName () );
10911097 } catch (RemoteException ex ) {
10921098 Log .e (TAG , "addProximityAlert: RemoteException" , ex );
10931099 }
@@ -1153,7 +1159,7 @@ public Location getLastKnownLocation(String provider) {
11531159 throw new IllegalArgumentException ("provider==null" );
11541160 }
11551161 try {
1156- return mService .getLastKnownLocation (provider );
1162+ return mService .getLastKnownLocation (provider , mContext . getPackageName () );
11571163 } catch (RemoteException ex ) {
11581164 Log .e (TAG , "getLastKnowLocation: RemoteException" , ex );
11591165 return null ;
0 commit comments