BT: The Phone doesn't "wake up" when trying to pair with it.
To improve the pairing request usability: - In the case where a notification shall be used the standard notification sound is added - When the screen is off notification is always used. Change-Id: I751a7913517c64de5d7ba06d7c17358197d002c5
This commit is contained in:
committed by
Jaikumar Ganesh
parent
5774d5d34b
commit
83c3b64ff7
@@ -27,6 +27,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BluetoothPairingRequest is a receiver for any Bluetooth pairing request. It
|
* BluetoothPairingRequest is a receiver for any Bluetooth pairing request. It
|
||||||
@@ -61,9 +62,13 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
|
|||||||
pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
|
pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
|
||||||
pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
|
PowerManager powerManager =
|
||||||
|
(PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||||
String deviceAddress = device != null ? device.getAddress() : null;
|
String deviceAddress = device != null ? device.getAddress() : null;
|
||||||
if (localManager.shouldShowDialogInForeground(deviceAddress)) {
|
if (powerManager.isScreenOn() &&
|
||||||
// Since the BT-related activity is in the foreground, just open the dialog
|
localManager.shouldShowDialogInForeground(deviceAddress)) {
|
||||||
|
// Since the screen is on and the BT-related activity is in the foreground,
|
||||||
|
// just open the dialog
|
||||||
context.startActivity(pairingIntent);
|
context.startActivity(pairingIntent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -88,6 +93,7 @@ public class BluetoothPairingRequest extends BroadcastReceiver {
|
|||||||
res.getString(R.string.bluetooth_notif_message) + name,
|
res.getString(R.string.bluetooth_notif_message) + name,
|
||||||
pending);
|
pending);
|
||||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||||
|
notification.defaults |= Notification.DEFAULT_SOUND;
|
||||||
|
|
||||||
NotificationManager manager = (NotificationManager)
|
NotificationManager manager = (NotificationManager)
|
||||||
context.getSystemService(Context.NOTIFICATION_SERVICE);
|
context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
Reference in New Issue
Block a user