Clean up bluetooth while driving code.
Test: robotests Change-Id: I50aedc61a9a7836672e934e188837dbe49c64be2
This commit is contained in:
@@ -10010,11 +10010,6 @@
|
||||
<!-- Title for preference showing the name of the device. [CHAR LIMIT=60]-->
|
||||
<string name="my_device_info_device_name_preference_title">Device name</string>
|
||||
|
||||
<!-- Settings item title for automatic Bluetooth on while driving preference [CHAR LIMIT=35] -->
|
||||
<string name="bluetooth_on_while_driving_pref">Use Bluetooth when driving</string>
|
||||
<!-- Settings item summary for automatic Bluetooth on while driving preference [CHAR LIMIT=100] -->
|
||||
<string name="bluetooth_on_while_driving_summary">Turn on Bluetooth automatically when driving</string>
|
||||
|
||||
<!-- Title for Wifi Access settings [CHAR LIMIT=35] -->
|
||||
<string name="change_wifi_state_title">Wi-Fi control</string>
|
||||
|
||||
|
@@ -44,14 +44,6 @@
|
||||
android:icon="@drawable/ic_android"
|
||||
android:order="-6"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="bluetooth_on_while_driving"
|
||||
android:title="@string/bluetooth_on_while_driving_pref"
|
||||
android:icon="@drawable/ic_settings_bluetooth"
|
||||
android:summary="@string/bluetooth_on_while_driving_summary"
|
||||
settings:controller="com.android.settings.connecteddevice.BluetoothOnWhileDrivingPreferenceController"
|
||||
android:order="-4"/>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="connected_device_printing"
|
||||
android:title="@string/print_settings"
|
||||
|
@@ -74,7 +74,6 @@ public class AdvancedConnectedDeviceDashboardFragment extends DashboardFragment
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
|
||||
controllers.add(new BluetoothFilesPreferenceController(context));
|
||||
controllers.add(new BluetoothOnWhileDrivingPreferenceController(context));
|
||||
|
||||
final PrintSettingPreferenceController printerController =
|
||||
new PrintSettingPreferenceController(context);
|
||||
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.connecteddevice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
/** Handles a toggle for a setting to turn on Bluetooth while driving. * */
|
||||
public class BluetoothOnWhileDrivingPreferenceController extends TogglePreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
static final String KEY_BLUETOOTH_ON_DRIVING = "bluetooth_on_while_driving";
|
||||
|
||||
public BluetoothOnWhileDrivingPreferenceController(Context context) {
|
||||
super(context, KEY_BLUETOOTH_ON_DRIVING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.BLUETOOTH_WHILE_DRIVING)) {
|
||||
return AVAILABLE;
|
||||
}
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
Settings.Secure.BLUETOOTH_ON_WHILE_DRIVING,
|
||||
0)
|
||||
!= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
final int value = isChecked ? 1 : 0;
|
||||
return Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), Settings.Secure.BLUETOOTH_ON_WHILE_DRIVING, value);
|
||||
}
|
||||
}
|
@@ -20,7 +20,6 @@ package com.android.settings.core;
|
||||
* This class keeps track of all feature flags in Settings.
|
||||
*/
|
||||
public class FeatureFlags {
|
||||
public static final String BLUETOOTH_WHILE_DRIVING = "settings_bluetooth_while_driving";
|
||||
public static final String AUDIO_SWITCHER_SETTINGS = "settings_audio_switcher";
|
||||
public static final String DYNAMIC_HOMEPAGE = "settings_dynamic_homepage";
|
||||
public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid";
|
||||
|
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.connecteddevice;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class BluetoothOnWhileDrivingPreferenceControllerTest {
|
||||
|
||||
private BluetoothOnWhileDrivingPreferenceController mController;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new BluetoothOnWhileDrivingPreferenceController(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_onWhenEnabled() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.BLUETOOTH_WHILE_DRIVING, true);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_offWhenDisabled() {
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_togglesSettingSecure() {
|
||||
mController.setChecked(true);
|
||||
|
||||
final String name = Secure.BLUETOOTH_ON_WHILE_DRIVING;
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(), name, 0)).isEqualTo(1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user