From e4b9c69442e796105dcbec2b6f13252969e9d2bb Mon Sep 17 00:00:00 2001 From: Pawan Wagh Date: Sat, 4 May 2024 00:14:20 +0000 Subject: [PATCH] Disallow turning off developer options in page-agnostic mode When device is in page-agnostic mode, it would be OEM unlocked and filesystem will be different than production. Don't allow to turn off developer options in that state. Bug: 329657279 Bug: 295035851 Test: m Settings && adb install -r $ANDROID_PRODUCT_OUT/system_ext/priv-app/Settings/Settings.apk Change-Id: I9b8a9dbaf8192bb3758c53501450eb45e2fe8d9c --- .../DevelopmentSettingsDashboardFragment.java | 9 +++++++++ .../android/settings/development/Enable16kUtils.java | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index 35b011a0a61..4038f4d8f0e 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -577,6 +577,15 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra if (Utils.isMonkeyRunning()) { return; } + + // Disabling developer options in page-agnostic mode isn't supported as device isn't in + // production state + if (Enable16kUtils.isPageAgnosticModeOn(getContext())) { + Enable16kUtils.showPageAgnosticWarning(getContext()); + onDisableDevelopmentOptionsRejected(); + return; + } + DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(getContext(), false); final SystemPropPoker poker = SystemPropPoker.getInstance(); poker.blockPokes(); diff --git a/src/com/android/settings/development/Enable16kUtils.java b/src/com/android/settings/development/Enable16kUtils.java index 7b6ab68bdce..00b7ee9fd3b 100644 --- a/src/com/android/settings/development/Enable16kUtils.java +++ b/src/com/android/settings/development/Enable16kUtils.java @@ -17,6 +17,7 @@ package com.android.settings.development; import android.content.Context; +import android.content.Intent; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; @@ -116,4 +117,13 @@ public class Enable16kUtils { public static boolean isUsing16kbPages() { return PAGE_SIZE == PAGE_SIZE_16KB; } + + /** + * show page-agnostic mode warning dialog to user + * @param context to start activity + */ + public static void showPageAgnosticWarning(@NonNull Context context) { + Intent intent = new Intent(context, PageAgnosticWarningActivity.class); + context.startActivityAsUser(intent, UserHandle.SYSTEM); + } }