Commit 19a684d7 authored by Hazem Ashmawy's avatar Hazem Ashmawy Committed by Commit Bot

[AW] DevUI: Check if crash collection is on/off in Activity#onResume

Check if crash collection is enabled or not in Activity#onResume so if
the user enabled crash collection then returns to the activity the error
message would resolve.

Fixed: 1054142
Test: enabling/disabling usage and diagnostics settings and return back to crash activity
Change-Id: I2fce207e4db3912b467492e2f2935c80009b866c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080490
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Auto-Submit: Hazem Ashmawy <hazems@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746560}
parent 1471ed69
...@@ -61,6 +61,7 @@ public class CrashesListActivity extends Activity { ...@@ -61,6 +61,7 @@ public class CrashesListActivity extends Activity {
private CrashListExpandableAdapter mCrashListViewAdapter; private CrashListExpandableAdapter mCrashListViewAdapter;
private WebViewPackageError mDifferentPackageError; private WebViewPackageError mDifferentPackageError;
private PersistentErrorView mCrashConsentError;
// There is a limit on the length of this query string, see https://crbug.com/1015923 // There is a limit on the length of this query string, see https://crbug.com/1015923
// TODO(https://crbug.com/1052295): add assert statement to check the length of this String. // TODO(https://crbug.com/1052295): add assert statement to check the length of this String.
...@@ -105,19 +106,11 @@ public class CrashesListActivity extends Activity { ...@@ -105,19 +106,11 @@ public class CrashesListActivity extends Activity {
mDifferentPackageError = mDifferentPackageError =
new WebViewPackageError(this, findViewById(R.id.crashes_list_activity_layout)); new WebViewPackageError(this, findViewById(R.id.crashes_list_activity_layout));
mCrashConsentError =
buildCrashConsentError(PlatformServiceBridge.getInstance().canUseGms());
// show the dialog once when the activity is created. // show the dialog once when the activity is created.
mDifferentPackageError.showDialogIfDifferent(); mDifferentPackageError.showDialogIfDifferent();
final boolean enableMinidumpUploadingForTesting = CommandLine.getInstance().hasSwitch(
AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH);
if (!enableMinidumpUploadingForTesting) {
PlatformServiceBridge.getInstance().queryMetricsSetting(enabled -> {
// enabled is a Boolean object and can be null.
if (!Boolean.TRUE.equals(enabled)) {
showCrashConsentError(PlatformServiceBridge.getInstance().canUseGms());
}
});
}
} }
@Override @Override
...@@ -128,6 +121,21 @@ public class CrashesListActivity extends Activity { ...@@ -128,6 +121,21 @@ public class CrashesListActivity extends Activity {
// activity. // activity.
mDifferentPackageError.showMessageIfDifferent(); mDifferentPackageError.showMessageIfDifferent();
mCrashListViewAdapter.updateCrashes(); mCrashListViewAdapter.updateCrashes();
// Firstly, check for the flag value in commandline file, since it doesn't require any IPCs.
if (CommandLine.getInstance().hasSwitch(
AwSwitches.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH)) {
mCrashConsentError.hide();
} else {
PlatformServiceBridge.getInstance().queryMetricsSetting(enabled -> {
// enabled is a Boolean object and can be null.
if (Boolean.TRUE.equals(enabled)) {
mCrashConsentError.hide();
} else {
mCrashConsentError.show();
}
});
}
} }
/** /**
...@@ -428,7 +436,7 @@ public class CrashesListActivity extends Activity { ...@@ -428,7 +436,7 @@ public class CrashesListActivity extends Activity {
} }
} }
private void showCrashConsentError(boolean canUseGms) { private PersistentErrorView buildCrashConsentError(boolean canUseGms) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle("Error Showing Crashes"); dialogBuilder.setTitle("Error Showing Crashes");
if (canUseGms) { if (canUseGms) {
...@@ -451,11 +459,10 @@ public class CrashesListActivity extends Activity { ...@@ -451,11 +459,10 @@ public class CrashesListActivity extends Activity {
dialogBuilder.setMessage("Crash collection is not supported at the moment."); dialogBuilder.setMessage("Crash collection is not supported at the moment.");
} }
new PersistentErrorView(this, PersistentErrorView.Type.ERROR) return new PersistentErrorView(this, PersistentErrorView.Type.ERROR)
.prependToLinearLayout(findViewById(R.id.crashes_list_activity_layout)) .prependToLinearLayout(findViewById(R.id.crashes_list_activity_layout))
.setText("Crash collection is disabled. Tap for more info.") .setText("Crash collection is disabled. Tap for more info.")
.setDialog(dialogBuilder.create()) .setDialog(dialogBuilder.create());
.show();
} }
@Override @Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment