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
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user