Add PM checker for AppOpsManager

Added null == pm to deal with the possible null pointer problem when
LowRamDevice gets AppOps

Bug:230592908
Fixes:237613199
Test: run gts -m GtsPreserveLegacyStorageHostTest -t android.scopedstorage.cts.host.PreserveLegacyStorageHostTest#testPreserveLegacy

Change-Id: I80f1662a694886ef2acde58ae3eec50254e08aa2
This commit is contained in:
ot903277
2022-04-27 16:53:53 +08:00
committed by Rajeev Kumar
parent 704399812f
commit 4968d79efe

View File

@@ -10291,6 +10291,9 @@ public class AppOpsManager {
// system alert window is disable on low ram phones starting from Q
final PackageManager pm = context.getPackageManager();
if (null == pm) {
return AppOpsManager.MODE_DEFAULT;
}
// TVs are constantly plugged in and has less concern for memory/power
if (ActivityManager.isLowRamDeviceStatic()
&& !pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK, 0)) {