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

Commit 1761a0fe authored by Guojing Yuan's avatar Guojing Yuan
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
Change-Id: I5539b3594feb5544c458c0fd1061b51a0a808900
parent 3bef74d0
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -93,9 +93,7 @@ import android.os.ParcelFileDescriptor;
import android.os.PowerWhitelistManager;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.ShellCallback;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
@@ -1064,13 +1062,14 @@ public class CompanionDeviceManagerService extends SystemService {
        }

        @Override
        public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
                String[] args, ShellCallback callback, ResultReceiver resultReceiver)
                throws RemoteException {
            new CompanionDeviceShellCommand(CompanionDeviceManagerService.this, mAssociationStore,
                    mDevicePresenceMonitor, mTransportManager, mSystemDataTransferProcessor,
                    mAssociationRequestsProcessor)
                    .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 CompanionDeviceShellCommand(CompanionDeviceManagerService.this,
                    mAssociationStore, mDevicePresenceMonitor, mTransportManager,
                    mSystemDataTransferProcessor, mAssociationRequestsProcessor)
                    .exec(this, in.getFileDescriptor(), out.getFileDescriptor(),
                            err.getFileDescriptor(), args);
        }

        @Override