summaryrefslogtreecommitdiff
path: root/packages/MtpDocumentsProvider
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-05-17 03:13:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-05-17 03:13:27 +0000
commit8b81a0a1fc439ac6cba9a237ea5246e2aec63033 (patch)
tree7222861d6902813fe324fae7c313ee33f6318619 /packages/MtpDocumentsProvider
parent487231e79cecdded08f3ab060b77902ad5b9b0b1 (diff)
parent3393bc9a7cea48bc85c75f1ec3d417c179a75ee5 (diff)
Merge "Set notification channel to MTP notification." into oc-dev
Diffstat (limited to 'packages/MtpDocumentsProvider')
-rw-r--r--packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java b/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java
index c5292b878f37..fe792667fc68 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/ServiceIntentSender.java
@@ -18,6 +18,8 @@ package com.android.mtp;
import android.annotation.NonNull;
import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -27,10 +29,21 @@ import com.android.internal.util.Preconditions;
* Sends intent to MtpDocumentsService.
*/
class ServiceIntentSender {
+ private final static String CHANNEL_ID = "device_notification_channel";
private Context mContext;
ServiceIntentSender(Context context) {
mContext = context;
+
+ // Create notification channel.
+ final NotificationChannel mChannel = new NotificationChannel(
+ CHANNEL_ID,
+ context.getResources().getString(
+ com.android.internal.R.string.default_notification_channel_label),
+ NotificationManager.IMPORTANCE_LOW);
+ final NotificationManager notificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.createNotificationChannel(mChannel);
}
/**
@@ -60,12 +73,11 @@ class ServiceIntentSender {
final String title = context.getResources().getString(
R.string.accessing_notification_title,
device.name);
- return new Notification.Builder(context)
+ return new Notification.Builder(context, CHANNEL_ID)
.setLocalOnly(true)
.setContentTitle(title)
.setSmallIcon(com.android.internal.R.drawable.stat_sys_data_usb)
.setCategory(Notification.CATEGORY_SYSTEM)
- .setPriority(Notification.PRIORITY_LOW)
.setFlag(Notification.FLAG_NO_CLEAR, true)
.build();
}