diff options
author | Hamster Tian <th0928@126.com> | 2014-04-30 16:11:31 +0200 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-02-02 15:25:14 +0000 |
commit | a6032a59de6438c5ff27cd21ca877527fd3ceb49 (patch) | |
tree | e02a9a2cfcb057216af6fd05b7c3037ff7f579a2 /src/com/android/settings/bluetooth | |
parent | 5d51ddacd3bf5ff392165d4c4802eb12633e187d (diff) | |
download | packages_apps_Settings-a6032a59de6438c5ff27cd21ca877527fd3ceb49.zip packages_apps_Settings-a6032a59de6438c5ff27cd21ca877527fd3ceb49.tar.gz packages_apps_Settings-a6032a59de6438c5ff27cd21ca877527fd3ceb49.tar.bz2 |
[3/3]Settings: add "Accept all files" option for incoming files via BT
* Adapted for CM13.
* PS2: empty line fix
* PS3: variable name fix
BT server in AOSP will check MIME type of incoming file. Only those with
explicitly allowed types will be accepted. The MIME type whitelist is in
packages/apps/Bluetooth/src/com/android/bluetooth/opp/Constants.java
But this can be annoying when we want to transfer RAR, APK or conf files
etc which do not exist in the list.
This patch adds the option "Accept all files" in
Settings -> Bluetooth -> menu.
This option is disabled by default, which ensures security.
Ref CYNGNOS-1825
Change-Id: I76e008211429bf3bd28183713043bee5d326c21a
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rw-r--r-- | src/com/android/settings/bluetooth/BluetoothSettings.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index be12e79..ec615e8 100644 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -61,6 +61,8 @@ import com.android.settingslib.bluetooth.BluetoothDeviceFilter; import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.bluetooth.LocalBluetoothManager; +import cyanogenmod.providers.CMSettings; + import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -75,6 +77,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem private static final int MENU_ID_SCAN = Menu.FIRST; private static final int MENU_ID_RENAME_DEVICE = Menu.FIRST + 1; private static final int MENU_ID_SHOW_RECEIVED = Menu.FIRST + 2; + private static final int MENU_ID_ACCEPT_ALL_FILES = Menu.FIRST + 3; /* Private intent to show the list of received files */ private static final String BTOPP_ACTION_OPEN_RECEIVED_FILES = @@ -270,6 +273,10 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem boolean isDiscovering = mLocalAdapter.isDiscovering(); int textId = isDiscovering ? R.string.bluetooth_searching_for_devices : R.string.bluetooth_search_for_devices; + + boolean isAcceptAllFilesEnabled = Settings.System.getInt(getContentResolver(), + CMSettings.System.BLUETOOTH_ACCEPT_ALL_FILES, 0) == 1; + menu.add(Menu.NONE, MENU_ID_SCAN, 0, textId) .setEnabled(bluetoothIsEnabled && !isDiscovering) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); @@ -278,6 +285,10 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(Menu.NONE, MENU_ID_SHOW_RECEIVED, 0, R.string.bluetooth_show_received_files) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + menu.add(Menu.NONE, MENU_ID_ACCEPT_ALL_FILES, 0, R.string.bluetooth_accept_all_files) + .setCheckable(true) + .setChecked(isAcceptAllFilesEnabled) + .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); super.onCreateOptionsMenu(menu, inflater); } @@ -302,6 +313,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES); getActivity().sendBroadcast(intent); return true; + + case MENU_ID_ACCEPT_ALL_FILES: + item.setChecked(!item.isChecked()); + Settings.System.putInt(getContentResolver(), + CMSettings.System.BLUETOOTH_ACCEPT_ALL_FILES, + item.isChecked() ? 1 : 0); + return true; } return super.onOptionsItemSelected(item); } |