Nullcheck device profile when re-granting on package change
Test: presubmit Fixes: 176250389 Change-Id: I9c4e071b12335fdfc1177ab60e03002ae2704cc3
This commit is contained in:
@@ -867,20 +867,22 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
||||
}
|
||||
|
||||
private void grantDeviceProfile(Association association) {
|
||||
mRoleManager.addRoleHolderAsUser(
|
||||
association.getDeviceProfile(),
|
||||
association.getPackageName(),
|
||||
RoleManager.MANAGE_HOLDERS_FLAG_DONT_KILL_APP,
|
||||
UserHandle.of(association.getUserId()),
|
||||
getContext().getMainExecutor(),
|
||||
success -> {
|
||||
if (!success) {
|
||||
Log.e(LOG_TAG, "Failed to grant device profile role "
|
||||
+ association.getDeviceProfile()
|
||||
+ " to " + association.getPackageName()
|
||||
+ " for user " + association.getUserId());
|
||||
}
|
||||
});
|
||||
if (association.getDeviceProfile() != null) {
|
||||
mRoleManager.addRoleHolderAsUser(
|
||||
association.getDeviceProfile(),
|
||||
association.getPackageName(),
|
||||
RoleManager.MANAGE_HOLDERS_FLAG_DONT_KILL_APP,
|
||||
UserHandle.of(association.getUserId()),
|
||||
getContext().getMainExecutor(),
|
||||
success -> {
|
||||
if (!success) {
|
||||
Log.e(LOG_TAG, "Failed to grant device profile role "
|
||||
+ association.getDeviceProfile()
|
||||
+ " to " + association.getPackageName()
|
||||
+ " for user " + association.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onDeviceDisconnected(String address) {
|
||||
|
||||
Reference in New Issue
Block a user