summaryrefslogtreecommitdiff
path: root/packages/Shell/src
diff options
context:
space:
mode:
author Wei Liu <luciferleo@google.com> 2016-07-19 17:29:50 +0000
committer android-build-merger <android-build-merger@google.com> 2016-07-19 17:29:50 +0000
commit213b94ee1ae3725ccebc2084dae6fcc5152d4e05 (patch)
tree22674f3a68688f9a96e659524f3d01e1ee15e104 /packages/Shell/src
parentfcda07b975f63cdd1fd2b1d0609fd328590ddf61 (diff)
parentbc3c068189eb256a336c21a010c5a633548571af (diff)
Merge \\"Use the Shell app to show the bugreport notification on Wear.\\" into nyc-mr1-dev am: 1dfbf794b5
am: bc3c068189 Change-Id: I4555c232c5fc9d10a9b9d9cd0d64ac80720e30e9
Diffstat (limited to 'packages/Shell/src')
-rw-r--r--packages/Shell/src/com/android/shell/BugreportProgressService.java88
1 files changed, 51 insertions, 37 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index 5a69b0ceaaae..235bfcc06a4d 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -215,6 +215,8 @@ public class BugreportProgressService extends Service {
private static final Bundle sNotificationBundle = new Bundle();
+ private boolean mIsWatch;
+
@Override
public void onCreate() {
mContext = getApplicationContext();
@@ -228,6 +230,9 @@ public class BugreportProgressService extends Service {
Log.w(TAG, "Could not create directory " + mScreenshotsDir);
}
}
+ final Configuration conf = mContext.getResources().getConfiguration();
+ mIsWatch = (conf.uiMode & Configuration.UI_MODE_TYPE_MASK) ==
+ Configuration.UI_MODE_TYPE_WATCH;
}
@Override
@@ -442,56 +447,68 @@ public class BugreportProgressService extends Service {
return;
}
+ if (info.finished) {
+ Log.w(TAG, "Not sending progress notification because bugreport has finished already ("
+ + info + ")");
+ return;
+ }
+
final NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
final String percentageText = nf.format((double) info.progress / info.max);
- final Action cancelAction = new Action.Builder(null, mContext.getString(
- com.android.internal.R.string.cancel), newCancelIntent(mContext, info)).build();
- final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
- infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
- infoIntent.putExtra(EXTRA_ID, info.id);
- final PendingIntent infoPendingIntent =
- PendingIntent.getService(mContext, info.id, infoIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- final Action infoAction = new Action.Builder(null,
- mContext.getString(R.string.bugreport_info_action),
- infoPendingIntent).build();
- final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
- screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
- screenshotIntent.putExtra(EXTRA_ID, info.id);
- PendingIntent screenshotPendingIntent = mTakingScreenshot ? null : PendingIntent
- .getService(mContext, info.id, screenshotIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- final Action screenshotAction = new Action.Builder(null,
- mContext.getString(R.string.bugreport_screenshot_action),
- screenshotPendingIntent).build();
-
- final String title = mContext.getString(R.string.bugreport_in_progress_title, info.id);
+
+ String title = mContext.getString(R.string.bugreport_in_progress_title, info.id);
+
+ // TODO: Remove this workaround when notification progress is implemented on Wear.
+ if (mIsWatch) {
+ nf.setMinimumFractionDigits(0);
+ nf.setMaximumFractionDigits(0);
+ final String watchPercentageText = nf.format((double) info.progress / info.max);
+ title = title + "\n" + watchPercentageText;
+ }
final String name =
info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed);
- final Notification notification = newBaseNotification(mContext)
+ final Notification.Builder builder = newBaseNotification(mContext)
.setContentTitle(title)
.setTicker(title)
.setContentText(name)
.setProgress(info.max, info.progress, false)
- .setOngoing(true)
- .setContentIntent(infoPendingIntent)
- .setActions(infoAction, screenshotAction, cancelAction)
- .build();
-
- if (info.finished) {
- Log.w(TAG, "Not sending progress notification because bugreport has finished already ("
- + info + ")");
- return;
+ .setOngoing(true);
+
+ // Wear bugreport doesn't need the bug info dialog, screenshot and cancel action.
+ if (!mIsWatch) {
+ final Action cancelAction = new Action.Builder(null, mContext.getString(
+ com.android.internal.R.string.cancel), newCancelIntent(mContext, info)).build();
+ final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
+ infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
+ infoIntent.putExtra(EXTRA_ID, info.id);
+ final PendingIntent infoPendingIntent =
+ PendingIntent.getService(mContext, info.id, infoIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ final Action infoAction = new Action.Builder(null,
+ mContext.getString(R.string.bugreport_info_action),
+ infoPendingIntent).build();
+ final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
+ screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
+ screenshotIntent.putExtra(EXTRA_ID, info.id);
+ PendingIntent screenshotPendingIntent = mTakingScreenshot ? null : PendingIntent
+ .getService(mContext, info.id, screenshotIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ final Action screenshotAction = new Action.Builder(null,
+ mContext.getString(R.string.bugreport_screenshot_action),
+ screenshotPendingIntent).build();
+ builder.setContentIntent(infoPendingIntent)
+ .setActions(infoAction, screenshotAction, cancelAction);
}
+
if (DEBUG) {
Log.d(TAG, "Sending 'Progress' notification for id " + info.id + " (pid " + info.pid
+ "): " + percentageText);
}
- sendForegroundabledNotification(info.id, notification);
+ sendForegroundabledNotification(info.id, builder.build());
}
private void sendForegroundabledNotification(int id, Notification notification) {
@@ -858,10 +875,7 @@ public class BugreportProgressService extends Service {
// Stop running on foreground, otherwise share notification cannot be dismissed.
stopForegroundWhenDone(id);
- final Configuration conf = mContext.getResources().getConfiguration();
- if ((conf.uiMode & Configuration.UI_MODE_TYPE_MASK) != Configuration.UI_MODE_TYPE_WATCH) {
- triggerLocalNotification(mContext, info);
- }
+ triggerLocalNotification(mContext, info);
}
/**