Clean up settings subsequent pairing aconfig flag
BUG: 362649019 Test: atest FastPairDeviceGroupControllerTest Flag: EXEMPT clean up Change-Id: Ia49b0e4e9e5b9af7fe33b2182344f7a43786f111
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
package: "com.android.settings.flags"
|
||||
container: "system_ext"
|
||||
|
||||
flag {
|
||||
name: "enable_subsequent_pair_settings_integration"
|
||||
namespace: "pixel_cross_device_control"
|
||||
description: "Gates whether to enable subsequent pair Settings integration."
|
||||
bug: "299405720"
|
||||
}
|
||||
|
||||
flag {
|
||||
name: "rotation_connected_display_setting"
|
||||
namespace: "display_manager"
|
||||
|
@@ -35,7 +35,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
/**
|
||||
@@ -66,15 +65,11 @@ public class FastPairDeviceGroupController extends BasePreferenceController
|
||||
|
||||
public FastPairDeviceGroupController(Context context) {
|
||||
super(context, KEY);
|
||||
if (Flags.enableSubsequentPairSettingsIntegration()) {
|
||||
FastPairFeatureProvider fastPairFeatureProvider =
|
||||
FeatureFactory.getFeatureFactory().getFastPairFeatureProvider();
|
||||
mFastPairDeviceUpdater =
|
||||
fastPairFeatureProvider.getFastPairDeviceUpdater(context, this);
|
||||
} else {
|
||||
Log.d(TAG, "Flag disabled. Ignored.");
|
||||
mFastPairDeviceUpdater = null;
|
||||
}
|
||||
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
}
|
||||
|
@@ -34,7 +34,6 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -75,15 +74,10 @@ public class FastPairDevicePreferenceController extends BasePreferenceController
|
||||
public FastPairDevicePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
|
||||
if (Flags.enableSubsequentPairSettingsIntegration()) {
|
||||
FastPairFeatureProvider fastPairFeatureProvider =
|
||||
FeatureFactory.getFeatureFactory().getFastPairFeatureProvider();
|
||||
mFastPairDeviceUpdater =
|
||||
fastPairFeatureProvider.getFastPairDeviceUpdater(context, this);
|
||||
} else {
|
||||
Log.d(TAG, "Flag disabled. Ignore.");
|
||||
mFastPairDeviceUpdater = null;
|
||||
}
|
||||
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.connecteddevice.fastpair.FastPairDeviceUpdater;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerListHelper;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.slices.SlicePreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
@@ -94,7 +93,6 @@ public class ConnectedDeviceDashboardFragmentTest {
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mFragment = new ConnectedDeviceDashboardFragment();
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION);
|
||||
mSetFlagsRule.enableFlags(com.android.settingslib.flags.Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
when(mFeatureFactory
|
||||
|
@@ -33,8 +33,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Looper;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
|
||||
@@ -45,7 +43,6 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
import com.android.settings.widget.GearPreference;
|
||||
@@ -107,7 +104,6 @@ public class FastPairDeviceGroupControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStart_flagOn_registerCallback() {
|
||||
// register the callback in onStart()
|
||||
mFastPairDeviceGroupController.onStart(mLifecycleOwner);
|
||||
@@ -120,7 +116,6 @@ public class FastPairDeviceGroupControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStop_flagOn_unregisterCallback() {
|
||||
// register broadcast first
|
||||
mContext.registerReceiver(
|
||||
@@ -133,51 +128,6 @@ public class FastPairDeviceGroupControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStart_flagOff_registerCallback() {
|
||||
// register the callback in onStart()
|
||||
mFastPairDeviceGroupController.onStart(mLifecycleOwner);
|
||||
assertThat(mFastPairDeviceUpdater).isNull();
|
||||
verify(mContext)
|
||||
.registerReceiver(
|
||||
mFastPairDeviceGroupController.mReceiver,
|
||||
mFastPairDeviceGroupController.mIntentFilter,
|
||||
Context.RECEIVER_EXPORTED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStop_flagOff_unregisterCallback() {
|
||||
// register broadcast first
|
||||
mContext.registerReceiver(
|
||||
mFastPairDeviceGroupController.mReceiver, null, Context.RECEIVER_EXPORTED);
|
||||
|
||||
// unregister the callback in onStop()
|
||||
mFastPairDeviceGroupController.onStop(mLifecycleOwner);
|
||||
assertThat(mFastPairDeviceUpdater).isNull();
|
||||
verify(mContext).unregisterReceiver(mFastPairDeviceGroupController.mReceiver);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_noFastPairFeature_returnUnSupported() {
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
assertThat(mFastPairDeviceGroupController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_noBluetoothFastPairFeature_returnUnSupported() {
|
||||
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
assertThat(mFastPairDeviceGroupController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_noBluetoothFeature_returnUnSupported() {
|
||||
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
@@ -186,7 +136,6 @@ public class FastPairDeviceGroupControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_withBluetoothFastPairFeature_returnSupported() {
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
@@ -231,14 +180,6 @@ public class FastPairDeviceGroupControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void displayPreference_notAvailable_doNothing() {
|
||||
mFastPairDeviceGroupController.displayPreference(mScreen);
|
||||
assertThat(mPreferenceGroup.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void displayPreference_isAvailable_fetchFastPairDevices() {
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
|
@@ -32,8 +32,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Looper;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
|
||||
@@ -44,7 +42,6 @@ import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
import com.android.settings.widget.GearPreference;
|
||||
@@ -108,7 +105,6 @@ public class FastPairDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStart_flagOn_registerCallback() {
|
||||
// register the callback in onStart()
|
||||
mFastPairDevicePrefController.onStart(mLifecycleOwner);
|
||||
@@ -121,20 +117,6 @@ public class FastPairDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStart_flagOff_registerCallback() {
|
||||
// register the callback in onStart()
|
||||
mFastPairDevicePrefController.onStart(mLifecycleOwner);
|
||||
assertThat(mFastPairDeviceUpdater).isNull();
|
||||
verify(mContext)
|
||||
.registerReceiver(
|
||||
mFastPairDevicePrefController.mReceiver,
|
||||
mFastPairDevicePrefController.mIntentFilter,
|
||||
Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStop_flagOn_unregisterCallback() {
|
||||
// register broadcast first
|
||||
mContext.registerReceiver(
|
||||
@@ -147,20 +129,6 @@ public class FastPairDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void onStop_flagOff_unregisterCallback() {
|
||||
// register broadcast first
|
||||
mContext.registerReceiver(
|
||||
mFastPairDevicePrefController.mReceiver, null, Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||
|
||||
// unregister the callback in onStop()
|
||||
mFastPairDevicePrefController.onStop(mLifecycleOwner);
|
||||
assertThat(mFastPairDeviceUpdater).isNull();
|
||||
verify(mContext).unregisterReceiver(mFastPairDevicePrefController.mReceiver);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_noBluetoothFeature_returnUnsupported() {
|
||||
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
@@ -169,25 +137,6 @@ public class FastPairDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_noFastPairFeature_returnUnsupported() {
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
assertThat(mFastPairDevicePrefController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_noBluetoothFastPairFeature_returnUnsupported() {
|
||||
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
assertThat(mFastPairDevicePrefController.getAvailabilityStatus())
|
||||
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SUBSEQUENT_PAIR_SETTINGS_INTEGRATION)
|
||||
public void getAvailabilityStatus_bothBluetoothFastPairFeature_returnSupported() {
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
|
||||
|
Reference in New Issue
Block a user