OSDN Git Service

RESTRICT AUTOMERGE
authorEugene Susla <eugenesusla@google.com>
Thu, 28 Mar 2019 20:50:17 +0000 (13:50 -0700)
committerAnis Assi <anisassi@google.com>
Tue, 28 Apr 2020 19:41:29 +0000 (12:41 -0700)
Prevent accessing companion records from arbitrary uids

Test: manual
Fixes: 129476618
Change-Id: I7b18cfcdf58e62a445cbb508116c6ce7c1cea8d7
(cherry picked from commit 84cccfe6cdbc57ee372ee1a0fea64c7a11c53766)

core/res/AndroidManifest.xml
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java

index 66c497e..e81268b 100644 (file)
     <permission android:name="android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS"
         android:protectionLevel="signature|privileged" />
 
+    <!-- Allows an application to manage the companion devices.
+         @hide -->
+    <permission android:name="android.permission.MANAGE_COMPANION_DEVICES"
+                android:protectionLevel="signature" />
+
     <!-- @SystemApi Allows an application to use SurfaceFlinger's low level features.
          <p>Not for use by third-party applications.
          @hide
index d44fe4d..bf2b83b 100644 (file)
@@ -629,6 +629,11 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                 + "associate USER_ID PACKAGE MAC_ADDRESS\n"
                 + "disassociate USER_ID PACKAGE MAC_ADDRESS";
 
+        ShellCmd() {
+            getContext().enforceCallingOrSelfPermission(
+                    android.Manifest.permission.MANAGE_COMPANION_DEVICES, "ShellCmd");
+        }
+
         @Override
         public int onCommand(String cmd) {
             switch (cmd) {