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

Commit eebd2767 authored by Eugene Susla's avatar Eugene Susla
Browse files

Fix companion uses-permission enforcement

Fixes: b/62662686
Test: Call CompanionDeviceManager#associate from app without uses-permission
declaration
Ensure exception is thrown

Call the method from app with the declaration
Ensure no exception is thrown

In debug mode catch the #isCallerSystem call from NotificationManagerService 
(which runs in the system process) and ensure it passes the check
Change-Id: I26e5d2a7f5e63a346d4ab50b9ded1ec7dbc246a5
parent ffd8343b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.os.IBinder;
import android.os.IDeviceIdleController;
import android.os.IInterface;
import android.os.Parcel;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
@@ -345,7 +346,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
    }

    private static boolean isCallerSystem() {
        return getCallingUserId() == UserHandle.USER_SYSTEM;
        return Binder.getCallingUid() == Process.SYSTEM_UID;
    }

    private ServiceConnection createServiceConnection(