summaryrefslogtreecommitdiff
path: root/services/usb
diff options
context:
space:
mode:
authorJoshua Duong <joshuaduong@google.com>2020-04-17 16:17:42 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-17 16:17:42 +0000
commitc5724f3543b630f5a1f9c2d72b651997b830564b (patch)
treec0540aa188dee7beb33fe40942f3d262ecb13f0a /services/usb
parent25402d17091c9126ab205c3e0bef8028bfe8c693 (diff)
parent9a419cda53f415465431ac9e48e4950191c19c6c (diff)
Merge "Fix PendingIntent hijacking for adb notifications." into rvc-dev am: 9a419cda53
Change-Id: I8f96b2aa8ca127380891f9a0a790224f092e9118
Diffstat (limited to 'services/usb')
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java36
1 files changed, 4 insertions, 32 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index 747c8d9d0890..7595e3f249ce 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -41,6 +41,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.debug.AdbManagerInternal;
+import android.debug.AdbNotifications;
import android.debug.AdbTransportType;
import android.debug.IAdbTransport;
import android.hardware.usb.ParcelableUsbPort;
@@ -1180,7 +1181,6 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
protected void updateAdbNotification(boolean force) {
if (mNotificationManager == null) return;
final int id = SystemMessage.NOTE_ADB_ACTIVE;
- final int titleRes = com.android.internal.R.string.adb_active_notification_title;
if (isAdbEnabled() && mConnected) {
if ("0".equals(getSystemProperty("persist.adb.notify", ""))) return;
@@ -1191,38 +1191,10 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
}
if (!mAdbNotificationShown) {
- Resources r = mContext.getResources();
- CharSequence title = r.getText(titleRes);
- CharSequence message = r.getText(
- com.android.internal.R.string.adb_active_notification_message);
-
- Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0,
- intent, 0, null, UserHandle.CURRENT);
-
- Notification notification =
- new Notification.Builder(mContext,
- SystemNotificationChannels.DEVELOPER_IMPORTANT)
- .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
- .setWhen(0)
- .setOngoing(true)
- .setTicker(title)
- .setDefaults(0) // please be quiet
- .setColor(mContext.getColor(
- com.android.internal.R.color
- .system_notification_accent_color))
- .setContentTitle(title)
- .setContentText(message)
- .setContentIntent(pi)
- .setVisibility(Notification.VISIBILITY_PUBLIC)
- .extend(new Notification.TvExtender()
- .setChannelId(ADB_NOTIFICATION_CHANNEL_ID_TV))
- .build();
+ Notification notification = AdbNotifications.createNotification(mContext,
+ AdbTransportType.USB);
mAdbNotificationShown = true;
- mNotificationManager.notifyAsUser(null, id, notification,
- UserHandle.ALL);
+ mNotificationManager.notifyAsUser(null, id, notification, UserHandle.ALL);
}
} else if (mAdbNotificationShown) {
mAdbNotificationShown = false;