From 177fd578c950f88f5070a90b5a20ca05bfb95a23 Mon Sep 17 00:00:00 2001 From: Pawan Wagh Date: Fri, 7 Mar 2025 19:58:25 +0000 Subject: [PATCH] Show failure reasons to user Sometimes device might have pending update which can cause 16KB toggle to fail. Show the pending update errors to user. Flag: EXEMPT bug_fix Test: atest Enable16KbTest Bug: 394678137 Bug: 400733054 Change-Id: Id032b2f14afb74af3b7458a426addc7e32e3a6f7 --- res/values/strings.xml | 5 +++++ .../Enable16kPagesPreferenceController.java | 20 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index e0e47932339..3da882d36ea 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -13149,6 +13149,11 @@ Data usage charges may apply. Application will be stopped to apply page size compat setting. + + Kernel update failed. Check and install any pending updates. + + Kernel update failed. Error occurred while applying OTA. + DSU Loader diff --git a/src/com/android/settings/development/Enable16kPagesPreferenceController.java b/src/com/android/settings/development/Enable16kPagesPreferenceController.java index d8ad55f4146..1c1b713562a 100644 --- a/src/com/android/settings/development/Enable16kPagesPreferenceController.java +++ b/src/com/android/settings/development/Enable16kPagesPreferenceController.java @@ -186,7 +186,13 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen public void onFailure(@NonNull Throwable t) { hideProgressDialog(); Log.e(TAG, "Failed to call applyPayload of UpdateEngineStable!", t); - displayToast(mContext.getString(R.string.toast_16k_update_failed_text)); + // installUpdate will always throw localized messages. + String message = t.getMessage(); + if (message != null) { + displayToast(message); + } else { + displayToast(mContext.getString(R.string.toast_16k_update_failed_text)); + } } }, ContextCompat.getMainExecutor(mContext)); @@ -208,10 +214,8 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen int status = data.getInt(SystemUpdateManager.KEY_STATUS); if (status != SystemUpdateManager.STATUS_UNKNOWN && status != SystemUpdateManager.STATUS_IDLE) { - throw new RuntimeException( - "System has pending update! Please restart the device to complete applying" - + " pending update. If you are seeing this after using 16KB developer" - + " options, please check configuration and OTA packages!"); + Log.e(TAG, "SystemUpdateManager is not available. Status :" + status); + throw new RuntimeException(mContext.getString(R.string.error_pending_updates)); } // Publish system update info @@ -223,7 +227,11 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen Log.i(TAG, "Update file path is " + updateFile.getAbsolutePath()); applyUpdateFile(updateFile); } catch (IOException e) { - throw new RuntimeException(e); + Log.e(TAG, "Error occurred while applying OTA ", e); + throw new RuntimeException(mContext.getString(R.string.error_ota_failed)); + } catch (Exception e) { + Log.e(TAG, "Unknown error occurred while applying OTA ", e); + throw new RuntimeException(mContext.getString(R.string.toast_16k_update_failed_text)); } }