summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/input/InputManagerService.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-04-20 19:28:00 -0700
committerJeff Brown <jeffbrown@google.com>2012-04-20 20:11:12 -0700
commit5bbd4b4f5fc19302fa017ad6afee6eb2d489d91a (patch)
tree2bc118a5ef332003cc7f6791968076c48b3cf84b /services/java/com/android/server/input/InputManagerService.java
parent9e6d4b035d4f012d23264d3d2bc946b1ca02dba1 (diff)
Get alias for Bluetooth devices.
Bluetooth devices can be renamed by the user. Make the input system aware of the user-specified name and transparently pass it down to applications. This enables the keyboard layout picker Settings UI to use device names that are consistent with what the user set in the Bluetooth UI. Bug: 6363157 Change-Id: I8eea26ce2c69c2a3f09c8de02e9e847610e0419c
Diffstat (limited to 'services/java/com/android/server/input/InputManagerService.java')
-rw-r--r--services/java/com/android/server/input/InputManagerService.java36
1 files changed, 34 insertions, 2 deletions
diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java
index a4ed31c040af..189a9c726746 100644
--- a/services/java/com/android/server/input/InputManagerService.java
+++ b/services/java/com/android/server/input/InputManagerService.java
@@ -26,6 +26,8 @@ import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
import android.Manifest;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -56,6 +58,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
+import android.server.BluetoothService;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
@@ -106,6 +109,7 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
private final Callbacks mCallbacks;
private final InputManagerHandler mHandler;
private boolean mSystemReady;
+ private BluetoothService mBluetoothService;
// Persistent data store. Must be locked each time during use.
private final PersistentDataStore mDataStore = new PersistentDataStore();
@@ -167,6 +171,7 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
int repeat, int token);
private static native void nativeCancelVibrate(int ptr, int deviceId, int token);
private static native void nativeReloadKeyboardLayouts(int ptr);
+ private static native void nativeReloadDeviceAliases(int ptr);
private static native String nativeDump(int ptr);
private static native void nativeMonitor(int ptr);
@@ -217,12 +222,12 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
updateShowTouchesFromSettings();
}
- public void systemReady() {
+ public void systemReady(BluetoothService bluetoothService) {
if (DEBUG) {
Slog.d(TAG, "System ready.");
}
+ mBluetoothService = bluetoothService;
mSystemReady = true;
- reloadKeyboardLayouts();
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
@@ -237,12 +242,30 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
reloadKeyboardLayouts();
}
}, filter, null, mHandler);
+
+ filter = new IntentFilter(BluetoothDevice.ACTION_ALIAS_CHANGED);
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DEBUG) {
+ Slog.d(TAG, "Bluetooth alias changed, reloading device names.");
+ }
+ reloadDeviceAliases();
+ }
+ }, filter, null, mHandler);
+
+ reloadKeyboardLayouts();
+ reloadDeviceAliases();
}
private void reloadKeyboardLayouts() {
nativeReloadKeyboardLayouts(mPtr);
}
+ private void reloadDeviceAliases() {
+ nativeReloadDeviceAliases(mPtr);
+ }
+
public void setDisplaySize(int displayId, int width, int height,
int externalWidth, int externalHeight) {
if (width <= 0 || height <= 0 || externalWidth <= 0 || externalHeight <= 0) {
@@ -1121,6 +1144,15 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
return result;
}
+ // Native callback.
+ private String getDeviceAlias(String uniqueId) {
+ if (mBluetoothService != null &&
+ BluetoothAdapter.checkBluetoothAddress(uniqueId)) {
+ return mBluetoothService.getRemoteAlias(uniqueId);
+ }
+ return null;
+ }
+
/**
* Callback interface implemented by the Window Manager.