diff options
20 files changed, 23 insertions, 1933 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index aac4cea6b..82cf9cdc5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -65,15 +65,6 @@ </activity> <activity android:name=".opp.BluetoothOppTransferActivity"> </activity> - <activity android:name=".opp.BluetoothDevicePickerActivity"> - </activity> - <activity android:name=".opp.BluetoothPinDialog" android:label="@string/bluetooth_pin_entry" - android:theme="@*android:style/Theme.Dialog.Alert"> - <intent-filter> - <action android:name="android.bluetooth.intent.action.PAIRING_REQUEST" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - </activity> <activity android:name=".opp.BluetoothOppLiveFolder" android:label="@string/btopp_live_folder"> <intent-filter> diff --git a/res/drawable/ic_bt_cellphone.png b/res/drawable/ic_bt_cellphone.png Binary files differdeleted file mode 100644 index 4bf7ba550..000000000 --- a/res/drawable/ic_bt_cellphone.png +++ /dev/null diff --git a/res/drawable/ic_bt_laptop.png b/res/drawable/ic_bt_laptop.png Binary files differdeleted file mode 100644 index 49a71c9da..000000000 --- a/res/drawable/ic_bt_laptop.png +++ /dev/null diff --git a/res/layout/bluetooth_pin_entry.xml b/res/layout/bluetooth_pin_entry.xml deleted file mode 100644 index 54cf08810..000000000 --- a/res/layout/bluetooth_pin_entry.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<ScrollView - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_height="fill_parent" - android:layout_width="fill_parent"> - - <LinearLayout - android:layout_height="wrap_content" - android:layout_width="fill_parent" - android:orientation="vertical"> - - <TextView - android:id="@+id/message" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:gravity="center_horizontal" - android:textAppearance="?android:attr/textAppearanceMedium" /> - - <EditText - android:id="@+id/text" - android:layout_height="wrap_content" - android:layout_width="fill_parent" - android:layout_marginTop="20dip" - android:layout_marginLeft="20dip" - android:layout_marginRight="20dip" - android:singleLine="true" /> - - </LinearLayout> - -</ScrollView> diff --git a/res/layout/device_picker.xml b/res/layout/device_picker.xml deleted file mode 100644 index 22b37eba3..000000000 --- a/res/layout/device_picker.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<PreferenceScreen - xmlns:android="http://schemas.android.com/apk/res/android"> - - <PreferenceCategory - android:title="@string/device_picker"/> - - <Preference - android:key="bt_scan" - android:title="@string/bluetooth_preference_scan_title" /> - - <com.android.bluetooth.opp.ProgressCategory - android:key="bt_device_list" - android:title="@string/bluetooth_devices" - android:orderingFromXml="false" /> - -</PreferenceScreen> - diff --git a/res/layout/preference_bluetooth.xml b/res/layout/preference_bluetooth.xml deleted file mode 100644 index b2b44feb3..000000000 --- a/res/layout/preference_bluetooth.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:minHeight="?android:attr/listPreferredItemHeight" - android:gravity="center_vertical" - android:paddingLeft="16dip" - android:paddingRight="?android:attr/scrollbarSize"> - - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginRight="6dip" - android:layout_marginTop="6dip" - android:layout_marginBottom="6dip" - android:layout_weight="1"> - - <TextView android:id="@+android:id/title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:textAppearance="?android:attr/textAppearanceLarge" /> - - <TextView android:id="@+android:id/summary" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@android:id/title" - android:layout_alignLeft="@android:id/title" - android:textAppearance="?android:attr/textAppearanceSmall" - android:maxLines="2" /> - - </RelativeLayout> - - <ImageView - android:id="@+id/btClass" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginRight="12dip" - android:layout_gravity="center_vertical" /> - -</LinearLayout>
\ No newline at end of file diff --git a/res/layout/preference_progress_category.xml b/res/layout/preference_progress_category.xml deleted file mode 100644 index e66b15dc2..000000000 --- a/res/layout/preference_progress_category.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Layout used for ProgressCategory in bluetooth settings. --> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - style="?android:attr/listSeparatorTextViewStyle"> - - <!-- This and the other text view have the style of the list separator text view without the background and padding --> - <TextView - style="?android:attr/listSeparatorTextViewStyle" - android:background="@null" - android:paddingLeft="0dip" - android:id="@+android:id/title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - /> - - <ProgressBar - android:id="@+id/scanning_progress" - android:text="@string/progress_scanning" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:layout_marginRight="?android:attr/scrollbarSize" - style="?android:attr/progressBarStyleSmallTitle" - /> - - <TextView - style="?android:attr/listSeparatorTextViewStyle" - android:background="@null" - android:paddingLeft="0dip" - android:id="@+id/scanning_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:layout_toLeftOf="@id/scanning_progress" - android:layout_marginRight="5sp" - android:text="@string/progress_scanning" - /> - -</RelativeLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index 8066b0382..515400ccd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -30,85 +30,6 @@ <string name="airplane_error_msg">Phone is currently in airplane mode, this action is forbidden!</string> - <!-- strings for device picker start --> - <string name="screen_device_picker">Scan Bluetooth device</string> - <string name="progress_scanning">Scanning</string> - <string name="bluetooth_devices">Bluetooth devices</string> - <string name="bluetooth_settings">Bluetooth settings</string> - <string name="device_picker">Bluetooth device picker</string> - <string name="bluetooth_preference_scan_title">Scan for devices</string> - <string name="bluetooth_connected">Connected</string> - <!-- Bluetooth settings. Message when a device is disconnected --> - <string name="bluetooth_disconnected">Disconnected</string> - <!-- Bluetooth settings. Message when disconnecting from a device --> - <string name="bluetooth_disconnecting">Disconnecting</string> - <!-- Bluetooth settings. Message when connecting to a device --> - <string name="bluetooth_connecting">Connecting</string> - <!-- Bluetooth settings. Message when the device state is unknown --> - <string name="bluetooth_unknown"></string> - <!-- - Bluetooth settings screen, summary text under individual Bluetooth - devices when not paired yet - --> - <string name="bluetooth_not_connected">Pair with this device</string> - <!-- - Bluetooth settings screen, summary text when unable to turn on - Bluetooth - --> - <string name="bluetooth_failed_to_enable">Unable to turn on Bluetooth</string> - <!-- - Bluetooth settings screen, summary text under individual Bluetooth - devices when failure to pair with one - --> - <string name="failed_to_pair">Unable to pair</string> - - <!-- Title for BT error dialogs. --> - <string name="bluetooth_error_title">Attention</string> - <!-- Message for the error dialog when BT pairing fails generically. --> - <string name="bluetooth_pairing_error_message">There was a problem pairing.</string> - <!-- - Notification ticker text (shown in the status bar) when a Bluetooth - device wants to pair with us - --> - <string name="bluetooth_notif_ticker">Bluetooth pairing request</string> - <!-- Notification title when a Bluetooth device wants to pair with us--> - <string name="bluetooth_notif_title">Pairing request</string> - <!-- - Notification message when a Bluetooth device wants to pair with us - --> - <string name="bluetooth_notif_message">Select to pair with</string> - - <!-- Title for the dialog to enter PIN. --> - <string name="bluetooth_pin_entry">Bluetooth pairing request</string> - <!-- Title for the bluetooth device info screen. --> - <string name="bluetooth_device_info">Bluetooth device info</string> - <!-- Message when the bluetooth is pairing with anotehr device --> - <string name="bluetooth_pairing_msg">Pairing</string> - <!-- Message when bluetooth dialog for pin entry is shwoing --> - <string name="bluetooth_enter_pin_msg">Type PIN to pair.</string> - - <!-- Bluetooth Device Selection Dialog --> - <!--Title for "Bluetooth Device Selection Dialog" --> - <string name="devicepicker_title">Select Device</string> - <!--The label of the available devices list" --> - <string name="available_devices">Available Devices</string> - <!--Summary text to show in header when scanning --> - <string name="scanning">Scanning</string> - <!-- - Summary text under individual Bluetooth devices when not paired with - one - --> - <string name="bluetooth_unpaired">Unpaired</string> - <!-- - Summary text under individual Bluetooth devices when paired with one - --> - <string name="bluetooth_paired">Paired</string> - <!--Summary text under individual Bluetooth devices when pairing --> - <string name="bluetooth_pairing">Pairing</string> - <!-- Menu item to scan for nearby bluetooth devices --> - <string name="bluetooth_scan_for_devices">Scan for devices</string> - <!-- strings for device picker end --> - <!-- Activate Bluetooth Confirmation Dialog --> <!--Title --> <string name="bt_enable_title">Bluetooth</string> diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerActivity.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerActivity.java deleted file mode 100644 index 49ba65126..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerActivity.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import java.util.List; -import java.util.WeakHashMap; - -import android.bluetooth.BluetoothDevice; -import android.os.Bundle; -import android.util.Log; -import android.util.Config; -import android.content.Intent; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceScreen; - -public class BluetoothDevicePickerActivity extends PreferenceActivity implements - BluetoothDevicePickerManager.Callback { - // public class BluetoothDevicePickerManager extends Activity { - static final int BASIC_PANEL = 0; - - static final int ADVANCED_PANEL = 1; - - private static final String LOG_TAG = "-------------BluetoothDevicePickerActivity"; - - private static final boolean DEBUG = true; - - private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV; - - /* for device picker */ - private static final String KEY_BT_DEVICE_LIST = "bt_device_list"; - - private static final String KEY_BT_SCAN = "bt_scan"; - - private ProgressCategory mDeviceList; - - private WeakHashMap<BluetoothDevicePickerDevice, BluetoothDevicePickerDevicePreference> mDevicePreferenceMap = new WeakHashMap<BluetoothDevicePickerDevice, BluetoothDevicePickerDevicePreference>(); - - private BluetoothDevicePickerManager mLocalManager; - - @Override - public void onCreate(Bundle icicle) { - log("onCreate"); - super.onCreate(icicle); - - addPreferencesFromResource(R.layout.device_picker); - mLocalManager = BluetoothDevicePickerManager.getInstance(this); - if (mLocalManager == null) { - log("mLocalManager is null"); - finish(); - } - - mDeviceList = (ProgressCategory)findPreference(KEY_BT_DEVICE_LIST); - } - - @Override - protected void onResume() { - super.onResume(); - log("onResume"); - mDevicePreferenceMap.clear(); - - mDeviceList.removeAll(); - if (mLocalManager != null) { - mLocalManager.startBluetoothEventListener(); - addDevices(); - mLocalManager.registerCallback(this); - mLocalManager.setForegroundActivity(this); - } - } - - @Override - public void onPause() { - super.onPause(); - mLocalManager.unregisterCallback(this); - } - - @Override - public void onStop() { - super.onStop(); - if (mLocalManager != null) { - mLocalManager.stopBluetoothEventListener(); - } - } - - @Override - public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, - Preference preference) { - log("onPreferenceTreeClick"); - - if (KEY_BT_SCAN.equals(preference.getKey())) { - log("begin to scan"); - mLocalManager.startScanning(true); - return super.onPreferenceTreeClick(preferenceScreen, preference); - } else if (preference instanceof BluetoothDevicePickerDevicePreference) { - log("user choosed a device"); - BluetoothDevicePickerDevicePreference btPreference = - (BluetoothDevicePickerDevicePreference) preference; - BluetoothDevicePickerDevice device = btPreference.getDevice(); - // device.onClicked(); - - if (device.getPairingStatus() == BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRED) { - log("the device chosed is paired, send intent to" + - " OPP with the BT device and finish this activity."); - BluetoothDevice remoteDevice = btPreference.getDevice().getRemoteDevice(); - Intent intent = new Intent(BluetoothShare.BLUETOOTH_DEVICE_SELECTED_ACTION); - intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class - .getName()); - intent.putExtra("BT_DEVICE", remoteDevice); - this.sendBroadcast(intent); - super.onPreferenceTreeClick(preferenceScreen, preference); - finish(); - } else { - log("the device chosed is NOT paired, try to pair" + - " with it and wait for bond request from bluez"); - device.pair(); - } - - return super.onPreferenceTreeClick(preferenceScreen, preference); - } - - return super.onPreferenceTreeClick(preferenceScreen, preference); - } - - public void onScanningStateChanged(boolean started) { - log("onScanningStateChanged"); - mDeviceList.setProgress(started); - } - - public void onDeviceAdded(BluetoothDevicePickerDevice device) { - log("onDeviceAdded"); - - if (mDevicePreferenceMap.get(device) != null) { - throw new IllegalStateException("Got onDeviceAdded, but device already exists"); - } - - createDevicePreference(device); - } - - public void onDeviceDeleted(BluetoothDevicePickerDevice device) { - BluetoothDevicePickerDevicePreference preference = mDevicePreferenceMap.remove(device); - if (preference != null) { - mDeviceList.removePreference(preference); - } - } - - public void onBondingStateChanged(BluetoothDevice remoteDevice, boolean created) { - log("onBondingStateChanged"); - if (created == true) { - Intent intent = new Intent(BluetoothShare.BLUETOOTH_DEVICE_SELECTED_ACTION); - intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName()); - intent.putExtra("BT_DEVICE", remoteDevice); - this.sendBroadcast(intent); - log("the device bond succeeded, send intent to OPP"); - } - - finish(); - } - - private void addDevices() { - List<BluetoothDevicePickerDevice> devices = mLocalManager.getLocalDeviceManager() - .getDevicesCopy(); - for (BluetoothDevicePickerDevice device : devices) { - onDeviceAdded(device); - } - } - - private void createDevicePreference(BluetoothDevicePickerDevice device) { - log("createDevicePreference"); - BluetoothDevicePickerDevicePreference preference = new BluetoothDevicePickerDevicePreference( - this, device); - mDeviceList.addPreference(preference); - mDevicePreferenceMap.put(device, preference); - } - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(LOG_TAG, message); - } - } -} diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerBtStatus.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerBtStatus.java deleted file mode 100644 index c89de11d7..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerBtStatus.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -/** - * BluetoothDevicePickerBtStatus is a helper class that contains constants for - * various status codes. - */ -public class BluetoothDevicePickerBtStatus { - private static final String TAG = "BluetoothDevicePickerBtStatus"; - - // Connection status - - public static final int CONNECTION_STATUS_UNKNOWN = 0; - - public static final int CONNECTION_STATUS_ACTIVE = 1; - - /** Use {@link #isConnected} to check for the connected state */ - public static final int CONNECTION_STATUS_CONNECTED = 2; - - public static final int CONNECTION_STATUS_CONNECTING = 3; - - public static final int CONNECTION_STATUS_DISCONNECTED = 4; - - public static final int CONNECTION_STATUS_DISCONNECTING = 5; - - public static final int getConnectionStatusSummary(int connectionStatus) { - switch (connectionStatus) { - case CONNECTION_STATUS_ACTIVE: - return R.string.bluetooth_connected; - case CONNECTION_STATUS_CONNECTED: - return R.string.bluetooth_connected; - case CONNECTION_STATUS_CONNECTING: - return R.string.bluetooth_connecting; - case CONNECTION_STATUS_DISCONNECTED: - return R.string.bluetooth_disconnected; - case CONNECTION_STATUS_DISCONNECTING: - return R.string.bluetooth_disconnecting; - case CONNECTION_STATUS_UNKNOWN: - return R.string.bluetooth_unknown; - default: - return 0; - } - } - - public static final boolean isConnectionStatusConnected(int connectionStatus) { - return connectionStatus == CONNECTION_STATUS_ACTIVE - || connectionStatus == CONNECTION_STATUS_CONNECTED; - } - - public static final boolean isConnectionStatusBusy(int connectionStatus) { - return connectionStatus == CONNECTION_STATUS_CONNECTING - || connectionStatus == CONNECTION_STATUS_DISCONNECTING; - } - - // Pairing status - - public static final int PAIRING_STATUS_UNPAIRED = 0; - - public static final int PAIRING_STATUS_PAIRED = 1; - - public static final int PAIRING_STATUS_PAIRING = 2; - - public static final int getPairingStatusSummary(int pairingStatus) { - switch (pairingStatus) { - case PAIRING_STATUS_PAIRED: - return R.string.bluetooth_paired; - case PAIRING_STATUS_PAIRING: - return R.string.bluetooth_pairing; - case PAIRING_STATUS_UNPAIRED: - return R.string.bluetooth_not_connected; - default: - return 0; - } - } -} diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerDevice.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerDevice.java deleted file mode 100644 index ecf5b5e6d..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerDevice.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothClass; -import android.bluetooth.BluetoothDevice; -import android.content.Context; -import android.text.TextUtils; -import android.util.Log; - -import java.util.ArrayList; -import java.util.List; - -/** - * BluetoothDevicePickerDevice represents a remote Bluetooth device. It contains - * attributes of the device (such as the address, name, RSSI, etc.) and - * functionality that can be performed on the device (pair, etc.). - */ -public class BluetoothDevicePickerDevice implements Comparable<BluetoothDevicePickerDevice> { - private static final String TAG = "BluetoothDevicePickerDevice"; - - private static final boolean V = BluetoothDevicePickerDevice.V; - - private final BluetoothDevice mDevice; - - private String mName; - - private short mRssi; - - private int mBtClass = BluetoothClass.ERROR; - - private boolean mVisible; - - private int mPairingStatus; - - private final BluetoothDevicePickerManager mLocalManager; - - private List<Callback> mCallbacks = new ArrayList<Callback>(); - - BluetoothDevicePickerDevice(Context context, BluetoothDevice device) { - mLocalManager = BluetoothDevicePickerManager.getInstance(context); - if (mLocalManager == null) { - throw new IllegalStateException( - "Cannot use BluetoothDevicePickerManager without Bluetooth hardware"); - } - - mDevice = device; - - fillData(); - } - - public void onClicked() { - Log.v(TAG, "onClicked"); - int pairingStatus = getPairingStatus(); - - if (pairingStatus == BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRED) { - // send intent to OPP - Log.v(TAG, "onClicked: PAIRING_STATUS_PAIRED"); - sendToOpp(); - } else if (pairingStatus == BluetoothDevicePickerBtStatus.PAIRING_STATUS_UNPAIRED) { - Log.v(TAG, "onClicked: PAIRING_STATUS_UNPAIRED"); - pair(); - } - } - - public void sendToOpp() { - if (!ensurePaired()) - return; - } - - private boolean ensurePaired() { - if (getPairingStatus() == BluetoothDevicePickerBtStatus.PAIRING_STATUS_UNPAIRED) { - pair(); - return false; - } else { - return true; - } - } - - public void pair() { - BluetoothAdapter adapter = mLocalManager.getBluetoothAdapter(); - Log.v(TAG, "pair enter"); - - // Pairing doesn't work if scanning, so cancel - if (adapter.isDiscovering()) { - Log.v(TAG, "is discovering"); - adapter.cancelDiscovery(); - } - - if (mDevice.createBond()) { - Log.v(TAG, "set status: PAIRING_STATUS_PAIRING"); - setPairingStatus(BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRING); - } - Log.v(TAG, "pair exit"); - } - - public void unpair() { - switch (getPairingStatus()) { - case BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRED: - mDevice.removeBond(); - break; - - case BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRING: - mDevice.cancelBondProcess(); - break; - } - } - - private void fillData() { - fetchName(); - mBtClass = mDevice.getBluetoothClass(); - mPairingStatus = mDevice.getBondState(); - mVisible = false; - dispatchAttributesChanged(); - } - - public BluetoothDevice getRemoteDevice() { - return mDevice; - } - - public String getName() { - return mName; - } - - public void refreshName() { - fetchName(); - dispatchAttributesChanged(); - } - - private void fetchName() { - mName = mDevice.getName(); - - if (TextUtils.isEmpty(mName)) { - mName = mDevice.getAddress(); - } - } - - public void refresh() { - dispatchAttributesChanged(); - } - - public boolean isVisible() { - return mVisible; - } - - void setVisible(boolean visible) { - if (mVisible != visible) { - mVisible = visible; - dispatchAttributesChanged(); - } - } - - public int getPairingStatus() { - return mPairingStatus; - } - - void setPairingStatus(int pairingStatus) { - if (mPairingStatus != pairingStatus) { - mPairingStatus = pairingStatus; - dispatchAttributesChanged(); - } - } - - void setRssi(short rssi) { - if (mRssi != rssi) { - mRssi = rssi; - dispatchAttributesChanged(); - } - } - - public int getBtClassDrawable() { - switch (BluetoothClass.Device.Major.getDeviceMajor(mBtClass)) { - case BluetoothClass.Device.Major.COMPUTER: - return R.drawable.ic_bt_laptop; - - case BluetoothClass.Device.Major.PHONE: - return R.drawable.ic_bt_cellphone; - - default: - return 0; - } - } - - public int getSummary() { - int pairingStatus = getPairingStatus(); - return BluetoothDevicePickerBtStatus.getPairingStatusSummary(pairingStatus); - } - - public void registerCallback(Callback callback) { - synchronized (mCallbacks) { - mCallbacks.add(callback); - } - } - - public void unregisterCallback(Callback callback) { - synchronized (mCallbacks) { - mCallbacks.remove(callback); - } - } - - private void dispatchAttributesChanged() { - synchronized (mCallbacks) { - for (Callback callback : mCallbacks) { - callback.onDeviceAttributesChanged(this); - } - } - } - - @Override - public String toString() { - return mDevice.toString(); - } - - @Override - public boolean equals(Object o) { - if ((o == null) || !(o instanceof BluetoothDevicePickerDevice)) { - throw new ClassCastException(); - } - - return mDevice.equals(((BluetoothDevicePickerDevice)o).mDevice); - } - - @Override - public int hashCode() { - return mDevice.hashCode(); - } - - public int compareTo(BluetoothDevicePickerDevice another) { - int comparison; - - // Paired above not paired - comparison = (another.mPairingStatus == BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRED ? 1 - : 0) - - (mPairingStatus == BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRED ? 1 : 0); - if (comparison != 0) - return comparison; - - // Visible above not visible - comparison = (another.mVisible ? 1 : 0) - (mVisible ? 1 : 0); - if (comparison != 0) - return comparison; - - // Stronger signal above weaker signal - comparison = another.mRssi - mRssi; - if (comparison != 0) - return comparison; - - // Fallback on name - return getName().compareTo(another.getName()); - } - - public interface Callback { - void onDeviceAttributesChanged(BluetoothDevicePickerDevice device); - } -} diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerDeviceManager.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerDeviceManager.java deleted file mode 100644 index fe77189b9..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerDeviceManager.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothClass; -import android.bluetooth.BluetoothDevice; -import android.util.Log; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - * BluetoothDevicePickerDeviceManager manages the set of remote Bluetooth - * devices. - */ -public class BluetoothDevicePickerDeviceManager { - private static final String TAG = "BluetoothDevicePickerDeviceManager"; - - final BluetoothDevicePickerManager mLocalManager; - - final List<BluetoothDevicePickerManager.Callback> mCallbacks; - - final List<BluetoothDevicePickerDevice> mDevices = new ArrayList<BluetoothDevicePickerDevice>(); - - public BluetoothDevicePickerDeviceManager(BluetoothDevicePickerManager localManager) { - mLocalManager = localManager; - mCallbacks = localManager.getCallbacks(); - Log.e(TAG, "BluetoothDevicePickerDeviceManager"); - readPairedDevices(); - } - - private synchronized void readPairedDevices() { - Log.e(TAG, "readPairedDevices"); - BluetoothAdapter adapter = mLocalManager.getBluetoothAdapter(); - Set<BluetoothDevice> bondedDevices = adapter.getBondedDevices(); - - if (bondedDevices == null) { - Log.e(TAG, "there is no bonded device"); - return; - } - - for (BluetoothDevice remoteDevice : bondedDevices) { - /* only show OPP capable devices: phone and computer */ - if (isOppCapableDevice(remoteDevice) == false) { - continue; - } - - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - if (device == null) { - device = new BluetoothDevicePickerDevice(mLocalManager.getContext(), remoteDevice); - mDevices.add(device); - dispatchDeviceAdded(device); - } - } - } - - public synchronized List<BluetoothDevicePickerDevice> getDevicesCopy() { - return new ArrayList<BluetoothDevicePickerDevice>(mDevices); - } - - void onBluetoothStateChanged(boolean enabled) { - if (enabled) { - readPairedDevices(); - } - } - - public synchronized void onDeviceAppeared(BluetoothDevice remoteDevice, short rssi) { - Log.e(TAG, "onDeviceAppeared"); - - /* only show OPP capable devices: phone and computer */ - if (isOppCapableDevice(remoteDevice) == false) { - return; - } - - boolean deviceAdded = false; - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - if (device == null) { - Log.e(TAG, "device is not found, add a new device"); - device = new BluetoothDevicePickerDevice(mLocalManager.getContext(), remoteDevice); - mDevices.add(device); - deviceAdded = true; - } - - device.setRssi(rssi); - device.setVisible(true); - - if (deviceAdded) { - Log.e(TAG, "call dispatchDeviceAdded"); - dispatchDeviceAdded(device); - } - } - - private boolean isOppCapableDevice(BluetoothDevice remoteDevice) { - Log.e(TAG, "isOppCapableDevice"); - - int btClass = remoteDevice.getBluetoothClass(); - int major = BluetoothClass.Device.Major.getDeviceMajor(btClass); - if ((major != BluetoothClass.Device.Major.COMPUTER) - && (major != BluetoothClass.Device.Major.PHONE)) { - Log.e(TAG, "this is NOT an OPP capable device"); - return false; - } else { - Log.e(TAG, "this is an OPP capable device"); - return true; - } - } - - public synchronized void onDeviceDisappeared(BluetoothDevice remoteDevice) { - Log.e(TAG, "onDeviceDisappeared"); - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - if (device == null) - return; - - device.setVisible(false); - checkForDeviceRemoval(device); - } - - private void checkForDeviceRemoval(BluetoothDevicePickerDevice device) { - Log.e(TAG, "checkForDeviceRemoval"); - if (device.getPairingStatus() == BluetoothDevicePickerBtStatus.PAIRING_STATUS_UNPAIRED - && !device.isVisible()) { - // If device isn't paired, remove it altogether - mDevices.remove(device); - dispatchDeviceDeleted(device); - } - } - - public synchronized void onDeviceNameUpdated(BluetoothDevice remoteDevice) { - Log.e(TAG, "onDeviceNameUpdated"); - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - if (device != null) { - device.refreshName(); - } - } - - public synchronized BluetoothDevicePickerDevice findDevice(BluetoothDevice remoteDevice) { - - for (int i = mDevices.size() - 1; i >= 0; i--) { - BluetoothDevicePickerDevice device = mDevices.get(i); - - if (device.getRemoteDevice().equals(remoteDevice)) { - return device; - } - } - - return null; - } - - public String getName(BluetoothDevice remoteDevice) { - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - return device != null ? device.getName() : remoteDevice.getAddress(); - } - - private void dispatchDeviceAdded(BluetoothDevicePickerDevice device) { - synchronized (mCallbacks) { - for (BluetoothDevicePickerManager.Callback callback : mCallbacks) { - callback.onDeviceAdded(device); - } - } - } - - private void dispatchDeviceDeleted(BluetoothDevicePickerDevice device) { - synchronized (mCallbacks) { - for (BluetoothDevicePickerManager.Callback callback : mCallbacks) { - callback.onDeviceDeleted(device); - } - } - } - - public synchronized void onBondingStateChanged(BluetoothDevice remoteDevice, boolean created) { - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - if (device == null) { - Log.e(TAG, "Got bonding state changed for " + remoteDevice - + ", but we have no record of that device."); - return; - } - - device.setPairingStatus(created ? BluetoothDevicePickerBtStatus.PAIRING_STATUS_PAIRED - : BluetoothDevicePickerBtStatus.PAIRING_STATUS_UNPAIRED); - checkForDeviceRemoval(device); - - if (created) { - synchronized (mCallbacks) { - for (BluetoothDevicePickerManager.Callback callback : mCallbacks) { - callback.onBondingStateChanged(remoteDevice, created); - } - } - - } - } - - public synchronized void onBondingError(BluetoothDevice remoteDevice) { - mLocalManager.showError(remoteDevice, R.string.bluetooth_error_title, - R.string.bluetooth_pairing_error_message); - } - - public synchronized void onProfileStateChanged(BluetoothDevice remoteDevice) { - BluetoothDevicePickerDevice device = findDevice(remoteDevice); - if (device == null) - return; - - device.refresh(); - } - - public synchronized void onScanningStateChanged(boolean started) { - Log.e(TAG, "onScanningStateChanged, started = " + started); - if (!started) - return; - - // If starting a new scan, clear old visibility - for (int i = mDevices.size() - 1; i >= 0; i--) { - BluetoothDevicePickerDevice device = mDevices.get(i); - device.setVisible(false); - checkForDeviceRemoval(device); - } - } -} diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerDevicePreference.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerDevicePreference.java deleted file mode 100644 index ea9ccc89a..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerDevicePreference.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import android.content.Context; -import android.preference.Preference; -import android.util.TypedValue; -import android.view.View; -import android.widget.ImageView; - -/** - * BluetoothDevicePickerDevicePreference is the preference type used to display - * each remote Bluetooth device in the Device Picker screen. - */ -public class BluetoothDevicePickerDevicePreference extends Preference implements - BluetoothDevicePickerDevice.Callback { - // public class BluetoothDevicePickerDevicePreference extends Preference{ - private static final String TAG = "BluetoothDevicePickerDevicePreference"; - - private static int sDimAlpha = Integer.MIN_VALUE; - - private BluetoothDevicePickerDevice mLocalDevice; - - private boolean mIsBusy; - - public BluetoothDevicePickerDevicePreference(Context context, - BluetoothDevicePickerDevice localDevice) { - super(context); - - if (sDimAlpha == Integer.MIN_VALUE) { - TypedValue outValue = new TypedValue(); - context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true); - sDimAlpha = (int)(outValue.getFloat() * 255); - } - - mLocalDevice = localDevice; - - setLayoutResource(R.layout.preference_bluetooth); - - localDevice.registerCallback(this); - - onDeviceAttributesChanged(localDevice); - } - - public BluetoothDevicePickerDevice getDevice() { - return mLocalDevice; - } - - @Override - protected void onPrepareForRemoval() { - super.onPrepareForRemoval(); - mLocalDevice.unregisterCallback(this); - } - - public void onDeviceAttributesChanged(BluetoothDevicePickerDevice device) { - setTitle(mLocalDevice.getName()); - setSummary(mLocalDevice.getSummary()); - mIsBusy = false; - notifyChanged(); - notifyHierarchyChanged(); - } - - @Override - public boolean isEnabled() { - return super.isEnabled() && !mIsBusy; - } - - @Override - protected void onBindView(View view) { - super.onBindView(view); - - ImageView btClass = (ImageView)view.findViewById(R.id.btClass); - btClass.setImageResource(mLocalDevice.getBtClassDrawable()); - btClass.setAlpha(isEnabled() ? 255 : sDimAlpha); - } - - @Override - public int compareTo(Preference another) { - if (!(another instanceof BluetoothDevicePickerDevicePreference)) { - return 1; - } - - return mLocalDevice - .compareTo(((BluetoothDevicePickerDevicePreference)another).mLocalDevice); - } - -} diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerListener.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerListener.java deleted file mode 100644 index db3878563..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerListener.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.opp.BluetoothDevicePickerManager.ExtendedBluetoothState; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothError; -import android.bluetooth.BluetoothIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Handler; -import android.util.Log; - -import android.app.NotificationManager; - -/** - * BluetoothEventRedirector receives broadcasts and callbacks from the Bluetooth - * API and dispatches the event on the UI thread to the right class in the - * Settings. - */ -public class BluetoothDevicePickerListener { - public static final int NOTIFICATION_ID = android.R.drawable.stat_sys_data_bluetooth; - - private static final String TAG = "BluetoothDevicePickerListener"; - - private static final boolean V = BluetoothDevicePickerManager.V; - - private BluetoothDevicePickerManager mManager; - - private Handler mUiHandler = new Handler(); - - private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (V) { - Log.v(TAG, "Received " + intent.getAction()); - } - - String action = intent.getAction(); - BluetoothDevice remoteDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE); - - if (action.equals(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION)) { - int state = intent.getIntExtra(BluetoothIntent.BLUETOOTH_STATE, - BluetoothError.ERROR); - if (state == BluetoothAdapter.BLUETOOTH_STATE_ON) { - mManager.setBluetoothStateInt(ExtendedBluetoothState.ENABLED); - } else if (state == BluetoothAdapter.BLUETOOTH_STATE_OFF) { - mManager.setBluetoothStateInt(ExtendedBluetoothState.DISABLED); - } - } else if (action.equals(BluetoothIntent.DISCOVERY_STARTED_ACTION)) { - mManager.onScanningStateChanged(true); - } else if (action.equals(BluetoothIntent.DISCOVERY_COMPLETED_ACTION)) { - mManager.onScanningStateChanged(false); - - } else if (action.equals(BluetoothIntent.PAIRING_REQUEST_ACTION)) { - Intent pinIntent = new Intent(); - pinIntent.setClass(context, BluetoothPinDialog.class); - pinIntent.putExtra(BluetoothIntent.DEVICE, remoteDevice); - pinIntent.setAction(BluetoothIntent.PAIRING_REQUEST_ACTION); - pinIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - // if this activity is in the foreground, open the pin dialog, - // else ignore - if (mManager.getForegroundActivity() != null) { - context.startActivity(pinIntent); - } - - /* clear the notification generated by Bluetooth Settings */ - NotificationManager manager = (NotificationManager)context - .getSystemService(Context.NOTIFICATION_SERVICE); - manager.cancel(NOTIFICATION_ID); - Log.v(TAG, "###after cancel"); - - } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION)) { - short rssi = intent.getShortExtra(BluetoothIntent.RSSI, Short.MIN_VALUE); - Log.v(TAG, "onReceive: REMOTE_DEVICE_FOUND_ACTION"); - mManager.getLocalDeviceManager().onDeviceAppeared(remoteDevice, rssi); - } else if (action.equals(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION)) { - mManager.getLocalDeviceManager().onDeviceDisappeared(remoteDevice); - } else if (action.equals(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION)) { - mManager.getLocalDeviceManager().onDeviceNameUpdated(remoteDevice); - } else if (action.equals(BluetoothIntent.BOND_STATE_CHANGED_ACTION)) { - Log.v(TAG, "onReceive: BOND_STATE_CHANGED_ACTION"); - int bondResult = intent.getIntExtra(BluetoothIntent.BOND_STATE, 99); - if (bondResult == BluetoothDevice.BOND_BONDED) { - Log.v(TAG, "onReceive: BOND_STATE_CHANGED_ACTION, BONDED"); - mManager.getLocalDeviceManager().onBondingStateChanged(remoteDevice, true); - } else if (bondResult == BluetoothDevice.BOND_NOT_BONDED) { - Log.v(TAG, "onReceive: BOND_STATE_CHANGED_ACTION, NOT_BONDED"); - mManager.getLocalDeviceManager().onBondingStateChanged(remoteDevice, false); - } - } - } - }; - - public BluetoothDevicePickerListener( - BluetoothDevicePickerManager localBluetoothDevicePickerManager) { - mManager = localBluetoothDevicePickerManager; - } - - public void start() { - IntentFilter filter = new IntentFilter(); - Log.v(TAG, "start"); - - // Bluetooth on/off broadcasts - filter.addAction(BluetoothIntent.BLUETOOTH_STATE_CHANGED_ACTION); - - // Discovery broadcasts - filter.addAction(BluetoothIntent.DISCOVERY_STARTED_ACTION); - filter.addAction(BluetoothIntent.DISCOVERY_COMPLETED_ACTION); - filter.addAction(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION); - filter.addAction(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION); - filter.addAction(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION); - - // Pairing broadcasts - filter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION); - - // Pin request - filter.addAction(BluetoothIntent.PAIRING_REQUEST_ACTION); - filter.addAction(BluetoothIntent.PAIRING_CANCEL_ACTION); - - mManager.getContext().registerReceiver(mBroadcastReceiver, filter); - } - - public void stop() { - mManager.getContext().unregisterReceiver(mBroadcastReceiver); - } - -} diff --git a/src/com/android/bluetooth/opp/BluetoothDevicePickerManager.java b/src/com/android/bluetooth/opp/BluetoothDevicePickerManager.java deleted file mode 100644 index 4358e3fca..000000000 --- a/src/com/android/bluetooth/opp/BluetoothDevicePickerManager.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import android.app.Activity; -import android.app.AlertDialog; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.widget.Toast; -import android.util.Log; -import android.util.Config; - -import java.util.ArrayList; -import java.util.List; - -public class BluetoothDevicePickerManager { - private static final boolean DEBUG = true; - - private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV; - - private static final String TAG = "BluetoothDevicePickerManager"; - - static final boolean V = true; - - public static final String EXTENDED_BLUETOOTH_STATE_CHANGED_ACTION = - "com.android.settings.bluetooth.intent.action.EXTENDED_BLUETOOTH_STATE_CHANGED"; - - private static final String SHARED_PREFERENCES_NAME = "bluetooth_settings"; - - private static BluetoothDevicePickerManager INSTANCE; - - /** Used when obtaining a reference to the singleton instance. */ - private static Object INSTANCE_LOCK = new Object(); - - private boolean mInitialized; - - private boolean mEventListenerRunning; - - private Context mContext; - - /** If a BT-related activity is in the foreground, this will be it. */ - private Activity mForegroundActivity; - - private BluetoothAdapter mAdapter; - - private BluetoothDevicePickerDeviceManager mLocalDeviceManager; - - private BluetoothDevicePickerListener mEventListener; - - public static enum ExtendedBluetoothState { - ENABLED, ENABLING, DISABLED, DISABLING, UNKNOWN - } - - private ExtendedBluetoothState mState = ExtendedBluetoothState.UNKNOWN; - - private List<Callback> mCallbacks = new ArrayList<Callback>(); - - private static final int SCAN_EXPIRATION_MS = 5 * 60 * 1000; // 5 mins - - private long mLastScan; - - public static BluetoothDevicePickerManager getInstance(Context context) { - synchronized (INSTANCE_LOCK) { - if (INSTANCE == null) { - INSTANCE = new BluetoothDevicePickerManager(); - } - - if (!INSTANCE.init(context)) { - return null; - } - - return INSTANCE; - } - } - - private boolean init(Context context) { - if (mInitialized) - return true; - mInitialized = true; - log("init"); - - // This will be around as long as this process is - mContext = context.getApplicationContext(); - - mAdapter = (BluetoothAdapter) context.getSystemService(Context.BLUETOOTH_SERVICE); - if (mAdapter == null) { - log("has no bluetooth service, exit"); - return false; - } - - mLocalDeviceManager = new BluetoothDevicePickerDeviceManager(this); - - mEventListener = new BluetoothDevicePickerListener(this); - if (startBluetoothEventListener() != 0) - return false; - - return true; - } - - public BluetoothAdapter getBluetoothAdapter() { - return mAdapter; - } - - public int stopBluetoothEventListener() { - if (!mEventListenerRunning) - return 0; - mEventListenerRunning = false; - - if (mEventListener != null) { - log("stopBluetoothEventListener"); - mEventListener.stop(); - return 0; - } - - return -1; - } - - public int startBluetoothEventListener() { - if (mEventListenerRunning) - return 0; - mEventListenerRunning = true; - - if (mEventListener != null) { - log("startBluetoothEventListener"); - mEventListener.start(); - return 0; - } - - return -1; - } - - public Context getContext() { - return mContext; - } - - public Activity getForegroundActivity() { - return mForegroundActivity; - } - - public void setForegroundActivity(Activity activity) { - mForegroundActivity = activity; - } - - public SharedPreferences getSharedPreferences() { - return mContext.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); - } - - public BluetoothDevicePickerDeviceManager getLocalDeviceManager() { - return mLocalDeviceManager; - } - - List<Callback> getCallbacks() { - return mCallbacks; - } - - public void registerCallback(Callback callback) { - synchronized (mCallbacks) { - mCallbacks.add(callback); - } - } - - public void unregisterCallback(Callback callback) { - synchronized (mCallbacks) { - mCallbacks.remove(callback); - } - } - - public void startScanning(boolean force) { - log("startScanning1"); - if (mAdapter.isDiscovering()) { - log("startScanning2"); - dispatchScanningStateChanged(true); - log("startScanning3"); - } else { - log("startScanning4"); - if (!force && mLastScan + SCAN_EXPIRATION_MS > System.currentTimeMillis()) - return; - - log("startScanning5"); - if (mAdapter.startDiscovery()) { - mLastScan = System.currentTimeMillis(); - } - } - } - - public ExtendedBluetoothState getBluetoothState() { - - if (mState == ExtendedBluetoothState.UNKNOWN) { - syncBluetoothState(); - } - - return mState; - } - - void setBluetoothStateInt(ExtendedBluetoothState state) { - mState = state; - - mContext.sendBroadcast(new Intent(EXTENDED_BLUETOOTH_STATE_CHANGED_ACTION)); - - if (state == ExtendedBluetoothState.ENABLED || state == ExtendedBluetoothState.DISABLED) { - // mLocalDeviceManager.onBluetoothStateChanged(state == - // ExtendedBluetoothState.ENABLED); - } - } - - private void syncBluetoothState() { - setBluetoothStateInt(mAdapter.isEnabled() ? ExtendedBluetoothState.ENABLED - : ExtendedBluetoothState.DISABLED); - } - - public void setBluetoothEnabled(boolean enabled) { - boolean wasSetStateSuccessful = enabled ? mAdapter.enable() : mAdapter.disable(); - - if (wasSetStateSuccessful) { - setBluetoothStateInt(enabled ? ExtendedBluetoothState.ENABLING - : ExtendedBluetoothState.DISABLING); - } else { - if (V) { - Log.v(TAG, "setBluetoothEnabled call, manager didn't return success for enabled: " - + enabled); - } - - syncBluetoothState(); - } - } - - void onScanningStateChanged(boolean started) { - mLocalDeviceManager.onScanningStateChanged(started); - log("onScanningStateChanged"); - dispatchScanningStateChanged(started); - } - - void onBondingStateChanged(BluetoothDevice remoteDevice, boolean created) { - log("onBondStateChanged1"); - synchronized (mCallbacks) { - for (Callback callback : mCallbacks) { - log("onBondStateChanged2"); - callback.onBondingStateChanged(remoteDevice, created); - } - } - } - - private void dispatchScanningStateChanged(boolean started) { - log("dispatchScanningStateChanged1"); - synchronized (mCallbacks) { - for (Callback callback : mCallbacks) { - log("dispatchScanningStateChanged2"); - callback.onScanningStateChanged(started); - } - } - } - - public void showError(BluetoothDevice remoteDevice, int titleResId, int messageResId) { - BluetoothDevicePickerDevice device = mLocalDeviceManager.findDevice(remoteDevice); - if (device == null) - return; - - String name = device.getName(); - String message = mContext.getString(messageResId, name); - - if (mForegroundActivity != null) { - // Need an activity context to show a dialog - AlertDialog ad = new AlertDialog.Builder(mForegroundActivity).setIcon( - android.R.drawable.ic_dialog_alert).setTitle(titleResId).setMessage(message) - .setPositiveButton(android.R.string.ok, null).show(); - } else { - // Fallback on a toast - Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); - } - } - - public interface Callback { - void onScanningStateChanged(boolean started); - - void onDeviceAdded(BluetoothDevicePickerDevice device); - - void onDeviceDeleted(BluetoothDevicePickerDevice device); - - void onBondingStateChanged(BluetoothDevice device, boolean created); - } - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(TAG, message); - } - } -} diff --git a/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java b/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java index 7fc42a2ba..0d78712a5 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java +++ b/src/com/android/bluetooth/opp/BluetoothOppLauncherActivity.java @@ -36,6 +36,8 @@ import com.android.bluetooth.R; import java.util.ArrayList; import android.app.Activity; +import android.bluetooth.BluetoothDevice; +import android.bluetooth.BluetoothIntent; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -123,8 +125,17 @@ public class BluetoothOppLauncherActivity extends Activity { if (Constants.LOGVV) { Log.v(TAG, "BT already enabled!! "); } - Intent in1 = new Intent(this, BluetoothDevicePickerActivity.class); + Intent in1 = new Intent(BluetoothIntent.DEVICE_PICKER_DEVICE_PICKER); in1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + //TODO modify to false after SDP query is ok + in1.putExtra(BluetoothIntent.DEVICE_PICKER_NEED_AUTH, true); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_FILTER_TYPE, + BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_TRANSFER); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_PACKAGE, + Constants.THIS_PACKAGE_NAME); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_CLASS, + BluetoothOppReceiver.class.getName()); + this.startActivity(in1); } } else if (action.equals(Constants.ACTION_OPEN)) { diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java index 99b65868d..d736b9078 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java +++ b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java @@ -78,16 +78,24 @@ public class BluetoothOppReceiver extends BroadcastReceiver { // reset the flags BluetoothOppManager.getInstance(context).mSendingFlag = false; - Intent in1 = new Intent(context, BluetoothDevicePickerActivity.class); + Intent in1 = new Intent(BluetoothIntent.DEVICE_PICKER_DEVICE_PICKER); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_NEED_AUTH, false); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_FILTER_TYPE, + BluetoothDevice.DEVICE_PICKER_FILTER_TYPE_TRANSFER); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_PACKAGE, + Constants.THIS_PACKAGE_NAME); + in1.putExtra(BluetoothIntent.DEVICE_PICKER_LAUNCH_CLASS, + BluetoothOppReceiver.class.getName()); + in1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(in1); } } } - } else if (action.equals(BluetoothShare.BLUETOOTH_DEVICE_SELECTED_ACTION)) { + } else if (action.equals(BluetoothIntent.DEVICE_PICKER_DEVICE_SELECTED)) { BluetoothOppManager mOppManager = BluetoothOppManager.getInstance(context); - BluetoothDevice remoteDevice = intent.getParcelableExtra("BT_DEVICE"); + BluetoothDevice remoteDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE); if (Constants.LOGVV) { Log.v(TAG, "Received BT device selected intent, bt device: " + remoteDevice); diff --git a/src/com/android/bluetooth/opp/BluetoothPinDialog.java b/src/com/android/bluetooth/opp/BluetoothPinDialog.java deleted file mode 100644 index 8ddfc657f..000000000 --- a/src/com/android/bluetooth/opp/BluetoothPinDialog.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothIntent; -import android.content.DialogInterface; -import android.content.Intent; -import android.os.Bundle; -import android.text.InputFilter; -import android.text.method.DigitsKeyListener; -import android.util.Log; -import android.util.Config; -import android.view.View; -import android.widget.EditText; -import android.widget.TextView; - -import com.android.internal.app.AlertActivity; -import com.android.internal.app.AlertController; - -/** - * BluetoothPinDialog asks the user to enter a PIN for pairing with a remote - * Bluetooth device. It is an activity that appears as a dialog. - */ -public class BluetoothPinDialog extends AlertActivity implements DialogInterface.OnClickListener { - private static final boolean DEBUG = true; - - private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV; - - private static final String TAG = "-------------BluetoothPinDialog"; - - static final boolean V = true; - - private BluetoothDevicePickerManager mLocalManager; - - private BluetoothDevice mRemoteDevice; - - private EditText mPinView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Intent intent = getIntent(); - if (!intent.getAction().equals(BluetoothIntent.PAIRING_REQUEST_ACTION)) { - Log.e(TAG, "Error: this activity may be started only with intent " - + BluetoothIntent.PAIRING_REQUEST_ACTION); - finish(); - } else { - log("get PAIRING_REQUEST_ACTION"); - // abortBroadcast(); - } - - mLocalManager = BluetoothDevicePickerManager.getInstance(this); - mRemoteDevice = intent.getParcelableExtra(BluetoothIntent.DEVICE); - - // Set up the "dialog" - final AlertController.AlertParams p = mAlertParams; - p.mIconId = android.R.drawable.ic_dialog_info; - p.mTitle = getString(R.string.bluetooth_pin_entry); - p.mView = createView(); - p.mPositiveButtonText = getString(android.R.string.ok); - p.mPositiveButtonListener = this; - p.mNegativeButtonText = getString(android.R.string.cancel); - p.mNegativeButtonListener = this; - setupAlert(); - } - - private View createView() { - View view = getLayoutInflater().inflate(R.layout.bluetooth_pin_entry, null); - - String name = mLocalManager.getLocalDeviceManager().getName(mRemoteDevice); - TextView messageView = (TextView)view.findViewById(R.id.message); - messageView.setText(getString(R.string.bluetooth_enter_pin_msg, name)); - - mPinView = (EditText)view.findViewById(R.id.text); - - return view; - } - - private void onPair(String pin) { - byte[] pinBytes = BluetoothDevice.convertPinToBytes(pin); - - if (pinBytes == null) { - return; - } - - mRemoteDevice.setPin(pinBytes); - } - - private void onCancel() { - mRemoteDevice.cancelPairingUserInput(); - } - - public void onClick(DialogInterface dialog, int which) { - switch (which) { - case DialogInterface.BUTTON_POSITIVE: - onPair(mPinView.getText().toString()); - break; - - case DialogInterface.BUTTON_NEGATIVE: - onCancel(); - break; - } - } - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(TAG, message); - } - } - -} diff --git a/src/com/android/bluetooth/opp/BluetoothShare.java b/src/com/android/bluetooth/opp/BluetoothShare.java index aa87f594c..ec4799908 100644 --- a/src/com/android/bluetooth/opp/BluetoothShare.java +++ b/src/com/android/bluetooth/opp/BluetoothShare.java @@ -69,15 +69,6 @@ public final class BluetoothShare implements BaseColumns { public static final String INCOMING_FILE_CONFIRMATION_REQUEST_ACTION = "android.btopp.intent.action.INCOMING_FILE_NOTIFICATION"; /** - * Broadcast Action: this is sent by the Device Picker component to indicate - * an BT device already selected. - */ - - public static final String BLUETOOTH_DEVICE_SELECTED_ACTION = "android.btopp.intent.action.DEVICE_SELECTED"; - - public static final String BLUETOOTH_DEVICE_PICKER_ACTION = "android.btopp.intent.action.DEVICE_SELECTING"; - - /** * The name of the column containing the URI of the file being * sent/received. * <P> diff --git a/src/com/android/bluetooth/opp/ProgressCategory.java b/src/com/android/bluetooth/opp/ProgressCategory.java deleted file mode 100644 index e97810e89..000000000 --- a/src/com/android/bluetooth/opp/ProgressCategory.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2008-2009, Motorola, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the Motorola, Inc. nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.android.bluetooth.opp; - -import com.android.bluetooth.R; - -import android.content.Context; -import android.preference.PreferenceCategory; -import android.util.AttributeSet; -import android.view.View; -import android.util.Config; -import android.util.Log; - -import java.util.Map; - -public class ProgressCategory extends PreferenceCategory { - private static final boolean DEBUG = true; - - private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV; - - private static final String TAG = "-------------PreferenceCategory"; - - static final boolean V = true; - - private boolean mProgress = false; - - public ProgressCategory(Context context, AttributeSet attrs) { - super(context, attrs); - log("ProgressCategory"); - setLayoutResource(R.layout.preference_progress_category); - } - - @Override - public void onBindView(View view) { - log("onBindView"); - super.onBindView(view); - - View textView = view.findViewById(R.id.scanning_text); - View progressBar = view.findViewById(R.id.scanning_progress); - int visibility = mProgress ? View.VISIBLE : View.INVISIBLE; - textView.setVisibility(visibility); - progressBar.setVisibility(visibility); - } - - /** - * Turn on/off the progress indicator and text on the right. - * @param progressOn whether or not the progress should be displayed - */ - public void setProgress(boolean progressOn) { - log("setProgress"); - mProgress = progressOn; - notifyChanged(); - } - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(TAG, message); - } - } -} |