Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a41acedc authored by Hemant Gupta's avatar Hemant Gupta Committed by Ajay Panicker
Browse files

PBAP: Convert notifications to use NotificationChannel

Test Setup:
===========
HW DUT: Pixel O
Remote1: MecApp PBAP Client

Steps:
=====
1. Enable BT on DUT and bond with Remote.
2. Connect from MecApp PBAP Client Tab and observe.(Request
   Authentication checkbox enabled in MecApp).

Expected Result:
================
Device should connect successfully.

Actual Result:
===========
In Step2, "The remote PBAP server did not accept the connect request error
  popup is displayed."

Reproducibility:
===========
5/5

Log trace:
Line 6855: 05-08 14:04:23.453 10051 11015 D BluetoothPbapService:
Pbap state 0 -> 2, result = 1
Line 6868: 05-08 14:04:23.465  1615  1751 E NotificationService:
Cannot post notification
without channel ID when targeting O  - notification=Notification
(pri=0 contentView=null vibrate=null
sound=default tick defaults=0x1 flags=0x18 color=0xff607d8b vis=PRIVATE)
Line 6947: 05-08 14:04:33.471 10051 10051 W BluetoothPbapService:
Release Wake Lock
Line 7155: 05-08 14:04:53.491 10051 11492 D BluetoothPbapObexServer:
onClose(): msg MSG_SERVERSESSION_CLOSE sent out.
Line 7172: 05-08 14:04:53.509 10051 10051 D BluetoothPbapService:
Pbap state 2 -> 0, result = 1

Root Cause:
In Android O, Bluetooth 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 connection works fine when remote sends authentication
challenge.

Bug: 38149308
Change-Id: Ifff0a81912f1bf11edc73279a9a127b791188d02
parent d26e4793
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,4 +13,5 @@
    <string name="unknownName">Unknown name</string>
    <string name="localPhoneName">My name</string>
    <string name="defaultnumber">000000</string>
    <string name="pbap_notification_group">Bluetooth Contact share</string>
</resources>
+7 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
package com.android.bluetooth.pbap;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -145,6 +146,8 @@ public class BluetoothPbapService extends ProfileService {

    private static final int NOTIFICATION_ID_AUTH = -1000002;

    private static final String PBAP_NOTIFICATION_CHANNEL = "pbap_notification_channel";

    private PowerManager.WakeLock mWakeLock = null;

    private BluetoothAdapter mAdapter;
@@ -704,6 +707,9 @@ public class BluetoothPbapService extends ProfileService {

        NotificationManager nm = (NotificationManager)
            getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel notificationChannel = new NotificationChannel(PBAP_NOTIFICATION_CHANNEL,
                getString(R.string.pbap_notification_group), NotificationManager.IMPORTANCE_HIGH);
        nm.createNotificationChannel(notificationChannel);

        // Create an intent triggered by clicking on the status icon.
        Intent clickIntent = new Intent();
@@ -721,7 +727,7 @@ public class BluetoothPbapService extends ProfileService {

        if (action.equals(AUTH_CHALL_ACTION)) {
            Notification notification =
                    new Notification.Builder(this)
                    new Notification.Builder(this, PBAP_NOTIFICATION_CHANNEL)
                            .setWhen(System.currentTimeMillis())
                            .setContentTitle(getString(R.string.auth_notif_title))
                            .setContentText(getString(R.string.auth_notif_message, name))