DivestOS/Patches/LineageOS-15.1/android_packages_apps_Settings/0004-PDB_Fixes.patch
Tad f122ccb9f1 Many changes
- Disable patches with restrictive licenses by default
- Update LICENSE
- Fixup the fix for F-Droid building
- 15.1: Fix forceencrypt on mako
- 15.1: Fix crashes when accessing factory reset and development settings menus
 on devices without support for factory reset protection or oem unlocking
2018-04-23 15:42:27 -04:00

68 lines
3.5 KiB
Diff

From e297ea5bd7bf902d6ed606c24cc0ab902dc6943b Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Mon, 23 Apr 2018 15:40:11 -0400
Subject: [PATCH] Fix crashes when the PersistentDataBlockManager service isn't
available
Change-Id: I58b82270ed052526004889deb8a2ede072e2da3b
---
.../android/settings/MasterClearConfirm.java | 17 ++++++++++++-----
.../development/DevelopmentSettings.java | 5 ++++-
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index 39bf01a0d9..8be58e8c85 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.oemlock.OemLockManager;
@@ -65,12 +66,18 @@ public class MasterClearConfirm extends OptionsMenuFragment {
return;
}
- final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
- getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
- final OemLockManager oemLockManager = (OemLockManager)
- getActivity().getSystemService(Context.OEM_LOCK_SERVICE);
+ PersistentDataBlockManager pdbManagerTmp = null;
+ OemLockManager oemLockManager = null;
+ if (!SystemProperties.get("ro.frp.pst").equals("")) {
+ pdbManagerTmp = (PersistentDataBlockManager)
+ getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
+ oemLockManager = (OemLockManager)
+ getActivity().getSystemService(Context.OEM_LOCK_SERVICE);
+ }
+
+ final PersistentDataBlockManager pdbManager = pdbManagerTmp;
- if (pdbManager != null && !oemLockManager.isOemUnlockAllowed() &&
+ if (pdbManager != null && oemLockManager != null && !oemLockManager.isOemUnlockAllowed() &&
Utils.isDeviceProvisioned(getActivity())) {
// if OEM unlock is allowed, the persistent data block will be wiped during FR
// process. If disabled, it will be wiped here, unless the device is still being
diff --git a/src/com/android/settings/development/DevelopmentSettings.java b/src/com/android/settings/development/DevelopmentSettings.java
index b29add1aa7..ac3d8a3273 100644
--- a/src/com/android/settings/development/DevelopmentSettings.java
+++ b/src/com/android/settings/development/DevelopmentSettings.java
@@ -420,7 +420,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
mWebViewUpdateService = WebViewFactory.getUpdateService();
- mOemLockManager = (OemLockManager) getSystemService(Context.OEM_LOCK_SERVICE);
+ mOemLockManager = null;
+ if(SystemProperties.getBoolean("ro.oem_unlock_supported", false)) {
+ mOemLockManager = (OemLockManager) getSystemService(Context.OEM_LOCK_SERVICE);
+ }
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
--
2.17.0