From 2432051bfda959469ec7ce0a75c41369f3ebff27 Mon Sep 17 00:00:00 2001 From: Ajay Panicker Date: Fri, 21 Apr 2017 16:31:50 -0700 Subject: [PATCH] Add Bluetooth Pairing notifications to a channel Bug: 37531430 Test: Send a pairing request to DUT from remote phone Change-Id: I2014b0aa3c4797cbf8e601003471372f4920d21d --- .../bluetooth/BluetoothPairingService.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java index 980b150d74f..58df9192d7b 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingService.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java @@ -17,6 +17,8 @@ package com.android.settings.bluetooth; import android.app.Notification; +import android.app.NotificationManager; +import android.app.NotificationChannel; import android.app.PendingIntent; import android.app.Service; import android.bluetooth.BluetoothDevice; @@ -42,6 +44,9 @@ public final class BluetoothPairingService extends Service { private static final String ACTION_DISMISS_PAIRING = "com.android.settings.bluetooth.ACTION_DISMISS_PAIRING"; + private static final String BLUETOOTH_NOTIFICATION_CHANNEL = + "bluetooth_notification_channel"; + private static final String TAG = "BluetoothPairingService"; private BluetoothDevice mDevice; @@ -94,6 +99,13 @@ public final class BluetoothPairingService extends Service { @Override public void onCreate() { + NotificationManager mgr = (NotificationManager)this + .getSystemService(Context.NOTIFICATION_SERVICE); + NotificationChannel notificationChannel = new NotificationChannel( + BLUETOOTH_NOTIFICATION_CHANNEL, + this.getString(R.string.bluetooth), + NotificationManager.IMPORTANCE_HIGH); + mgr.createNotificationChannel(notificationChannel); } @Override @@ -105,7 +117,8 @@ public final class BluetoothPairingService extends Service { } Resources res = getResources(); - Notification.Builder builder = new Notification.Builder(this) + Notification.Builder builder = new Notification.Builder(this, + BLUETOOTH_NOTIFICATION_CHANNEL) .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth) .setTicker(res.getString(R.string.bluetooth_notif_ticker));