diff options
Diffstat (limited to 'src/com')
3 files changed, 26 insertions, 10 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java index 5b06661..ba1d918 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java @@ -65,8 +65,10 @@ public final class BluetoothPairingRequest extends BroadcastReceiver { PowerManager powerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); String deviceAddress = device != null ? device.getAddress() : null; - if (powerManager.isScreenOn() && - LocalBluetoothPreferences.shouldShowDialogInForeground(context, deviceAddress)) { + String deviceName = device != null ? device.getName() : null; + boolean shouldShowDialog= LocalBluetoothPreferences.shouldShowDialogInForeground( + context, deviceAddress, deviceName); + if (powerManager.isInteractive() && shouldShowDialog) { // Since the screen is on and the BT-related activity is in the foreground, // just open the dialog context.startActivity(pairingIntent); diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java index 074e0bd..fc6b876 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java @@ -107,6 +107,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_CLASS_NAME, mReturnClass); String deviceAddress = mDevice != null ? mDevice.getAddress() : null; + String deviceName = mDevice != null ? mDevice.getName() : null; String title = null; String message = null; PowerManager powerManager = @@ -114,7 +115,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { if (powerManager.isScreenOn() && LocalBluetoothPreferences.shouldShowDialogInForeground( - context, deviceAddress)) { + context, deviceAddress, deviceName)) { context.startActivity(connectionAccessIntent); } else { // Acquire wakelock so that LCD comes up since screen is off @@ -134,27 +135,27 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT, BluetoothDevice.CONNECTION_ACCESS_NO); deleteIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, mRequestType); - String deviceName = mDevice != null ? mDevice.getAliasName() : null; + String deviceAlias = mDevice != null ? mDevice.getAliasName() : null; switch (mRequestType) { case BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS: title = context.getString(R.string.bluetooth_phonebook_request); message = context.getString(R.string.bluetooth_pb_acceptance_dialog_text, - deviceName, deviceName); + deviceAlias, deviceAlias); break; case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS: title = context.getString(R.string.bluetooth_map_request); message = context.getString(R.string.bluetooth_map_acceptance_dialog_text, - deviceName, deviceName); + deviceAlias, deviceAlias); break; case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS: title = context.getString(R.string.bluetooth_sap_request); message = context.getString(R.string.bluetooth_sap_acceptance_dialog_text, - deviceName, deviceName); + deviceAlias, deviceAlias); break; default: title = context.getString(R.string.bluetooth_connection_permission_request); message = context.getString(R.string.bluetooth_connection_dialog_text, - deviceName, deviceName); + deviceAlias, deviceAlias); break; } Notification notification = new Notification.Builder(context) diff --git a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java index 9f2553f..401b13c 100644 --- a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java +++ b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java @@ -20,6 +20,7 @@ import android.app.QueuedWork; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.text.TextUtils; import android.util.Log; import com.android.settingslib.bluetooth.LocalBluetoothAdapter; @@ -62,10 +63,10 @@ final class LocalBluetoothPreferences { } static boolean shouldShowDialogInForeground(Context context, - String deviceAddress) { + String deviceAddress, String deviceName) { LocalBluetoothManager manager = Utils.getLocalBtManager(context); if (manager == null) { - if(DEBUG) Log.v(TAG, "manager == null - do not show dialog."); + if (DEBUG) Log.v(TAG, "manager == null - do not show dialog."); return false; } @@ -115,6 +116,18 @@ final class LocalBluetoothPreferences { } } } + + + if (!TextUtils.isEmpty(deviceName)) { + // If the device is a custom BT keyboard specifically for this device + String packagedKeyboardName = context.getString( + com.android.internal.R.string.config_packagedKeyboardName); + if (deviceName.equals(packagedKeyboardName)) { + if (DEBUG) Log.v(TAG, "showing dialog for packaged keyboard"); + return true; + } + } + if (DEBUG) Log.v(TAG, "Found no reason to show the dialog - do not show dialog."); return false; } |