2024-06-16 15:55:36 -04:00
|
|
|
From 42515cb6e3148d89efab6fd39537b874a3f29853 Mon Sep 17 00:00:00 2001
|
2024-06-13 15:08:09 -04:00
|
|
|
From: Guojing Yuan <guojing@google.com>
|
|
|
|
Date: Thu, 14 Dec 2023 19:30:04 +0000
|
2024-06-16 15:55:36 -04:00
|
|
|
Subject: [PATCH] Check permissions for CDM shell commands
|
2024-06-13 15:08:09 -04:00
|
|
|
|
|
|
|
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 1761a0fee9c2cd9787bbb7fbdbe30b4c2b03396e)
|
2024-06-16 15:55:36 -04:00
|
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8d008c61451dba86aa9f14c6bcd661db2cea4856)
|
2024-06-13 15:08:09 -04:00
|
|
|
Merged-In: I5539b3594feb5544c458c0fd1061b51a0a808900
|
|
|
|
Change-Id: I5539b3594feb5544c458c0fd1061b51a0a808900
|
|
|
|
---
|
2024-06-16 15:55:36 -04:00
|
|
|
.../companion/CompanionDeviceManagerService.java | 14 ++++++++------
|
|
|
|
1 file changed, 8 insertions(+), 6 deletions(-)
|
2024-06-13 15:08:09 -04:00
|
|
|
|
|
|
|
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
|
2024-06-16 15:55:36 -04:00
|
|
|
index 91c2abc024304..275f31f1b6eb0 100644
|
2024-06-13 15:08:09 -04:00
|
|
|
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
|
|
|
|
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
|
2024-06-16 15:55:36 -04:00
|
|
|
@@ -28,6 +28,7 @@
|
|
|
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
|
|
|
|
|
|
|
import android.annotation.CheckResult;
|
|
|
|
+import android.annotation.NonNull;
|
|
|
|
import android.annotation.Nullable;
|
|
|
|
import android.app.AppOpsManager;
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
@@ -52,11 +53,10 @@
|
|
|
|
import android.os.IDeviceIdleController;
|
|
|
|
import android.os.IInterface;
|
2024-06-13 15:08:09 -04:00
|
|
|
import android.os.Parcel;
|
|
|
|
+import android.os.ParcelFileDescriptor;
|
2024-06-16 15:55:36 -04:00
|
|
|
import android.os.Process;
|
2024-06-13 15:08:09 -04:00
|
|
|
import android.os.RemoteException;
|
|
|
|
-import android.os.ResultReceiver;
|
|
|
|
import android.os.ServiceManager;
|
|
|
|
-import android.os.ShellCallback;
|
2024-06-16 15:55:36 -04:00
|
|
|
import android.os.ShellCommand;
|
2024-06-13 15:08:09 -04:00
|
|
|
import android.os.UserHandle;
|
2024-06-16 15:55:36 -04:00
|
|
|
import android.os.UserManagerInternal;
|
|
|
|
@@ -455,10 +455,12 @@ private void checkUsesFeature(String pkg, int userId) {
|
2024-06-13 15:08:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
|
|
|
|
- String[] args, ShellCallback callback, ResultReceiver resultReceiver)
|
|
|
|
- throws RemoteException {
|
2024-06-16 15:55:36 -04:00
|
|
|
- new ShellCmd().exec(this, in, out, err, args, callback, resultReceiver);
|
2024-06-13 15:08:09 -04:00
|
|
|
+ public int handleShellCommand(@NonNull ParcelFileDescriptor in,
|
|
|
|
+ @NonNull ParcelFileDescriptor out, @NonNull ParcelFileDescriptor err,
|
|
|
|
+ @NonNull String[] args) {
|
2024-06-16 15:55:36 -04:00
|
|
|
+ return new ShellCmd()
|
2024-06-13 15:08:09 -04:00
|
|
|
+ .exec(this, in.getFileDescriptor(), out.getFileDescriptor(),
|
|
|
|
+ err.getFileDescriptor(), args);
|
|
|
|
}
|
2024-06-16 15:55:36 -04:00
|
|
|
}
|
2024-06-13 15:08:09 -04:00
|
|
|
|