Snap for 4831764 from e716b47d60 to qt-release
Change-Id: I7b152948c6ae2801f4c1ce316c0d3122caaaa827
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/color_mode_preview_height"
|
||||
android:paddingBottom="@dimen/color_mode_preview_padding_bottom"
|
||||
android:scaleType="centerCrop"
|
||||
android:cropToPadding="true"
|
||||
android:src="@drawable/color_mode_preview"
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
<dimen name="captioning_preview_height">200dp</dimen>
|
||||
|
||||
<dimen name="color_mode_preview_height">320dp</dimen>
|
||||
<dimen name="color_mode_preview_padding_bottom">40dp</dimen>
|
||||
|
||||
<dimen name="ring_progress_bar_thickness">4dp</dimen>
|
||||
<dimen name="settings_side_margin">0dip</dimen>
|
||||
|
||||
@@ -7410,7 +7410,7 @@
|
||||
<!-- Do not disturb settings, messages, events and reminders title [CHAR LIMIT=100]-->
|
||||
<string name="zen_msg_event_reminder_title">Messages, events & reminders</string>
|
||||
<!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
|
||||
<string name="zen_msg_event_reminder_footer">When Do Not Disturb is on, messages, reminders, and events will muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.</string>
|
||||
<string name="zen_msg_event_reminder_footer">When Do Not Disturb is on, messages, reminders, and events will be muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.</string>
|
||||
|
||||
<!-- Do not disturb onboarding dialog, accept new settings [CHAR LIMIT=30]-->
|
||||
<string name="zen_onboarding_ok">Done</string>
|
||||
@@ -7975,9 +7975,15 @@
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: All messages summary -->
|
||||
<string name="zen_mode_all_messages">Messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Messages option (ie: text messages) -->
|
||||
<string name="zen_mode_all_messages_list">messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Selected messages summary -->
|
||||
<string name="zen_mode_selected_messages">Some messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Selected messages (ie: some text messages are allowed to bypass dnd) -->
|
||||
<string name="zen_mode_selected_messages_list">some messages</string>
|
||||
|
||||
<!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From anyone -->
|
||||
<string name="zen_mode_from_anyone">From anyone</string>
|
||||
|
||||
@@ -8002,21 +8008,36 @@
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
|
||||
<string name="zen_mode_alarms">Alarms</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Alarms option (ie: sound from alarm clock) -->
|
||||
<string name="zen_mode_alarms_list">alarms</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
|
||||
<string name="zen_mode_media">Media</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Media (ie: sound from video) -->
|
||||
<string name="zen_mode_media_list">media</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch sounds -->
|
||||
<string name="zen_mode_system">Touch sounds</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: System sounds (ie: touch sounds) -->
|
||||
<string name="zen_mode_system_list">touch sounds</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
|
||||
<string name="zen_mode_reminders">Reminders</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Reminders (ie: calendar reminders are allowed to bypass dnd) -->
|
||||
<string name="zen_mode_reminders_list">reminders</string>
|
||||
|
||||
<!-- [CHAR LIMIT=70] Zen mode settings: Allow reminders toggle title -->
|
||||
<string name="zen_mode_reminders_title">Allow reminders</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
|
||||
<string name="zen_mode_events">Events</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Events (ie: calendar events) -->
|
||||
<string name="zen_mode_events_list">events</string>
|
||||
|
||||
<!-- [CHAR LIMIT=70] Zen mode settings: Allow events toggle title -->
|
||||
<string name="zen_mode_events_title">Allow events</string>
|
||||
|
||||
@@ -8032,6 +8053,9 @@
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers option -->
|
||||
<string name="zen_mode_repeat_callers">Repeat callers</string>
|
||||
|
||||
<!-- [CHAR LIMIT=50] Zen mode settings: Repeat callers (ie: repeat callers are allowed to bypass dnd) -->
|
||||
<string name="zen_mode_repeat_callers_list">repeat callers</string>
|
||||
|
||||
<!-- [CHAR LIMIT=70] Zen mode settings: Allow repeat callers toggle title -->
|
||||
<string name="zen_mode_repeat_callers_title">Allow repeat callers</string>
|
||||
|
||||
@@ -9918,6 +9942,9 @@
|
||||
<!-- Help URI, smart battery page [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_smart_battery_settings" translatable="false"></string>
|
||||
|
||||
<!-- Help URI, prevent ringing gesture [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_prevent_ringing_gesture" translatable="false"></string>
|
||||
|
||||
<!-- Title label for dnd suggestion, which is displayed in Settings homepage [CHAR LIMIT=100] -->
|
||||
<string name="zen_suggestion_title">Update Do Not Disturb</string>
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
android:key="color_mode"
|
||||
android:title="@string/color_mode_title"
|
||||
android:fragment="com.android.settings.display.ColorModePreferenceFragment"
|
||||
settings:controller="com.android.settings.display.ColorModePreferenceController"
|
||||
settings:keywords="@string/keywords_color_mode" />
|
||||
|
||||
<Preference
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||
import com.android.settings.display.CameraGesturePreferenceController;
|
||||
import com.android.settings.display.ColorModePreferenceController;
|
||||
import com.android.settings.display.LiftToWakePreferenceController;
|
||||
import com.android.settings.display.NightDisplayPreferenceController;
|
||||
import com.android.settings.display.NightModePreferenceController;
|
||||
@@ -94,7 +93,6 @@ public class DisplaySettings extends DashboardFragment {
|
||||
controllers.add(new WallpaperPreferenceController(context));
|
||||
controllers.add(new ThemePreferenceController(context));
|
||||
controllers.add(new BrightnessLevelPreferenceController(context, lifecycle));
|
||||
controllers.add(new ColorModePreferenceController(context));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.WallpaperColors;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -68,15 +70,27 @@ public class FallbackHome extends Activity {
|
||||
// we don't flash the wallpaper before SUW
|
||||
mProvisioned = Settings.Global.getInt(getContentResolver(),
|
||||
Settings.Global.DEVICE_PROVISIONED, 0) != 0;
|
||||
int flags;
|
||||
if (!mProvisioned) {
|
||||
setTheme(R.style.FallbackHome_SetupWizard);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
flags = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
} else {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||
flags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
||||
}
|
||||
|
||||
// Set the system ui flags to light status bar if the wallpaper supports dark text to match
|
||||
// current system ui color tints.
|
||||
final WallpaperColors colors = getSystemService(WallpaperManager.class)
|
||||
.getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
|
||||
if (colors != null
|
||||
&& (colors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_TEXT) != 0) {
|
||||
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
| View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
}
|
||||
getWindow().getDecorView().setSystemUiVisibility(flags);
|
||||
|
||||
registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
|
||||
maybeFinish();
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@ import android.net.NetworkPolicyManager;
|
||||
import android.net.NetworkTemplate;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.text.BidiFormatter;
|
||||
@@ -43,20 +39,20 @@ import com.android.settings.R;
|
||||
import com.android.settings.SummaryPreference;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.NetworkPolicyEditor;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.net.DataUsageController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
/**
|
||||
* Legacy {@link DataUsageSummary} fragment.
|
||||
*/
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Indexable,
|
||||
DataUsageEditController {
|
||||
|
||||
@@ -143,7 +139,7 @@ public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Ind
|
||||
}
|
||||
mDataUsageTemplate = hasMobileData ? R.string.cell_data_template
|
||||
: hasWifiRadio ? R.string.wifi_data_template
|
||||
: R.string.ethernet_data_template;
|
||||
: R.string.ethernet_data_template;
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@@ -204,7 +200,7 @@ public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Ind
|
||||
category.setTemplate(getNetworkTemplate(subId), subId, services);
|
||||
category.pushTemplates(services);
|
||||
if (subInfo != null && !TextUtils.isEmpty(subInfo.getDisplayName())) {
|
||||
Preference title = category.findPreference(KEY_MOBILE_USAGE_TITLE);
|
||||
Preference title = category.findPreference(KEY_MOBILE_USAGE_TITLE);
|
||||
title.setTitle(subInfo.getDisplayName());
|
||||
}
|
||||
}
|
||||
@@ -260,7 +256,7 @@ public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Ind
|
||||
|
||||
final SpannableString amountTemplate = new SpannableString(
|
||||
context.getString(com.android.internal.R.string.fileSizeSuffix)
|
||||
.replace("%1$s", "^1").replace("%2$s", "^2"));
|
||||
.replace("%1$s", "^1").replace("%2$s", "^2"));
|
||||
final CharSequence formattedUsage = TextUtils.expandTemplate(amountTemplate,
|
||||
enlargedValue, usedResult.units);
|
||||
|
||||
@@ -359,52 +355,5 @@ public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Ind
|
||||
}
|
||||
|
||||
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
|
||||
= SummaryProvider::new;
|
||||
|
||||
/**
|
||||
* For search
|
||||
*/
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
List<SearchIndexableResource> resources = new ArrayList<>();
|
||||
SearchIndexableResource resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_legacy;
|
||||
resources.add(resource);
|
||||
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_cellular;
|
||||
resources.add(resource);
|
||||
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_wifi;
|
||||
resources.add(resource);
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
|
||||
if (!DataUsageUtils.hasMobileData(context)) {
|
||||
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)) {
|
||||
keys.add(KEY_WIFI_DATA_USAGE);
|
||||
}
|
||||
|
||||
// This title is named Wifi, and will confuse users.
|
||||
keys.add(KEY_WIFI_USAGE_TITLE);
|
||||
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
= SummaryProvider::new;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ public class ImeiInfoDialogController {
|
||||
static final int ID_GSM_SETTINGS = R.id.gsm_settings;
|
||||
|
||||
private static CharSequence getTextAsDigits(CharSequence text) {
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
return "";
|
||||
}
|
||||
if (TextUtils.isDigitsOnly(text)) {
|
||||
final Spannable spannable = new SpannableStringBuilder(text);
|
||||
final TtsSpan span = new TtsSpan.DigitsBuilder(text.toString()).build();
|
||||
|
||||
@@ -27,15 +27,14 @@ import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class ColorModePreferenceController extends BasePreferenceController {
|
||||
private static final String TAG = "ColorModePreference";
|
||||
private static final String KEY_COLOR_MODE = "color_mode";
|
||||
|
||||
private static final int SURFACE_FLINGER_TRANSACTION_QUERY_WIDE_COLOR = 1024;
|
||||
|
||||
private final ConfigurationWrapper mConfigWrapper;
|
||||
private ColorDisplayController mColorDisplayController;
|
||||
|
||||
public ColorModePreferenceController(Context context) {
|
||||
super(context, KEY_COLOR_MODE);
|
||||
public ColorModePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mConfigWrapper = new ConfigurationWrapper();
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ public class ColorModePreferenceController extends BasePreferenceController {
|
||||
public int getAvailabilityStatus() {
|
||||
return mConfigWrapper.isScreenWideColorGamut()
|
||||
&& !getColorDisplayController().getAccessibilityTransformActivated() ?
|
||||
AVAILABLE : DISABLED_FOR_USER;
|
||||
AVAILABLE_UNSEARCHABLE : DISABLED_FOR_USER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,8 @@ package com.android.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@@ -23,13 +25,18 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@SearchIndexable
|
||||
public class ColorModePreferenceFragment extends RadioButtonPickerFragment
|
||||
implements ColorDisplayController.Callback {
|
||||
|
||||
@@ -181,4 +188,15 @@ public class ColorModePreferenceFragment extends RadioButtonPickerFragment
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.color_mode_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,18 +24,12 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseLongArray;
|
||||
@@ -48,7 +42,6 @@ import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
|
||||
import com.android.settings.fuelgauge.batterytip.StatsManagerConfig;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.utils.PowerUtil;
|
||||
|
||||
@@ -58,6 +51,12 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
/**
|
||||
* Utils for battery operation
|
||||
*/
|
||||
@@ -93,14 +92,14 @@ public class BatteryUtils {
|
||||
|
||||
public static BatteryUtils getInstance(Context context) {
|
||||
if (sInstance == null || sInstance.isDataCorrupted()) {
|
||||
sInstance = new BatteryUtils(context);
|
||||
sInstance = new BatteryUtils(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
BatteryUtils(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mContext = context;
|
||||
mPackageManager = context.getPackageManager();
|
||||
mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||
mPowerUsageFeatureProvider = FeatureFactory.getFactory(
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PreventRingingGestureSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return 0;
|
||||
return R.string.help_uri_prevent_ringing_gesture;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
|
||||
@@ -25,6 +25,7 @@ import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.widget.RestrictedAppPreference;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -130,8 +131,11 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
|
||||
private List<Preference> getLocationServices() {
|
||||
// If location access is locked down by device policy then we only show injected settings
|
||||
// for the primary profile.
|
||||
final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
|
||||
|
||||
return mInjector.getInjectedSettings(mFragment.getPreferenceManager().getContext(),
|
||||
mLocationEnabler.isManagedProfileRestrictedByBase()
|
||||
(profileUserId != UserHandle.USER_NULL
|
||||
&& mLocationEnabler.getShareLocationEnforcedAdmin(profileUserId) != null)
|
||||
? UserHandle.myUserId() : UserHandle.USER_CURRENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,11 +138,11 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
||||
|
||||
protected boolean isChannelBlockable() {
|
||||
if (mChannel != null && mAppRow != null) {
|
||||
if (!mAppRow.systemApp) {
|
||||
return true;
|
||||
if (!isChannelConfigurable()) {
|
||||
return mChannel.getImportance() == IMPORTANCE_NONE;
|
||||
}
|
||||
|
||||
return mChannel.isBlockableSystem()
|
||||
return mChannel.isBlockableSystem() || !mAppRow.systemApp
|
||||
|| mChannel.getImportance() == IMPORTANCE_NONE;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -119,22 +119,22 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_ALARMS == category
|
||||
|| PRIORITY_CATEGORY_MEDIA == category
|
||||
|| PRIORITY_CATEGORY_SYSTEM == category);
|
||||
|| PRIORITY_CATEGORY_SYSTEM == category, false);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_sound_all_muted);
|
||||
} else if (numCategories == 1) {
|
||||
return mContext.getString(R.string.zen_sound_one_allowed,
|
||||
enabledCategories.get(0).toLowerCase());
|
||||
enabledCategories.get(0));
|
||||
} else if (numCategories == 2) {
|
||||
return mContext.getString(R.string.zen_sound_two_allowed,
|
||||
enabledCategories.get(0).toLowerCase(),
|
||||
enabledCategories.get(1).toLowerCase());
|
||||
enabledCategories.get(0),
|
||||
enabledCategories.get(1));
|
||||
} else if (numCategories == 3) {
|
||||
return mContext.getString(R.string.zen_sound_three_allowed,
|
||||
enabledCategories.get(0).toLowerCase(),
|
||||
enabledCategories.get(1).toLowerCase(),
|
||||
enabledCategories.get(2).toLowerCase());
|
||||
enabledCategories.get(0),
|
||||
enabledCategories.get(1),
|
||||
enabledCategories.get(2));
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_sound_none_muted);
|
||||
}
|
||||
@@ -143,17 +143,17 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
String getCallsSettingSummary(Policy policy) {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_CALLS == category
|
||||
|| PRIORITY_CATEGORY_REPEAT_CALLERS == category);
|
||||
|| PRIORITY_CATEGORY_REPEAT_CALLERS == category, false);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
} else if (numCategories == 1) {
|
||||
return mContext.getString(R.string.zen_mode_calls_summary_one,
|
||||
enabledCategories.get(0).toLowerCase());
|
||||
enabledCategories.get(0));
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_calls_summary_two,
|
||||
enabledCategories.get(0).toLowerCase(),
|
||||
enabledCategories.get(1).toLowerCase());
|
||||
enabledCategories.get(0),
|
||||
enabledCategories.get(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_EVENTS == category
|
||||
|| PRIORITY_CATEGORY_REMINDERS == category
|
||||
|| PRIORITY_CATEGORY_MESSAGES == category);
|
||||
|| PRIORITY_CATEGORY_MESSAGES == category, true);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
@@ -169,19 +169,19 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
return enabledCategories.get(0);
|
||||
} else if (numCategories == 2) {
|
||||
return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
|
||||
enabledCategories.get(1).toLowerCase());
|
||||
enabledCategories.get(1));
|
||||
} else if (numCategories == 3){
|
||||
final List<String> summaries = new ArrayList<>();
|
||||
summaries.add(enabledCategories.get(0));
|
||||
summaries.add(enabledCategories.get(1).toLowerCase());
|
||||
summaries.add(enabledCategories.get(2).toLowerCase());
|
||||
summaries.add(enabledCategories.get(1));
|
||||
summaries.add(enabledCategories.get(2));
|
||||
|
||||
return ListFormatter.getInstance().format(summaries);
|
||||
} else {
|
||||
final List<String> summaries = new ArrayList<>();
|
||||
summaries.add(enabledCategories.get(0));
|
||||
summaries.add(enabledCategories.get(1).toLowerCase());
|
||||
summaries.add(enabledCategories.get(2).toLowerCase());
|
||||
summaries.add(enabledCategories.get(1));
|
||||
summaries.add(enabledCategories.get(2));
|
||||
summaries.add(mContext.getString(R.string.zen_mode_other_options));
|
||||
|
||||
return ListFormatter.getInstance().format(summaries);
|
||||
@@ -251,48 +251,18 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
}
|
||||
|
||||
private List<String> getEnabledCategories(Policy policy,
|
||||
Predicate<Integer> filteredCategories) {
|
||||
Predicate<Integer> filteredCategories, boolean capitalizeFirstInList) {
|
||||
List<String> enabledCategories = new ArrayList<>();
|
||||
for (int category : ALL_PRIORITY_CATEGORIES) {
|
||||
boolean isFirst = capitalizeFirstInList && enabledCategories.isEmpty();
|
||||
if (filteredCategories.test(category) && isCategoryEnabled(policy, category)) {
|
||||
if (category == PRIORITY_CATEGORY_ALARMS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_alarms));
|
||||
} else if (category == PRIORITY_CATEGORY_MEDIA) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_media));
|
||||
} else if (category == PRIORITY_CATEGORY_SYSTEM) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_system));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_all_messages));
|
||||
} else {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_selected_messages));
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_events));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
|
||||
enabledCategories.add(mContext.getString(R.string.zen_mode_reminders));
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_CALLS) {
|
||||
if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_all_callers));
|
||||
} else if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_CONTACTS){
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_contacts_callers));
|
||||
} else {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_starred_callers));
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
|
||||
if (!enabledCategories.contains(mContext.getString(
|
||||
R.string.zen_mode_all_callers))) {
|
||||
enabledCategories.add(mContext.getString(
|
||||
R.string.zen_mode_repeat_callers));
|
||||
}
|
||||
if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS
|
||||
&& isCategoryEnabled(policy, Policy.PRIORITY_CATEGORY_CALLS)
|
||||
&& policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
enabledCategories.add(getCategory(category, policy, isFirst));
|
||||
}
|
||||
}
|
||||
return enabledCategories;
|
||||
@@ -301,6 +271,70 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
private boolean isCategoryEnabled(Policy policy, int categoryType) {
|
||||
return (policy.priorityCategories & categoryType) != 0;
|
||||
}
|
||||
|
||||
private String getCategory(int category, Policy policy, boolean isFirst) {
|
||||
if (category == PRIORITY_CATEGORY_ALARMS) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_alarms);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_alarms_list);
|
||||
}
|
||||
} else if (category == PRIORITY_CATEGORY_MEDIA) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_media);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_media_list);
|
||||
}
|
||||
} else if (category == PRIORITY_CATEGORY_SYSTEM) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_system);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_system_list);
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_all_messages);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_all_messages_list);
|
||||
}
|
||||
} else {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_selected_messages);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_selected_messages_list);
|
||||
}
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_events);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_events_list);
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REMINDERS) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_reminders);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_reminders_list);
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_CALLS) {
|
||||
if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
return mContext.getString(R.string.zen_mode_all_callers);
|
||||
} else if (policy.priorityCallSenders == Policy.PRIORITY_SENDERS_CONTACTS){
|
||||
return mContext.getString(R.string.zen_mode_contacts_callers);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_starred_callers);
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_REPEAT_CALLERS) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_repeat_callers);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_repeat_callers_list);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.UserManager;
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||
@@ -54,6 +53,8 @@ import com.android.settings.users.UserFeatureProvider;
|
||||
import com.android.settings.users.UserFeatureProviderImpl;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/**
|
||||
* {@link FeatureFactory} implementation for AOSP Settings.
|
||||
*/
|
||||
@@ -93,7 +94,8 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context) {
|
||||
if (mPowerUsageFeatureProvider == null) {
|
||||
mPowerUsageFeatureProvider = new PowerUsageFeatureProviderImpl(context);
|
||||
mPowerUsageFeatureProvider = new PowerUsageFeatureProviderImpl(
|
||||
context.getApplicationContext());
|
||||
}
|
||||
return mPowerUsageFeatureProvider;
|
||||
}
|
||||
@@ -101,7 +103,8 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public DashboardFeatureProvider getDashboardFeatureProvider(Context context) {
|
||||
if (mDashboardFeatureProvider == null) {
|
||||
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(context);
|
||||
mDashboardFeatureProvider = new DashboardFeatureProviderImpl(
|
||||
context.getApplicationContext());
|
||||
}
|
||||
return mDashboardFeatureProvider;
|
||||
}
|
||||
@@ -117,10 +120,11 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
||||
if (mApplicationFeatureProvider == null) {
|
||||
mApplicationFeatureProvider = new ApplicationFeatureProviderImpl(context,
|
||||
context.getPackageManager(),
|
||||
final Context appContext = context.getApplicationContext();
|
||||
mApplicationFeatureProvider = new ApplicationFeatureProviderImpl(appContext,
|
||||
appContext.getPackageManager(),
|
||||
AppGlobals.getPackageManager(),
|
||||
(DevicePolicyManager) context
|
||||
(DevicePolicyManager) appContext
|
||||
.getSystemService(Context.DEVICE_POLICY_SERVICE));
|
||||
}
|
||||
return mApplicationFeatureProvider;
|
||||
@@ -137,12 +141,14 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public EnterprisePrivacyFeatureProvider getEnterprisePrivacyFeatureProvider(Context context) {
|
||||
if (mEnterprisePrivacyFeatureProvider == null) {
|
||||
mEnterprisePrivacyFeatureProvider = new EnterprisePrivacyFeatureProviderImpl(context,
|
||||
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE),
|
||||
context.getPackageManager(),
|
||||
UserManager.get(context),
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE),
|
||||
context.getResources());
|
||||
final Context appContext = context.getApplicationContext();
|
||||
mEnterprisePrivacyFeatureProvider = new EnterprisePrivacyFeatureProviderImpl(appContext,
|
||||
(DevicePolicyManager) appContext.getSystemService(
|
||||
Context.DEVICE_POLICY_SERVICE),
|
||||
appContext.getPackageManager(),
|
||||
UserManager.get(appContext),
|
||||
(ConnectivityManager) appContext.getSystemService(Context.CONNECTIVITY_SERVICE),
|
||||
appContext.getResources());
|
||||
}
|
||||
return mEnterprisePrivacyFeatureProvider;
|
||||
}
|
||||
@@ -171,7 +177,8 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public SuggestionFeatureProvider getSuggestionFeatureProvider(Context context) {
|
||||
if (mSuggestionFeatureProvider == null) {
|
||||
mSuggestionFeatureProvider = new SuggestionFeatureProviderImpl(context);
|
||||
mSuggestionFeatureProvider = new SuggestionFeatureProviderImpl(
|
||||
context.getApplicationContext());
|
||||
}
|
||||
return mSuggestionFeatureProvider;
|
||||
}
|
||||
@@ -179,7 +186,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public UserFeatureProvider getUserFeatureProvider(Context context) {
|
||||
if (mUserFeatureProvider == null) {
|
||||
mUserFeatureProvider = new UserFeatureProviderImpl(context);
|
||||
mUserFeatureProvider = new UserFeatureProviderImpl(context.getApplicationContext());
|
||||
}
|
||||
return mUserFeatureProvider;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,6 @@ import android.media.MediaRouter;
|
||||
import android.media.MediaRouter.Callback;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
@@ -64,6 +61,10 @@ import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
/**
|
||||
* Abstract class for audio switcher controller to notify subclass
|
||||
* updating the current status of switcher entry. Subclasses must overwrite
|
||||
@@ -74,7 +75,7 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
implements Preference.OnPreferenceChangeListener, BluetoothCallback,
|
||||
LifecycleObserver, OnStart, OnStop {
|
||||
|
||||
private static final String TAG = "AudioSwitchPreferenceController";
|
||||
private static final String TAG = "AudioSwitchPrefCtrl";
|
||||
private static final int INVALID_INDEX = -1;
|
||||
|
||||
protected final List<BluetoothDevice> mConnectedDevices;
|
||||
@@ -170,12 +171,20 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (mLocalBluetoothManager == null) {
|
||||
Log.e(TAG, "Bluetooth is not supported on this device");
|
||||
return;
|
||||
}
|
||||
mLocalBluetoothManager.setForegroundActivity(mContext);
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
if (mLocalBluetoothManager == null) {
|
||||
Log.e(TAG, "Bluetooth is not supported on this device");
|
||||
return;
|
||||
}
|
||||
mLocalBluetoothManager.setForegroundActivity(null);
|
||||
unregister();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.net.wifi.WifiConfiguration;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class WifiUtils {
|
||||
|
||||
private static final int SSID_ASCII_MIN_LENGTH = 1;
|
||||
@@ -38,7 +40,7 @@ public class WifiUtils {
|
||||
if (TextUtils.isEmpty(ssid)) {
|
||||
return false;
|
||||
}
|
||||
return ssid.length() > SSID_ASCII_MAX_LENGTH;
|
||||
return ssid.getBytes(StandardCharsets.UTF_8).length > SSID_ASCII_MAX_LENGTH;
|
||||
}
|
||||
|
||||
public static boolean isSSIDTooShort(String ssid) {
|
||||
@@ -59,8 +61,9 @@ public class WifiUtils {
|
||||
|
||||
/**
|
||||
* This method is a stripped and negated version of WifiConfigStore.canModifyNetwork.
|
||||
*
|
||||
* @param context Context of caller
|
||||
* @param config The WiFi config.
|
||||
* @param config The WiFi config.
|
||||
* @return true if Settings cannot modify the config due to lockDown.
|
||||
*/
|
||||
public static boolean isNetworkLockedDown(Context context, WifiConfiguration config) {
|
||||
|
||||
@@ -7,6 +7,7 @@ com.android.settings.accounts.AccountDetailDashboardFragment
|
||||
com.android.settings.accounts.ManagedProfileSettings
|
||||
com.android.settings.fuelgauge.PowerUsageAnomalyDetails
|
||||
com.android.settings.fuelgauge.AdvancedPowerUsageDetail
|
||||
com.android.settings.datausage.DataUsageSummaryLegacy
|
||||
com.android.settings.development.featureflags.FeatureFlagsDashboard
|
||||
com.android.settings.development.qstile.DevelopmentTileConfigFragment
|
||||
com.android.settings.deviceinfo.StorageProfileFragment
|
||||
|
||||
@@ -128,4 +128,19 @@ public class ImeiInfoDialogControllerTest {
|
||||
verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
|
||||
verify(mDialog).removeViewFromScreen(ID_CDMA_SETTINGS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void populateImeiInfo_emptyImei_shouldSetMeid_imeiSetToEmptyString() {
|
||||
doReturn(true).when(mController).isCdmaLteEnabled();
|
||||
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
|
||||
when(mTelephonyManager.getImei(anyInt())).thenReturn(null);
|
||||
|
||||
mController.populateImeiInfo();
|
||||
|
||||
verify(mDialog).setText(ID_MEID_NUMBER_VALUE, MEID_NUMBER);
|
||||
verify(mDialog).setText(ID_MIN_NUMBER_VALUE, MIN_NUMBER);
|
||||
verify(mDialog).setText(ID_PRL_VERSION_VALUE, PRL_VERSION);
|
||||
verify(mDialog).setText(eq(ID_IMEI_VALUE), eq(""));
|
||||
verify(mDialog).setText(eq(ID_IMEI_SV_VALUE), any());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.R;
|
||||
@@ -35,63 +34,69 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class ColorModePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private Preference mPreference;
|
||||
@Mock
|
||||
private ColorDisplayController mColorDisplayController;
|
||||
|
||||
private Context mContext;
|
||||
private Preference mPreference;
|
||||
private ColorModePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = spy(new ColorModePreferenceController(mContext));
|
||||
mController = spy(new ColorModePreferenceController(mContext, "test"));
|
||||
mPreference = new Preference(mContext);
|
||||
doReturn(mColorDisplayController).when(mController).getColorDisplayController();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_colorModeAutomatic_shouldSetSummaryToAutomatic() {
|
||||
when(mColorDisplayController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_AUTOMATIC);
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_AUTOMATIC);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_automatic));
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.color_mode_option_automatic));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_colorModeSaturated_shouldSetSummaryToSaturated() {
|
||||
when(mColorDisplayController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_SATURATED);
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_SATURATED);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_saturated));
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.color_mode_option_saturated));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_colorModeBoosted_shouldSetSummaryToBoosted() {
|
||||
when(mColorDisplayController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_BOOSTED);
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_BOOSTED);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_boosted));
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.color_mode_option_boosted));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_colorModeNatural_shouldSetSummaryToNatural() {
|
||||
when(mColorDisplayController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_NATURAL);
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_NATURAL);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_natural));
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.color_mode_option_natural));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.UserManager;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -50,6 +49,8 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class, ShadowFragment.class})
|
||||
public class BackgroundActivityPreferenceControllerTest {
|
||||
@@ -89,6 +90,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
|
||||
mShadowContext = RuntimeEnvironment.application;
|
||||
FakeFeatureFactory.setupForTest();
|
||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
when(mContext.getSystemService(Context.APP_OPS_SERVICE)).thenReturn(mAppOpsManager);
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
@@ -118,7 +120,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_restrictApp_showDialog() {
|
||||
doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager)
|
||||
.checkOpNoThrow(anyInt(), anyInt(), anyString());
|
||||
.checkOpNoThrow(anyInt(), anyInt(), anyString());
|
||||
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
@@ -128,7 +130,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_unRestrictApp_showDialog() {
|
||||
doReturn(AppOpsManager.MODE_IGNORED).when(mAppOpsManager)
|
||||
.checkOpNoThrow(anyInt(), anyInt(), anyString());
|
||||
.checkOpNoThrow(anyInt(), anyInt(), anyString());
|
||||
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.settings.location;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -25,24 +26,17 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
import com.android.settings.widget.RestrictedAppPreference;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -52,6 +46,14 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(
|
||||
shadows = {
|
||||
@@ -133,6 +135,8 @@ public class LocationServicePreferenceControllerTest {
|
||||
doReturn(preferences)
|
||||
.when(mSettingsInjector).getInjectedSettings(any(Context.class), anyInt());
|
||||
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||
ShadowUserManager.getShadow().setProfileIdsWithDisabled(new int[]{UserHandle.myUserId()});
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.updateState(mCategory);
|
||||
@@ -142,6 +146,50 @@ public class LocationServicePreferenceControllerTest {
|
||||
verify(mCategory).addPreference(pref2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void workProfileDisallowShareLocationOn_getParentUserLocationServicesOnly() {
|
||||
final int fakeWorkProfileId = 123;
|
||||
ShadowUserManager.getShadow().setProfileIdsWithDisabled(
|
||||
new int[]{UserHandle.myUserId(), fakeWorkProfileId});
|
||||
|
||||
// Mock RestrictedLockUtils.checkIfRestrictionEnforced and let it return non-null.
|
||||
final List<UserManager.EnforcingUser> enforcingUsers = new ArrayList<>();
|
||||
enforcingUsers.add(new UserManager.EnforcingUser(fakeWorkProfileId,
|
||||
UserManager.RESTRICTION_SOURCE_DEVICE_OWNER));
|
||||
final ComponentName componentName = new ComponentName("test", "test");
|
||||
// Ensure that RestrictedLockUtils.checkIfRestrictionEnforced doesn't return null.
|
||||
ShadowUserManager.getShadow().setUserRestrictionSources(
|
||||
UserManager.DISALLOW_SHARE_LOCATION,
|
||||
UserHandle.of(fakeWorkProfileId),
|
||||
enforcingUsers);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(componentName);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
mController.updateState(mCategory);
|
||||
verify(mSettingsInjector).getInjectedSettings(
|
||||
any(Context.class), eq(UserHandle.myUserId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void workProfileDisallowShareLocationOff_getAllUserLocationServices() {
|
||||
final int fakeWorkProfileId = 123;
|
||||
ShadowUserManager.getShadow().setProfileIdsWithDisabled(
|
||||
new int[]{UserHandle.myUserId(), fakeWorkProfileId});
|
||||
|
||||
// Mock RestrictedLockUtils.checkIfRestrictionEnforced and let it return null.
|
||||
// Empty enforcing users.
|
||||
final List<UserManager.EnforcingUser> enforcingUsers = new ArrayList<>();
|
||||
ShadowUserManager.getShadow().setUserRestrictionSources(
|
||||
UserManager.DISALLOW_SHARE_LOCATION,
|
||||
UserHandle.of(fakeWorkProfileId),
|
||||
enforcingUsers);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
mController.updateState(mCategory);
|
||||
verify(mSettingsInjector).getInjectedSettings(
|
||||
any(Context.class), eq(UserHandle.USER_CURRENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onLocationModeChanged_shouldRequestReloadInjectedSettigns() {
|
||||
mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
|
||||
@@ -158,8 +206,9 @@ public class LocationServicePreferenceControllerTest {
|
||||
preferences.add(pref);
|
||||
doReturn(preferences).when(mSettingsInjector)
|
||||
.getInjectedSettings(any(Context.class), anyInt());
|
||||
ShadowUserManager.getShadow().setProfileIdsWithDisabled(new int[]{UserHandle.myUserId()});
|
||||
|
||||
int userId = UserHandle.myUserId();
|
||||
final int userId = UserHandle.myUserId();
|
||||
List<UserManager.EnforcingUser> enforcingUsers = new ArrayList<>();
|
||||
enforcingUsers.add(new UserManager.EnforcingUser(userId,
|
||||
UserManager.RESTRICTION_SOURCE_DEVICE_OWNER));
|
||||
|
||||
@@ -138,6 +138,7 @@ public class BlockPreferenceControllerTest {
|
||||
public void testIsAvailable_nonSystemApp() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = false;
|
||||
appRow.lockedChannelId = "not this";
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
|
||||
@@ -261,6 +261,34 @@ public class NotificationPreferenceControllerTest {
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChannelBlockable_notConfigurable() {
|
||||
String sameId = "apples";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = false;
|
||||
appRow.lockedChannelId = sameId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(sameId);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChannelBlockable_notConfigurableButBlocked() {
|
||||
String sameId = "apples";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.systemApp = false;
|
||||
appRow.lockedChannelId = sameId;
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(sameId);
|
||||
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChannelGroupBlockable_nonSystemBlockable() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
|
||||
@@ -186,6 +186,8 @@ public class AudioOutputSwitchPreferenceControllerTest {
|
||||
|
||||
AudioSwitchPreferenceController controller = new AudioSwitchPreferenceControllerTestable(
|
||||
mContext, TEST_KEY);
|
||||
controller.onStart();
|
||||
controller.onStop();
|
||||
|
||||
assertThat(mLocalBluetoothManager).isNull();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.robolectric.annotation.Resetter;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -45,6 +46,7 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
|
||||
private final List<UserInfo> mUserProfileInfos = new ArrayList<>();
|
||||
private final Set<Integer> mManagedProfiles = new HashSet<>();
|
||||
private boolean mIsQuietModeEnabled = false;
|
||||
private int[] profileIdsForUser;
|
||||
|
||||
@Resetter
|
||||
public void reset() {
|
||||
@@ -96,7 +98,11 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
|
||||
@Implementation
|
||||
public List<EnforcingUser> getUserRestrictionSources(
|
||||
String restrictionKey, UserHandle userHandle) {
|
||||
return mRestrictionSources.get(restrictionKey + userHandle.getIdentifier());
|
||||
// Return empty list when there is no enforcing user, otherwise might trigger
|
||||
// NullPointer Exception in RestrictedLockUtils.checkIfRestrictionEnforced.
|
||||
List<EnforcingUser> enforcingUsers =
|
||||
mRestrictionSources.get(restrictionKey + userHandle.getIdentifier());
|
||||
return enforcingUsers == null ? Collections.emptyList() : enforcingUsers;
|
||||
}
|
||||
|
||||
public void setUserRestrictionSources(
|
||||
@@ -121,4 +127,13 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
|
||||
public void setQuietModeEnabled(boolean enabled) {
|
||||
mIsQuietModeEnabled = enabled;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public int[] getProfileIdsWithDisabled(@UserIdInt int userId) {
|
||||
return profileIdsForUser;
|
||||
}
|
||||
|
||||
public void setProfileIdsWithDisabled(int[] profileIds) {
|
||||
profileIdsForUser = profileIds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class WifiUtilsTest {
|
||||
@Test
|
||||
public void testSSID() {
|
||||
assertThat(WifiUtils.isSSIDTooLong("123")).isFalse();
|
||||
assertThat(WifiUtils.isSSIDTooLong("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎")).isTrue();
|
||||
assertThat(WifiUtils.isSSIDTooLong("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎")).isTrue();
|
||||
|
||||
assertThat(WifiUtils.isSSIDTooShort("123")).isFalse();
|
||||
assertThat(WifiUtils.isSSIDTooShort("")).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user