Add some pages to search index.
* Notification access page * VR Listener page * Feature flags in dev options * QS Tile developer options * User dictionary * Billing cycle * Some accessibilty pages Bug: 70720645 Test: robotests Change-Id: I4f7d3d65b2803cebf178ac345a79721232df707c
This commit is contained in:
@@ -2423,7 +2423,7 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.VrListenerSettings" />
|
||||
android:value="com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
|
@@ -14,7 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="autoclick_preference_screen"
|
||||
android:title="@string/accessibility_autoclick_preference_title">
|
||||
|
||||
|
||||
|
@@ -14,7 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="daltonizer_preference_screen"
|
||||
android:title="@string/accessibility_display_daltonizer_preference_title">
|
||||
|
||||
<ListPreference
|
||||
|
@@ -76,7 +76,7 @@
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
|
||||
android:key="autoclick_preference_screen"
|
||||
android:key="autoclick_preference"
|
||||
android:title="@string/accessibility_autoclick_preference_title"/>
|
||||
|
||||
<SwitchPreference
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
|
||||
android:key="daltonizer_preference_screen"
|
||||
android:key="daltonizer_preference"
|
||||
android:title="@string/accessibility_display_daltonizer_preference_title"
|
||||
android:icon="@drawable/ic_daltonizer"/>
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="billing_cycle_settings"
|
||||
android:title="@string/billing_cycle">
|
||||
|
||||
<Preference
|
||||
|
@@ -17,4 +17,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/quick_settings_developer_tiles" />
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="development_tile_settings"
|
||||
android:title="@string/quick_settings_developer_tiles"
|
||||
settings:controller="com.android.settings.development.qstile.DevelopmentTilePreferenceController" />
|
||||
|
@@ -17,4 +17,12 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/feature_flags_dashboard_title" />
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="feature_flags_settings"
|
||||
android:title="@string/feature_flags_dashboard_title">
|
||||
<PreferenceCategory
|
||||
android:key="feature_flag_category"
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
android:title="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.development.featureflags.FeatureFlagsPreferenceController" />
|
||||
</PreferenceScreen>
|
||||
|
@@ -63,7 +63,9 @@
|
||||
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
||||
<Preference
|
||||
android:key="key_user_dictionary_settings"
|
||||
android:title="@string/user_dict_settings_title" />
|
||||
android:title="@string/user_dict_settings_title"
|
||||
android:fragment="com.android.settings.inputmethod.UserDictionaryList"
|
||||
settings:controller="com.android.settings.language.UserDictionaryPreferenceController" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
@@ -17,4 +17,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/manage_notification_access_title" />
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="notification_access_screen"
|
||||
android:title="@string/manage_notification_access_title"
|
||||
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessScreenPreferenceController" />
|
||||
|
@@ -68,7 +68,7 @@
|
||||
android:key="notification_access"
|
||||
android:title="@string/manage_notification_access_title"
|
||||
android:fragment="com.android.settings.notification.NotificationAccessSettings"
|
||||
settings:controller="com.android.settings.applications.specialaccess.NotificationAccessController" />
|
||||
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessController" />
|
||||
|
||||
<Preference
|
||||
android:key="picture_in_picture"
|
||||
@@ -112,9 +112,9 @@
|
||||
<Preference
|
||||
android:key="enabled_vr_listeners"
|
||||
android:title="@string/vr_listeners_title"
|
||||
android:fragment="com.android.settings.applications.VrListenerSettings"
|
||||
android:fragment="com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings"
|
||||
settings:keywords="@string/keywords_vr_listener"
|
||||
settings:controller="com.android.settings.applications.specialaccess.EnabledVrListenersController">
|
||||
settings:controller="com.android.settings.applications.specialaccess.vrlistener.EnabledVrListenersController">
|
||||
<extra
|
||||
android:name="classname"
|
||||
android:value="com.android.settings.Settings$VrListenersSettingsActivity" />
|
||||
|
@@ -17,4 +17,7 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/vr_listeners_title" />
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="vr_listener_settings"
|
||||
android:title="@string/vr_listeners_title"
|
||||
settings:controller="com.android.settings.applications.specialaccess.vrlistener.VrListenerScreenPreferenceController" />
|
||||
|
@@ -119,11 +119,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private static final String TTS_SETTINGS_PREFERENCE =
|
||||
"tts_settings_preference";
|
||||
private static final String AUTOCLICK_PREFERENCE_SCREEN =
|
||||
"autoclick_preference_screen";
|
||||
"autoclick_preference";
|
||||
private static final String VIBRATION_PREFERENCE_SCREEN =
|
||||
"vibration_preference_screen";
|
||||
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
|
||||
"daltonizer_preference_screen";
|
||||
"daltonizer_preference";
|
||||
|
||||
// Extras passed to sub-fragments.
|
||||
static final String EXTRA_PREFERENCE_KEY = "preference_key";
|
||||
@@ -882,6 +882,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
// Duplicates in Language & Input
|
||||
keys.add(TTS_SETTINGS_PREFERENCE);
|
||||
|
||||
// Duplicates in child page
|
||||
keys.add(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
|
||||
keys.add(AUTOCLICK_PREFERENCE_SCREEN);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
|
@@ -16,16 +16,24 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.SeekBarPreference;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -33,6 +41,7 @@ import androidx.preference.Preference;
|
||||
* Fragment for preference screen for settings related to Automatically click after mouse stops
|
||||
* feature.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class ToggleAutoclickPreferenceFragment extends ToggleFeaturePreferenceFragment
|
||||
implements SwitchBar.OnSwitchChangeListener, Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -178,4 +187,18 @@ public class ToggleAutoclickPreferenceFragment extends ToggleFeaturePreferenceFr
|
||||
private int delayToSeekBarProgress(int delay) {
|
||||
return (delay - MIN_AUTOCLICK_DELAY) / AUTOCLICK_DELAY_STEP;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.accessibility_autoclick_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -16,18 +16,27 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@SearchIndexable
|
||||
public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener {
|
||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
||||
@@ -117,4 +126,19 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
onPreferenceToggled(mPreferenceKey, isChecked);
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.accessibility_daltonizer_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -23,13 +23,16 @@ import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class ZenAccessController extends BasePreferenceController {
|
||||
|
||||
private final ActivityManager mActivityManager;
|
||||
|
||||
public ZenAccessController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !ActivityManager.isLowRamDeviceStatic()
|
||||
return !mActivityManager.isLowRamDevice()
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess;
|
||||
package com.android.settings.applications.specialaccess.notificationaccess;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
@@ -30,7 +30,7 @@ public class NotificationAccessController extends BasePreferenceController {
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !ActivityManager.isLowRamDeviceStatic()
|
||||
? AVAILABLE
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.applications.specialaccess.notificationaccess;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class NotificationAccessScreenPreferenceController extends BasePreferenceController {
|
||||
|
||||
public NotificationAccessScreenPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return !ActivityManager.isLowRamDeviceStatic()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess;
|
||||
package com.android.settings.applications.specialaccess.vrlistener;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
@@ -24,15 +24,18 @@ import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class EnabledVrListenersController extends BasePreferenceController {
|
||||
|
||||
private final ActivityManager mActivityManager;
|
||||
|
||||
public EnabledVrListenersController(Context context, String key) {
|
||||
super(context, key);
|
||||
mActivityManager = mContext.getSystemService(ActivityManager.class);
|
||||
}
|
||||
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_enabled_vr_listeners)
|
||||
&& !ActivityManager.isLowRamDeviceStatic()
|
||||
? AVAILABLE
|
||||
&& !mActivityManager.isLowRamDevice()
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.applications.specialaccess.vrlistener;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class VrListenerScreenPreferenceController extends BasePreferenceController {
|
||||
|
||||
private final ActivityManager mActivityManager;
|
||||
|
||||
public VrListenerScreenPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mActivityManager = mContext.getSystemService(ActivityManager.class);
|
||||
}
|
||||
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_show_enabled_vr_listeners)
|
||||
&& !mActivityManager.isLowRamDevice()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
@@ -13,9 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.applications;
|
||||
package com.android.settings.applications.specialaccess.vrlistener;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.service.vr.VrListenerService;
|
||||
|
||||
@@ -23,8 +25,15 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.utils.ManagedServiceSettings;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class VrListenerSettings extends ManagedServiceSettings {
|
||||
private static final String TAG = VrListenerSettings.class.getSimpleName();
|
||||
private static final Config CONFIG = new Config.Builder()
|
||||
@@ -66,4 +75,19 @@ public class VrListenerSettings extends ManagedServiceSettings {
|
||||
FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider().action(getContext(),
|
||||
logCategory, packageName);
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final List<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.vr_listeners_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@@ -38,7 +38,7 @@ import com.android.settings.applications.DirectoryAccessDetails;
|
||||
import com.android.settings.applications.ProcessStatsSummary;
|
||||
import com.android.settings.applications.ProcessStatsUi;
|
||||
import com.android.settings.applications.UsageAccessDetails;
|
||||
import com.android.settings.applications.VrListenerSettings;
|
||||
import com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.applications.appinfo.DrawOverlayDetails;
|
||||
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
|
||||
|
@@ -26,6 +26,7 @@ import android.content.res.Resources;
|
||||
import android.net.NetworkPolicy;
|
||||
import android.net.NetworkTemplate;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.text.format.Time;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -38,12 +39,19 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.NetworkPolicyEditor;
|
||||
import com.android.settingslib.net.DataUsageController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
@SearchIndexable
|
||||
public class BillingCycleSettings extends DataUsageBase implements
|
||||
Preference.OnPreferenceChangeListener, DataUsageEditController {
|
||||
|
||||
@@ -450,4 +458,24 @@ public class BillingCycleSettings extends DataUsageBase implements
|
||||
.putBoolean(KEY_SET_DATA_LIMIT, true).apply();
|
||||
}
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.billing_cycle;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return DataUsageUtils.hasMobileData(context);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -368,7 +368,6 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
|
||||
keys.add(KEY_MOBILE_USAGE_TITLE);
|
||||
keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE);
|
||||
keys.add(KEY_MOBILE_DATA_USAGE);
|
||||
keys.add(KEY_MOBILE_BILLING_CYCLE);
|
||||
}
|
||||
|
||||
if (!DataUsageUtils.hasWifiRadio(context)) {
|
||||
@@ -380,6 +379,8 @@ public class DataUsageSummary extends DataUsageBaseFragment implements DataUsage
|
||||
|
||||
// Duplicate entry for "Data saver"
|
||||
keys.add(KEY_RESTRICT_BACKGROUND);
|
||||
// Duplicate entry for "Data warning & limit"
|
||||
keys.add(KEY_MOBILE_BILLING_CYCLE);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
@@ -17,16 +17,22 @@
|
||||
package com.android.settings.development.featureflags;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class FeatureFlagsDashboard extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "FeatureFlagsDashboard";
|
||||
@@ -59,13 +65,43 @@ public class FeatureFlagsDashboard extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPrefControllers(context, getLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPrefControllers(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
final Lifecycle lifecycle = getLifecycle();
|
||||
final FeatureFlagFooterPreferenceController footerController =
|
||||
new FeatureFlagFooterPreferenceController(context);
|
||||
controllers.add(new FeatureFlagsPreferenceController(context, lifecycle));
|
||||
controllers.add(footerController);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(footerController);
|
||||
}
|
||||
controllers.add(footerController);
|
||||
return controllers;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final List<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.feature_flags_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPrefControllers(context, null /* lifecycle */);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -19,57 +19,48 @@ package com.android.settings.development.featureflags;
|
||||
import android.content.Context;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
public class FeatureFlagsPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, LifecycleObserver, OnStart {
|
||||
public class FeatureFlagsPreferenceController extends BasePreferenceController
|
||||
implements LifecycleObserver, OnStart {
|
||||
|
||||
private PreferenceScreen mScreen;
|
||||
private PreferenceGroup mGroup;
|
||||
|
||||
public FeatureFlagsPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
public FeatureFlagsPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return null;
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mScreen = screen;
|
||||
mGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (mScreen == null) {
|
||||
if (mGroup == null) {
|
||||
return;
|
||||
}
|
||||
final Map<String, String> featureMap = FeatureFlagUtils.getAllFeatureFlags();
|
||||
if (featureMap == null) {
|
||||
return;
|
||||
}
|
||||
mScreen.removeAll();
|
||||
final Context prefContext = mScreen.getContext();
|
||||
mGroup.removeAll();
|
||||
final Context prefContext = mGroup.getContext();
|
||||
for (String feature : featureMap.keySet()) {
|
||||
mScreen.addPreference(new FeatureFlagPreference(prefContext, feature));
|
||||
mGroup.addPreference(new FeatureFlagPreference(prefContext, feature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,15 +17,20 @@
|
||||
package com.android.settings.development.qstile;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class DevelopmentTileConfigFragment extends DashboardFragment {
|
||||
private static final String TAG = "DevelopmentTileConfig";
|
||||
|
||||
@@ -39,15 +44,27 @@ public class DevelopmentTileConfigFragment extends DashboardFragment {
|
||||
return R.xml.development_tile_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new DevelopmentTilePreferenceController(context));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.DEVELOPMENT_QS_TILE_CONFIG;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final List<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.development_tile_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import android.service.quicksettings.TileService;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,33 +37,28 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
public class DevelopmentTilePreferenceController extends AbstractPreferenceController {
|
||||
public class DevelopmentTilePreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String TAG = "DevTilePrefController";
|
||||
private final OnChangeHandler mOnChangeHandler;
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public DevelopmentTilePreferenceController(Context context) {
|
||||
super(context);
|
||||
public DevelopmentTilePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mOnChangeHandler = new OnChangeHandler(context);
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return null;
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
Context context = screen.getContext();
|
||||
Intent intent = new Intent(TileService.ACTION_QS_TILE)
|
||||
final Context context = screen.getContext();
|
||||
final Intent intent = new Intent(TileService.ACTION_QS_TILE)
|
||||
.setPackage(context.getPackageName());
|
||||
final List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent,
|
||||
PackageManager.MATCH_DISABLED_COMPONENTS);
|
||||
|
@@ -19,11 +19,19 @@ package com.android.settings.inputmethod;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class UserDictionaryList extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "UserDictionaryList";
|
||||
@@ -66,4 +74,18 @@ public class UserDictionaryList extends DashboardFragment {
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.user_dictionary_list_fragment;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -57,7 +57,6 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
||||
private static final String KEY_KEYBOARDS_CATEGORY = "keyboards_category";
|
||||
private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
|
||||
private static final String KEY_POINTER_AND_TTS_CATEGORY = "pointer_and_tts_category";
|
||||
private static final String KEY_GAME_CONTROLLER_CATEGORY = "game_controller_settings_category";
|
||||
private static final String KEY_PHYSICAL_KEYBOARD = "physical_keyboard_pref";
|
||||
|
||||
@Override
|
||||
@@ -124,7 +123,6 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
||||
// Input Assistance
|
||||
controllers.add(new SpellCheckerPreferenceController(context));
|
||||
controllers.add(new DefaultAutofillPreferenceController(context));
|
||||
controllers.add(new UserDictionaryPreferenceController(context));
|
||||
|
||||
return controllers;
|
||||
}
|
||||
|
@@ -20,33 +20,24 @@ import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.inputmethod.UserDictionaryList;
|
||||
import com.android.settings.inputmethod.UserDictionaryListPreferenceController;
|
||||
import com.android.settings.inputmethod.UserDictionarySettings;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
public class UserDictionaryPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
public class UserDictionaryPreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String KEY_USER_DICTIONARY_SETTINGS = "key_user_dictionary_settings";
|
||||
|
||||
public UserDictionaryPreferenceController(Context context) {
|
||||
super(context);
|
||||
public UserDictionaryPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_USER_DICTIONARY_SETTINGS;
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -82,6 +83,9 @@ public class NfcPaymentPreferenceController extends BasePreferenceController imp
|
||||
if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (NfcAdapter.getDefaultAdapter(mContext) == null) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (mPaymentBackend == null) {
|
||||
mPaymentBackend = new PaymentBackend(mContext);
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
|
||||
@@ -32,13 +33,20 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.utils.ManagedServiceSettings;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Settings screen for managing notification listener permissions
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class NotificationAccessSettings extends ManagedServiceSettings {
|
||||
private static final String TAG = NotificationAccessSettings.class.getSimpleName();
|
||||
private static final String TAG = "NotificationAccessSettings";
|
||||
private static final Config CONFIG = new Config.Builder()
|
||||
.setTag(TAG)
|
||||
.setSetting(Settings.Secure.ENABLED_NOTIFICATION_LISTENERS)
|
||||
@@ -166,4 +174,18 @@ public class NotificationAccessSettings extends ManagedServiceSettings {
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final List<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.notification_access_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
com.android.settings.accessibility.AccessibilitySettingsForSetupWizard
|
||||
com.android.settings.accessibility.CaptionPropertiesFragment
|
||||
com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment
|
||||
com.android.settings.accessibility.ToggleAutoclickPreferenceFragment
|
||||
com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment
|
||||
com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment
|
||||
com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard
|
||||
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
|
||||
@@ -24,18 +22,14 @@ com.android.settings.applications.ProcessStatsUi
|
||||
com.android.settings.applications.RunningServices
|
||||
com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails
|
||||
com.android.settings.applications.UsageAccessDetails
|
||||
com.android.settings.applications.VrListenerSettings
|
||||
com.android.settings.backup.ToggleBackupSettingFragment
|
||||
com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment
|
||||
com.android.settings.bluetooth.BluetoothDeviceDetailsFragment
|
||||
com.android.settings.bluetooth.BluetoothPairingDetail
|
||||
com.android.settings.bluetooth.DevicePickerFragment
|
||||
com.android.settings.datausage.AppDataUsage
|
||||
com.android.settings.datausage.BillingCycleSettings
|
||||
com.android.settings.datausage.DataUsageList
|
||||
com.android.settings.datetime.timezone.TimeZoneSettings
|
||||
com.android.settings.development.featureflags.FeatureFlagsDashboard
|
||||
com.android.settings.development.qstile.DevelopmentTileConfigFragment
|
||||
com.android.settings.deviceinfo.PrivateVolumeSettings
|
||||
com.android.settings.deviceinfo.PublicVolumeSettings
|
||||
com.android.settings.deviceinfo.StorageProfileFragment
|
||||
@@ -53,14 +47,12 @@ com.android.settings.IccLockSettings
|
||||
com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
|
||||
com.android.settings.inputmethod.KeyboardLayoutPickerFragment
|
||||
com.android.settings.inputmethod.SpellCheckersSettings
|
||||
com.android.settings.inputmethod.UserDictionaryList
|
||||
com.android.settings.localepicker.LocaleListEditor
|
||||
com.android.settings.network.ApnEditor
|
||||
com.android.settings.network.ApnSettings
|
||||
com.android.settings.notification.AppNotificationSettings
|
||||
com.android.settings.notification.ChannelGroupNotificationSettings
|
||||
com.android.settings.notification.ChannelNotificationSettings
|
||||
com.android.settings.notification.NotificationAccessSettings
|
||||
com.android.settings.notification.NotificationStation
|
||||
com.android.settings.notification.RedactionInterstitial$RedactionInterstitialFragment
|
||||
com.android.settings.notification.ZenModeEventRuleSettings
|
||||
|
@@ -51,6 +51,6 @@ public class ZenAccessControllerTest {
|
||||
@Test
|
||||
public void isAvailable_lowMemory_false() {
|
||||
mActivityManager.setIsLowRamDevice(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -14,8 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.specialaccess;
|
||||
package com.android.settings.applications.specialaccess.vrlistener;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -45,19 +47,19 @@ public class EnabledVrListenersControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_byDefault_true() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
public void getAvailability_byDefault_unsearchable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_lowMemory_false() {
|
||||
public void getAvailability_lowMemory_unavailable() {
|
||||
mActivityManager.setIsLowRamDevice(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void isAvailable_disabled_false() {
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
public void getAvailability_disabled_unavailable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.applications.specialaccess.vrlistener;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowActivityManager;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class VrListenerScreenPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private VrListenerScreenPreferenceController mController;
|
||||
private ShadowActivityManager mActivityManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new VrListenerScreenPreferenceController(mContext, "key");
|
||||
mActivityManager = Shadow.extract(mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_byDefault_searchable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_lowMemory_unavailable() {
|
||||
mActivityManager.setIsLowRamDevice(true);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void getAvailability_disabled_unavailable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -11,10 +11,10 @@
|
||||
* 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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications;
|
||||
package com.android.settings.applications.specialaccess.vrlistener;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Matchers.eq;
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.development.featureflags;
|
||||
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -35,7 +34,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@@ -43,33 +42,31 @@ public class FeatureFlagPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private PreferenceCategory mCategory;
|
||||
private Context mContext;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
private Lifecycle mLifecycle;
|
||||
private FeatureFlagsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mLifecycleOwner = () -> mLifecycle;
|
||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||
mController = new FeatureFlagsPreferenceController(mContext, mLifecycle);
|
||||
when(mScreen.getContext()).thenReturn(mContext);
|
||||
mController = new FeatureFlagsPreferenceController(mContext, "test_key");
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory);
|
||||
when(mCategory.getContext()).thenReturn(mContext);
|
||||
mController.displayPreference(mScreen);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyConstants() {
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mController.getPreferenceKey()).isNull();
|
||||
public void getAvailability_available() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldRefreshFeatureFlags() {
|
||||
mLifecycle.handleLifecycleEvent(ON_START);
|
||||
mController.onStart();
|
||||
|
||||
verify(mScreen).removeAll();
|
||||
verify(mScreen, atLeastOnce()).addPreference(any(FeatureFlagPreference.class));
|
||||
verify(mCategory).removeAll();
|
||||
verify(mCategory, atLeastOnce()).addPreference(any(FeatureFlagPreference.class));
|
||||
}
|
||||
}
|
||||
|
@@ -70,9 +70,7 @@ public class DevelopmentTilePreferenceControllerTest {
|
||||
mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||
when(mScreen.getContext()).thenReturn(mContext);
|
||||
|
||||
mController = new DevelopmentTilePreferenceController(mContext);
|
||||
assertThat(mController.getPreferenceKey()).isNull();
|
||||
|
||||
mController = new DevelopmentTilePreferenceController(mContext, "testkey");
|
||||
mOnChangeHandler = spy(new DevelopmentTilePreferenceController.OnChangeHandler(mContext));
|
||||
ReflectionHelpers.setField(mOnChangeHandler, "mStatusBarService", mStatusBarService);
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ public class UserDictionaryPreferenceControllerTest {
|
||||
}
|
||||
|
||||
private TestController(Context context) {
|
||||
super(context);
|
||||
super(context, "test_key");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user