Clean up: move speciall access stuff into single package
Bug: 110207366 Test: robotests Change-Id: I17ad7a15d1e44bb7690d2b18ed6e2b6b17b46d8a
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="special_access"
|
android:key="special_access"
|
||||||
android:fragment="com.android.settings.applications.SpecialAccessSettings"
|
android:fragment="com.android.settings.applications.specialaccess.SpecialAccessSettings"
|
||||||
android:title="@string/special_access"
|
android:title="@string/special_access"
|
||||||
android:order="20" />
|
android:order="20" />
|
||||||
|
|
||||||
|
@@ -24,7 +24,8 @@
|
|||||||
android:key="high_power_apps"
|
android:key="high_power_apps"
|
||||||
android:title="@string/high_power_apps"
|
android:title="@string/high_power_apps"
|
||||||
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
||||||
settings:keywords="@string/keywords_ignore_optimizations">
|
settings:keywords="@string/keywords_ignore_optimizations"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.HighPowerAppsController">
|
||||||
<extra
|
<extra
|
||||||
android:name="classname"
|
android:name="classname"
|
||||||
android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />
|
android:value="com.android.settings.Settings$HighPowerApplicationsActivity" />
|
||||||
@@ -33,7 +34,8 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="device_administrators"
|
android:key="device_administrators"
|
||||||
android:title="@string/manage_device_admin"
|
android:title="@string/manage_device_admin"
|
||||||
android:fragment="com.android.settings.DeviceAdminSettings" />
|
android:fragment="com.android.settings.DeviceAdminSettings"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.DeviceAdministratorsController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="system_alert_window"
|
android:key="system_alert_window"
|
||||||
@@ -48,7 +50,8 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="zen_access"
|
android:key="zen_access"
|
||||||
android:title="@string/manage_zen_access_title"
|
android:title="@string/manage_zen_access_title"
|
||||||
android:fragment="com.android.settings.notification.ZenAccessSettings" />
|
android:fragment="com.android.settings.notification.ZenAccessSettings"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.ZenAccessController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="write_settings_apps"
|
android:key="write_settings_apps"
|
||||||
@@ -63,23 +66,27 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="notification_access"
|
android:key="notification_access"
|
||||||
android:title="@string/manage_notification_access_title"
|
android:title="@string/manage_notification_access_title"
|
||||||
android:fragment="com.android.settings.notification.NotificationAccessSettings" />
|
android:fragment="com.android.settings.notification.NotificationAccessSettings"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.NotificationAccessController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="picture_in_picture"
|
android:key="picture_in_picture"
|
||||||
android:title="@string/picture_in_picture_title"
|
android:title="@string/picture_in_picture_title"
|
||||||
android:fragment="com.android.settings.applications.appinfo.PictureInPictureSettings"
|
android:fragment="com.android.settings.applications.appinfo.PictureInPictureSettings"
|
||||||
settings:keywords="@string/picture_in_picture_keywords" />
|
settings:keywords="@string/picture_in_picture_keywords"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.PictureInPictureController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="premium_sms"
|
android:key="premium_sms"
|
||||||
android:title="@string/premium_sms_access"
|
android:title="@string/premium_sms_access"
|
||||||
android:fragment="com.android.settings.applications.PremiumSmsAccess" />
|
android:fragment="com.android.settings.applications.PremiumSmsAccess"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.PremiumSmsController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="data_saver"
|
android:key="data_saver"
|
||||||
android:title="@string/unrestricted_data_saver"
|
android:title="@string/unrestricted_data_saver"
|
||||||
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess" />
|
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.DataSaverController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="manage_external_sources"
|
android:key="manage_external_sources"
|
||||||
@@ -105,7 +112,8 @@
|
|||||||
android:key="enabled_vr_listeners"
|
android:key="enabled_vr_listeners"
|
||||||
android:title="@string/vr_listeners_title"
|
android:title="@string/vr_listeners_title"
|
||||||
android:fragment="com.android.settings.applications.VrListenerSettings"
|
android:fragment="com.android.settings.applications.VrListenerSettings"
|
||||||
settings:keywords="@string/keywords_vr_listener">
|
settings:keywords="@string/keywords_vr_listener"
|
||||||
|
settings:controller="com.android.settings.applications.specialaccess.EnabledVrListenersController">
|
||||||
<extra
|
<extra
|
||||||
android:name="classname"
|
android:name="classname"
|
||||||
android:value="com.android.settings.Settings$VrListenersSettingsActivity" />
|
android:value="com.android.settings.Settings$VrListenersSettingsActivity" />
|
||||||
|
@@ -1,106 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 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;
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
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.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SearchIndexable
|
|
||||||
public class SpecialAccessSettings extends DashboardFragment {
|
|
||||||
|
|
||||||
private static final String TAG = "SpecialAccessSettings";
|
|
||||||
private static final String[] DISABLED_FEATURES_LOW_RAM =
|
|
||||||
new String[]{"notification_access", "zen_access", "enabled_vr_listeners",
|
|
||||||
"picture_in_picture"};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.special_access;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle icicle) {
|
|
||||||
super.onCreate(icicle);
|
|
||||||
|
|
||||||
if (ActivityManager.isLowRamDeviceStatic()) {
|
|
||||||
for (String disabledFeature : DISABLED_FEATURES_LOW_RAM) {
|
|
||||||
Preference pref = findPreference(disabledFeature);
|
|
||||||
if (pref != null) {
|
|
||||||
removePreference(disabledFeature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
||||||
return buildPreferenceControllers(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
|
||||||
@NonNull Context context) {
|
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
|
||||||
controllers.add(new HighPowerAppsController(context));
|
|
||||||
controllers.add(new DeviceAdministratorsController(context));
|
|
||||||
controllers.add(new PremiumSmsController(context));
|
|
||||||
controllers.add(new DataSaverController(context));
|
|
||||||
controllers.add(new EnabledVrListenersController(context));
|
|
||||||
return controllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return MetricsEvent.SPECIAL_ACCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.special_access;
|
|
||||||
result.add(sir);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
|
||||||
Context context) {
|
|
||||||
return buildPreferenceControllers(context);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@@ -15,20 +15,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
public class DataSaverController extends BasePreferenceController {
|
public class DataSaverController extends BasePreferenceController {
|
||||||
|
|
||||||
@VisibleForTesting static final String KEY_DATA_SAVER = "data_saver";
|
public DataSaverController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public DataSaverController(Context context) {
|
|
||||||
super(context, KEY_DATA_SAVER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailabilityStatus
|
@AvailabilityStatus
|
@@ -14,20 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
public class DeviceAdministratorsController extends BasePreferenceController {
|
public class DeviceAdministratorsController extends BasePreferenceController {
|
||||||
|
|
||||||
@VisibleForTesting static final String KEY_DEVICE_ADMIN = "device_administrators";
|
public DeviceAdministratorsController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public DeviceAdministratorsController(Context context) {
|
|
||||||
super(context, KEY_DEVICE_ADMIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailabilityStatus
|
@AvailabilityStatus
|
@@ -14,25 +14,24 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
public class EnabledVrListenersController extends BasePreferenceController {
|
public class EnabledVrListenersController extends BasePreferenceController {
|
||||||
|
|
||||||
@VisibleForTesting static final String KEY_ENABLED_VR_LISTENERS = "enabled_vr_listeners";
|
public EnabledVrListenersController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public EnabledVrListenersController(Context context) {
|
|
||||||
super(context, KEY_ENABLED_VR_LISTENERS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailabilityStatus
|
@AvailabilityStatus
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return mContext.getResources().getBoolean(R.bool.config_show_enabled_vr_listeners)
|
return mContext.getResources().getBoolean(R.bool.config_show_enabled_vr_listeners)
|
||||||
|
&& !ActivityManager.isLowRamDeviceStatic()
|
||||||
? AVAILABLE
|
? AVAILABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
@@ -14,20 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
public class HighPowerAppsController extends BasePreferenceController {
|
public class HighPowerAppsController extends BasePreferenceController {
|
||||||
|
|
||||||
@VisibleForTesting static final String KEY_HIGH_POWER_APPS = "high_power_apps";
|
public HighPowerAppsController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public HighPowerAppsController(Context context) {
|
|
||||||
super(context, KEY_HIGH_POWER_APPS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailabilityStatus
|
@AvailabilityStatus
|
@@ -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;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
public class NotificationAccessController extends BasePreferenceController {
|
||||||
|
|
||||||
|
public NotificationAccessController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return !ActivityManager.isLowRamDeviceStatic()
|
||||||
|
? AVAILABLE
|
||||||
|
: 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;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
public class PictureInPictureController extends BasePreferenceController {
|
||||||
|
|
||||||
|
public PictureInPictureController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return !ActivityManager.isLowRamDeviceStatic()
|
||||||
|
? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
}
|
@@ -14,20 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
public class PremiumSmsController extends BasePreferenceController {
|
public class PremiumSmsController extends BasePreferenceController {
|
||||||
|
|
||||||
@VisibleForTesting static final String KEY_PREMIUM_SMS = "premium_sms";
|
public PremiumSmsController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
public PremiumSmsController(Context context) {
|
|
||||||
super(context, KEY_PREMIUM_SMS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailabilityStatus
|
@AvailabilityStatus
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
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 SpecialAccessSettings extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "SpecialAccessSettings";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLogTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.special_access;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return MetricsEvent.SPECIAL_ACCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.special_access;
|
||||||
|
result.add(sir);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@@ -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;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
public class ZenAccessController extends BasePreferenceController {
|
||||||
|
|
||||||
|
public ZenAccessController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return !ActivityManager.isLowRamDeviceStatic()
|
||||||
|
? AVAILABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 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;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
|
||||||
public class SpecialAccessSettingsTest {
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private SpecialAccessSettings mFragment;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
|
||||||
mFragment = new SpecialAccessSettings() {
|
|
||||||
@Override
|
|
||||||
public Context getContext() {
|
|
||||||
return mContext;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSearchIndexProvider_shouldIndexResource() {
|
|
||||||
final List<SearchIndexableResource> indexRes =
|
|
||||||
SpecialAccessSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext,
|
|
||||||
true /* enabled */);
|
|
||||||
final List<String> niks =
|
|
||||||
SpecialAccessSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
|
||||||
|
|
||||||
assertThat(indexRes).isNotNull();
|
|
||||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(R.xml.special_access);
|
|
||||||
assertThat(niks).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Config(qualifiers = "mcc999")
|
|
||||||
public void testSearchIndexProvider_ifElementsAreNotShown_shouldNotBeIndexed() {
|
|
||||||
final List<String> niks =
|
|
||||||
SpecialAccessSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
|
||||||
|
|
||||||
assertThat(niks).contains(HighPowerAppsController.KEY_HIGH_POWER_APPS);
|
|
||||||
assertThat(niks).contains(DeviceAdministratorsController.KEY_DEVICE_ADMIN);
|
|
||||||
assertThat(niks).contains(PremiumSmsController.KEY_PREMIUM_SMS);
|
|
||||||
assertThat(niks).contains(DataSaverController.KEY_DATA_SAVER);
|
|
||||||
assertThat(niks).contains(EnabledVrListenersController.KEY_ENABLED_VR_LISTENERS);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -40,7 +40,7 @@ public class DataSaverControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||||
mController = new DataSaverController(mContext);
|
mController = new DataSaverController(mContext, "key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -40,7 +40,7 @@ public class DeviceAdministratorsControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||||
mController = new DeviceAdministratorsController(mContext);
|
mController = new DeviceAdministratorsController(mContext, "key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@@ -14,10 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@@ -26,31 +25,39 @@ import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.shadow.api.Shadow;
|
||||||
|
import org.robolectric.shadows.ShadowActivityManager;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
public class EnabledVrListenersControllerTest {
|
public class EnabledVrListenersControllerTest {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private EnabledVrListenersController mController;
|
private EnabledVrListenersController mController;
|
||||||
|
private ShadowActivityManager mActivityManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
mContext = RuntimeEnvironment.application;
|
||||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
mController = new EnabledVrListenersController(mContext, "key");
|
||||||
mController = new EnabledVrListenersController(mContext);
|
mActivityManager = Shadow.extract(mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnabledVrListeners_byDefault_shouldBeShown() {
|
public void isAvailable_byDefault_true() {
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_lowMemory_false() {
|
||||||
|
mActivityManager.setIsLowRamDevice(true);
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Config(qualifiers = "mcc999")
|
@Config(qualifiers = "mcc999")
|
||||||
public void testEnabledVrListeners_ifDisabled_shouldNotBeShown() {
|
public void isAvailable_disabled_false() {
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -40,7 +40,7 @@ public class HighPowerAppsControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||||
mController = new HighPowerAppsController(mContext);
|
mController = new HighPowerAppsController(mContext, "key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications.specialaccess;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -40,7 +40,7 @@ public class PremiumSmsControllerTest {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||||
mController = new PremiumSmsController(mContext);
|
mController = new PremiumSmsController(mContext, "key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
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.shadow.api.Shadow;
|
||||||
|
import org.robolectric.shadows.ShadowActivityManager;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
public class ZenAccessControllerTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private ZenAccessController mController;
|
||||||
|
private ShadowActivityManager mActivityManager;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mController = new ZenAccessController(mContext, "key");
|
||||||
|
mActivityManager = Shadow.extract(mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_byDefault_true() {
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_lowMemory_false() {
|
||||||
|
mActivityManager.setIsLowRamDevice(true);
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user