fix: Hastily init of SharedPreference (CE type) on Prefs1 system (#7334)
This commit is contained in:
1 parent
ffbf2226ef
commit
09e0cb129c
1 file changed
+10
-1
@@ -35,6 +35,7 @@ import android.util.Log;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.BitmapCreationCheck;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.util.LockedUserState;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
|
||||
import org.chickenhook.restrictionbypass.Unseal;
|
||||
@@ -58,7 +59,15 @@ public class MainProcessInitializer implements ResourceBasedOverride {
|
||||
Log.e(TAG, "Unseal fail!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
PreferenceManager.getInstance(context);
|
||||
|
||||
// LC-Note: SharedPreferences will initialise *after* Direct Boot is disengaged once the user has unlocked the Keyguard once.
|
||||
// Attempting to call a prefs system while SharedPrefs are not initialised will result in a Java ISE crash
|
||||
// because it's in (CE) Credential Encrypted storage. (In other words, just wait till the user unlocked their phone once)
|
||||
//
|
||||
// *Unless* your SharedPreferences instance is explicitly told to run in device-protected storage or (DE) Device Encrypted storage,
|
||||
// but in this case it's not, but it's something to keep in mind.
|
||||
LockedUserState.get(context).runOnUserUnlocked(() -> PreferenceManager.getInstance(context));
|
||||
|
||||
Overrides.getObject(
|
||||
MainProcessInitializer.class, context, R.string.main_process_initializer_class)
|
||||
.init(context);
|
||||
|
||||
Reference in new issue
Block a user