diff options
author | 2025-02-10 02:41:27 -0800 | |
---|---|---|
committer | 2025-02-10 02:41:27 -0800 | |
commit | f62226ef47adc8649cb423641fe1cf92d688effd (patch) | |
tree | e4df27b9c0b200d7a93aceb38ca67c12bfd3e049 /packages/Shell/src | |
parent | 673ab751d24ad4c4a7124609912bc972405a09ac (diff) |
Move BugreportPrefs constants to shared location between sysui and shell
bug:380825247
Manual test:
- M -> to build
- sh vendor/google/tools/flashall -> to install changes
- Set watch to test mode: adb shell am broadcast -a com.google.android.clockwork.action.TEST_MODE
- Select Take bug report and press in details when finished
Flag: EXEMPT refactor
Bugreport: https://drive.google.com/file/d/1vCUk5Q18jWH2IPEbhTBUCZf0K3WE74LD/view?usp=sharing&resourcekey=0-qTNzJx3VoCf3lpsUEBCUIg
(cherry picked from https://partner-android-review.googlesource.com/q/commit:beeaf50d15a1bafb48f006b7cd77393d04180b3f)
Merged-In: Id59ecadbecd84f79474184c0110aa6536ec8abf4
Change-Id: Id59ecadbecd84f79474184c0110aa6536ec8abf4
Diffstat (limited to 'packages/Shell/src')
3 files changed, 35 insertions, 25 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportPrefs.java b/packages/Shell/src/com/android/shell/BugreportPrefs.java index 93690d48cd04..b0fd925daec3 100644 --- a/packages/Shell/src/com/android/shell/BugreportPrefs.java +++ b/packages/Shell/src/com/android/shell/BugreportPrefs.java @@ -23,25 +23,24 @@ import android.content.SharedPreferences; * Preferences related to bug reports. */ final class BugreportPrefs { - static final String PREFS_BUGREPORT = "bugreports"; - - private static final String KEY_WARNING_STATE = "warning-state"; - - static final int STATE_UNKNOWN = 0; - // Shows the warning dialog. - static final int STATE_SHOW = 1; - // Skips the warning dialog. - static final int STATE_HIDE = 2; static int getWarningState(Context context, int def) { - final SharedPreferences prefs = context.getSharedPreferences( - PREFS_BUGREPORT, Context.MODE_PRIVATE); - return prefs.getInt(KEY_WARNING_STATE, def); + String prefsBugreport = context.getResources().getString( + com.android.internal.R.string.prefs_bugreport); + String keyWarningState = context.getResources().getString( + com.android.internal.R.string.key_warning_state); + final SharedPreferences prefs = context.getSharedPreferences(prefsBugreport, + Context.MODE_PRIVATE); + return prefs.getInt(keyWarningState, def); } static void setWarningState(Context context, int value) { - final SharedPreferences prefs = context.getSharedPreferences( - PREFS_BUGREPORT, Context.MODE_PRIVATE); - prefs.edit().putInt(KEY_WARNING_STATE, value).apply(); + String prefsBugreport = context.getResources().getString( + com.android.internal.R.string.prefs_bugreport); + String keyWarningState = context.getResources().getString( + com.android.internal.R.string.key_warning_state); + final SharedPreferences prefs = context.getSharedPreferences(prefsBugreport, + Context.MODE_PRIVATE); + prefs.edit().putInt(keyWarningState, value).apply(); } } diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 61f49db07abc..fb0678fedb56 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -21,8 +21,6 @@ import static android.content.pm.PackageManager.FEATURE_LEANBACK; import static android.content.pm.PackageManager.FEATURE_TELEVISION; import static android.os.Process.THREAD_PRIORITY_BACKGROUND; -import static com.android.shell.BugreportPrefs.STATE_HIDE; -import static com.android.shell.BugreportPrefs.STATE_UNKNOWN; import static com.android.shell.BugreportPrefs.getWarningState; import static com.android.shell.flags.Flags.handleBugreportsForWear; @@ -1347,7 +1345,11 @@ public class BugreportProgressService extends Service { } private boolean hasUserDecidedNotToGetWarningMessage() { - return getWarningState(mContext, STATE_UNKNOWN) == STATE_HIDE; + int bugreportStateUnknown = mContext.getResources().getInteger( + com.android.internal.R.integer.bugreport_state_unknown); + int bugreportStateHide = mContext.getResources().getInteger( + com.android.internal.R.integer.bugreport_state_hide); + return getWarningState(mContext, bugreportStateUnknown) == bugreportStateHide; } private void maybeShowWarningMessageAndCloseNotification(int id) { diff --git a/packages/Shell/src/com/android/shell/BugreportWarningActivity.java b/packages/Shell/src/com/android/shell/BugreportWarningActivity.java index a44e23603f52..0e835f91aca6 100644 --- a/packages/Shell/src/com/android/shell/BugreportWarningActivity.java +++ b/packages/Shell/src/com/android/shell/BugreportWarningActivity.java @@ -16,9 +16,6 @@ package com.android.shell; -import static com.android.shell.BugreportPrefs.STATE_HIDE; -import static com.android.shell.BugreportPrefs.STATE_SHOW; -import static com.android.shell.BugreportPrefs.STATE_UNKNOWN; import static com.android.shell.BugreportPrefs.getWarningState; import static com.android.shell.BugreportPrefs.setWarningState; import static com.android.shell.BugreportProgressService.sendShareIntent; @@ -69,12 +66,19 @@ public class BugreportWarningActivity extends AlertActivity mConfirmRepeat = (CheckBox) ap.mView.findViewById(android.R.id.checkbox); - final int state = getWarningState(this, STATE_UNKNOWN); + int bugreportStateUnknown = getResources().getInteger( + com.android.internal.R.integer.bugreport_state_unknown); + int bugreportStateHide = getResources().getInteger( + com.android.internal.R.integer.bugreport_state_hide); + int bugreportStateShow = getResources().getInteger( + com.android.internal.R.integer.bugreport_state_show); + + final int state = getWarningState(this, bugreportStateUnknown); final boolean checked; if (Build.IS_USER) { - checked = state == STATE_HIDE; // Only checks if specifically set to. + checked = state == bugreportStateHide; // Only checks if specifically set to. } else { - checked = state != STATE_SHOW; // Checks by default. + checked = state != bugreportStateShow; // Checks by default. } mConfirmRepeat.setChecked(checked); @@ -83,9 +87,14 @@ public class BugreportWarningActivity extends AlertActivity @Override public void onClick(DialogInterface dialog, int which) { + int bugreportStateHide = getResources().getInteger( + com.android.internal.R.integer.bugreport_state_hide); + int bugreportStateShow = getResources().getInteger( + com.android.internal.R.integer.bugreport_state_show); if (which == AlertDialog.BUTTON_POSITIVE) { // Remember confirm state, and launch target - setWarningState(this, mConfirmRepeat.isChecked() ? STATE_HIDE : STATE_SHOW); + setWarningState(this, mConfirmRepeat.isChecked() ? bugreportStateHide + : bugreportStateShow); if (mSendIntent != null) { sendShareIntent(this, mSendIntent); } |