From c324562b6a45689ab2aac604c21d456bfad5f65a Mon Sep 17 00:00:00 2001 From: Yingzhe Li Date: Tue, 28 Sep 2021 05:39:27 +0000 Subject: Display WearBugreportWarningActivity on Wear after bugreport is done Display WearBugreportWarningActivity as the bug report warning dialog after bugreport is done on Wear. WearBugreportWarningActivity is defined in ClockworkShell. Bug: 190226948 Test: manual test Take bugreport on Wear, verify that WearBugreportWarningActivity can be displayed when user choose to display warning dialog: screenshot.googleplex.com/4udFJuu6M9JmXE4, screenshot.googleplex.com/4GFT9G5EMHMkwVm also verify that no warning dialog will be displayed on future bugreports when user choose "Don't show again" from warning dialog https://screenshot.googleplex.com/BzyxTJ8siUTA6Xs (cherry picked from commit 0402d0b12d61f72ee8628b6ef9efad4e74e18fcd) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:470cbee933a650ec239f9300bdcbe95f8f3fe874) Merged-In: I81cfae4e79f0904b6ca18889fcca65b647c3db4b Change-Id: I81cfae4e79f0904b6ca18889fcca65b647c3db4b --- .../com/android/shell/BugreportProgressService.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'packages/Shell/src') diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index e069a9ac776b..42952de1b2b9 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -1212,13 +1212,31 @@ public class BugreportProgressService extends Service { private void maybeShowWarningMessageAndCloseNotification(int id) { if (!hasUserDecidedNotToGetWarningMessage()) { - Intent warningIntent = buildWarningIntent(mContext, /* sendIntent */ null); + Intent warningIntent; + if (mIsWatch) { + warningIntent = buildWearWarningIntent(); + } else { + warningIntent = buildWarningIntent(mContext, /* sendIntent */ null); + } warningIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(warningIntent); } NotificationManager.from(mContext).cancel(id); } + /** + * Build intent to show warning dialog on Wear after bugreport is done + */ + private Intent buildWearWarningIntent() { + Intent intent = new Intent(); + intent.setClassName(mContext, getPackageName() + ".WearBugreportWarningActivity"); + if (mContext.getPackageManager().resolveActivity(intent, /* flags */ 0) == null) { + Log.e(TAG, "Cannot find wear bugreport warning activity"); + return buildWarningIntent(mContext, /* sendIntent */ null); + } + return intent; + } + private void shareBugreport(int id, BugreportInfo sharedInfo) { shareBugreport(id, sharedInfo, !hasUserDecidedNotToGetWarningMessage()); } -- cgit v1.2.3-59-g8ed1b