Fix PermissionHelper NullPointerException
During the FOTA process, the app can be deleted depending on the situation. If the app is deleted, PackageInfo needs a null check because it can be returned null. Test: FOTA from S OS to T OS Test: System app is deleted by policy during FOTA process Test: Monitor notification permission migration. Change-Id: I72a69c3e8998f3182cec10dd1583020096204ad4
This commit is contained in:
@@ -257,9 +257,11 @@ public final class PermissionHelper {
|
||||
private boolean packageRequestsNotificationPermission(String packageName,
|
||||
@UserIdInt int userId) {
|
||||
try {
|
||||
String[] permissions = mPackageManager.getPackageInfo(packageName, GET_PERMISSIONS,
|
||||
userId).requestedPermissions;
|
||||
return ArrayUtils.contains(permissions, NOTIFICATION_PERMISSION);
|
||||
PackageInfo pi = mPackageManager.getPackageInfo(packageName, GET_PERMISSIONS, userId);
|
||||
if (pi != null) {
|
||||
String[] permissions = pi.requestedPermissions;
|
||||
return ArrayUtils.contains(permissions, NOTIFICATION_PERMISSION);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Could not reach system server", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user