summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2014-06-18 09:23:15 -0400
committerJulia Reynolds <juliacr@google.com>2014-07-23 21:06:21 +0000
commit1a0297c544cb15ed4b56e70575b169b3889543b7 (patch)
treea1f8b859245632ee0ac092c55028f8987b921aea /src/com/android/settings/bluetooth
parent289a63f509972372e37fc95de630a5410b4ebd5c (diff)
downloadpackages_apps_Settings-1a0297c544cb15ed4b56e70575b169b3889543b7.zip
packages_apps_Settings-1a0297c544cb15ed4b56e70575b169b3889543b7.tar.gz
packages_apps_Settings-1a0297c544cb15ed4b56e70575b169b3889543b7.tar.bz2
Use restrictionsprovider framework in Settings.
Bug: 15305103 Change-Id: Ib0147e366fe90de3512d0cc06e2a47ee16012dff
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothSettings.java42
-rw-r--r--src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java6
2 files changed, 36 insertions, 12 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 0bcac62..f1125bc 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -140,6 +140,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
}
super.onResume();
+ if (isUiRestricted()) {
+ setDeviceListGroup(getPreferenceScreen());
+ removeAllDevices();
+ mEmptyView.setText(R.string.bluetooth_empty_list_user_restricted);
+ return;
+ }
+
getActivity().registerReceiver(mReceiver, mIntentFilter);
if (mLocalAdapter != null) {
updateContent(mLocalAdapter.getBluetoothState(), mActivityStarted);
@@ -155,6 +162,11 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
if (mBluetoothEnabler != null) {
mBluetoothEnabler.pause();
}
+
+ if (isUiRestricted()) {
+ return;
+ }
+
getActivity().unregisterReceiver(mReceiver);
// Make the device only visible to connected devices.
@@ -165,7 +177,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (mLocalAdapter == null) return;
// If the user is not allowed to configure bluetooth, do not show the menu.
- if (isRestrictedAndNotPinProtected()) return;
+ if (isUiRestricted()) return;
boolean bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON;
boolean isDiscovering = mLocalAdapter.isDiscovering();
@@ -219,7 +231,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
}
private void startScanning() {
- if (isRestrictedAndNotPinProtected()) return;
+ if (isUiRestricted()) return;
if (!mAvailableDevicesCategoryIsPresent) {
getPreferenceScreen().addPreference(mAvailableDevicesCategory);
}
@@ -252,6 +264,11 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
preferenceScreen.setOrderingAsAdded(true);
mDevicePreferenceMap.clear();
+ if (isUiRestricted()) {
+ messageId = R.string.bluetooth_empty_list_user_restricted;
+ break;
+ }
+
// Paired devices category
if (mPairedDevicesCategory == null) {
mPairedDevicesCategory = new PreferenceCategory(getActivity());
@@ -270,11 +287,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
} else {
mAvailableDevicesCategory.removeAll();
}
- if (!isRestrictedAndNotPinProtected()) {
- addDeviceCategory(mAvailableDevicesCategory,
- R.string.bluetooth_preference_found_devices,
- BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER);
- }
+ addDeviceCategory(mAvailableDevicesCategory,
+ R.string.bluetooth_preference_found_devices,
+ BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER);
int numberOfAvailableDevices = mAvailableDevicesCategory.getPreferenceCount();
mAvailableDevicesCategoryIsPresent = true;
@@ -313,6 +328,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
case BluetoothAdapter.STATE_OFF:
messageId = R.string.bluetooth_empty_list_bluetooth_off;
+ if (isUiRestricted()) {
+ messageId = R.string.bluetooth_empty_list_user_restricted;
+ }
break;
case BluetoothAdapter.STATE_TURNING_ON:
@@ -323,7 +341,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
setDeviceListGroup(preferenceScreen);
removeAllDevices();
mEmptyView.setText(messageId);
- getActivity().invalidateOptionsMenu();
+ if (!isUiRestricted()) {
+ getActivity().invalidateOptionsMenu();
+ }
}
@Override
@@ -336,7 +356,9 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
public void onScanningStateChanged(boolean started) {
super.onScanningStateChanged(started);
// Update options' enabled state
- getActivity().invalidateOptionsMenu();
+ if (getActivity() != null) {
+ getActivity().invalidateOptionsMenu();
+ }
}
@Override
@@ -350,7 +372,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
public void onClick(View v) {
// User clicked on advanced options icon for a device in the list
if (v.getTag() instanceof CachedBluetoothDevice) {
- if (isRestrictedAndNotPinProtected()) return;
+ if (isUiRestricted()) return;
CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index 9ced992..f482ecd 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -96,7 +96,7 @@ public abstract class DeviceListPreferenceFragment extends
@Override
public void onResume() {
super.onResume();
- if (mLocalManager == null) return;
+ if (mLocalManager == null || isUiRestricted()) return;
mLocalManager.setForegroundActivity(getActivity());
mLocalManager.getEventManager().registerCallback(this);
@@ -107,7 +107,9 @@ public abstract class DeviceListPreferenceFragment extends
@Override
public void onPause() {
super.onPause();
- if (mLocalManager == null) return;
+ if (mLocalManager == null || isUiRestricted()) {
+ return;
+ }
removeAllDevices();
mLocalManager.setForegroundActivity(null);