Loading location/java/android/location/ILocationListener.aidl +2 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,6 @@ oneway interface ILocationListener void onProviderEnabled(String provider); @UnsupportedAppUsage void onProviderDisabled(String provider); // --- deprecated --- @UnsupportedAppUsage void onStatusChanged(String provider, int status, in Bundle extras); // called when the listener is removed from the server side; no further callbacks are expected void onRemoved(); } location/java/android/location/LocationManager.java +13 −34 Original line number Diff line number Diff line Loading @@ -2480,9 +2480,6 @@ public class LocationManager { deliverResult(location); } @Override public void onStatusChanged(String provider, int status, Bundle extras) {} @Override public void onProviderEnabled(String provider) {} Loading @@ -2493,6 +2490,11 @@ public class LocationManager { deliverResult(null); } @Override public void onRemoved() { deliverResult(null); } private synchronized void deliverResult(@Nullable Location location) { if (mExecutor == null) { return; Loading Loading @@ -2567,37 +2569,6 @@ public class LocationManager { } } @Override public void onStatusChanged(String provider, int status, Bundle extras) { Executor currentExecutor = mExecutor; if (currentExecutor == null) { return; } try { currentExecutor.execute(() -> { try { if (currentExecutor != mExecutor) { return; } // we may be under the binder identity if a direct executor is used long identity = Binder.clearCallingIdentity(); try { mListener.onStatusChanged(provider, status, extras); } finally { Binder.restoreCallingIdentity(identity); } } finally { locationCallbackFinished(); } }); } catch (RejectedExecutionException e) { locationCallbackFinished(); throw e; } } @Override public void onProviderEnabled(String provider) { Executor currentExecutor = mExecutor; Loading Loading @@ -2660,6 +2631,14 @@ public class LocationManager { } } @Override public void onRemoved() { unregister(); synchronized (mListeners) { mListeners.remove(mListener, this); } } private void locationCallbackFinished() { try { mService.locationCallbackFinished(this); Loading services/core/java/com/android/server/LocationManagerService.java +12 −0 Original line number Diff line number Diff line Loading @@ -1478,6 +1478,16 @@ public class LocationManagerService extends ILocationManager.Stub { return true; } public void callRemovedLocked() { if (mListener != null) { try { mListener.onRemoved(); } catch (RemoteException e) { // doesn't matter } } } @Override public void binderDied() { if (D) Log.d(TAG, "Remote " + mListenerName + " died."); Loading Loading @@ -3091,6 +3101,8 @@ public class LocationManagerService extends ILocationManager.Stub { // track expired records if (r.mRealRequest.getNumUpdates() <= 0 || r.mRealRequest.getExpireAt() < now) { // notify the client it can remove this listener r.mReceiver.callRemovedLocked(); if (deadUpdateRecords == null) { deadUpdateRecords = new ArrayList<>(); } Loading Loading
location/java/android/location/ILocationListener.aidl +2 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,6 @@ oneway interface ILocationListener void onProviderEnabled(String provider); @UnsupportedAppUsage void onProviderDisabled(String provider); // --- deprecated --- @UnsupportedAppUsage void onStatusChanged(String provider, int status, in Bundle extras); // called when the listener is removed from the server side; no further callbacks are expected void onRemoved(); }
location/java/android/location/LocationManager.java +13 −34 Original line number Diff line number Diff line Loading @@ -2480,9 +2480,6 @@ public class LocationManager { deliverResult(location); } @Override public void onStatusChanged(String provider, int status, Bundle extras) {} @Override public void onProviderEnabled(String provider) {} Loading @@ -2493,6 +2490,11 @@ public class LocationManager { deliverResult(null); } @Override public void onRemoved() { deliverResult(null); } private synchronized void deliverResult(@Nullable Location location) { if (mExecutor == null) { return; Loading Loading @@ -2567,37 +2569,6 @@ public class LocationManager { } } @Override public void onStatusChanged(String provider, int status, Bundle extras) { Executor currentExecutor = mExecutor; if (currentExecutor == null) { return; } try { currentExecutor.execute(() -> { try { if (currentExecutor != mExecutor) { return; } // we may be under the binder identity if a direct executor is used long identity = Binder.clearCallingIdentity(); try { mListener.onStatusChanged(provider, status, extras); } finally { Binder.restoreCallingIdentity(identity); } } finally { locationCallbackFinished(); } }); } catch (RejectedExecutionException e) { locationCallbackFinished(); throw e; } } @Override public void onProviderEnabled(String provider) { Executor currentExecutor = mExecutor; Loading Loading @@ -2660,6 +2631,14 @@ public class LocationManager { } } @Override public void onRemoved() { unregister(); synchronized (mListeners) { mListeners.remove(mListener, this); } } private void locationCallbackFinished() { try { mService.locationCallbackFinished(this); Loading
services/core/java/com/android/server/LocationManagerService.java +12 −0 Original line number Diff line number Diff line Loading @@ -1478,6 +1478,16 @@ public class LocationManagerService extends ILocationManager.Stub { return true; } public void callRemovedLocked() { if (mListener != null) { try { mListener.onRemoved(); } catch (RemoteException e) { // doesn't matter } } } @Override public void binderDied() { if (D) Log.d(TAG, "Remote " + mListenerName + " died."); Loading Loading @@ -3091,6 +3101,8 @@ public class LocationManagerService extends ILocationManager.Stub { // track expired records if (r.mRealRequest.getNumUpdates() <= 0 || r.mRealRequest.getExpireAt() < now) { // notify the client it can remove this listener r.mReceiver.callRemovedLocked(); if (deadUpdateRecords == null) { deadUpdateRecords = new ArrayList<>(); } Loading