diff options
author | Shaleen Jain <shaleen.jain95@gmail.com> | 2015-01-30 07:49:42 +0530 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-26 16:11:14 -0700 |
commit | 0a34d3d16555f77bdaada3a6a64af22751d09013 (patch) | |
tree | 08990353d446d90b4e61a0138742ec88204e3f1f /src/com/android/settings/profiles | |
parent | cbcf45885f3e6848acef2b76c395455775e6874c (diff) | |
download | packages_apps_Settings-0a34d3d16555f77bdaada3a6a64af22751d09013.zip packages_apps_Settings-0a34d3d16555f77bdaada3a6a64af22751d09013.tar.gz packages_apps_Settings-0a34d3d16555f77bdaada3a6a64af22751d09013.tar.bz2 |
Profiles: add triggers only for connections supported.
Change-Id: I048828749b0ec8934ee8d88ed99cd0d53a6753b3
Diffstat (limited to 'src/com/android/settings/profiles')
-rw-r--r-- | src/com/android/settings/profiles/SetupActionsFragment.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/com/android/settings/profiles/SetupActionsFragment.java b/src/com/android/settings/profiles/SetupActionsFragment.java index 28ca71f..4f7e5fa 100644 --- a/src/com/android/settings/profiles/SetupActionsFragment.java +++ b/src/com/android/settings/profiles/SetupActionsFragment.java @@ -36,6 +36,7 @@ import android.media.RingtoneManager; import android.net.ConnectivityManager; import android.net.wifi.WifiManager; import android.net.wimax.WimaxHelper; +import android.nfc.NfcAdapter; import android.nfc.NfcManager; import android.os.AsyncTask; import android.os.Bundle; @@ -154,8 +155,12 @@ public class SetupActionsFragment extends SettingsPreferenceFragment // triggers mItems.add(new Header(getString(R.string.profile_triggers_header))); mItems.add(generateTriggerItem(TriggerItem.WIFI)); - mItems.add(generateTriggerItem(TriggerItem.BLUETOOTH)); - mItems.add(generateTriggerItem(TriggerItem.NFC)); + if (DeviceUtils.deviceSupportsBluetooth()) { + mItems.add(generateTriggerItem(TriggerItem.BLUETOOTH)); + } + if (DeviceUtils.deviceSupportsNfc(getActivity())) { + mItems.add(generateTriggerItem(TriggerItem.NFC)); + } // connection overrides mItems.add(new Header(getString(R.string.profile_connectionoverrides_title))); @@ -302,9 +307,12 @@ public class SetupActionsFragment extends SettingsPreferenceFragment @Override protected Void doInBackground(Profile... params) { // bt - mProfile.setConnectionSettings( - new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH, - BluetoothAdapter.getDefaultAdapter().isEnabled() ? 1 : 0, true)); + BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); + if (btAdapter != null) { + mProfile.setConnectionSettings( + new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH, + btAdapter.isEnabled() ? 1 : 0, true)); + } // gps LocationManager locationManager = (LocationManager) @@ -343,9 +351,12 @@ public class SetupActionsFragment extends SettingsPreferenceFragment // nfc NfcManager nfcManager = (NfcManager) getSystemService(Context.NFC_SERVICE); - mProfile.setConnectionSettings( - new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_NFC, - nfcManager.getDefaultAdapter().isEnabled() ? 1 : 0, true)); + NfcAdapter nfcAdapter = nfcManager.getDefaultAdapter(); + if (nfcAdapter != null) { + mProfile.setConnectionSettings( + new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_NFC, + nfcAdapter.isEnabled() ? 1 : 0, true)); + } // alarm volume final AudioManager am = (AudioManager) getActivity() |