Loading android/app/src/com/android/bluetooth/sap/SapServer.java +43 −34 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.android.bluetooth.sap; import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.bluetooth.BluetoothSap; Loading Loading @@ -84,6 +85,7 @@ public class SapServer extends Thread implements Callback { public static final String SAP_DISCONNECT_TYPE_EXTRA = "com.android.bluetooth.sap.extra.DISCONNECT_TYPE"; public static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth; private static final String SAP_NOTIFICATION_CHANNEL = "sap_notification_channel"; public static final int ISAP_GET_SERVICE_DELAY_MILLIS = 3 * 1000; private static final int DISCONNECT_TIMEOUT_IMMEDIATE = 5000; /* ms */ private static final int DISCONNECT_TIMEOUT_RFCOMM = 2000; /* ms */ Loading Loading @@ -208,6 +210,12 @@ public class SapServer extends Thread implements Callback { { String title, text, button, ticker; Notification notification; NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel notificationChannel = new NotificationChannel(SAP_NOTIFICATION_CHANNEL, mContext.getString(R.string.bluetooth_sap_notif_title), NotificationManager.IMPORTANCE_HIGH); notificationManager.createNotificationChannel(notificationChannel); if(VERBOSE) Log.i(TAG, "setNotification type: " + type); /* For PTS TC_SERVER_DCN_BV_03_I we need to expose the option to send immediate disconnect * without first sending a graceful disconnect. Loading @@ -229,13 +237,14 @@ public class SapServer extends Thread implements Callback { text = mContext.getString(R.string.bluetooth_sap_notif_disconnecting); ticker = mContext.getString(R.string.bluetooth_sap_notif_ticker); } if(!pts_test) { if (!pts_test) { sapDisconnectIntent.putExtra(SapServer.SAP_DISCONNECT_TYPE_EXTRA, type); PendingIntent pIntentDisconnect = PendingIntent.getBroadcast(mContext, type, sapDisconnectIntent,flags); notification = new Notification.Builder(mContext).setOngoing(true) .addAction(android.R.drawable.stat_sys_data_bluetooth, button, pIntentDisconnect) notification = new Notification.Builder(mContext, SAP_NOTIFICATION_CHANNEL) .setOngoing(true) .addAction(android.R.drawable.stat_sys_data_bluetooth, button, pIntentDisconnect) .setContentTitle(title) .setTicker(ticker) .setContentText(text) Loading @@ -245,7 +254,6 @@ public class SapServer extends Thread implements Callback { .setOnlyAlertOnce(true) .build(); } else { sapDisconnectIntent.putExtra(SapServer.SAP_DISCONNECT_TYPE_EXTRA, SapMessage.DISC_GRACEFULL); Intent sapForceDisconnectIntent = new Intent(SapServer.SAP_DISCONNECT_ACTION); Loading @@ -255,12 +263,16 @@ public class SapServer extends Thread implements Callback { SapMessage.DISC_GRACEFULL, sapDisconnectIntent,flags); PendingIntent pIntentForceDisconnect = PendingIntent.getBroadcast(mContext, SapMessage.DISC_IMMEDIATE, sapForceDisconnectIntent,flags); notification = new Notification.Builder(mContext).setOngoing(true) notification = new Notification.Builder(mContext, SAP_NOTIFICATION_CHANNEL) .setOngoing(true) .addAction(android.R.drawable.stat_sys_data_bluetooth, mContext.getString(R.string.bluetooth_sap_notif_disconnect_button), mContext.getString( R.string.bluetooth_sap_notif_disconnect_button), pIntentDisconnect) .addAction(android.R.drawable.stat_sys_data_bluetooth, mContext.getString(R.string.bluetooth_sap_notif_force_disconnect_button), mContext.getString( R.string.bluetooth_sap_notif_force_disconnect_button), pIntentForceDisconnect) .setContentTitle(title) .setTicker(ticker) Loading @@ -275,9 +287,6 @@ public class SapServer extends Thread implements Callback { // cannot be set with the builder notification.flags |= Notification.FLAG_NO_CLEAR |Notification.FLAG_ONLY_ALERT_ONCE; NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); } Loading Loading
android/app/src/com/android/bluetooth/sap/SapServer.java +43 −34 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.android.bluetooth.sap; import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.bluetooth.BluetoothSap; Loading Loading @@ -84,6 +85,7 @@ public class SapServer extends Thread implements Callback { public static final String SAP_DISCONNECT_TYPE_EXTRA = "com.android.bluetooth.sap.extra.DISCONNECT_TYPE"; public static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth; private static final String SAP_NOTIFICATION_CHANNEL = "sap_notification_channel"; public static final int ISAP_GET_SERVICE_DELAY_MILLIS = 3 * 1000; private static final int DISCONNECT_TIMEOUT_IMMEDIATE = 5000; /* ms */ private static final int DISCONNECT_TIMEOUT_RFCOMM = 2000; /* ms */ Loading Loading @@ -208,6 +210,12 @@ public class SapServer extends Thread implements Callback { { String title, text, button, ticker; Notification notification; NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel notificationChannel = new NotificationChannel(SAP_NOTIFICATION_CHANNEL, mContext.getString(R.string.bluetooth_sap_notif_title), NotificationManager.IMPORTANCE_HIGH); notificationManager.createNotificationChannel(notificationChannel); if(VERBOSE) Log.i(TAG, "setNotification type: " + type); /* For PTS TC_SERVER_DCN_BV_03_I we need to expose the option to send immediate disconnect * without first sending a graceful disconnect. Loading @@ -229,13 +237,14 @@ public class SapServer extends Thread implements Callback { text = mContext.getString(R.string.bluetooth_sap_notif_disconnecting); ticker = mContext.getString(R.string.bluetooth_sap_notif_ticker); } if(!pts_test) { if (!pts_test) { sapDisconnectIntent.putExtra(SapServer.SAP_DISCONNECT_TYPE_EXTRA, type); PendingIntent pIntentDisconnect = PendingIntent.getBroadcast(mContext, type, sapDisconnectIntent,flags); notification = new Notification.Builder(mContext).setOngoing(true) .addAction(android.R.drawable.stat_sys_data_bluetooth, button, pIntentDisconnect) notification = new Notification.Builder(mContext, SAP_NOTIFICATION_CHANNEL) .setOngoing(true) .addAction(android.R.drawable.stat_sys_data_bluetooth, button, pIntentDisconnect) .setContentTitle(title) .setTicker(ticker) .setContentText(text) Loading @@ -245,7 +254,6 @@ public class SapServer extends Thread implements Callback { .setOnlyAlertOnce(true) .build(); } else { sapDisconnectIntent.putExtra(SapServer.SAP_DISCONNECT_TYPE_EXTRA, SapMessage.DISC_GRACEFULL); Intent sapForceDisconnectIntent = new Intent(SapServer.SAP_DISCONNECT_ACTION); Loading @@ -255,12 +263,16 @@ public class SapServer extends Thread implements Callback { SapMessage.DISC_GRACEFULL, sapDisconnectIntent,flags); PendingIntent pIntentForceDisconnect = PendingIntent.getBroadcast(mContext, SapMessage.DISC_IMMEDIATE, sapForceDisconnectIntent,flags); notification = new Notification.Builder(mContext).setOngoing(true) notification = new Notification.Builder(mContext, SAP_NOTIFICATION_CHANNEL) .setOngoing(true) .addAction(android.R.drawable.stat_sys_data_bluetooth, mContext.getString(R.string.bluetooth_sap_notif_disconnect_button), mContext.getString( R.string.bluetooth_sap_notif_disconnect_button), pIntentDisconnect) .addAction(android.R.drawable.stat_sys_data_bluetooth, mContext.getString(R.string.bluetooth_sap_notif_force_disconnect_button), mContext.getString( R.string.bluetooth_sap_notif_force_disconnect_button), pIntentForceDisconnect) .setContentTitle(title) .setTicker(ticker) Loading @@ -275,9 +287,6 @@ public class SapServer extends Thread implements Callback { // cannot be set with the builder notification.flags |= Notification.FLAG_NO_CLEAR |Notification.FLAG_ONLY_ALERT_ONCE; NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); } Loading