Settings: Convert notifications to use NotificationChannel (2/2)
Test Setup: =========== HW DUT: Pixel O Remote: MecApp (PBAP Client, MAP Client, SAP Client) Steps: ===== 1. Enable BT on DUT and bond with Remote. 2. Connect from MecApp for PBAP, MAP, SAP and observe if connection goes through fine. Reproducibility: =============== 5/5 Observation: ============ MAP, PBAP and SAP cannot be connected. Root cause: In Android O, notifications are hidden by default. This must be changed to use notification channels so that the priority of the notifications can be updated. Test: PBAP/MAP/SAP connection works fine with MecApp. Bug: 38331825 Change-Id: I51de0ea303037bf88773352d99f092673acda2e3 (cherry picked from commit bd9f532013f0397879101f68f21ac8841fec344b)
This commit is contained in:
committed by
Andre Eisenbach
parent
11e7781b32
commit
7bec5bf895
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.bluetooth;
|
package com.android.settings.bluetooth;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
@@ -45,6 +46,12 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
private static final String NOTIFICATION_TAG_PBAP = "Phonebook Access" ;
|
private static final String NOTIFICATION_TAG_PBAP = "Phonebook Access" ;
|
||||||
private static final String NOTIFICATION_TAG_MAP = "Message Access";
|
private static final String NOTIFICATION_TAG_MAP = "Message Access";
|
||||||
private static final String NOTIFICATION_TAG_SAP = "SIM Access";
|
private static final String NOTIFICATION_TAG_SAP = "SIM Access";
|
||||||
|
/* TODO: Consolidate this multiple defined but common channel ID with other
|
||||||
|
* handlers that declare and use the same channel ID */
|
||||||
|
private static final String BLUETOOTH_NOTIFICATION_CHANNEL =
|
||||||
|
"bluetooth_notification_channel";
|
||||||
|
|
||||||
|
private NotificationChannel mNotificationChannel = null;
|
||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
int mRequestType;
|
int mRequestType;
|
||||||
@@ -151,7 +158,16 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
deviceAlias, deviceAlias);
|
deviceAlias, deviceAlias);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Notification notification = new Notification.Builder(context)
|
NotificationManager notificationManager =
|
||||||
|
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
if (mNotificationChannel == null) {
|
||||||
|
mNotificationChannel = new NotificationChannel(BLUETOOTH_NOTIFICATION_CHANNEL,
|
||||||
|
context.getString(R.string.bluetooth),
|
||||||
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
notificationManager.createNotificationChannel(mNotificationChannel);
|
||||||
|
}
|
||||||
|
Notification notification = new Notification.Builder(context,
|
||||||
|
BLUETOOTH_NOTIFICATION_CHANNEL)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
.setTicker(message)
|
.setTicker(message)
|
||||||
.setContentText(message)
|
.setContentText(message)
|
||||||
@@ -169,9 +185,6 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
|
|
||||||
notification.flags |= Notification.FLAG_NO_CLEAR; // Cannot be set with the builder.
|
notification.flags |= Notification.FLAG_NO_CLEAR; // Cannot be set with the builder.
|
||||||
|
|
||||||
NotificationManager notificationManager =
|
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
|
|
||||||
notificationManager.notify(getNotificationTag(mRequestType), NOTIFICATION_ID,
|
notificationManager.notify(getNotificationTag(mRequestType), NOTIFICATION_ID,
|
||||||
notification);
|
notification);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user