Fix crashes seen when checking for carrierConfig certificates

1. Do not throw exception when packageName is not found
2. Fix NPE caused by null SubscriptionInfo

Bug: 140122832
Test: Utest and manual test
Change-Id: I686647419896a1780f0697b3ed5d319363675f5f
Merged-In: I686647419896a1780f0697b3ed5d319363675f5f
This commit is contained in:
Nazanin Bakhshi
2019-08-29 16:19:12 -07:00
committed by Malcolm Chen
parent 8fe1f7cb5c
commit e55c2f992c
2 changed files with 8 additions and 4 deletions

View File

@@ -580,7 +580,8 @@ public class SubscriptionInfo implements Parcelable {
try {
packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Unknown package: " + packageName, e);
Log.d("SubscriptionInfo", "canManageSubscription: Unknown package: " + packageName, e);
return false;
}
for (UiccAccessRule rule : allAccessRules) {
if (rule.getCarrierPrivilegeStatus(packageInfo)
@@ -612,7 +613,9 @@ public class SubscriptionInfo implements Parcelable {
*/
public @Nullable List<UiccAccessRule> getAllAccessRules() {
List<UiccAccessRule> merged = new ArrayList<>();
if (mNativeAccessRules != null) merged.addAll(getAccessRules());
if (mNativeAccessRules != null) {
merged.addAll(getAccessRules());
}
if (mCarrierConfigAccessRules != null) {
merged.addAll(Arrays.asList(mCarrierConfigAccessRules));
}

View File

@@ -2642,7 +2642,7 @@ public class SubscriptionManager {
* @hide
*/
public boolean canManageSubscription(SubscriptionInfo info, String packageName) {
if (info.getAllAccessRules() == null) {
if (info == null || info.getAllAccessRules() == null) {
return false;
}
PackageManager packageManager = mContext.getPackageManager();
@@ -2650,7 +2650,8 @@ public class SubscriptionManager {
try {
packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Unknown package: " + packageName, e);
logd("Unknown package: " + packageName);
return false;
}
for (UiccAccessRule rule : info.getAllAccessRules()) {
if (rule.getCarrierPrivilegeStatus(packageInfo)