Nullcheck device profile when re-granting on package change

Test: presubmit
Fixes: 176250389
Change-Id: I9c4e071b12335fdfc1177ab60e03002ae2704cc3
This commit is contained in:
Eugene Susla
2020-12-23 18:14:15 -08:00
parent 65144f2e3d
commit d170c5c7f3

View File

@@ -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) {