diff options
author | Nick Pelly <npelly@google.com> | 2009-09-08 17:40:43 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-09-09 10:52:18 -0700 |
commit | b24e11baac589fe16426f2d243b460ab84991c7b (patch) | |
tree | fff4842c3fe188414743e077294984a1f0389a7c /core/java/android/server | |
parent | de893f550301a60274e87aa8168225e7a7a42184 (diff) | |
download | frameworks_base-b24e11baac589fe16426f2d243b460ab84991c7b.zip frameworks_base-b24e11baac589fe16426f2d243b460ab84991c7b.tar.gz frameworks_base-b24e11baac589fe16426f2d243b460ab84991c7b.tar.bz2 |
API_CHANGE
Deprecate BluetoothError.java.
I spent a lot of time experimenting with a class BluetoothError to enumerate
the many error codes returned by the Bluetooth API. But at the end of the day
they were never used. The vast majority of method calls only really need a
true/false error value, and often not even that.
Methods which do need more detailed error enumeration (for example, bonding
failures) can have there own enumerated error codes. But there is no need
for a common set of error codes.
Also change the IPC failed warnings in BluetoothA2dp to Log.e. These indicate
a very serious error.
Introduce BluetoothAdapter.ERROR and BluetoothDevice.ERROR as helper sentinel
values.
Diffstat (limited to 'core/java/android/server')
-rw-r--r-- | core/java/android/server/BluetoothA2dpService.java | 40 | ||||
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 3 | ||||
-rw-r--r-- | core/java/android/server/BluetoothService.java | 5 |
3 files changed, 22 insertions, 26 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index 4fa81bb..a24e0d2 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -25,7 +25,6 @@ package android.server; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothError; import android.bluetooth.BluetoothIntent; import android.bluetooth.BluetoothUuid; import android.bluetooth.IBluetoothA2dp; @@ -83,7 +82,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { intent.getParcelableExtra(BluetoothIntent.DEVICE); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, - BluetoothError.ERROR); + BluetoothAdapter.ERROR); switch (state) { case BluetoothAdapter.STATE_ON: onBluetoothEnable(); @@ -94,7 +93,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } } else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) { int bondState = intent.getIntExtra(BluetoothIntent.BOND_STATE, - BluetoothError.ERROR); + BluetoothDevice.ERROR); switch(bondState) { case BluetoothDevice.BOND_BONDED: setSinkPriority(device, BluetoothA2dp.PRIORITY_AUTO); @@ -273,7 +272,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { mAudioManager.setParameters(BLUETOOTH_ENABLED + "=false"); } - public synchronized int connectSink(BluetoothDevice device) { + public synchronized boolean connectSink(BluetoothDevice device) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) log("connectSink(" + device + ")"); @@ -284,11 +283,11 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { BluetoothA2dp.STATE_CONNECTED, BluetoothA2dp.STATE_PLAYING, BluetoothA2dp.STATE_DISCONNECTING}).size() != 0) { - return BluetoothError.ERROR; + return false; } if (mAudioDevices.get(device) == null && !addAudioSink(device)) - return BluetoothError.ERROR; + return false; int state = mAudioDevices.get(device); @@ -296,44 +295,44 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { case BluetoothA2dp.STATE_CONNECTED: case BluetoothA2dp.STATE_PLAYING: case BluetoothA2dp.STATE_DISCONNECTING: - return BluetoothError.ERROR; + return false; case BluetoothA2dp.STATE_CONNECTING: - return BluetoothError.SUCCESS; + return true; } String path = mBluetoothService.getObjectPathFromAddress(device.getAddress()); if (path == null) - return BluetoothError.ERROR; + return false; // State is DISCONNECTED if (!connectSinkNative(path)) { - return BluetoothError.ERROR; + return false; } - return BluetoothError.SUCCESS; + return true; } - public synchronized int disconnectSink(BluetoothDevice device) { + public synchronized boolean disconnectSink(BluetoothDevice device) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (DBG) log("disconnectSink(" + device + ")"); String path = mBluetoothService.getObjectPathFromAddress(device.getAddress()); if (path == null) { - return BluetoothError.ERROR; + return false; } switch (getSinkState(device)) { case BluetoothA2dp.STATE_DISCONNECTED: - return BluetoothError.ERROR; + return false; case BluetoothA2dp.STATE_DISCONNECTING: - return BluetoothError.SUCCESS; + return true; } // State is CONNECTING or CONNECTED or PLAYING if (!disconnectSinkNative(path)) { - return BluetoothError.ERROR; + return false; } else { - return BluetoothError.SUCCESS; + return true; } } @@ -359,15 +358,14 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { BluetoothA2dp.PRIORITY_OFF); } - public synchronized int setSinkPriority(BluetoothDevice device, int priority) { + public synchronized boolean setSinkPriority(BluetoothDevice device, int priority) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); if (!BluetoothDevice.checkBluetoothAddress(device.getAddress())) { - return BluetoothError.ERROR; + return false; } return Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.getBluetoothA2dpSinkPriorityKey(device.getAddress()), priority) ? - BluetoothError.SUCCESS : BluetoothError.ERROR; + Settings.Secure.getBluetoothA2dpSinkPriorityKey(device.getAddress()), priority); } private synchronized void onSinkPropertyChanged(String path, String []propValues) { diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 9f36f7e..b5eb9ac 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -20,7 +20,6 @@ import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothError; import android.bluetooth.BluetoothIntent; import android.bluetooth.BluetoothUuid; import android.content.Context; @@ -169,7 +168,7 @@ class BluetoothEventLoop { private void onCreatePairedDeviceResult(String address, int result) { address = address.toUpperCase(); - if (result == BluetoothError.SUCCESS) { + if (result == BluetoothDevice.BOND_SUCCESS) { mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED); if (mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) { mBluetoothService.getBondState().clearPinAttempts(address); diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 6940075..6482c4c 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -27,7 +27,6 @@ package android.server; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothError; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothIntent; import android.bluetooth.IBluetooth; @@ -810,7 +809,7 @@ public class BluetoothService extends IBluetooth.Stub { public synchronized int getBondState(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (!BluetoothDevice.checkBluetoothAddress(address)) { - return BluetoothError.ERROR; + return BluetoothDevice.ERROR; } return mBondState.getBondState(address.toUpperCase()); } @@ -984,7 +983,7 @@ public class BluetoothService extends IBluetooth.Stub { public int getRemoteServiceChannel(String address, String uuid) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (!BluetoothDevice.checkBluetoothAddress(address)) { - return BluetoothError.ERROR_IPC; + return BluetoothDevice.ERROR; } return getDeviceServiceChannelNative(getObjectPathFromAddress(address), uuid, 0x0004); } |