packages/apps/Settings
Revisão | 66b6591d4c14400a18573a11880db16bb26ab80a (tree) |
---|---|
Hora | 2015-10-21 02:23:40 |
Autor | Michael Wright <michaelwr@goog...> |
Commiter | Android (Google) Code Review |
Merge "Always show pairing dialog for device-specific keyboard." into mnc-dr-dev
@@ -65,8 +65,10 @@ public final class BluetoothPairingRequest extends BroadcastReceiver { | ||
65 | 65 | PowerManager powerManager = |
66 | 66 | (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
67 | 67 | String deviceAddress = device != null ? device.getAddress() : null; |
68 | - if (powerManager.isScreenOn() && | |
69 | - LocalBluetoothPreferences.shouldShowDialogInForeground(context, deviceAddress)) { | |
68 | + String deviceName = device != null ? device.getName() : null; | |
69 | + boolean shouldShowDialog= LocalBluetoothPreferences.shouldShowDialogInForeground( | |
70 | + context, deviceAddress, deviceName); | |
71 | + if (powerManager.isInteractive() && shouldShowDialog) { | |
70 | 72 | // Since the screen is on and the BT-related activity is in the foreground, |
71 | 73 | // just open the dialog |
72 | 74 | context.startActivity(pairingIntent); |
@@ -107,6 +107,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { | ||
107 | 107 | connectionAccessIntent.putExtra(BluetoothDevice.EXTRA_CLASS_NAME, mReturnClass); |
108 | 108 | |
109 | 109 | String deviceAddress = mDevice != null ? mDevice.getAddress() : null; |
110 | + String deviceName = mDevice != null ? mDevice.getName() : null; | |
110 | 111 | String title = null; |
111 | 112 | String message = null; |
112 | 113 | PowerManager powerManager = |
@@ -114,7 +115,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { | ||
114 | 115 | |
115 | 116 | if (powerManager.isScreenOn() |
116 | 117 | && LocalBluetoothPreferences.shouldShowDialogInForeground( |
117 | - context, deviceAddress)) { | |
118 | + context, deviceAddress, deviceName)) { | |
118 | 119 | context.startActivity(connectionAccessIntent); |
119 | 120 | } else { |
120 | 121 | // Acquire wakelock so that LCD comes up since screen is off |
@@ -134,27 +135,27 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { | ||
134 | 135 | deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT, |
135 | 136 | BluetoothDevice.CONNECTION_ACCESS_NO); |
136 | 137 | deleteIntent.putExtra(BluetoothDevice.EXTRA_ACCESS_REQUEST_TYPE, mRequestType); |
137 | - String deviceName = mDevice != null ? mDevice.getAliasName() : null; | |
138 | + String deviceAlias = mDevice != null ? mDevice.getAliasName() : null; | |
138 | 139 | switch (mRequestType) { |
139 | 140 | case BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS: |
140 | 141 | title = context.getString(R.string.bluetooth_phonebook_request); |
141 | 142 | message = context.getString(R.string.bluetooth_pb_acceptance_dialog_text, |
142 | - deviceName, deviceName); | |
143 | + deviceAlias, deviceAlias); | |
143 | 144 | break; |
144 | 145 | case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS: |
145 | 146 | title = context.getString(R.string.bluetooth_map_request); |
146 | 147 | message = context.getString(R.string.bluetooth_map_acceptance_dialog_text, |
147 | - deviceName, deviceName); | |
148 | + deviceAlias, deviceAlias); | |
148 | 149 | break; |
149 | 150 | case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS: |
150 | 151 | title = context.getString(R.string.bluetooth_sap_request); |
151 | 152 | message = context.getString(R.string.bluetooth_sap_acceptance_dialog_text, |
152 | - deviceName, deviceName); | |
153 | + deviceAlias, deviceAlias); | |
153 | 154 | break; |
154 | 155 | default: |
155 | 156 | title = context.getString(R.string.bluetooth_connection_permission_request); |
156 | 157 | message = context.getString(R.string.bluetooth_connection_dialog_text, |
157 | - deviceName, deviceName); | |
158 | + deviceAlias, deviceAlias); | |
158 | 159 | break; |
159 | 160 | } |
160 | 161 | Notification notification = new Notification.Builder(context) |
@@ -20,6 +20,7 @@ import android.app.QueuedWork; | ||
20 | 20 | import android.content.Context; |
21 | 21 | import android.content.SharedPreferences; |
22 | 22 | import android.content.res.Configuration; |
23 | +import android.text.TextUtils; | |
23 | 24 | import android.util.Log; |
24 | 25 | |
25 | 26 | import com.android.settingslib.bluetooth.LocalBluetoothAdapter; |
@@ -62,10 +63,10 @@ final class LocalBluetoothPreferences { | ||
62 | 63 | } |
63 | 64 | |
64 | 65 | static boolean shouldShowDialogInForeground(Context context, |
65 | - String deviceAddress) { | |
66 | + String deviceAddress, String deviceName) { | |
66 | 67 | LocalBluetoothManager manager = Utils.getLocalBtManager(context); |
67 | 68 | if (manager == null) { |
68 | - if(DEBUG) Log.v(TAG, "manager == null - do not show dialog."); | |
69 | + if (DEBUG) Log.v(TAG, "manager == null - do not show dialog."); | |
69 | 70 | return false; |
70 | 71 | } |
71 | 72 |
@@ -115,6 +116,18 @@ final class LocalBluetoothPreferences { | ||
115 | 116 | } |
116 | 117 | } |
117 | 118 | } |
119 | + | |
120 | + | |
121 | + if (!TextUtils.isEmpty(deviceName)) { | |
122 | + // If the device is a custom BT keyboard specifically for this device | |
123 | + String packagedKeyboardName = context.getString( | |
124 | + com.android.internal.R.string.config_packagedKeyboardName); | |
125 | + if (deviceName.equals(packagedKeyboardName)) { | |
126 | + if (DEBUG) Log.v(TAG, "showing dialog for packaged keyboard"); | |
127 | + return true; | |
128 | + } | |
129 | + } | |
130 | + | |
118 | 131 | if (DEBUG) Log.v(TAG, "Found no reason to show the dialog - do not show dialog."); |
119 | 132 | return false; |
120 | 133 | } |