Pass binder identity through sendExtraCommand
Allow providers to see the identity of the caller of sendExtraCommand and update documentation. Bug: 116799964 Test: Presubmits Change-Id: Ibb63dc3ce223bc1e3ae89e65cf2973a3619c057f
This commit is contained in:
@@ -48,6 +48,7 @@ import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.location.ProviderProperties;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -2298,18 +2299,19 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends additional commands to a location provider.
|
||||
* Can be used to support provider specific extensions to the Location Manager API
|
||||
* Sends additional commands to a location provider. Can be used to support provider specific
|
||||
* extensions to the Location Manager API.
|
||||
*
|
||||
* @param provider name of the location provider.
|
||||
* @param command name of the command to send to the provider.
|
||||
* @param extras optional arguments for the command (or null).
|
||||
* The provider may optionally fill the extras Bundle with results from the command.
|
||||
*
|
||||
* @return true if the command succeeds.
|
||||
* @param command name of the command to send to the provider.
|
||||
* @param extras optional arguments for the command (or null).
|
||||
* @return true always
|
||||
*/
|
||||
public boolean sendExtraCommand(
|
||||
@NonNull String provider, @NonNull String command, @Nullable Bundle extras) {
|
||||
Preconditions.checkArgument(provider != null, "invalid null provider");
|
||||
Preconditions.checkArgument(command != null, "invalid null command");
|
||||
|
||||
try {
|
||||
return mService.sendExtraCommand(provider, command, extras);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -1098,12 +1098,9 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
@GuardedBy("mLock")
|
||||
public void sendExtraCommandLocked(String command, Bundle extras) {
|
||||
if (mProvider != null) {
|
||||
long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mProvider.sendExtraCommand(command, extras);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
// intentionally do not clear binder identity so that providers can evaluate who
|
||||
// is sending the extra command
|
||||
mProvider.sendExtraCommand(command, extras);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,9 @@ public abstract class AbstractLocationProvider {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Sends a custom command to this provider. */
|
||||
/**
|
||||
* Sends a custom command to this provider. Called with the original binder identity of the
|
||||
* caller.
|
||||
*/
|
||||
public abstract void sendExtraCommand(String command, Bundle extras);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user