Don't opt-out of warning dialog by default on user builds.
BUG: 28341946
Change-Id: I9ce6bf52a02a14055d4ded41aac50c79abdb4ee9
diff --git a/packages/Shell/src/com/android/shell/BugreportWarningActivity.java b/packages/Shell/src/com/android/shell/BugreportWarningActivity.java
index da33a65..2426ba0 100644
--- a/packages/Shell/src/com/android/shell/BugreportWarningActivity.java
+++ b/packages/Shell/src/com/android/shell/BugreportWarningActivity.java
@@ -25,6 +25,7 @@
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.CheckBox;
@@ -59,7 +60,15 @@
ap.mNegativeButtonListener = this;
mConfirmRepeat = (CheckBox) ap.mView.findViewById(android.R.id.checkbox);
- mConfirmRepeat.setChecked(getWarningState(this, STATE_UNKNOWN) != STATE_SHOW);
+
+ final int state = getWarningState(this, STATE_UNKNOWN);
+ final boolean checked;
+ if (Build.TYPE.equals("user")) {
+ checked = state == STATE_HIDE; // Only checks if specifically set to.
+ } else {
+ checked = state != STATE_SHOW; // Checks by default.
+ }
+ mConfirmRepeat.setChecked(checked);
setupAlert();
}
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index 07c1546..44e956a 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -63,6 +63,7 @@
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.service.notification.StatusBarNotification;
@@ -517,7 +518,14 @@
mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm_dont_repeat));
final boolean firstTime = propertyState == null || propertyState == STATE_UNKNOWN;
if (firstTime) {
- assertTrue("Checkbox should be checked by default", dontShowAgain.isChecked());
+ if (Build.TYPE.equals("user")) {
+ assertFalse("Checkbox should NOT be checked by default on user builds",
+ dontShowAgain.isChecked());
+ mUiBot.click(dontShowAgain, "dont-show-again");
+ } else {
+ assertTrue("Checkbox should be checked by default on build type " + Build.TYPE,
+ dontShowAgain.isChecked());
+ }
} else {
assertFalse("Checkbox should not be checked", dontShowAgain.isChecked());
mUiBot.click(dontShowAgain, "dont-show-again");