diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 100ac2c83bf..17bb5ff4ab3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -197,11 +197,6 @@
-
-
-
-
-
@@ -396,31 +391,29 @@
android:value="com.android.settings.ApnSettings" />
-
+
+ android:label="@string/devices_title"
+ android:targetActivity=".Settings$ConnectedDeviceDashboardActivity"
+ android:exported="true">
-
-
+
-
+ android:value="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment" />
+
+ android:value="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment" />
Your device name is visible to apps on your phone. It may also be seen by other people when you connect to Bluetooth devices or set up a Wi-Fi hotspot.
+
+ Devices
diff --git a/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceController.java b/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceController.java
deleted file mode 100644
index 2f06b9387eb..00000000000
--- a/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceController.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.bluetooth;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.widget.MasterSwitchController;
-import com.android.settings.widget.MasterSwitchPreference;
-import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.core.lifecycle.events.OnStop;
-
-//TODO(b/69926683): remove this controller in Android P.
-public class BluetoothMasterSwitchPreferenceController extends AbstractPreferenceController
- implements PreferenceControllerMixin, OnSummaryChangeListener, LifecycleObserver, OnResume,
- OnPause, OnStart, OnStop {
-
- public static final String KEY_TOGGLE_BLUETOOTH = "toggle_bluetooth";
-
- private LocalBluetoothManager mBluetoothManager;
- private MasterSwitchPreference mBtPreference;
- private BluetoothEnabler mBluetoothEnabler;
- private BluetoothSummaryUpdater mSummaryUpdater;
- private RestrictionUtils mRestrictionUtils;
- private InstrumentedPreferenceFragment mFragment;
-
- public BluetoothMasterSwitchPreferenceController(Context context,
- LocalBluetoothManager bluetoothManager, InstrumentedPreferenceFragment fragment) {
- this(context, bluetoothManager, new RestrictionUtils(), fragment);
- }
-
- @VisibleForTesting
- public BluetoothMasterSwitchPreferenceController(Context context,
- LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils,
- InstrumentedPreferenceFragment fragment) {
- super(context);
- mBluetoothManager = bluetoothManager;
- mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
- mRestrictionUtils = restrictionUtils;
- mFragment = fragment;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mBtPreference = (MasterSwitchPreference) screen.findPreference(KEY_TOGGLE_BLUETOOTH);
- mBluetoothEnabler = new BluetoothEnabler(mContext,
- new MasterSwitchController(mBtPreference),
- FeatureFactory.getFactory(mContext).getMetricsFeatureProvider(), mBluetoothManager,
- MetricsEvent.ACTION_SETTINGS_MASTER_SWITCH_BLUETOOTH_TOGGLE,
- mRestrictionUtils);
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (KEY_TOGGLE_BLUETOOTH.equals(preference.getKey())) {
- new SubSettingLauncher(mContext)
- .setDestination(BluetoothSettings.class.getName())
- .setTitle(R.string.bluetooth)
- .setSourceMetricsCategory(mFragment.getMetricsCategory())
- .launch();
- return true;
- }
- return super.handlePreferenceTreeClick(preference);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_TOGGLE_BLUETOOTH;
- }
-
- @Override
- public void onResume() {
- mSummaryUpdater.register(true);
- }
-
- @Override
- public void onPause() {
- mSummaryUpdater.register(false);
- }
-
- @Override
- public void onStart() {
- if (mBluetoothEnabler != null) {
- mBluetoothEnabler.resume(mContext);
- }
- }
-
- @Override
- public void onStop() {
- if (mBluetoothEnabler != null) {
- mBluetoothEnabler.pause();
- }
- }
-
- @Override
- public void onSummaryChanged(String summary) {
- if (mBtPreference != null) {
- mBtPreference.setSummary(summary);
- }
- }
-
-}
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
deleted file mode 100644
index 5a521dd3069..00000000000
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.bluetooth;
-
-import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
-
-import android.app.Activity;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceGroup;
-import android.text.Spannable;
-import android.text.style.TextAppearanceSpan;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.LinkifyUtils;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.location.ScanningSettings;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.search.SearchIndexableRaw;
-import com.android.settings.widget.GearPreference;
-import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
-import com.android.settings.widget.SwitchBar;
-import com.android.settings.widget.SwitchBarController;
-import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
-import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.widget.FooterPreference;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * BluetoothSettings is the Settings screen for Bluetooth configuration and
- * connection management.
- */
-public class BluetoothSettings extends DeviceListPreferenceFragment implements Indexable {
- private static final String TAG = "BluetoothSettings";
- private static final int PAIRED_DEVICE_ORDER = 1;
- private static final int PAIRING_PREF_ORDER = 2;
-
- @VisibleForTesting
- static final String KEY_PAIRED_DEVICES = "paired_devices";
- @VisibleForTesting
- static final String KEY_FOOTER_PREF = "footer_preference";
- private static final String KEY_RENAME_DEVICES = "bt_rename_device";
-
- @VisibleForTesting
- PreferenceGroup mPairedDevicesCategory;
- @VisibleForTesting
- FooterPreference mFooterPreference;
- private Preference mPairingPreference;
- private BluetoothEnabler mBluetoothEnabler;
- private AlwaysDiscoverable mAlwaysDiscoverable;
-
- private SwitchBar mSwitchBar;
-
- private BluetoothDeviceNamePreferenceController mDeviceNamePrefController;
- @VisibleForTesting
- BluetoothPairingPreferenceController mPairingPrefController;
-
- // For Search
- @VisibleForTesting
- static final String DATA_KEY_REFERENCE = "main_toggle_bluetooth";
-
- public BluetoothSettings() {
- super(DISALLOW_CONFIG_BLUETOOTH);
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.BLUETOOTH;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- final SettingsActivity activity = (SettingsActivity) getActivity();
- mSwitchBar = activity.getSwitchBar();
-
- mBluetoothEnabler = new BluetoothEnabler(activity, new SwitchBarController(mSwitchBar),
- mMetricsFeatureProvider, Utils.getLocalBtManager(activity),
- MetricsEvent.ACTION_BLUETOOTH_TOGGLE);
- mBluetoothEnabler.setupSwitchController();
- if (mLocalAdapter != null) {
- mAlwaysDiscoverable = new AlwaysDiscoverable(getContext(), mLocalAdapter);
- }
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
-
- mBluetoothEnabler.teardownSwitchController();
- }
-
- @Override
- void initPreferencesFromPreferenceScreen() {
- mPairingPreference = mPairingPrefController.createBluetoothPairingPreference(
- PAIRING_PREF_ORDER);
- mFooterPreference = (FooterPreference) findPreference(KEY_FOOTER_PREF);
- mPairedDevicesCategory = (PreferenceGroup) findPreference(KEY_PAIRED_DEVICES);
- }
-
- @Override
- public void onStart() {
- // resume BluetoothEnabler before calling super.onStart() so we don't get
- // any onDeviceAdded() callbacks before setting up view in updateContent()
- if (mBluetoothEnabler != null) {
- mBluetoothEnabler.resume(getActivity());
- }
- super.onStart();
- // Always show paired devices regardless whether user-friendly name exists
- mShowDevicesWithoutNames = true;
- if (isUiRestricted()) {
- getPreferenceScreen().removeAll();
- if (!isUiRestrictedByOnlyAdmin()) {
- getEmptyTextView().setText(R.string.bluetooth_empty_list_user_restricted);
- }
- return;
- }
-
- if (mLocalAdapter != null) {
- updateContent(mLocalAdapter.getBluetoothState());
- }
- }
-
- @Override
- public void onStop() {
- super.onStop();
- mPairedDevicesCategory.removeAll();
- if (mBluetoothEnabler != null) {
- mBluetoothEnabler.pause();
- }
-
- // Make the device only visible to connected devices.
- if (mAlwaysDiscoverable != null) {
- mAlwaysDiscoverable.stop();
- }
-
- if (isUiRestricted()) {
- return;
- }
- }
-
- @Override
- public String getDeviceListKey() {
- return KEY_PAIRED_DEVICES;
- }
-
- private void updateContent(int bluetoothState) {
- int messageId = 0;
-
- switch (bluetoothState) {
- case BluetoothAdapter.STATE_ON:
- displayEmptyMessage(false);
- mDevicePreferenceMap.clear();
-
- if (isUiRestricted()) {
- messageId = R.string.bluetooth_empty_list_user_restricted;
- break;
- }
-
- addDeviceCategory(mPairedDevicesCategory,
- R.string.bluetooth_preference_paired_devices,
- BluetoothDeviceFilter.BONDED_DEVICE_FILTER, true);
- mPairedDevicesCategory.addPreference(mPairingPreference);
- updateFooterPreference(mFooterPreference);
-
- if (mAlwaysDiscoverable != null) {
- mAlwaysDiscoverable.start();
- }
- return; // not break
-
- case BluetoothAdapter.STATE_TURNING_OFF:
- messageId = R.string.bluetooth_turning_off;
- mLocalAdapter.stopScanning();
- break;
-
- case BluetoothAdapter.STATE_OFF:
- setOffMessage();
- if (isUiRestricted()) {
- messageId = R.string.bluetooth_empty_list_user_restricted;
- }
- break;
-
- case BluetoothAdapter.STATE_TURNING_ON:
- messageId = R.string.bluetooth_turning_on;
- break;
- }
-
- displayEmptyMessage(true);
- if (messageId != 0) {
- getEmptyTextView().setText(messageId);
- }
- }
-
- private void setOffMessage() {
- final TextView emptyView = getEmptyTextView();
- if (emptyView == null) {
- return;
- }
- final CharSequence briefText = getText(R.string.bluetooth_empty_list_bluetooth_off);
-
- final ContentResolver resolver = getActivity().getContentResolver();
- final boolean bleScanningMode = Settings.Global.getInt(
- resolver, Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
-
- if (!bleScanningMode) {
- // Show only the brief text if the scanning mode has been turned off.
- emptyView.setText(briefText, TextView.BufferType.SPANNABLE);
- } else {
- final StringBuilder contentBuilder = new StringBuilder();
- contentBuilder.append(briefText);
- contentBuilder.append("\n\n");
- contentBuilder.append(getText(R.string.ble_scan_notify_text));
- LinkifyUtils.linkify(emptyView, contentBuilder, new LinkifyUtils.OnClickListener() {
- @Override
- public void onClick() {
- new SubSettingLauncher(getActivity())
- .setSourceMetricsCategory(getMetricsCategory())
- .setDestination(ScanningSettings.class.getName())
- .setTitle(R.string.location_scanning_screen_title)
- .launch();
- }
- });
- }
- setTextSpan(emptyView.getText(), briefText);
- }
-
- @VisibleForTesting
- void displayEmptyMessage(boolean display) {
- final Activity activity = getActivity();
- activity.findViewById(android.R.id.list_container).setVisibility(
- display ? View.INVISIBLE : View.VISIBLE);
- activity.findViewById(android.R.id.empty).setVisibility(
- display ? View.VISIBLE : View.GONE);
- }
-
- @Override
- public void onBluetoothStateChanged(int bluetoothState) {
- super.onBluetoothStateChanged(bluetoothState);
- updateContent(bluetoothState);
- }
-
- @Override
- public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
- updateContent(mLocalAdapter.getBluetoothState());
- }
-
- @VisibleForTesting
- void setTextSpan(CharSequence text, CharSequence briefText) {
- if (text instanceof Spannable) {
- Spannable boldSpan = (Spannable) text;
- boldSpan.setSpan(
- new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0,
- briefText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- }
-
- @VisibleForTesting
- void setLocalBluetoothAdapter(LocalBluetoothAdapter localAdapter) {
- mLocalAdapter = localAdapter;
- }
-
- private final GearPreference.OnGearClickListener mDeviceProfilesListener = pref -> {
- // User clicked on advanced options icon for a device in the list
- if (!(pref instanceof BluetoothDevicePreference)) {
- Log.w(TAG, "onClick() called for other View: " + pref);
- return;
- }
- final CachedBluetoothDevice device =
- ((BluetoothDevicePreference) pref).getBluetoothDevice();
- if (device == null) {
- Log.w(TAG, "No BT device attached with this pref: " + pref);
- return;
- }
- final Bundle args = new Bundle();
- Context context = getActivity();
- boolean useDetailPage = FeatureFactory.getFactory(context).getBluetoothFeatureProvider(
- context).isDeviceDetailPageEnabled();
- if (!useDetailPage) {
- // Old version - uses a dialog.
- args.putString(DeviceProfilesSettings.ARG_DEVICE_ADDRESS,
- device.getDevice().getAddress());
- final DeviceProfilesSettings profileSettings = new DeviceProfilesSettings();
- profileSettings.setArguments(args);
- profileSettings.show(getFragmentManager(),
- DeviceProfilesSettings.class.getSimpleName());
- } else {
- // New version - uses a separate screen.
- args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS,
- device.getDevice().getAddress());
- new SubSettingLauncher(context)
- .setDestination(BluetoothDeviceDetailsFragment.class.getName())
- .setArguments(args)
- .setTitle(R.string.device_details_title)
- .setSourceMetricsCategory(getMetricsCategory())
- .launch();
- }
- };
-
- /**
- * Add a listener, which enables the advanced settings icon.
- *
- * @param preference the newly added preference
- */
- @Override
- void initDevicePreference(BluetoothDevicePreference preference) {
- preference.setOrder(PAIRED_DEVICE_ORDER);
- CachedBluetoothDevice cachedDevice = preference.getCachedDevice();
- if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
- // Only paired device have an associated advanced settings screen
- preference.setOnGearClickListener(mDeviceProfilesListener);
- }
- }
-
- @Override
- public int getHelpResource() {
- return R.string.help_url_bluetooth;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.bluetooth_settings;
- }
-
- @Override
- protected List createPreferenceControllers(Context context) {
- final List controllers = new ArrayList<>();
- final Lifecycle lifecycle = getLifecycle();
- mDeviceNamePrefController = new BluetoothDeviceNamePreferenceController(context, lifecycle);
- mPairingPrefController = new BluetoothPairingPreferenceController(context, this);
- controllers.add(mDeviceNamePrefController);
- controllers.add(mPairingPrefController);
- controllers.add(new BluetoothFilesPreferenceController(context));
- controllers.add(
- new BluetoothDeviceRenamePreferenceController(context, KEY_RENAME_DEVICES, this,
- lifecycle));
-
- return controllers;
- }
-
- @VisibleForTesting
- static class SummaryProvider implements SummaryLoader.SummaryProvider, OnSummaryChangeListener {
-
- private final LocalBluetoothManager mBluetoothManager;
- private final Context mContext;
- private final SummaryLoader mSummaryLoader;
-
- @VisibleForTesting
- BluetoothSummaryUpdater mSummaryUpdater;
-
- public SummaryProvider(Context context, SummaryLoader summaryLoader,
- LocalBluetoothManager bluetoothManager) {
- mBluetoothManager = bluetoothManager;
- mContext = context;
- mSummaryLoader = summaryLoader;
- mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
- }
-
- @Override
- public void setListening(boolean listening) {
- mSummaryUpdater.register(listening);
- }
-
- @Override
- public void onSummaryChanged(String summary) {
- if (mSummaryLoader != null) {
- mSummaryLoader.setSummary(this, summary);
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
-
- return new SummaryProvider(activity, summaryLoader, Utils.getLocalBtManager(activity));
- }
- };
-
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List getRawDataToIndex(Context context,
- boolean enabled) {
-
- final List result = new ArrayList();
-
- final Resources res = context.getResources();
-
- // Add fragment title
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.bluetooth_settings);
- data.screenTitle = res.getString(R.string.bluetooth_settings);
- data.key = DATA_KEY_REFERENCE;
- data.keywords = res.getString(R.string.keywords_bluetooth_settings);
- result.add(data);
-
- // Removed paired bluetooth device indexing. See BluetoothSettingsObsolete.java.
- return result;
- }
-
- @Override
- public List getNonIndexableKeys(Context context) {
- List keys = super.getNonIndexableKeys(context);
- if (!FeatureFactory.getFactory(context).getBluetoothFeatureProvider(
- context).isPairingPageEnabled()) {
- keys.add(DATA_KEY_REFERENCE);
- }
- return keys;
- }
- };
-}
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index 207a4b0643e..04593176c49 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -42,7 +42,6 @@ import java.util.WeakHashMap;
* Parent class for settings fragments that contain a list of Bluetooth
* devices.
*
- * @see BluetoothSettings
* @see DevicePickerFragment
*/
// TODO: Refactor this fragment
@@ -204,10 +203,6 @@ public abstract class DeviceListPreferenceFragment extends
mDevicePreferenceMap.put(cachedDevice, preference);
}
- /**
- * Overridden in {@link BluetoothSettings} to add a listener.
- * @param preference the newly added preference
- */
void initDevicePreference(BluetoothDevicePreference preference) {
// Does nothing by default
}
diff --git a/src/com/android/settings/bluetooth/DevicePickerActivity.java b/src/com/android/settings/bluetooth/DevicePickerActivity.java
index d3d9d78e975..43ba05d8812 100644
--- a/src/com/android/settings/bluetooth/DevicePickerActivity.java
+++ b/src/com/android/settings/bluetooth/DevicePickerActivity.java
@@ -23,7 +23,7 @@ import com.android.settings.R;
/**
* Activity for Bluetooth device picker dialog. The device picker logic
- * is implemented in the {@link BluetoothSettings} fragment.
+ * is implemented in the {@link BluetoothPairingDetail} fragment.
*/
public final class DevicePickerActivity extends Activity {
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index ec0671614e2..b3dd8acf763 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -17,14 +17,12 @@ package com.android.settings.connecteddevice;
import android.app.Activity;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.bluetooth.BluetoothSwitchPreferenceController;
-import com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.nfc.NfcPreferenceController;
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index bbba8eaac67..c3317fe2379 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -55,7 +55,6 @@ import com.android.settings.applications.assist.ManageAssist;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.backup.ToggleBackupSettingFragment;
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
-import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
@@ -145,7 +144,6 @@ public class SettingsGateway {
WifiSettings.class.getName(),
ConfigureWifiSettings.class.getName(),
SavedAccessPointsWifiSettings.class.getName(),
- BluetoothSettings.class.getName(),
SimSettings.class.getName(),
TetherSettings.class.getName(),
WifiP2pSettings.class.getName(),
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index 0bc8de62d8d..78b18a6bdd9 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -35,7 +35,6 @@ import com.android.settings.applications.SpecialAccessSettings;
import com.android.settings.applications.assist.ManageAssist;
import com.android.settings.backup.BackupSettingsActivity;
import com.android.settings.backup.BackupSettingsFragment;
-import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
import com.android.settings.datausage.DataUsageSummary;
@@ -110,7 +109,6 @@ public class SearchIndexableResourcesImpl implements SearchIndexableResources {
addIndex(WifiSettings.class);
addIndex(NetworkDashboardFragment.class);
addIndex(ConfigureWifiSettings.class);
- addIndex(BluetoothSettings.class);
addIndex(SimSettings.class);
addIndex(DataUsageSummary.class);
addIndex(DataUsageSummaryLegacy.class);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
deleted file mode 100644
index f46d2e3ee58..00000000000
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.bluetooth;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.widget.MasterSwitchPreference;
-import com.android.settingslib.bluetooth.BluetoothCallback;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class BluetoothMasterSwitchPreferenceControllerTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private LocalBluetoothManager mBluetoothManager;
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private MasterSwitchPreference mPreference;
- @Mock
- private RestrictionUtils mRestrictionUtils;
- @Mock
- private InstrumentedPreferenceFragment mFragment;
-
- private Context mContext;
- private BluetoothMasterSwitchPreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application.getApplicationContext());
- FakeFeatureFactory.setupForTest();
-
- mController = new BluetoothMasterSwitchPreferenceController(
- mContext, mBluetoothManager, mRestrictionUtils, mFragment);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
- when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
- }
-
- @Test
- public void isAvailable_shouldAlwaysReturnTrue() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void onResume_shouldRegisterCallback() {
- mController.onResume();
-
- verify(mBluetoothManager.getEventManager()).registerCallback(any(BluetoothCallback.class));
- }
-
- @Test
- public void onPause_shouldUnregisterCallback() {
- mController.onPause();
-
- verify(mBluetoothManager.getEventManager())
- .unregisterCallback(any(BluetoothCallback.class));
- }
-
- @Test
- public void onStart_shouldRegisterPreferenceChangeListener() {
- mController.displayPreference(mScreen);
- mController.onStart();
-
- verify(mPreference).setOnPreferenceChangeListener(any(OnPreferenceChangeListener.class));
- }
-
- @Test
- public void onStop_shouldRegisterPreferenceChangeListener() {
- mController.displayPreference(mScreen);
- mController.onStart();
- mController.onStop();
-
- verify(mPreference).setOnPreferenceChangeListener(null);
- }
-
- @Test
- public void onSummaryUpdated_shouldUpdatePreferenceSummary() {
- mController.displayPreference(mScreen);
-
- mController.onSummaryChanged("test summary");
-
- verify(mPreference).setSummary("test summary");
- }
-}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java
deleted file mode 100644
index 3a67dcb5063..00000000000
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsSummaryProviderTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.bluetooth;
-
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class BluetoothSettingsSummaryProviderTest {
-
- private Context mContext;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private LocalBluetoothManager mBluetoothManager;
- @Mock
- private SummaryLoader mSummaryLoader;
-
- private BluetoothSettings.SummaryProvider mSummaryProvider;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application.getApplicationContext();
- mSummaryProvider =
- new BluetoothSettings.SummaryProvider(mContext, mSummaryLoader, mBluetoothManager);
- }
-
- @Test
- public void setListening_shouldRegister() {
- mSummaryProvider.setListening(true);
-
- verify(mBluetoothManager.getEventManager()).registerCallback(
- mSummaryProvider.mSummaryUpdater);
- }
-
- @Test
- public void setNotListening_shouldUnregister() {
- mSummaryProvider.setListening(false);
-
- verify(mBluetoothManager.getEventManager()).unregisterCallback(
- mSummaryProvider.mSummaryUpdater);
- }
-
- @Test
- public void onSummaryChanged_shouldSetSummary() {
- final String summary = "Bluetooth summary";
- mSummaryProvider.onSummaryChanged(summary);
-
- verify(mSummaryLoader).setSummary(mSummaryProvider, summary);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
deleted file mode 100644
index e52049d389e..00000000000
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.bluetooth;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceGroup;
-import android.view.View;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.widget.FooterPreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class BluetoothSettingsTest {
-
- private static final String FOOTAGE_MAC_STRING = "Bluetooth mac: xxxx";
-
- @Mock
- private Resources mResource;
- @Mock
- private LocalBluetoothAdapter mLocalAdapter;
- @Mock
- private Activity mActivity;
- @Mock
- private PreferenceGroup mPairedDevicesCategory;
- @Mock
- private BluetoothPairingPreferenceController mPairingPreferenceController;
- private Context mContext;
- private BluetoothSettings mFragment;
- private FakeFeatureFactory mFeatureFactory;
- private Preference mFooterPreference;
- private TextView mEmptyMessage;
- private View mContainer;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
- mFeatureFactory = FakeFeatureFactory.setupForTest();
-
- mFragment = spy(new BluetoothSettings());
-
- doReturn(mContext).when(mFragment).getContext();
- doReturn(mResource).when(mFragment).getResources();
- doReturn(mActivity).when(mFragment).getActivity();
-
- mContainer = new View(mContext);
- mEmptyMessage = new TextView(mContext);
- doReturn(mContainer).when(mActivity).findViewById(android.R.id.list_container);
- doReturn(mEmptyMessage).when(mActivity).findViewById(android.R.id.empty);
-
- mFooterPreference = new FooterPreference(RuntimeEnvironment.application);
- mFragment.setLocalBluetoothAdapter(mLocalAdapter);
- mFragment.mPairingPrefController = mPairingPreferenceController;
- }
-
- @Test
- public void setTextSpan_notSpannable_shouldNotCrash() {
- final String str = "test";
- mFragment.setTextSpan(str, "hello");
- }
-
- @Test
- public void setUpdateMyDevicePreference_setTitleCorrectly() {
- doReturn(FOOTAGE_MAC_STRING).when(mFragment)
- .getString(eq(R.string.bluetooth_footer_mac_message), any());
-
- mFragment.updateFooterPreference(mFooterPreference);
-
- assertThat(mFooterPreference.getTitle()).isEqualTo(FOOTAGE_MAC_STRING);
- }
-
- @Test
- public void testDisplayEmptyMessage_showEmptyMessage() {
- mFragment.displayEmptyMessage(true);
-
- assertThat(mContainer.getVisibility()).isEqualTo(View.INVISIBLE);
- assertThat(mEmptyMessage.getVisibility()).isEqualTo(View.VISIBLE);
- }
-
- @Test
- public void testDisplayEmptyMessage_hideEmptyMessage() {
- mFragment.displayEmptyMessage(false);
-
- assertThat(mContainer.getVisibility()).isEqualTo(View.VISIBLE);
- assertThat(mEmptyMessage.getVisibility()).isEqualTo(View.GONE);
- }
-
- @Test
- public void testInitPreferencesFromPreferenceScreen() {
- doReturn(mPairedDevicesCategory).when(mFragment)
- .findPreference(BluetoothSettings.KEY_PAIRED_DEVICES);
- doReturn(mFooterPreference).when(mFragment)
- .findPreference(BluetoothSettings.KEY_FOOTER_PREF);
-
- mFragment.initPreferencesFromPreferenceScreen();
-
- assertThat(mFragment.mPairedDevicesCategory).isEqualTo(mPairedDevicesCategory);
- assertThat(mFragment.mFooterPreference).isEqualTo(mFooterPreference);
- }
-
- @Test
- public void testSearchIndexProvider_pairPageEnabled_keyNotAdded() {
- doReturn(true).when(mFeatureFactory.bluetoothFeatureProvider).isPairingPageEnabled();
-
- final List keys =
- BluetoothSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
-
- assertThat(keys).doesNotContain(BluetoothSettings.DATA_KEY_REFERENCE);
- }
-
- @Test
- public void testSearchIndexProvider_pairPageDisabled_keyAdded() {
- final List keys =
- BluetoothSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
-
- assertThat(keys).contains(BluetoothSettings.DATA_KEY_REFERENCE);
- }
-}