From fb2d3b7abb45d3818e2671d02fc3d41459394a96 Mon Sep 17 00:00:00 2001 From: Shawn Willden Date: Fri, 21 Mar 2025 15:38:19 -0700 Subject: [PATCH 1/2] Catch security exception on isOemUnlockAllowed As of Android 15, devices with FRP active will throw an exception when loading developer options attempts to update the OEM unlock state, which causes the app to crash. This CL just catches the exception and reports that OEM unlock is not, in fact, settable. A full fix should probably tell the user that OEM unlock may not be set because FRP is active, rather than just quietly failing and logging the situation, but because GMS Core is soon going to begin blocking access to the Android UI when FRP is active, meaning that developer options won't even be reachable and the user will be informed about FRP state by GMS Core, the effort that would require isn't justified. Note that this CL does not add a test for this change because it is not possible for CTS to put the device in FRP-active state to test the relevant case. Manual testing is required. Test: SettingsUnitTests Flag: EXEMPT bugfix Bug: 405023810 Change-Id: Ic43de93a4208bbc17f2e287d52f9baf281cd678c --- .../development/OemUnlockPreferenceController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/development/OemUnlockPreferenceController.java b/src/com/android/settings/development/OemUnlockPreferenceController.java index 3053defac86..8149d07f59c 100644 --- a/src/com/android/settings/development/OemUnlockPreferenceController.java +++ b/src/com/android/settings/development/OemUnlockPreferenceController.java @@ -236,7 +236,13 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon @VisibleForTesting boolean isOemUnlockedAllowed() { - return mOemLockManager.isOemUnlockAllowed(); + try { + return mOemLockManager.isOemUnlockAllowed(); + } catch (SecurityException e) { + // This exception is thrown if the device is not allowed to check (or change) the OEM + // unlock setting because Factory Reset Protection is active. + Log.e(TAG, "Failed to check OEM unlock allowed", e); + return false; + } } - } From a9de5ee4ceccb0257940db8ed85398da21f5169e Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Fri, 21 Mar 2025 17:54:38 -0700 Subject: [PATCH 2/2] Increase 16 KB test timeout, to see how it affects flakes. Bug: 405230142 Test: N/A Change-Id: I6370880160eb6024afa505ed1e42542184940d91 --- .../android/settings/development/test/Enable16KbDeviceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java b/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java index b84a99f2c33..79aaa164caa 100644 --- a/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java +++ b/tests/Enable16KbTests/test_16kb_app/src/com/android/settings/development/test/Enable16KbDeviceTest.java @@ -41,7 +41,7 @@ import java.util.Locale; @RunWith(AndroidJUnit4.class) public class Enable16KbDeviceTest { - private static final long TIMEOUT = 2000; + private static final long TIMEOUT = 3000; private static final String ENABLE_16K_TOGGLE = "Boot with 16 KB page size"; private static final String BUILD_NUMBER = "Build number";