diff options
| author | 2017-09-27 21:56:35 +0000 | |
|---|---|---|
| committer | 2017-09-27 21:56:35 +0000 | |
| commit | 6bd8c7afce742d6df7d2ac3b798e62395b0de6fb (patch) | |
| tree | c4ecf0131dfc495890ac9f6c4a4ec1eb37af14dd | |
| parent | 023c37e7b67c0ca9972b77ef3e05ea48fa013cac (diff) | |
| parent | ac7bbb840b8edc04a21af381d7dfbd9a57c9af15 (diff) | |
Merge "Show dialog if top app is killed by lmk"
| -rw-r--r-- | core/res/res/values/strings.xml | 7 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 3 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 30 |
3 files changed, 40 insertions, 0 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 7416113b4e90..afcb35feaedd 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -2709,6 +2709,8 @@ <string name="yes">OK</string> <!-- Preference framework strings. --> <string name="no">Cancel</string> + <!-- Preference framework strings. --> + <string name="close">CLOSE</string> <!-- This is the generic "attention" string to be used in attention dialogs. Typically combined with setIconAttribute(android.R.attr.alertDialogIcon) (or setIcon(android.R.drawable.ic_dialog_alert) on legacy versions of the platform) --> @@ -2841,6 +2843,11 @@ <!-- [CHAR LIMIT=200] Compat mode dialog: hint to re-enable compat mode dialog. --> <string name="screen_compat_mode_hint">Re-enable this in System settings > Apps > Downloaded.</string> + <!-- Text of the alert that is displayed when a top application is killed by lmk. --> + <string name="top_app_killed_title">App isn\'t responding</string> + <!-- Top app killed by lmk dialog message. --> + <string name="top_app_killed_message"><xliff:g id="app_name">%1$s</xliff:g> may be using too much memory.</string> + <!-- [CHAR LIMIT=200] Unsupported display size dialog: message. Refers to "Display size" setting. --> <string name="unsupported_display_size_message"><xliff:g id="app_name">%1$s</xliff:g> does not support the current Display size setting and may behave unexpectedly.</string> <!-- [CHAR LIMIT=50] Unsupported display size dialog: check box label. --> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 4f03e7b06d97..96695538b7ce 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1893,6 +1893,9 @@ <java-symbol type="string" name="anr_application_process" /> <java-symbol type="string" name="anr_process" /> <java-symbol type="string" name="anr_title" /> + <java-symbol type="string" name="top_app_killed_title" /> + <java-symbol type="string" name="top_app_killed_message" /> + <java-symbol type="string" name="close" /> <java-symbol type="string" name="car_mode_disable_notification_message" /> <java-symbol type="string" name="car_mode_disable_notification_title" /> <java-symbol type="string" name="chooser_wallpaper" /> diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 57bcda7a5646..7295bcb9bc91 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1711,6 +1711,7 @@ public class ActivityManagerService extends IActivityManager.Stub static final int PUSH_TEMP_WHITELIST_UI_MSG = 68; static final int SERVICE_FOREGROUND_CRASH_MSG = 69; static final int DISPATCH_OOM_ADJ_OBSERVER_MSG = 70; + static final int TOP_APP_KILLED_BY_LMK_MSG = 73; static final int FIRST_ACTIVITY_STACK_MSG = 100; static final int FIRST_BROADCAST_QUEUE_MSG = 200; @@ -1938,6 +1939,17 @@ public class ActivityManagerService extends IActivityManager.Stub dispatchProcessDied(pid, uid); break; } + case TOP_APP_KILLED_BY_LMK_MSG: { + final String appName = (String) msg.obj; + final AlertDialog d = new BaseErrorDialog(mUiContext); + d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); + d.setTitle(mUiContext.getText(R.string.top_app_killed_title)); + d.setMessage(mUiContext.getString(R.string.top_app_killed_message, appName)); + d.setButton(DialogInterface.BUTTON_POSITIVE, mUiContext.getText(R.string.close), + obtainMessage(DISMISS_DIALOG_UI_MSG, d)); + d.show(); + break; + } case DISPATCH_UIDS_CHANGED_UI_MSG: { dispatchUidsChanged(); } break; @@ -5396,6 +5408,7 @@ public class ActivityManagerService extends IActivityManager.Stub boolean doLowMem = app.instr == null; boolean doOomAdj = doLowMem; if (!app.killedByAm) { + maybeNotifyTopAppKilled(app); Slog.i(TAG, "Process " + app.processName + " (pid " + pid + ") has died: " + ProcessList.makeOomAdjString(app.setAdj) + ProcessList.makeProcStateString(app.setProcState)); @@ -5429,6 +5442,23 @@ public class ActivityManagerService extends IActivityManager.Stub } } + /** Show system error dialog when a top app is killed by LMK */ + void maybeNotifyTopAppKilled(ProcessRecord app) { + if (!shouldNotifyTopAppKilled(app)) { + return; + } + + Message msg = mHandler.obtainMessage(TOP_APP_KILLED_BY_LMK_MSG); + msg.obj = mContext.getPackageManager().getApplicationLabel(app.info); + mUiHandler.sendMessage(msg); + } + + /** Only show notification when the top app is killed on low ram devices */ + private boolean shouldNotifyTopAppKilled(ProcessRecord app) { + return app.curSchedGroup == ProcessList.SCHED_GROUP_TOP_APP && + ActivityManager.isLowRamDeviceStatic(); + } + /** * If a stack trace dump file is configured, dump process stack traces. * @param clearTraces causes the dump file to be erased prior to the new |