Merge "Nullcheck device profile when re-granting on package change"

This commit is contained in:
Eugene Susla
2020-12-24 05:51:20 +00:00
committed by Android (Google) Code Review

View File

@@ -872,20 +872,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) {