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

Commit 7cbcca68 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass binder identity through sendExtraCommand"

parents 5418160c ad6b6187
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);
}