Merge "Clean up AwareFeatureProvider from Settings"
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.Utils;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
import com.android.settings.slices.CustomSliceable;
|
||||
|
||||
@@ -59,12 +57,10 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
|
||||
|
||||
private final Context mContext;
|
||||
private final AmbientDisplayConfiguration mConfig;
|
||||
private final AwareFeatureProvider mFeatureProvider;
|
||||
|
||||
public AlwaysOnDisplaySlice(Context context) {
|
||||
mContext = context;
|
||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context).getAwareFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,12 +103,9 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
|
||||
final boolean isChecked = intent.getBooleanExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE,
|
||||
false);
|
||||
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_WAKE_DISPLAY_GESTURE,
|
||||
(isAwareEnabled && isAwareSupported && isChecked) ? 1 : 0);
|
||||
Settings.Secure.putInt(resolver, DOZE_WAKE_DISPLAY_GESTURE, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -21,26 +21,19 @@ import android.hardware.display.AmbientDisplayConfiguration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GesturesSettingPreferenceController extends BasePreferenceController {
|
||||
private final AssistGestureFeatureProvider mFeatureProvider;
|
||||
private final AwareFeatureProvider mAwareFeatureProvider;
|
||||
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";
|
||||
|
||||
public GesturesSettingPreferenceController(Context context) {
|
||||
super(context, KEY_GESTURES_SETTINGS);
|
||||
mFeatureProvider = FeatureFactory.getFactory(context).getAssistGestureFeatureProvider();
|
||||
mAwareFeatureProvider = FeatureFactory.getFactory(context).getAwareFeatureProvider();
|
||||
public GesturesSettingPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -27,7 +27,6 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
@@ -176,8 +175,6 @@ public abstract class FeatureFactory {
|
||||
*/
|
||||
public abstract BluetoothFeatureProvider getBluetoothFeatureProvider();
|
||||
|
||||
public abstract AwareFeatureProvider getAwareFeatureProvider();
|
||||
|
||||
public abstract FaceFeatureProvider getFaceFeatureProvider();
|
||||
|
||||
/**
|
||||
|
@@ -33,8 +33,6 @@ import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
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.FaceFeatureProviderImpl;
|
||||
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
|
||||
@@ -109,7 +107,6 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
private PanelFeatureProvider mPanelFeatureProvider;
|
||||
private ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
private AwareFeatureProvider mAwareFeatureProvider;
|
||||
private FaceFeatureProvider mFaceFeatureProvider;
|
||||
private BiometricsRepositoryProvider mBiometricsRepositoryProvider;
|
||||
private WifiTrackerLibProvider mWifiTrackerLibProvider;
|
||||
@@ -304,14 +301,6 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
return mBluetoothFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AwareFeatureProvider getAwareFeatureProvider() {
|
||||
if (mAwareFeatureProvider == null) {
|
||||
mAwareFeatureProvider = new AwareFeatureProviderImpl();
|
||||
}
|
||||
return mAwareFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||
if (mFaceFeatureProvider == null) {
|
||||
|
@@ -20,14 +20,12 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
@@ -39,8 +37,6 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SystemDashboardFrag";
|
||||
|
||||
public static final String EXTRA_SHOW_AWARE_DISABLED = "show_aware_dialog_disabled";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -50,17 +46,6 @@ public class SystemDashboardFragment extends DashboardFragment {
|
||||
if (getVisiblePreferenceCount(screen) == screen.getInitialExpandedChildrenCount() + 1) {
|
||||
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
|
||||
|
Reference in New Issue
Block a user