Handle Aware sensor status for Always On
- "Always On" preference will be hiden when aware sensor is available - Extract NavModeCandidateInfo from SystemNavigationGestureSettings Bug: 136610131 Test: robotest & manual Change-Id: If58c70549339b66116f19df7193d85bb04e3f1b7
This commit is contained in:
@@ -17,6 +17,7 @@ package com.android.settings.display;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.display.AmbientDisplayConfiguration;
|
import android.hardware.display.AmbientDisplayConfiguration;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -29,6 +30,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
|||||||
private final int OFF = 0;
|
private final int OFF = 0;
|
||||||
|
|
||||||
private static final int MY_USER = UserHandle.myUserId();
|
private static final int MY_USER = UserHandle.myUserId();
|
||||||
|
private static final String PROP_AWARE_AVAILABLE = "ro.vendor.aware_available";
|
||||||
|
|
||||||
private AmbientDisplayConfiguration mConfig;
|
private AmbientDisplayConfiguration mConfig;
|
||||||
private OnPreferenceChangedCallback mCallback;
|
private OnPreferenceChangedCallback mCallback;
|
||||||
@@ -43,7 +45,9 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return isAvailable(getConfig()) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return isAvailable(getConfig())
|
||||||
|
&& !SystemProperties.getBoolean(PROP_AWARE_AVAILABLE, false) ?
|
||||||
|
AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -31,7 +31,6 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.om.IOverlayManager;
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.om.OverlayInfo;
|
import android.content.om.OverlayInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
@@ -48,6 +47,7 @@ import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
|||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
|
import com.android.settings.utils.CandidateInfoExtra;
|
||||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||||
import com.android.settings.widget.RadioButtonPreferenceWithExtraWidget;
|
import com.android.settings.widget.RadioButtonPreferenceWithExtraWidget;
|
||||||
import com.android.settings.widget.VideoPreference;
|
import com.android.settings.widget.VideoPreference;
|
||||||
@@ -150,12 +150,12 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void bindPreferenceExtra(RadioButtonPreference pref,
|
public void bindPreferenceExtra(RadioButtonPreference pref,
|
||||||
String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
|
String key, CandidateInfo info, String defaultKey, String systemDefaultKey) {
|
||||||
if (!(info instanceof NavModeCandidateInfo)
|
if (!(info instanceof CandidateInfoExtra)
|
||||||
|| !(pref instanceof RadioButtonPreferenceWithExtraWidget)) {
|
|| !(pref instanceof RadioButtonPreferenceWithExtraWidget)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pref.setSummary(((NavModeCandidateInfo) info).loadSummary());
|
pref.setSummary(((CandidateInfoExtra) info).loadSummary());
|
||||||
|
|
||||||
RadioButtonPreferenceWithExtraWidget p = (RadioButtonPreferenceWithExtraWidget) pref;
|
RadioButtonPreferenceWithExtraWidget p = (RadioButtonPreferenceWithExtraWidget) pref;
|
||||||
if (info.getKey() == KEY_SYSTEM_NAV_GESTURAL) {
|
if (info.getKey() == KEY_SYSTEM_NAV_GESTURAL) {
|
||||||
@@ -175,25 +175,25 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected List<? extends CandidateInfo> getCandidates() {
|
protected List<? extends CandidateInfo> getCandidates() {
|
||||||
final Context c = getContext();
|
final Context c = getContext();
|
||||||
List<NavModeCandidateInfo> candidates = new ArrayList<>();
|
List<CandidateInfoExtra> candidates = new ArrayList<>();
|
||||||
|
|
||||||
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
|
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY)) {
|
NAV_BAR_MODE_GESTURAL_OVERLAY)) {
|
||||||
candidates.add(new NavModeCandidateInfo(
|
candidates.add(new CandidateInfoExtra(
|
||||||
c.getText(R.string.edge_to_edge_navigation_title),
|
c.getText(R.string.edge_to_edge_navigation_title),
|
||||||
c.getText(R.string.edge_to_edge_navigation_summary),
|
c.getText(R.string.edge_to_edge_navigation_summary),
|
||||||
KEY_SYSTEM_NAV_GESTURAL, true /* enabled */));
|
KEY_SYSTEM_NAV_GESTURAL, true /* enabled */));
|
||||||
}
|
}
|
||||||
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
|
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
|
||||||
NAV_BAR_MODE_2BUTTON_OVERLAY)) {
|
NAV_BAR_MODE_2BUTTON_OVERLAY)) {
|
||||||
candidates.add(new NavModeCandidateInfo(
|
candidates.add(new CandidateInfoExtra(
|
||||||
c.getText(R.string.swipe_up_to_switch_apps_title),
|
c.getText(R.string.swipe_up_to_switch_apps_title),
|
||||||
c.getText(R.string.swipe_up_to_switch_apps_summary),
|
c.getText(R.string.swipe_up_to_switch_apps_summary),
|
||||||
KEY_SYSTEM_NAV_2BUTTONS, true /* enabled */));
|
KEY_SYSTEM_NAV_2BUTTONS, true /* enabled */));
|
||||||
}
|
}
|
||||||
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
|
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
|
||||||
NAV_BAR_MODE_3BUTTON_OVERLAY)) {
|
NAV_BAR_MODE_3BUTTON_OVERLAY)) {
|
||||||
candidates.add(new NavModeCandidateInfo(
|
candidates.add(new CandidateInfoExtra(
|
||||||
c.getText(R.string.legacy_navigation_title),
|
c.getText(R.string.legacy_navigation_title),
|
||||||
c.getText(R.string.legacy_navigation_summary),
|
c.getText(R.string.legacy_navigation_summary),
|
||||||
KEY_SYSTEM_NAV_3BUTTONS, true /* enabled */));
|
KEY_SYSTEM_NAV_3BUTTONS, true /* enabled */));
|
||||||
@@ -325,39 +325,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment {
|
|||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NavModeCandidateInfo extends CandidateInfo {
|
|
||||||
private final CharSequence mLabel;
|
|
||||||
private final CharSequence mSummary;
|
|
||||||
private final String mKey;
|
|
||||||
|
|
||||||
NavModeCandidateInfo(CharSequence label, CharSequence summary, String key,
|
|
||||||
boolean enabled) {
|
|
||||||
super(enabled);
|
|
||||||
mLabel = label;
|
|
||||||
mSummary = summary;
|
|
||||||
mKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence loadLabel() {
|
|
||||||
return mLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CharSequence loadSummary() {
|
|
||||||
return mSummary;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Drawable loadIcon() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getKey() {
|
|
||||||
return mKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.system_navigation_gesture_settings) {
|
new BaseSearchIndexProvider(R.xml.system_navigation_gesture_settings) {
|
||||||
|
|
||||||
|
54
src/com/android/settings/utils/CandidateInfoExtra.java
Normal file
54
src/com/android/settings/utils/CandidateInfoExtra.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.utils;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import com.android.settingslib.widget.CandidateInfo;
|
||||||
|
|
||||||
|
public class CandidateInfoExtra extends CandidateInfo {
|
||||||
|
private final CharSequence mLabel;
|
||||||
|
private final CharSequence mSummary;
|
||||||
|
private final String mKey;
|
||||||
|
|
||||||
|
public CandidateInfoExtra(CharSequence label, CharSequence summary, String key,
|
||||||
|
boolean enabled) {
|
||||||
|
super(enabled);
|
||||||
|
mLabel = label;
|
||||||
|
mSummary = summary;
|
||||||
|
mKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence loadLabel() {
|
||||||
|
return mLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence loadSummary() {
|
||||||
|
return mSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable loadIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return mKey;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user