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

Commit 6eae4a6a authored by Eugene Susla's avatar Eugene Susla
Browse files

Prevent accessing companion records from arbitrary uids

Test: manual
Fixes: 129476618
Change-Id: I7b18cfcdf58e62a445cbb508116c6ce7c1cea8d7
parent b4264999
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -3452,6 +3452,11 @@
    <permission android:name="android.permission.OBSERVE_ROLE_HOLDERS"
    <permission android:name="android.permission.OBSERVE_ROLE_HOLDERS"
                android:protectionLevel="signature|installer" />
                android:protectionLevel="signature|installer" />


    <!-- 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.
    <!-- @SystemApi Allows an application to use SurfaceFlinger's low level features.
         <p>Not for use by third-party applications.
         <p>Not for use by third-party applications.
         @hide
         @hide
+1 −0
Original line number Original line Diff line number Diff line
@@ -172,6 +172,7 @@
    <uses-permission android:name="android.permission.READ_CLIPBOARD_IN_BACKGROUND" />
    <uses-permission android:name="android.permission.READ_CLIPBOARD_IN_BACKGROUND" />
    <!-- Permission needed to wipe the device for Test Harness Mode -->
    <!-- Permission needed to wipe the device for Test Harness Mode -->
    <uses-permission android:name="android.permission.ENABLE_TEST_HARNESS_MODE" />
    <uses-permission android:name="android.permission.ENABLE_TEST_HARNESS_MODE" />
    <uses-permission android:name="android.permission.MANAGE_COMPANION_DEVICES" />


    <uses-permission android:name="android.permission.MANAGE_APPOPS" />
    <uses-permission android:name="android.permission.MANAGE_APPOPS" />


+5 −0
Original line number Original line Diff line number Diff line
@@ -632,6 +632,11 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                + "associate USER_ID PACKAGE MAC_ADDRESS\n"
                + "associate USER_ID PACKAGE MAC_ADDRESS\n"
                + "disassociate USER_ID PACKAGE MAC_ADDRESS";
                + "disassociate USER_ID PACKAGE MAC_ADDRESS";


        ShellCmd() {
            getContext().enforceCallingOrSelfPermission(
                    android.Manifest.permission.MANAGE_COMPANION_DEVICES, "ShellCmd");
        }

        @Override
        @Override
        public int onCommand(String cmd) {
        public int onCommand(String cmd) {
            switch (cmd) {
            switch (cmd) {