Snap for 8451773 from 9a5acb3dc8 to tm-qpr1-release
Change-Id: I9aa121a5155f6281f45c6b38908baa2d57014ab4
This commit is contained in:
@@ -74,8 +74,8 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/profile_badge"
|
android:id="@+id/profile_badge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="16dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="16dp"
|
||||||
android:layout_marginEnd="6dp"
|
android:layout_marginEnd="6dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:contentDescription="@*android:string/notification_work_profile_content_description"
|
android:contentDescription="@*android:string/notification_work_profile_content_description"
|
||||||
|
|||||||
@@ -519,14 +519,11 @@
|
|||||||
<string name="preference_of_system_locale_title">System language</string>
|
<string name="preference_of_system_locale_title">System language</string>
|
||||||
|
|
||||||
<!-- Summary for preference of the system default locale. [CHAR LIMIT=50]-->
|
<!-- Summary for preference of the system default locale. [CHAR LIMIT=50]-->
|
||||||
<string name="preference_of_system_locale_summary">System default - <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g></string>
|
<string name="preference_of_system_locale_summary">System default</string>
|
||||||
|
|
||||||
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
||||||
<string name="desc_no_available_supported_locale">Language selection for this app isn\u2019t available from Settings.</string>
|
<string name="desc_no_available_supported_locale">Language selection for this app isn\u2019t available from Settings.</string>
|
||||||
|
|
||||||
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
|
||||||
<string name="desc_disallow_locale_change_in_settings">You can\u2019t select a language for this app from Settings.</string>
|
|
||||||
|
|
||||||
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
||||||
<plurals name="dlg_remove_locales_title">
|
<plurals name="dlg_remove_locales_title">
|
||||||
<item quantity="one">Remove selected language?</item>
|
<item quantity="one">Remove selected language?</item>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.service.oemlock.OemLockManager;
|
import android.service.oemlock.OemLockManager;
|
||||||
@@ -67,6 +68,8 @@ import com.google.android.setupdesign.GlifLayout;
|
|||||||
public class MainClearConfirm extends InstrumentedFragment {
|
public class MainClearConfirm extends InstrumentedFragment {
|
||||||
private static final String TAG = "MainClearConfirm";
|
private static final String TAG = "MainClearConfirm";
|
||||||
|
|
||||||
|
private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
|
||||||
|
|
||||||
@VisibleForTesting View mContentView;
|
@VisibleForTesting View mContentView;
|
||||||
private boolean mEraseSdCard;
|
private boolean mEraseSdCard;
|
||||||
@VisibleForTesting boolean mEraseEsims;
|
@VisibleForTesting boolean mEraseEsims;
|
||||||
@@ -83,6 +86,11 @@ public class MainClearConfirm extends InstrumentedFragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pre-flight check hardware support PersistentDataBlockManager
|
||||||
|
if (SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
|
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
|
||||||
getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
||||||
|
|
||||||
|
|||||||
@@ -41,21 +41,6 @@ public class RingVibrationPreferenceConfig extends VibrationPreferenceConfig {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int readIntensity() {
|
|
||||||
final int vibrateWhenRinging = Settings.System.getInt(mContentResolver,
|
|
||||||
Settings.System.VIBRATE_WHEN_RINGING, ON);
|
|
||||||
|
|
||||||
if ((vibrateWhenRinging == OFF)
|
|
||||||
&& !mAudioManager.isRampingRingerEnabled()) {
|
|
||||||
// VIBRATE_WHEN_RINGING is deprecated but should still be applied if the user has
|
|
||||||
// turned it off and has not enabled the ramping ringer (old three-state setting).
|
|
||||||
return Vibrator.VIBRATION_INTENSITY_OFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.readIntensity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateIntensity(int intensity) {
|
public boolean updateIntensity(int intensity) {
|
||||||
final boolean success = super.updateIntensity(intensity);
|
final boolean success = super.updateIntensity(intensity);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.app.Dialog;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
@@ -32,6 +33,8 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
|||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -49,6 +52,26 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
private static final String RESET_KEY = "reset";
|
private static final String RESET_KEY = "reset";
|
||||||
private static final String BOLD_TEXT_KEY = "toggle_force_bold_text";
|
private static final String BOLD_TEXT_KEY = "toggle_force_bold_text";
|
||||||
private static final String HIGHT_TEXT_CONTRAST_KEY = "toggle_high_text_contrast_preference";
|
private static final String HIGHT_TEXT_CONTRAST_KEY = "toggle_high_text_contrast_preference";
|
||||||
|
private static final String NEED_RESET_SETTINGS = "need_reset_settings";
|
||||||
|
private FontWeightAdjustmentPreferenceController mFontWeightAdjustmentController;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
List<ResetStateListener> mResetStateListeners;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean mNeedResetSettings;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
mNeedResetSettings = false;
|
||||||
|
mResetStateListeners = getResetStateListeners();
|
||||||
|
|
||||||
|
if (icicle != null && icicle.getBoolean(NEED_RESET_SETTINGS)) {
|
||||||
|
mResetStateListeners.forEach(ResetStateListener::resetState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
@@ -69,7 +92,7 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
final FontSizeData fontSizeData = new FontSizeData(context);
|
final FontSizeData fontSizeData = new FontSizeData(context);
|
||||||
final DisplaySizeData displaySizeData = new DisplaySizeData(context);
|
final DisplaySizeData displaySizeData = createDisplaySizeData(context);
|
||||||
|
|
||||||
final TextReadingPreviewController previewController = new TextReadingPreviewController(
|
final TextReadingPreviewController previewController = new TextReadingPreviewController(
|
||||||
context, PREVIEW_KEY, fontSizeData, displaySizeData);
|
context, PREVIEW_KEY, fontSizeData, displaySizeData);
|
||||||
@@ -85,9 +108,9 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
displaySizeController.setInteractionListener(previewController);
|
displaySizeController.setInteractionListener(previewController);
|
||||||
controllers.add(displaySizeController);
|
controllers.add(displaySizeController);
|
||||||
|
|
||||||
final FontWeightAdjustmentPreferenceController fontWeightController =
|
mFontWeightAdjustmentController =
|
||||||
new FontWeightAdjustmentPreferenceController(context, BOLD_TEXT_KEY);
|
new FontWeightAdjustmentPreferenceController(context, BOLD_TEXT_KEY);
|
||||||
controllers.add(fontWeightController);
|
controllers.add(mFontWeightAdjustmentController);
|
||||||
|
|
||||||
final HighTextContrastPreferenceController highTextContrastController =
|
final HighTextContrastPreferenceController highTextContrastController =
|
||||||
new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY);
|
new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY);
|
||||||
@@ -126,12 +149,35 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
return super.getDialogMetricsCategory(dialogId);
|
return super.getDialogMetricsCategory(dialogId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
if (mNeedResetSettings) {
|
||||||
|
outState.putBoolean(NEED_RESET_SETTINGS, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
DisplaySizeData createDisplaySizeData(Context context) {
|
||||||
|
return new DisplaySizeData(context);
|
||||||
|
}
|
||||||
|
|
||||||
private void onPositiveButtonClicked(DialogInterface dialog, int which) {
|
private void onPositiveButtonClicked(DialogInterface dialog, int which) {
|
||||||
// To avoid showing the dialog again, probably the onDetach() of SettingsDialogFragment
|
// To avoid showing the dialog again, probably the onDetach() of SettingsDialogFragment
|
||||||
// was interrupted by unexpectedly recreating the activity.
|
// was interrupted by unexpectedly recreating the activity.
|
||||||
removeDialog(DialogEnums.DIALOG_RESET_SETTINGS);
|
removeDialog(DialogEnums.DIALOG_RESET_SETTINGS);
|
||||||
|
|
||||||
getResetStateListeners().forEach(ResetStateListener::resetState);
|
if (mFontWeightAdjustmentController.isChecked()) {
|
||||||
|
// TODO(b/228956791): Consider replacing or removing it once the root cause is
|
||||||
|
// clarified and the better method is available.
|
||||||
|
// Probably has the race condition issue between "Bold text" and the other features
|
||||||
|
// including "Display Size", “Font Size” if they would be enabled at the same time,
|
||||||
|
// so our workaround is that the “Bold text” would be reset first and then do the
|
||||||
|
// remaining to avoid flickering problem.
|
||||||
|
mNeedResetSettings = true;
|
||||||
|
mFontWeightAdjustmentController.resetState();
|
||||||
|
} else {
|
||||||
|
mResetStateListeners.forEach(ResetStateListener::resetState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResetStateListener> getResetStateListeners() {
|
private List<ResetStateListener> getResetStateListeners() {
|
||||||
|
|||||||
@@ -208,13 +208,9 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
LocaleList packageLocaleList = getPackageLocales();
|
LocaleList packageLocaleList = getPackageLocales();
|
||||||
String[] assetLocaleList = getAssetLocales();
|
String[] assetLocaleList = getAssetLocales();
|
||||||
// TODO add apended url string, "Learn more", to these both sentenses.
|
// TODO add apended url string, "Learn more", to these both sentenses.
|
||||||
if (packageLocaleList == null && assetLocaleList.length == 0) {
|
if ((packageLocaleList != null && packageLocaleList.isEmpty())
|
||||||
// There is no locale info from PackageManager amd AssetManager.
|
|| (packageLocaleList == null && assetLocaleList.length == 0)) {
|
||||||
return R.string.desc_no_available_supported_locale;
|
return R.string.desc_no_available_supported_locale;
|
||||||
} else if (packageLocaleList != null && packageLocaleList.isEmpty()) {
|
|
||||||
// LocaleConfig is empty, and this means only allow user modify language
|
|
||||||
// by the application.
|
|
||||||
return R.string.desc_disallow_locale_change_in_settings;
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -276,9 +272,7 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
final Context contextAsUser = context.createContextAsUser(userHandle, 0);
|
final Context contextAsUser = context.createContextAsUser(userHandle, 0);
|
||||||
Locale appLocale = getAppDefaultLocale(contextAsUser, entry.info.packageName);
|
Locale appLocale = getAppDefaultLocale(contextAsUser, entry.info.packageName);
|
||||||
if (appLocale == null) {
|
if (appLocale == null) {
|
||||||
Locale systemLocale = Locale.getDefault();
|
return context.getString(R.string.preference_of_system_locale_summary);
|
||||||
return context.getString(R.string.preference_of_system_locale_summary,
|
|
||||||
systemLocale.getDisplayName(systemLocale));
|
|
||||||
} else {
|
} else {
|
||||||
return appLocale.getDisplayName(appLocale);
|
return appLocale.getDisplayName(appLocale);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,15 +69,6 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationInfo ai;
|
|
||||||
try {
|
|
||||||
ai = getPackageManager().getApplicationInfo(mPackageName, 0);
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
debugLog("Requested package doesn't exist: " + mPackageName);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getPackageManager().checkPermission(
|
if (getPackageManager().checkPermission(
|
||||||
Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, mPackageName)
|
Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, mPackageName)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
@@ -87,6 +78,15 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ApplicationInfo ai;
|
||||||
|
try {
|
||||||
|
ai = getPackageManager().getApplicationInfo(mPackageName, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
debugLog("Requested package doesn't exist: " + mPackageName);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final AlertController.AlertParams p = mAlertParams;
|
final AlertController.AlertParams p = mAlertParams;
|
||||||
final CharSequence appLabel = ai.loadSafeLabel(getPackageManager(),
|
final CharSequence appLabel = ai.loadSafeLabel(getPackageManager(),
|
||||||
PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.SAFE_LABEL_FLAG_TRIM
|
PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.SAFE_LABEL_FLAG_TRIM
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.net.Uri;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.provider.SettingsSlicesContract;
|
import android.provider.SettingsSlicesContract;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
@@ -101,6 +102,11 @@ public class BatterySaverButtonPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||||
|
// Cancel preference's check state once it's first time launch
|
||||||
|
if (isChecked && (Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 0) == 0)) {
|
||||||
|
mPreference.setChecked(false);
|
||||||
|
}
|
||||||
setChecked(isChecked);
|
setChecked(isChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.om.IOverlayManager;
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.om.OverlayInfo;
|
import android.content.om.OverlayInfo;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
@@ -49,6 +50,7 @@ import com.android.settings.support.actionbar.HelpResourceProvider;
|
|||||||
import com.android.settings.utils.CandidateInfoExtra;
|
import com.android.settings.utils.CandidateInfoExtra;
|
||||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
import com.android.settingslib.search.SearchIndexableRaw;
|
||||||
import com.android.settingslib.widget.CandidateInfo;
|
import com.android.settingslib.widget.CandidateInfo;
|
||||||
import com.android.settingslib.widget.IllustrationPreference;
|
import com.android.settingslib.widget.IllustrationPreference;
|
||||||
import com.android.settingslib.widget.SelectorWithWidgetPreference;
|
import com.android.settingslib.widget.SelectorWithWidgetPreference;
|
||||||
@@ -320,6 +322,39 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
protected boolean isPageSearchEnabled(Context context) {
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
return SystemNavigationPreferenceController.isGestureAvailable(context);
|
return SystemNavigationPreferenceController.isGestureAvailable(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
|
||||||
|
boolean enabled) {
|
||||||
|
final Resources res = context.getResources();
|
||||||
|
final List<SearchIndexableRaw> result = new ArrayList<>();
|
||||||
|
|
||||||
|
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(context,
|
||||||
|
NAV_BAR_MODE_GESTURAL_OVERLAY)) {
|
||||||
|
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||||
|
data.title = res.getString(R.string.edge_to_edge_navigation_title);
|
||||||
|
data.key = KEY_SYSTEM_NAV_GESTURAL;
|
||||||
|
result.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(context,
|
||||||
|
NAV_BAR_MODE_2BUTTON_OVERLAY)) {
|
||||||
|
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||||
|
data.title = res.getString(R.string.swipe_up_to_switch_apps_title);
|
||||||
|
data.key = KEY_SYSTEM_NAV_2BUTTONS;
|
||||||
|
result.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(context,
|
||||||
|
NAV_BAR_MODE_3BUTTON_OVERLAY)) {
|
||||||
|
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||||
|
data.title = res.getString(R.string.legacy_navigation_title);
|
||||||
|
data.key = KEY_SYSTEM_NAV_3BUTTONS;
|
||||||
|
result.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// From HelpResourceProvider
|
// From HelpResourceProvider
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.util.Log;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.app.LocalePickerWithRegion;
|
import com.android.internal.app.LocalePickerWithRegion;
|
||||||
@@ -49,6 +50,7 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
|||||||
private LocalePickerWithRegion mLocalePickerWithRegion;
|
private LocalePickerWithRegion mLocalePickerWithRegion;
|
||||||
private AppLocaleDetails mAppLocaleDetails;
|
private AppLocaleDetails mAppLocaleDetails;
|
||||||
private Context mContextAsUser;
|
private Context mContextAsUser;
|
||||||
|
private View mAppLocaleDetailContainer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -82,7 +84,7 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
|||||||
false /* translate only */,
|
false /* translate only */,
|
||||||
mPackageName);
|
mPackageName);
|
||||||
mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName);
|
mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName);
|
||||||
|
mAppLocaleDetailContainer = launchAppLocaleDetailsPage();
|
||||||
// Launch Locale picker part.
|
// Launch Locale picker part.
|
||||||
launchLocalePickerPage();
|
launchLocalePickerPage();
|
||||||
}
|
}
|
||||||
@@ -134,12 +136,14 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
|||||||
fragmentManager.registerFragmentLifecycleCallbacks(
|
fragmentManager.registerFragmentLifecycleCallbacks(
|
||||||
new android.app.FragmentManager.FragmentLifecycleCallbacks() {
|
new android.app.FragmentManager.FragmentLifecycleCallbacks() {
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentResumed(
|
public void onFragmentViewCreated(
|
||||||
android.app.FragmentManager fm,
|
android.app.FragmentManager fm,
|
||||||
android.app.Fragment f) {
|
android.app.Fragment f, View v, Bundle s) {
|
||||||
super.onFragmentResumed(fm, f);
|
super.onFragmentViewCreated(fm, f, v, s);
|
||||||
mLocalePickerWithRegion.getListView()
|
ListView listView = (ListView) v.findViewById(android.R.id.list);
|
||||||
.addHeaderView(launchAppLocaleDetailsPage());
|
if (listView != null) {
|
||||||
|
listView.addHeaderView(mAppLocaleDetailContainer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
|
|||||||
@@ -356,8 +356,10 @@ public class NotificationHistoryActivity extends CollapsingToolbarBaseActivity {
|
|||||||
}
|
}
|
||||||
final int newState = isChecked ? 1 : 0;
|
final int newState = isChecked ? 1 : 0;
|
||||||
if (oldState != newState) {
|
if (oldState != newState) {
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
for (int user : mUm.getProfileIds(ActivityManager.getCurrentUser(), false)) {
|
||||||
NOTIFICATION_HISTORY_ENABLED, newState);
|
Settings.Secure.putIntForUser(getContentResolver(),
|
||||||
|
NOTIFICATION_HISTORY_ENABLED, newState, user);
|
||||||
|
}
|
||||||
mUiEventLogger.log(isChecked ? NotificationHistoryEvent.NOTIFICATION_HISTORY_ON
|
mUiEventLogger.log(isChecked ? NotificationHistoryEvent.NOTIFICATION_HISTORY_ON
|
||||||
: NotificationHistoryEvent.NOTIFICATION_HISTORY_OFF);
|
: NotificationHistoryEvent.NOTIFICATION_HISTORY_OFF);
|
||||||
Log.d(TAG, "onSwitchChange history to " + isChecked);
|
Log.d(TAG, "onSwitchChange history to " + isChecked);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class NotificationSbnAdapter extends
|
|||||||
int userId = normalizeUserId(sbn);
|
int userId = normalizeUserId(sbn);
|
||||||
if (!mUserBadgeCache.containsKey(userId)) {
|
if (!mUserBadgeCache.containsKey(userId)) {
|
||||||
Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
|
Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
|
||||||
UserHandle.of(userId), -1);
|
UserHandle.of(userId), 0);
|
||||||
mUserBadgeCache.put(userId, profile);
|
mUserBadgeCache.put(userId, profile);
|
||||||
}
|
}
|
||||||
holder.setProfileBadge(mUserBadgeCache.get(userId));
|
holder.setProfileBadge(mUserBadgeCache.get(userId));
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.notification.zen;
|
package com.android.settings.notification.zen;
|
||||||
|
|
||||||
|
import static android.app.NotificationManager.EXTRA_AUTOMATIC_RULE_ID;
|
||||||
|
|
||||||
import android.app.AutomaticZenRule;
|
import android.app.AutomaticZenRule;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
@@ -79,7 +81,8 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
|||||||
ComponentName configurationActivity, String ruleId) {
|
ComponentName configurationActivity, String ruleId) {
|
||||||
final Intent intent = new Intent()
|
final Intent intent = new Intent()
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||||
.putExtra(ConditionProviderService.EXTRA_RULE_ID, ruleId);
|
.putExtra(ConditionProviderService.EXTRA_RULE_ID, ruleId)
|
||||||
|
.putExtra(EXTRA_AUTOMATIC_RULE_ID, ruleId);
|
||||||
if (configurationActivity != null) {
|
if (configurationActivity != null) {
|
||||||
intent.setComponent(configurationActivity);
|
intent.setComponent(configurationActivity);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.notification.zen;
|
package com.android.settings.notification.zen;
|
||||||
|
|
||||||
|
import static android.app.NotificationManager.EXTRA_AUTOMATIC_RULE_ID;
|
||||||
|
|
||||||
import android.app.AutomaticZenRule;
|
import android.app.AutomaticZenRule;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -72,9 +74,12 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
|
|
||||||
mId = intent.getStringExtra(ConditionProviderService.EXTRA_RULE_ID);
|
mId = intent.getStringExtra(ConditionProviderService.EXTRA_RULE_ID);
|
||||||
if (mId == null) {
|
if (mId == null) {
|
||||||
Log.w(TAG, "rule id is null");
|
mId = intent.getStringExtra(EXTRA_AUTOMATIC_RULE_ID);
|
||||||
toastAndFinish();
|
if (mId == null) {
|
||||||
return;
|
Log.w(TAG, "rule id is null");
|
||||||
|
toastAndFinish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "mId=" + mId);
|
if (DEBUG) Log.d(TAG, "mId=" + mId);
|
||||||
|
|||||||
@@ -661,10 +661,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertSafeToStartCustomActivity(Intent intent) {
|
private void assertSafeToStartCustomActivity(Intent intent) {
|
||||||
// Activity can be started if it belongs to the same app
|
EventLog.writeEvent(0x534e4554, "223578534", -1 /* UID */, "");
|
||||||
if (intent.getPackage() != null && intent.getPackage().equals(packageName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ResolveInfo resolveInfo = mPackageManager.resolveActivity(
|
ResolveInfo resolveInfo = mPackageManager.resolveActivity(
|
||||||
intent, PackageManager.MATCH_DEFAULT_ONLY);
|
intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi.tether;
|
package com.android.settings.wifi.tether;
|
||||||
|
|
||||||
import static android.net.TetheringManager.ACTION_TETHER_STATE_CHANGED;
|
|
||||||
import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;
|
import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
@@ -32,7 +31,6 @@ import android.util.FeatureFlagUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.PreferenceGroup;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
@@ -79,8 +77,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
|||||||
TetherChangeReceiver mTetherChangeReceiver;
|
TetherChangeReceiver mTetherChangeReceiver;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TETHER_STATE_CHANGE_FILTER = new IntentFilter(ACTION_TETHER_STATE_CHANGED);
|
TETHER_STATE_CHANGE_FILTER = new IntentFilter(WIFI_AP_STATE_CHANGED_ACTION);
|
||||||
TETHER_STATE_CHANGE_FILTER.addAction(WIFI_AP_STATE_CHANGED_ACTION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WifiTetherSettings() {
|
public WifiTetherSettings() {
|
||||||
@@ -269,12 +266,7 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
|
|||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
Log.d(TAG, "updating display config due to receiving broadcast action " + action);
|
Log.d(TAG, "updating display config due to receiving broadcast action " + action);
|
||||||
updateDisplayWithNewConfig();
|
updateDisplayWithNewConfig();
|
||||||
if (action.equals(ACTION_TETHER_STATE_CHANGED)) {
|
if (action.equals(WIFI_AP_STATE_CHANGED_ACTION)) {
|
||||||
if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED
|
|
||||||
&& mRestartWifiApAfterConfigChange) {
|
|
||||||
startTether();
|
|
||||||
}
|
|
||||||
} else if (action.equals(WIFI_AP_STATE_CHANGED_ACTION)) {
|
|
||||||
int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_STATE, 0);
|
int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_STATE, 0);
|
||||||
if (state == WifiManager.WIFI_AP_STATE_DISABLED
|
if (state == WifiManager.WIFI_AP_STATE_DISABLED
|
||||||
&& mRestartWifiApAfterConfigChange) {
|
&& mRestartWifiApAfterConfigChange) {
|
||||||
|
|||||||
@@ -121,22 +121,22 @@ public class RingVibrationIntensityPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
|
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayRingIntensity() {
|
||||||
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
||||||
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
||||||
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
|
assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|||||||
@@ -116,22 +116,24 @@ public class RingVibrationTogglePreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
|
public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldIgnoreAndUseIntensity() {
|
||||||
|
// VIBRATE_WHEN_RINGING is deprecated and should have no effect on the ring vibration
|
||||||
|
// setting. The ramping ringer is also independent now, instead of a 3-state setting.
|
||||||
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
|
||||||
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.isChecked()).isFalse();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
|
||||||
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
Vibrator.VIBRATION_INTENSITY_MEDIUM);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.isChecked()).isFalse();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
assertThat(mPreference.isChecked()).isFalse();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
|
||||||
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.accessibility;
|
||||||
|
|
||||||
|
import static com.android.settings.accessibility.FontWeightAdjustmentPreferenceController.BOLD_TEXT_ADJUSTMENT;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
|
||||||
|
import com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Answers;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link TextReadingPreferenceFragment}.
|
||||||
|
*/
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class TextReadingPreferenceFragmentTest {
|
||||||
|
private TextReadingPreferenceFragment mFragment;
|
||||||
|
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
|
private PreferenceManager mPreferenceManager;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext.setTheme(R.style.Theme_AppCompat);
|
||||||
|
|
||||||
|
mFragment = spy(new TextReadingPreferenceFragment());
|
||||||
|
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
|
||||||
|
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||||
|
when(mFragment.getContext()).thenReturn(mContext);
|
||||||
|
when(mFragment.getActivity()).thenReturn(Robolectric.setupActivity(FragmentActivity.class));
|
||||||
|
|
||||||
|
// Avoid a NPE is happened in ShadowWindowManagerGlobal
|
||||||
|
doReturn(mock(DisplaySizeData.class)).when(mFragment).createDisplaySizeData(mContext);
|
||||||
|
mFragment.createPreferenceControllers(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onDialogPositiveButtonClicked_boldTextEnabled_needResetSettings() {
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.FONT_WEIGHT_ADJUSTMENT, BOLD_TEXT_ADJUSTMENT);
|
||||||
|
final AlertDialog dialog = (AlertDialog) mFragment.onCreateDialog(
|
||||||
|
DialogEnums.DIALOG_RESET_SETTINGS);
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
|
||||||
|
|
||||||
|
assertThat(mFragment.mNeedResetSettings).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onDialogPositiveButtonClicked_boldTextDisabled_resetAllListeners() {
|
||||||
|
final ResetStateListener listener1 = mock(ResetStateListener.class);
|
||||||
|
final ResetStateListener listener2 = mock(ResetStateListener.class);
|
||||||
|
mFragment.mResetStateListeners = new ArrayList<>(Arrays.asList(listener1, listener2));
|
||||||
|
final AlertDialog dialog = (AlertDialog) mFragment.onCreateDialog(
|
||||||
|
DialogEnums.DIALOG_RESET_SETTINGS);
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
|
||||||
|
|
||||||
|
verify(listener1).resetState();
|
||||||
|
verify(listener2).resetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.provider.SettingsSlicesContract;
|
import android.provider.SettingsSlicesContract;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
@@ -75,6 +76,24 @@ public class BatterySaverButtonPreferenceControllerTest {
|
|||||||
.isEqualTo(SettingsSlicesContract.AUTHORITY);
|
.isEqualTo(SettingsSlicesContract.AUTHORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onSwitchChanged_isCheckedButNotAcked_preferenceIsUnchecked() {
|
||||||
|
setLowPowerWarningAcked(/* acked= */ 0);
|
||||||
|
|
||||||
|
mController.onSwitchChanged(/* switchView= */ null, /* isChecked= */ true);
|
||||||
|
|
||||||
|
assertThat(mPreference.isChecked()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onSwitchChanged_isCheckedAndAcked_setPowerSaveMode() {
|
||||||
|
setLowPowerWarningAcked(/* acked= */ 1);
|
||||||
|
|
||||||
|
mController.onSwitchChanged(/* switchView= */ null, /* isChecked= */ true);
|
||||||
|
|
||||||
|
verify(mPowerManager).setPowerSaveModeEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_lowPowerOn_preferenceIsChecked() {
|
public void updateState_lowPowerOn_preferenceIsChecked() {
|
||||||
when(mPowerManager.isPowerSaveMode()).thenReturn(true);
|
when(mPowerManager.isPowerSaveMode()).thenReturn(true);
|
||||||
@@ -126,4 +145,12 @@ public class BatterySaverButtonPreferenceControllerTest {
|
|||||||
public void isPublicSlice_returnsTrue() {
|
public void isPublicSlice_returnsTrue() {
|
||||||
assertThat(mController.isPublicSlice()).isTrue();
|
assertThat(mController.isPublicSlice()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0 means not acked, 1 means acked.
|
||||||
|
private void setLowPowerWarningAcked(int acked) {
|
||||||
|
Settings.Secure.putInt(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED,
|
||||||
|
acked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import static junit.framework.Assert.assertEquals;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -41,10 +42,14 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.om.IOverlayManager;
|
import android.content.om.IOverlayManager;
|
||||||
import android.content.om.OverlayInfo;
|
import android.content.om.OverlayInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
import com.android.settingslib.search.SearchIndexableRaw;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -67,6 +72,8 @@ public class SystemNavigationGestureSettingsTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private IOverlayManager mOverlayManager;
|
private IOverlayManager mOverlayManager;
|
||||||
@Mock
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
@Mock
|
||||||
private OverlayInfo mOverlayInfoEnabled;
|
private OverlayInfo mOverlayInfoEnabled;
|
||||||
@Mock
|
@Mock
|
||||||
private OverlayInfo mOverlayInfoDisabled;
|
private OverlayInfo mOverlayInfoDisabled;
|
||||||
@@ -75,16 +82,17 @@ public class SystemNavigationGestureSettingsTest {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
mSettings = new SystemNavigationGestureSettings();
|
mSettings = new SystemNavigationGestureSettings();
|
||||||
|
|
||||||
when(mOverlayInfoDisabled.isEnabled()).thenReturn(false);
|
when(mOverlayInfoDisabled.isEnabled()).thenReturn(false);
|
||||||
when(mOverlayInfoEnabled.isEnabled()).thenReturn(true);
|
when(mOverlayInfoEnabled.isEnabled()).thenReturn(true);
|
||||||
when(mOverlayManager.getOverlayInfo(any(), anyInt())).thenReturn(mOverlayInfoDisabled);
|
when(mOverlayManager.getOverlayInfo(any(), anyInt())).thenReturn(mOverlayInfoDisabled);
|
||||||
|
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchIndexProvider_shouldIndexResource() {
|
public void searchIndexProvider_shouldIndexResource() {
|
||||||
final List<SearchIndexableResource> indexRes =
|
final List<SearchIndexableResource> indexRes =
|
||||||
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
||||||
RuntimeEnvironment.application, true /* enabled */);
|
RuntimeEnvironment.application, true /* enabled */);
|
||||||
@@ -93,6 +101,29 @@ public class SystemNavigationGestureSettingsTest {
|
|||||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchIndexProvider_gesturePackageExist_shouldBeIndexed()
|
||||||
|
throws NameNotFoundException {
|
||||||
|
PackageInfo info = new PackageInfo();
|
||||||
|
when(mPackageManager.getPackageInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, 0))
|
||||||
|
.thenReturn(info);
|
||||||
|
|
||||||
|
final List<SearchIndexableRaw> indexRaws =
|
||||||
|
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
|
.getRawDataToIndex(mContext, true /* enabled */);
|
||||||
|
|
||||||
|
assertThat(indexRaws).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchIndexProvider_noNavigationPackageExist_shouldReturnEmpty() {
|
||||||
|
final List<SearchIndexableRaw> indexRaws =
|
||||||
|
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
|
.getRawDataToIndex(mContext, true /* enabled */);
|
||||||
|
|
||||||
|
assertThat(indexRaws).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetCurrentSystemNavigationMode() {
|
public void testGetCurrentSystemNavigationMode() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.notification.zen;
|
package com.android.settings.notification.zen;
|
||||||
|
|
||||||
|
import static android.app.NotificationManager.EXTRA_AUTOMATIC_RULE_ID;
|
||||||
|
import static android.service.notification.ConditionProviderService.EXTRA_RULE_ID;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -24,6 +27,7 @@ import android.app.AutomaticZenRule;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.ComponentInfo;
|
import android.content.pm.ComponentInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -166,4 +170,21 @@ public class AbstractZenModeAutomaticRulePreferenceControllerTest {
|
|||||||
|
|
||||||
assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "activity"));
|
assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "activity"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetRuleIntent() throws Exception {
|
||||||
|
AutomaticZenRule rule = new AutomaticZenRule("name", null,
|
||||||
|
new ComponentName(mContext.getPackageName(), "test"), Uri.EMPTY,
|
||||||
|
new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
|
||||||
|
rule.setPackageName(mContext.getPackageName());
|
||||||
|
|
||||||
|
when(mPm.getPackageUid(null, 0)).thenReturn(-1);
|
||||||
|
when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1);
|
||||||
|
|
||||||
|
Intent intent = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getRuleIntent(null, rule.getConfigurationActivity(), "id");
|
||||||
|
|
||||||
|
assertThat("id").isEqualTo(intent.getStringExtra(EXTRA_RULE_ID));
|
||||||
|
assertThat("id").isEqualTo(intent.getStringExtra(EXTRA_AUTOMATIC_RULE_ID));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user