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

Commit 9b539032 authored by Guojing Yuan's avatar Guojing Yuan Committed by Android Build Coastguard Worker
Browse files

[CDM][CMD] Check permissions for CDM shell commands

Override handleShellCommand instead of onShellCommand because
Binder.onShellCommand checks the necessary permissions of the caller.

Bug: 313428840

Test: manually tested CDM shell commands
(cherry picked from commit 1761a0fe)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:eb68b0d423afb55159b1c02b0897f597c0905916)
Merged-In: I5539b3594feb5544c458c0fd1061b51a0a808900
Change-Id: I5539b3594feb5544c458c0fd1061b51a0a808900
parent 4432d030
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -86,12 +86,11 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.PowerWhitelistManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.ShellCallback;
import android.os.ShellCommand;
import android.os.UserHandle;
import android.os.UserManager;
@@ -700,10 +699,12 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }

        @Override
        public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
                String[] args, ShellCallback callback, ResultReceiver resultReceiver)
                throws RemoteException {
            new ShellCmd().exec(this, in, out, err, args, callback, resultReceiver);
        public int handleShellCommand(@NonNull ParcelFileDescriptor in,
                @NonNull ParcelFileDescriptor out, @NonNull ParcelFileDescriptor err,
                @NonNull String[] args) {
            return new ShellCmd()
                    .exec(this, in.getFileDescriptor(), out.getFileDescriptor(),
                            err.getFileDescriptor(), args);
        }

        @Override