Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad6b6187 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

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
parent 82e696d5
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -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.
     * @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) {
+3 −6
Original line number Diff line number Diff line
@@ -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 {
                // intentionally do not clear binder identity so that providers can evaluate who
                // is sending the extra command
                mProvider.sendExtraCommand(command, extras);
                } finally {
                    Binder.restoreCallingIdentity(identity);
                }
            }
        }

+4 −1
Original line number Diff line number Diff line
@@ -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);
}