Merge "Enabling bugreport notifications on TV"
This commit is contained in:
committed by
Android (Google) Code Review
commit
4fd2455141
9
packages/Shell/res/drawable/ic_bug_report_black_24dp.xml
Normal file
9
packages/Shell/res/drawable/ic_bug_report_black_24dp.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
@@ -4,9 +4,9 @@
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -16,6 +16,9 @@
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="app_label">Shell</string>
|
||||
|
||||
<!-- Title of notification channel for bug report related notifications. [CHAR LIMIT=50] -->
|
||||
<string name="bugreport_notification_channel">Bug reports</string>
|
||||
|
||||
<!-- Title of notification indicating a bugreport is being generated. [CHAR LIMIT=50] -->
|
||||
<string name="bugreport_in_progress_title">Bug report <xliff:g id="id">#%d</xliff:g> is being generated</string>
|
||||
<!-- Title of notification indicating a bugreport has been successfully captured. [CHAR LIMIT=50] -->
|
||||
|
||||
@@ -57,6 +57,7 @@ import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Notification;
|
||||
import android.app.Notification.Action;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
@@ -64,6 +65,7 @@ import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
@@ -196,6 +198,8 @@ public class BugreportProgressService extends Service {
|
||||
*/
|
||||
private static final String SCREENSHOT_DIR = "bugreports";
|
||||
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "bugreports";
|
||||
|
||||
/** Managed dumpstate processes (keyed by id) */
|
||||
private final SparseArray<DumpstateListener> mProcesses = new SparseArray<>();
|
||||
|
||||
@@ -240,6 +244,12 @@ public class BugreportProgressService extends Service {
|
||||
final Configuration conf = mContext.getResources().getConfiguration();
|
||||
mIsWatch = (conf.uiMode & Configuration.UI_MODE_TYPE_MASK) ==
|
||||
Configuration.UI_MODE_TYPE_WATCH;
|
||||
NotificationManager nm = NotificationManager.from(mContext);
|
||||
nm.createNotificationChannel(
|
||||
new NotificationChannel(NOTIFICATION_CHANNEL_ID,
|
||||
mContext.getString(R.string.bugreport_notification_channel),
|
||||
isTv(this) ? NotificationManager.IMPORTANCE_DEFAULT
|
||||
: NotificationManager.IMPORTANCE_LOW));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1008,13 +1018,16 @@ public class BugreportProgressService extends Service {
|
||||
sNotificationBundle.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
|
||||
context.getString(com.android.internal.R.string.android_system_label));
|
||||
}
|
||||
return new Notification.Builder(context)
|
||||
return new Notification.Builder(context, NOTIFICATION_CHANNEL_ID)
|
||||
.addExtras(sNotificationBundle)
|
||||
.setCategory(Notification.CATEGORY_SYSTEM)
|
||||
.setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
|
||||
.setSmallIcon(
|
||||
isTv(context) ? R.drawable.ic_bug_report_black_24dp
|
||||
: com.android.internal.R.drawable.stat_sys_adb)
|
||||
.setLocalOnly(true)
|
||||
.setColor(context.getColor(
|
||||
com.android.internal.R.color.system_notification_accent_color));
|
||||
com.android.internal.R.color.system_notification_accent_color))
|
||||
.extend(new Notification.TvExtender());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1333,6 +1346,10 @@ public class BugreportProgressService extends Service {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isTv(Context context) {
|
||||
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a character is valid on bugreport names.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user