Clean up AwareFeatureProvider from Settings
Bug: 287566056 Test: m Settings Change-Id: I7f7f57809c55bf8824b427f0d4a232cacdbe88a7
This commit is contained in:
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 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.aware;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
public interface AwareFeatureProvider {
|
|
||||||
/** Returns true if the aware sensor is supported. */
|
|
||||||
boolean isSupported(Context context);
|
|
||||||
|
|
||||||
/** Returns true if the aware feature is enabled. */
|
|
||||||
boolean isEnabled(Context context);
|
|
||||||
|
|
||||||
/** Show information dialog. */
|
|
||||||
void showRestrictionDialog(Fragment parent);
|
|
||||||
|
|
||||||
/** Return Quick Gestures Summary. */
|
|
||||||
CharSequence getGestureSummary(Context context, boolean sensorSupported,
|
|
||||||
boolean assistGestureEnabled, boolean assistGestureSilenceEnabled);
|
|
||||||
}
|
|
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 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.aware;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
public class AwareFeatureProviderImpl implements AwareFeatureProvider {
|
|
||||||
@Override
|
|
||||||
public boolean isSupported(Context context) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled(Context context) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showRestrictionDialog(Fragment parent) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence getGestureSummary(Context context, boolean sensorSupported,
|
|
||||||
boolean assistGestureEnabled, boolean assistGestureSilenceEnabled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -36,8 +36,6 @@ import androidx.slice.builders.SliceAction;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settings.slices.CustomSliceRegistry;
|
import com.android.settings.slices.CustomSliceRegistry;
|
||||||
import com.android.settings.slices.CustomSliceable;
|
import com.android.settings.slices.CustomSliceable;
|
||||||
|
|
||||||
@@ -59,12 +57,10 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
|
|||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final AmbientDisplayConfiguration mConfig;
|
private final AmbientDisplayConfiguration mConfig;
|
||||||
private final AwareFeatureProvider mFeatureProvider;
|
|
||||||
|
|
||||||
public AlwaysOnDisplaySlice(Context context) {
|
public AlwaysOnDisplaySlice(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
mFeatureProvider = FeatureFactory.getFactory(context).getAwareFeatureProvider();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,12 +103,9 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
|
|||||||
final boolean isChecked = intent.getBooleanExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE,
|
final boolean isChecked = intent.getBooleanExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE,
|
||||||
false);
|
false);
|
||||||
final ContentResolver resolver = mContext.getContentResolver();
|
final ContentResolver resolver = mContext.getContentResolver();
|
||||||
final boolean isAwareSupported = mFeatureProvider.isSupported(mContext);
|
|
||||||
final boolean isAwareEnabled = mFeatureProvider.isEnabled(mContext);
|
|
||||||
|
|
||||||
Settings.Secure.putInt(resolver, DOZE_ALWAYS_ON, isChecked ? 1 : 0);
|
Settings.Secure.putInt(resolver, DOZE_ALWAYS_ON, isChecked ? 1 : 0);
|
||||||
Settings.Secure.putInt(resolver, DOZE_WAKE_DISPLAY_GESTURE,
|
Settings.Secure.putInt(resolver, DOZE_WAKE_DISPLAY_GESTURE, 0);
|
||||||
(isAwareEnabled && isAwareSupported && isChecked) ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,26 +21,19 @@ import android.hardware.display.AmbientDisplayConfiguration;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GesturesSettingPreferenceController extends BasePreferenceController {
|
public class GesturesSettingPreferenceController extends BasePreferenceController {
|
||||||
private final AssistGestureFeatureProvider mFeatureProvider;
|
|
||||||
private final AwareFeatureProvider mAwareFeatureProvider;
|
|
||||||
private List<AbstractPreferenceController> mGestureControllers;
|
private List<AbstractPreferenceController> mGestureControllers;
|
||||||
|
|
||||||
private static final String KEY_GESTURES_SETTINGS = "gesture_settings";
|
|
||||||
private static final String FAKE_PREF_KEY = "fake_key_only_for_get_available";
|
private static final String FAKE_PREF_KEY = "fake_key_only_for_get_available";
|
||||||
|
|
||||||
public GesturesSettingPreferenceController(Context context) {
|
public GesturesSettingPreferenceController(Context context, String key) {
|
||||||
super(context, KEY_GESTURES_SETTINGS);
|
super(context, key);
|
||||||
mFeatureProvider = FeatureFactory.getFactory(context).getAssistGestureFeatureProvider();
|
|
||||||
mAwareFeatureProvider = FeatureFactory.getFactory(context).getAwareFeatureProvider();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -27,7 +27,6 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
|||||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||||
import com.android.settings.accounts.AccountFeatureProvider;
|
import com.android.settings.accounts.AccountFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||||
@@ -176,8 +175,6 @@ public abstract class FeatureFactory {
|
|||||||
*/
|
*/
|
||||||
public abstract BluetoothFeatureProvider getBluetoothFeatureProvider();
|
public abstract BluetoothFeatureProvider getBluetoothFeatureProvider();
|
||||||
|
|
||||||
public abstract AwareFeatureProvider getAwareFeatureProvider();
|
|
||||||
|
|
||||||
public abstract FaceFeatureProvider getFaceFeatureProvider();
|
public abstract FaceFeatureProvider getFaceFeatureProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -33,8 +33,6 @@ import com.android.settings.accounts.AccountFeatureProvider;
|
|||||||
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.aware.AwareFeatureProviderImpl;
|
|
||||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
import com.android.settings.biometrics.face.FaceFeatureProviderImpl;
|
import com.android.settings.biometrics.face.FaceFeatureProviderImpl;
|
||||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||||
@@ -109,7 +107,6 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
private PanelFeatureProvider mPanelFeatureProvider;
|
private PanelFeatureProvider mPanelFeatureProvider;
|
||||||
private ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
private ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||||
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||||
private AwareFeatureProvider mAwareFeatureProvider;
|
|
||||||
private FaceFeatureProvider mFaceFeatureProvider;
|
private FaceFeatureProvider mFaceFeatureProvider;
|
||||||
private BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
private BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
||||||
private WifiTrackerLibProvider mWifiTrackerLibProvider;
|
private WifiTrackerLibProvider mWifiTrackerLibProvider;
|
||||||
@@ -304,14 +301,6 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
return mBluetoothFeatureProvider;
|
return mBluetoothFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AwareFeatureProvider getAwareFeatureProvider() {
|
|
||||||
if (mAwareFeatureProvider == null) {
|
|
||||||
mAwareFeatureProvider = new AwareFeatureProviderImpl();
|
|
||||||
}
|
|
||||||
return mAwareFeatureProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||||
if (mFaceFeatureProvider == null) {
|
if (mFaceFeatureProvider == null) {
|
||||||
|
@@ -20,14 +20,12 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
@@ -39,8 +37,6 @@ public class SystemDashboardFragment extends DashboardFragment {
|
|||||||
|
|
||||||
private static final String TAG = "SystemDashboardFrag";
|
private static final String TAG = "SystemDashboardFrag";
|
||||||
|
|
||||||
public static final String EXTRA_SHOW_AWARE_DISABLED = "show_aware_dialog_disabled";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
@@ -50,17 +46,6 @@ public class SystemDashboardFragment extends DashboardFragment {
|
|||||||
if (getVisiblePreferenceCount(screen) == screen.getInitialExpandedChildrenCount() + 1) {
|
if (getVisiblePreferenceCount(screen) == screen.getInitialExpandedChildrenCount() + 1) {
|
||||||
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
|
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
showRestrictionDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public void showRestrictionDialog() {
|
|
||||||
final Bundle args = getArguments();
|
|
||||||
if (args != null && args.getBoolean(EXTRA_SHOW_AWARE_DISABLED, false)) {
|
|
||||||
FeatureFactory.getFactory(getContext()).getAwareFeatureProvider()
|
|
||||||
.showRestrictionDialog(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 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.aware;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class AwareFeatureProviderImplTest {
|
|
||||||
private Context mContext;
|
|
||||||
private AwareFeatureProviderImpl mImpl;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
mImpl = new AwareFeatureProviderImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isSupported_shouldReturnFalse() {
|
|
||||||
assertThat(mImpl.isSupported(mContext)).isFalse();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -37,9 +37,7 @@ import androidx.slice.SliceProvider;
|
|||||||
import androidx.slice.widget.SliceLiveData;
|
import androidx.slice.widget.SliceLiveData;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.slices.CustomSliceRegistry;
|
import com.android.settings.slices.CustomSliceRegistry;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -55,8 +53,6 @@ public class AlwaysOnDisplaySliceTest {
|
|||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private AlwaysOnDisplaySlice mSlice;
|
private AlwaysOnDisplaySlice mSlice;
|
||||||
private FakeFeatureFactory mFeatureFactory;
|
|
||||||
private AwareFeatureProvider mFeatureProvider;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private AmbientDisplayConfiguration mConfig;
|
private AmbientDisplayConfiguration mConfig;
|
||||||
@@ -65,8 +61,6 @@ public class AlwaysOnDisplaySliceTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
|
||||||
mFeatureProvider = mFeatureFactory.getAwareFeatureProvider();
|
|
||||||
|
|
||||||
// Set-up specs for SliceMetadata.
|
// Set-up specs for SliceMetadata.
|
||||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||||
@@ -116,11 +110,9 @@ public class AlwaysOnDisplaySliceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onNotifyChange_toggleOn_awareNotSupported_enableAoD() {
|
public void onNotifyChange_toggleOn_enableAoD() {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE, true);
|
intent.putExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE, true);
|
||||||
when(mFeatureProvider.isEnabled(mContext)).thenReturn(false);
|
|
||||||
when(mFeatureProvider.isSupported(mContext)).thenReturn(false);
|
|
||||||
|
|
||||||
mSlice.onNotifyChange(intent);
|
mSlice.onNotifyChange(intent);
|
||||||
|
|
||||||
@@ -128,32 +120,4 @@ public class AlwaysOnDisplaySliceTest {
|
|||||||
assertThat(Settings.Secure.getInt(resolver, DOZE_ALWAYS_ON, 0)).isEqualTo(1);
|
assertThat(Settings.Secure.getInt(resolver, DOZE_ALWAYS_ON, 0)).isEqualTo(1);
|
||||||
assertThat(Settings.Secure.getInt(resolver, DOZE_WAKE_DISPLAY_GESTURE, 0)).isEqualTo(0);
|
assertThat(Settings.Secure.getInt(resolver, DOZE_WAKE_DISPLAY_GESTURE, 0)).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onNotifyChange_toggleOn_awareDisabled_enableAoD() {
|
|
||||||
final Intent intent = new Intent();
|
|
||||||
intent.putExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE, true);
|
|
||||||
when(mFeatureProvider.isEnabled(mContext)).thenReturn(false);
|
|
||||||
when(mFeatureProvider.isSupported(mContext)).thenReturn(true);
|
|
||||||
|
|
||||||
mSlice.onNotifyChange(intent);
|
|
||||||
|
|
||||||
final ContentResolver resolver = mContext.getContentResolver();
|
|
||||||
assertThat(Settings.Secure.getInt(resolver, DOZE_ALWAYS_ON, 0)).isEqualTo(1);
|
|
||||||
assertThat(Settings.Secure.getInt(resolver, DOZE_WAKE_DISPLAY_GESTURE, 0)).isEqualTo(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onNotifyChange_toggleOn_awareSupported_enableAoD() {
|
|
||||||
final Intent intent = new Intent();
|
|
||||||
intent.putExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE, true);
|
|
||||||
when(mFeatureProvider.isEnabled(mContext)).thenReturn(true);
|
|
||||||
when(mFeatureProvider.isSupported(mContext)).thenReturn(true);
|
|
||||||
|
|
||||||
mSlice.onNotifyChange(intent);
|
|
||||||
|
|
||||||
final ContentResolver resolver = mContext.getContentResolver();
|
|
||||||
assertThat(Settings.Secure.getInt(resolver, DOZE_ALWAYS_ON, 0)).isEqualTo(1);
|
|
||||||
assertThat(Settings.Secure.getInt(resolver, DOZE_WAKE_DISPLAY_GESTURE, 0)).isEqualTo(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ public class GesturesSettingsPreferenceControllerTest {
|
|||||||
doReturn(mock(DevicePolicyManager.class)).when(mActivity)
|
doReturn(mock(DevicePolicyManager.class)).when(mActivity)
|
||||||
.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
FakeFeatureFactory.setupForTest();
|
FakeFeatureFactory.setupForTest();
|
||||||
mController = new GesturesSettingPreferenceController(mActivity);
|
mController = new GesturesSettingPreferenceController(mActivity, "test_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -18,17 +18,11 @@ package com.android.settings.system;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
@@ -75,27 +69,4 @@ public class SystemDashboardFragmentTest {
|
|||||||
|
|
||||||
assertThat(keys).containsAtLeastElementsIn(niks);
|
assertThat(keys).containsAtLeastElementsIn(niks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void showRestrictionDialog_hasValidExtra_shouldShowDialog() {
|
|
||||||
final AwareFeatureProvider mProvider =
|
|
||||||
FakeFeatureFactory.setupForTest().mAwareFeatureProvider;
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean(SystemDashboardFragment.EXTRA_SHOW_AWARE_DISABLED, true);
|
|
||||||
when(mFragment.getArguments()).thenReturn(bundle);
|
|
||||||
|
|
||||||
mFragment.showRestrictionDialog();
|
|
||||||
|
|
||||||
verify(mProvider).showRestrictionDialog(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void showRestrictionDialog_hasInvalidExtra_shouldNotShowDialog() {
|
|
||||||
final AwareFeatureProvider mProvider =
|
|
||||||
FakeFeatureFactory.setupForTest().mAwareFeatureProvider;
|
|
||||||
|
|
||||||
mFragment.showRestrictionDialog();
|
|
||||||
|
|
||||||
verify(mProvider, never()).showRestrictionDialog(any());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,6 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
|||||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||||
import com.android.settings.accounts.AccountFeatureProvider;
|
import com.android.settings.accounts.AccountFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||||
@@ -81,7 +80,6 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
|
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
|
||||||
public final AccountFeatureProvider mAccountFeatureProvider;
|
public final AccountFeatureProvider mAccountFeatureProvider;
|
||||||
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||||
public final AwareFeatureProvider mAwareFeatureProvider;
|
|
||||||
public final FaceFeatureProvider mFaceFeatureProvider;
|
public final FaceFeatureProvider mFaceFeatureProvider;
|
||||||
public final BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
public final BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
||||||
|
|
||||||
@@ -140,7 +138,6 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
||||||
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
||||||
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
||||||
mAwareFeatureProvider = mock(AwareFeatureProvider.class);
|
|
||||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||||
mBiometricsRepositoryProvider = mock(BiometricsRepositoryProvider.class);
|
mBiometricsRepositoryProvider = mock(BiometricsRepositoryProvider.class);
|
||||||
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
||||||
@@ -257,11 +254,6 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
return mBluetoothFeatureProvider;
|
return mBluetoothFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AwareFeatureProvider getAwareFeatureProvider() {
|
|
||||||
return mAwareFeatureProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||||
return mFaceFeatureProvider;
|
return mFaceFeatureProvider;
|
||||||
|
@@ -21,7 +21,6 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
|
|||||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
|
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
|
||||||
import com.android.settings.accounts.AccountFeatureProvider
|
import com.android.settings.accounts.AccountFeatureProvider
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider
|
import com.android.settings.applications.ApplicationFeatureProvider
|
||||||
import com.android.settings.aware.AwareFeatureProvider
|
|
||||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
|
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
|
||||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||||
@@ -147,10 +146,6 @@ class FakeFeatureFactory : FeatureFactory() {
|
|||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAwareFeatureProvider(): AwareFeatureProvider {
|
|
||||||
TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFaceFeatureProvider(): FaceFeatureProvider {
|
override fun getFaceFeatureProvider(): FaceFeatureProvider {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
|||||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||||
import com.android.settings.accounts.AccountFeatureProvider;
|
import com.android.settings.accounts.AccountFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
import com.android.settings.aware.AwareFeatureProvider;
|
|
||||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||||
@@ -76,7 +75,6 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
|
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
|
||||||
public final AccountFeatureProvider mAccountFeatureProvider;
|
public final AccountFeatureProvider mAccountFeatureProvider;
|
||||||
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||||
public final AwareFeatureProvider mAwareFeatureProvider;
|
|
||||||
public final FaceFeatureProvider mFaceFeatureProvider;
|
public final FaceFeatureProvider mFaceFeatureProvider;
|
||||||
public final BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
public final BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
||||||
|
|
||||||
@@ -126,7 +124,6 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
||||||
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
||||||
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
||||||
mAwareFeatureProvider = mock(AwareFeatureProvider.class);
|
|
||||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||||
mBiometricsRepositoryProvider = mock(BiometricsRepositoryProvider.class);
|
mBiometricsRepositoryProvider = mock(BiometricsRepositoryProvider.class);
|
||||||
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
||||||
@@ -243,11 +240,6 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
return mBluetoothFeatureProvider;
|
return mBluetoothFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AwareFeatureProvider getAwareFeatureProvider() {
|
|
||||||
return mAwareFeatureProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||||
return mFaceFeatureProvider;
|
return mFaceFeatureProvider;
|
||||||
|
Reference in New Issue
Block a user