Snap for 8581479 from a6533a7f1e to tm-qpr1-release
Change-Id: I871629a3cdb3f5a51e5ee1c6cb3f9358f76f5387
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
-->
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24.0"
|
|
||||||
android:viewportHeight="24.0">
|
|
||||||
<path
|
|
||||||
android:pathData="M11,15h2v2h-2v-2zM11,7h2v6h-2L11,7zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"
|
|
||||||
android:fillColor="?android:attr/colorError"
|
|
||||||
android:fillType="evenOdd"/>
|
|
||||||
</vector>
|
|
||||||
@@ -500,15 +500,6 @@
|
|||||||
<!-- Title for the App's locale picker activity. [CHAR LIMIT=50]-->
|
<!-- Title for the App's locale picker activity. [CHAR LIMIT=50]-->
|
||||||
<string name="app_locale_picker_title">App Language</string>
|
<string name="app_locale_picker_title">App Language</string>
|
||||||
|
|
||||||
<!-- Title for the warning message of the locale picker activity. [CHAR LIMIT=50]-->
|
|
||||||
<string name="warnings_title">Update the app</string>
|
|
||||||
|
|
||||||
<!-- Summary for the warning message of the locale picker activity. [CHAR LIMIT=70]-->
|
|
||||||
<string name="warnings_summary">You need to update the app for the latest available languages</string>
|
|
||||||
|
|
||||||
<!-- Button text on warning message [CHAR LIMIT=20]-->
|
|
||||||
<string name="warnings_button_update">Update now</string>
|
|
||||||
|
|
||||||
<!-- Category for the suggested app's locales. [CHAR LIMIT=50]-->
|
<!-- Category for the suggested app's locales. [CHAR LIMIT=50]-->
|
||||||
<string name="suggested_app_locales_title">Suggested languages</string>
|
<string name="suggested_app_locales_title">Suggested languages</string>
|
||||||
|
|
||||||
@@ -4751,7 +4742,7 @@
|
|||||||
<!-- [CHAR LIMIT=NONE] Manage applications screen, menu item. Title of dialog to confirm resetting user's app preferences. -->
|
<!-- [CHAR LIMIT=NONE] Manage applications screen, menu item. Title of dialog to confirm resetting user's app preferences. -->
|
||||||
<string name="reset_app_preferences_title">Reset app preferences?</string>
|
<string name="reset_app_preferences_title">Reset app preferences?</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Manage applications screen, menu item. Body of dialog to confirm resetting user's app preferences. -->
|
<!-- [CHAR LIMIT=NONE] Manage applications screen, menu item. Body of dialog to confirm resetting user's app preferences. -->
|
||||||
<string name="reset_app_preferences_desc">This will reset all preferences for:\n\n<li>Disabled apps</li>\n<li>Disabled app notifications</li>\n<li>Default applications for actions</li>\n<li>Background data restrictions for apps</li>\n<li>Any permission restrictions</li>\n\nYou will not lose any app data.</string>
|
<string name="reset_app_preferences_desc">This will reset all preferences for:\n\n<li>Disabled apps</li>\n<li>Disabled app notifications</li>\n<li>Default applications for actions</li>\n<li>Background data restrictions for apps</li>\n<li>Any permission restrictions</li>\n<li>Battery usage settings</li>\n\nYou will not lose any app data.</string>
|
||||||
<!-- [CHAR LIMIT=25] Manage applications screen, menu item. Confirmation button of dialog to confirm resetting user's app preferences. -->
|
<!-- [CHAR LIMIT=25] Manage applications screen, menu item. Confirmation button of dialog to confirm resetting user's app preferences. -->
|
||||||
<string name="reset_app_preferences_button">Reset apps</string>
|
<string name="reset_app_preferences_button">Reset apps</string>
|
||||||
<!-- Manage applications screen, individual app screen, button label when the user wants to manage the space taken up by an app. -->
|
<!-- Manage applications screen, individual app screen, button label when the user wants to manage the space taken up by an app. -->
|
||||||
@@ -7860,7 +7851,11 @@
|
|||||||
<string name="help_label">Help & feedback</string>
|
<string name="help_label">Help & feedback</string>
|
||||||
|
|
||||||
<!-- Summary text for support setting tile [CHAR LIMIT=None] -->
|
<!-- Summary text for support setting tile [CHAR LIMIT=None] -->
|
||||||
<string name="support_summary">Help articles, phone & chat</string>
|
<string name="support_summary" product="default">Help articles, phone & chat</string>
|
||||||
|
<!-- Summary text for support setting tile [CHAR LIMIT=None] -->
|
||||||
|
<string name="support_summary" product="tablet">Help articles, tablet & chat</string>
|
||||||
|
<!-- Summary text for support setting tile [CHAR LIMIT=None] -->
|
||||||
|
<string name="support_summary" product="device">Help articles, device & chat</string>
|
||||||
|
|
||||||
<!-- Help URI, Default [DO NOT TRANSLATE] -->
|
<!-- Help URI, Default [DO NOT TRANSLATE] -->
|
||||||
<string name="help_uri_default" translatable="false"></string>
|
<string name="help_uri_default" translatable="false"></string>
|
||||||
|
|||||||
@@ -24,13 +24,6 @@
|
|||||||
android:title="@string/desc_app_locale_disclaimer"
|
android:title="@string/desc_app_locale_disclaimer"
|
||||||
android:order="1"/>
|
android:order="1"/>
|
||||||
|
|
||||||
<com.android.settingslib.widget.BannerMessagePreference
|
|
||||||
android:key="key_warnings"
|
|
||||||
android:order="20"
|
|
||||||
android:icon="@drawable/ic_error_outline"
|
|
||||||
android:title="@string/warnings_title"
|
|
||||||
android:summary="@string/warnings_summary"/>
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
<com.android.settingslib.widget.LayoutPreference
|
||||||
android:key="app_locale_description"
|
android:key="app_locale_description"
|
||||||
android:order="30"
|
android:order="30"
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ import android.widget.SeekBar;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.instrumentation.SettingsStatsLog;
|
|
||||||
import com.android.settings.widget.LabeledSeekBarPreference;
|
import com.android.settings.widget.LabeledSeekBarPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,9 +36,6 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements
|
|||||||
private ProgressInteractionListener mInteractionListener;
|
private ProgressInteractionListener mInteractionListener;
|
||||||
private LabeledSeekBarPreference mSeekBarPreference;
|
private LabeledSeekBarPreference mSeekBarPreference;
|
||||||
|
|
||||||
@EntryPoint
|
|
||||||
private int mEntryPoint;
|
|
||||||
|
|
||||||
private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener =
|
private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener =
|
||||||
new SeekBar.OnSeekBarChangeListener() {
|
new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -51,11 +46,6 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements
|
|||||||
mInteractionListener.onProgressChanged();
|
mInteractionListener.onProgressChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsStatsLog.write(
|
|
||||||
SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
|
|
||||||
AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()),
|
|
||||||
progress,
|
|
||||||
AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,14 +97,6 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements
|
|||||||
mSeekBarPreference.setProgress(defaultProgress);
|
mSeekBarPreference.setProgress(defaultProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The entry point is used for logging.
|
|
||||||
*
|
|
||||||
* @param entryPoint from which settings page
|
|
||||||
*/
|
|
||||||
void setEntryPoint(@EntryPoint int entryPoint) {
|
|
||||||
mEntryPoint = entryPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for callbacks when users interact with the seek bar.
|
* Interface for callbacks when users interact with the seek bar.
|
||||||
|
|||||||
@@ -129,18 +129,17 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
|
|
||||||
final TextReadingPreviewController previewController = new TextReadingPreviewController(
|
final TextReadingPreviewController previewController = new TextReadingPreviewController(
|
||||||
context, PREVIEW_KEY, fontSizeData, displaySizeData);
|
context, PREVIEW_KEY, fontSizeData, displaySizeData);
|
||||||
|
previewController.setEntryPoint(mEntryPoint);
|
||||||
controllers.add(previewController);
|
controllers.add(previewController);
|
||||||
|
|
||||||
final PreviewSizeSeekBarController fontSizeController = new PreviewSizeSeekBarController(
|
final PreviewSizeSeekBarController fontSizeController = new PreviewSizeSeekBarController(
|
||||||
context, FONT_SIZE_KEY, fontSizeData);
|
context, FONT_SIZE_KEY, fontSizeData);
|
||||||
fontSizeController.setInteractionListener(previewController);
|
fontSizeController.setInteractionListener(previewController);
|
||||||
fontSizeController.setEntryPoint(mEntryPoint);
|
|
||||||
controllers.add(fontSizeController);
|
controllers.add(fontSizeController);
|
||||||
|
|
||||||
final PreviewSizeSeekBarController displaySizeController = new PreviewSizeSeekBarController(
|
final PreviewSizeSeekBarController displaySizeController = new PreviewSizeSeekBarController(
|
||||||
context, DISPLAY_SIZE_KEY, displaySizeData);
|
context, DISPLAY_SIZE_KEY, displaySizeData);
|
||||||
displaySizeController.setInteractionListener(previewController);
|
displaySizeController.setInteractionListener(previewController);
|
||||||
displaySizeController.setEntryPoint(mEntryPoint);
|
|
||||||
controllers.add(displaySizeController);
|
controllers.add(displaySizeController);
|
||||||
|
|
||||||
mFontWeightAdjustmentController =
|
mFontWeightAdjustmentController =
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.settings.accessibility;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.core.instrumentation.SettingsStatsLog;
|
||||||
import com.android.settings.display.PreviewPagerAdapter;
|
import com.android.settings.display.PreviewPagerAdapter;
|
||||||
import com.android.settings.widget.LabeledSeekBarPreference;
|
import com.android.settings.widget.LabeledSeekBarPreference;
|
||||||
|
|
||||||
@@ -38,6 +41,7 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
class TextReadingPreviewController extends BasePreferenceController implements
|
class TextReadingPreviewController extends BasePreferenceController implements
|
||||||
PreviewSizeSeekBarController.ProgressInteractionListener {
|
PreviewSizeSeekBarController.ProgressInteractionListener {
|
||||||
|
private static final String TAG = "TextReadingPreviewCtrl";
|
||||||
static final int[] PREVIEW_SAMPLE_RES_IDS = new int[]{
|
static final int[] PREVIEW_SAMPLE_RES_IDS = new int[]{
|
||||||
R.layout.accessibility_text_reading_preview_app_grid,
|
R.layout.accessibility_text_reading_preview_app_grid,
|
||||||
R.layout.screen_zoom_preview_1,
|
R.layout.screen_zoom_preview_1,
|
||||||
@@ -58,6 +62,9 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
private LabeledSeekBarPreference mFontSizePreference;
|
private LabeledSeekBarPreference mFontSizePreference;
|
||||||
private LabeledSeekBarPreference mDisplaySizePreference;
|
private LabeledSeekBarPreference mDisplaySizePreference;
|
||||||
|
|
||||||
|
@EntryPoint
|
||||||
|
private int mEntryPoint;
|
||||||
|
|
||||||
private final Choreographer.FrameCallback mCommit = f -> {
|
private final Choreographer.FrameCallback mCommit = f -> {
|
||||||
tryCommitFontSizeConfig();
|
tryCommitFontSizeConfig();
|
||||||
tryCommitDisplaySizeConfig();
|
tryCommitDisplaySizeConfig();
|
||||||
@@ -92,8 +99,8 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
/* message= */ "Display size preference is null, the preview controller"
|
/* message= */ "Display size preference is null, the preview controller"
|
||||||
+ " couldn't get the info");
|
+ " couldn't get the info");
|
||||||
|
|
||||||
mLastFontProgress = mFontSizePreference.getProgress();
|
mLastFontProgress = mFontSizeData.getInitialIndex();
|
||||||
mLastDisplayProgress = mDisplaySizePreference.getProgress();
|
mLastDisplayProgress = mDisplaySizeData.getInitialIndex();
|
||||||
|
|
||||||
final Configuration origConfig = mContext.getResources().getConfiguration();
|
final Configuration origConfig = mContext.getResources().getConfiguration();
|
||||||
final boolean isLayoutRtl =
|
final boolean isLayoutRtl =
|
||||||
@@ -131,6 +138,15 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
postCommitDelayed(CHANGE_BY_SEEKBAR_DELAY_MS);
|
postCommitDelayed(CHANGE_BY_SEEKBAR_DELAY_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entry point is used for logging.
|
||||||
|
*
|
||||||
|
* @param entryPoint from which settings page
|
||||||
|
*/
|
||||||
|
void setEntryPoint(@EntryPoint int entryPoint) {
|
||||||
|
mEntryPoint = entryPoint;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Avoids the flicker when switching to the previous or next level.
|
* Avoids the flicker when switching to the previous or next level.
|
||||||
*
|
*
|
||||||
@@ -162,6 +178,16 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
if (fontProgress != mLastFontProgress) {
|
if (fontProgress != mLastFontProgress) {
|
||||||
mFontSizeData.commit(fontProgress);
|
mFontSizeData.commit(fontProgress);
|
||||||
mLastFontProgress = fontProgress;
|
mLastFontProgress = fontProgress;
|
||||||
|
|
||||||
|
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
||||||
|
Log.d(TAG, "Font size: " + fontProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsStatsLog.write(
|
||||||
|
SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
|
||||||
|
AccessibilityStatsLogUtils.convertToItemKeyName(mFontSizePreference.getKey()),
|
||||||
|
fontProgress,
|
||||||
|
AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +196,17 @@ class TextReadingPreviewController extends BasePreferenceController implements
|
|||||||
if (displayProgress != mLastDisplayProgress) {
|
if (displayProgress != mLastDisplayProgress) {
|
||||||
mDisplaySizeData.commit(displayProgress);
|
mDisplaySizeData.commit(displayProgress);
|
||||||
mLastDisplayProgress = displayProgress;
|
mLastDisplayProgress = displayProgress;
|
||||||
|
|
||||||
|
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
||||||
|
Log.d(TAG, "Display size: " + displayProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsStatsLog.write(
|
||||||
|
SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED,
|
||||||
|
AccessibilityStatsLogUtils.convertToItemKeyName(
|
||||||
|
mDisplaySizePreference.getKey()),
|
||||||
|
displayProgress,
|
||||||
|
AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
return AccessibilityGestureNavigationTutorial
|
return AccessibilityGestureNavigationTutorial
|
||||||
.showAccessibilityGestureTutorialDialog(getPrefContext());
|
.showAccessibilityGestureTutorialDialog(getPrefContext());
|
||||||
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
|
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
|
||||||
final CharSequence dialogTitle = getPrefContext().getString(
|
final CharSequence dialogTitle = getShortcutTitle();
|
||||||
R.string.accessibility_shortcut_title, mPackageName);
|
|
||||||
final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent())
|
final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent())
|
||||||
? DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW
|
? DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW
|
||||||
: DialogType.EDIT_SHORTCUT_MAGNIFICATION;
|
: DialogType.EDIT_SHORTCUT_MAGNIFICATION;
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ public class AppLocaleUtil {
|
|||||||
* Check the function of per app language is supported by current application.
|
* Check the function of per app language is supported by current application.
|
||||||
*/
|
*/
|
||||||
public static boolean isAppLocaleSupported(Context context, String packageName) {
|
public static boolean isAppLocaleSupported(Context context, String packageName) {
|
||||||
if (getPackageLocales(context, packageName) != null) {
|
LocaleList localeList = getPackageLocales(context, packageName);
|
||||||
|
if (localeList != null && localeList.size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,8 @@ import android.app.Activity;
|
|||||||
import android.app.LocaleManager;
|
import android.app.LocaleManager;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.InstallSourceInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -34,7 +30,6 @@ import android.util.FeatureFlagUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -48,8 +43,6 @@ import com.android.settings.applications.AppLocaleUtil;
|
|||||||
import com.android.settings.widget.EntityHeaderController;
|
import com.android.settings.widget.EntityHeaderController;
|
||||||
import com.android.settingslib.applications.AppUtils;
|
import com.android.settingslib.applications.AppUtils;
|
||||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||||
import com.android.settingslib.widget.BannerMessagePreference;
|
|
||||||
import com.android.settingslib.widget.BannerMessagePreference.AttentionLevel;
|
|
||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -62,7 +55,6 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
private static final String TAG = "AppLocaleDetails";
|
private static final String TAG = "AppLocaleDetails";
|
||||||
|
|
||||||
private static final String KEY_APP_DESCRIPTION = "app_locale_description";
|
private static final String KEY_APP_DESCRIPTION = "app_locale_description";
|
||||||
private static final String KEY_WARNINGS = "key_warnings";
|
|
||||||
private static final String KEY_APP_DISCLAIMER = "app_locale_disclaimer";
|
private static final String KEY_APP_DISCLAIMER = "app_locale_disclaimer";
|
||||||
|
|
||||||
private boolean mCreated = false;
|
private boolean mCreated = false;
|
||||||
@@ -96,7 +88,6 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
||||||
mPrefOfDisclaimer = getPreferenceScreen().findPreference(KEY_APP_DISCLAIMER);
|
mPrefOfDisclaimer = getPreferenceScreen().findPreference(KEY_APP_DISCLAIMER);
|
||||||
mApplicationInfo = getApplicationInfo(mPackageName, getContext().getUserId());
|
mApplicationInfo = getApplicationInfo(mPackageName, getContext().getUserId());
|
||||||
setWarningMessage();
|
|
||||||
setDisclaimerPreference();
|
setDisclaimerPreference();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +110,6 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshUi() {
|
private void refreshUi() {
|
||||||
setWarningMessage();
|
|
||||||
setDescription();
|
setDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,26 +146,6 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
getPreferenceScreen().addPreference(pref);
|
getPreferenceScreen().addPreference(pref);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWarningMessage() {
|
|
||||||
BannerMessagePreference warningPreference =
|
|
||||||
(BannerMessagePreference) getPreferenceScreen().findPreference(KEY_WARNINGS);
|
|
||||||
try {
|
|
||||||
InstallSourceInfo installSourceInfo =
|
|
||||||
getContext().getPackageManager().getInstallSourceInfo(mPackageName);
|
|
||||||
if (mApplicationInfo.isSystemApp()
|
|
||||||
&& installSourceInfo.getInstallingPackageName() == null) {
|
|
||||||
warningPreference.setAttentionLevel(AttentionLevel.MEDIUM);
|
|
||||||
warningPreference.setPositiveButtonOnClickListener(mBannerButtonClickListener);
|
|
||||||
warningPreference.setPositiveButtonText(R.string.warnings_button_update);
|
|
||||||
warningPreference.setVisible(true);
|
|
||||||
} else {
|
|
||||||
warningPreference.setVisible(false);
|
|
||||||
}
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
Log.e(TAG, "Exception while retrieving the package installer of " + mPackageName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDisclaimerPreference() {
|
private void setDisclaimerPreference() {
|
||||||
if (FeatureFlagUtils.isEnabled(
|
if (FeatureFlagUtils.isEnabled(
|
||||||
getContext(), FeatureFlagUtils.SETTINGS_APP_LOCALE_OPT_IN_ENABLED)) {
|
getContext(), FeatureFlagUtils.SETTINGS_APP_LOCALE_OPT_IN_ENABLED)) {
|
||||||
@@ -192,19 +162,6 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private OnClickListener mBannerButtonClickListener = new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startActivity(getAppSearchIntent(mPackageName));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static Intent getAppSearchIntent(String pkg) {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
||||||
intent.setData(Uri.parse("market://details?id=" + pkg));
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ApplicationInfo getApplicationInfo(String packageName, int userId) {
|
private ApplicationInfo getApplicationInfo(String packageName, int userId) {
|
||||||
ApplicationInfo applicationInfo;
|
ApplicationInfo applicationInfo;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ public class ButtonActionDialogFragment extends InstrumentedDialogFragment imple
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// When it's in a multi-window mode, force stopping an app will lead to an activity
|
||||||
|
// recreate, and the dialog fragment will also be recreated. So dismiss the dialog before
|
||||||
|
// stopping the app.
|
||||||
|
if (mId == ButtonActionDialogFragment.DialogType.FORCE_STOP) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
final AppButtonsDialogListener lsn =
|
final AppButtonsDialogListener lsn =
|
||||||
(AppButtonsDialogListener) getTargetFragment();
|
(AppButtonsDialogListener) getTargetFragment();
|
||||||
lsn.handleDialogClick(mId);
|
lsn.handleDialogClick(mId);
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase implements
|
|||||||
lottieAnimationView.setVisibility(View.GONE);
|
lottieAnimationView.setVisibility(View.GONE);
|
||||||
lottieAnimationViewPortrait.setVisibility(View.VISIBLE);
|
lottieAnimationViewPortrait.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
|
case Surface.ROTATION_180:
|
||||||
|
lottieAnimationView.setVisibility(View.VISIBLE);
|
||||||
|
lottieAnimationView.setRotation(180);
|
||||||
|
lottieAnimationViewPortrait.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
case Surface.ROTATION_270:
|
case Surface.ROTATION_270:
|
||||||
lottieAnimationView.setVisibility(View.GONE);
|
lottieAnimationView.setVisibility(View.GONE);
|
||||||
lottieAnimationViewPortrait.setVisibility(View.VISIBLE);
|
lottieAnimationViewPortrait.setVisibility(View.VISIBLE);
|
||||||
@@ -353,10 +358,7 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase implements
|
|||||||
@Override
|
@Override
|
||||||
public void onOrientationChanged(int orientation) {
|
public void onOrientationChanged(int orientation) {
|
||||||
final int currentRotation = getDisplay().getRotation();
|
final int currentRotation = getDisplay().getRotation();
|
||||||
if ((mPreviousRotation == Surface.ROTATION_90
|
if ((currentRotation + 2) % 4 == mPreviousRotation) {
|
||||||
&& currentRotation == Surface.ROTATION_270) || (
|
|
||||||
mPreviousRotation == Surface.ROTATION_270
|
|
||||||
&& currentRotation == Surface.ROTATION_90)) {
|
|
||||||
mPreviousRotation = currentRotation;
|
mPreviousRotation = currentRotation;
|
||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
|
|||||||
if (mStorageEntry.isPrivate()) {
|
if (mStorageEntry.isPrivate()) {
|
||||||
if (!mStorageEntry.isDefaultInternalStorage()) {
|
if (!mStorageEntry.isDefaultInternalStorage()) {
|
||||||
mRename.setVisible(true);
|
mRename.setVisible(true);
|
||||||
mUnmount.setVisible(true);
|
|
||||||
mFormatAsPortable.setVisible(true);
|
mFormatAsPortable.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
|||||||
private static final IntentFilter INTENT_FILTER_LOCATION_MODE_CHANGED =
|
private static final IntentFilter INTENT_FILTER_LOCATION_MODE_CHANGED =
|
||||||
new IntentFilter(LocationManager.MODE_CHANGED_ACTION);
|
new IntentFilter(LocationManager.MODE_CHANGED_ACTION);
|
||||||
private final LocationManager mLocationManager;
|
private final LocationManager mLocationManager;
|
||||||
/** Total number of apps that has location permission. */
|
|
||||||
private int mNumTotal = -1;
|
|
||||||
private int mNumTotalLoading = 0;
|
private int mNumTotalLoading = 0;
|
||||||
|
/** Summary text. */
|
||||||
|
private static String sSummary = null;
|
||||||
private BroadcastReceiver mReceiver;
|
private BroadcastReceiver mReceiver;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
private AtomicInteger loadingInProgress = new AtomicInteger(0);
|
private AtomicInteger loadingInProgress = new AtomicInteger(0);
|
||||||
@@ -51,12 +51,11 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (mLocationManager.isLocationEnabled()) {
|
if (mLocationManager.isLocationEnabled()) {
|
||||||
if (mNumTotal == -1) {
|
if (sSummary == null) {
|
||||||
return mContext.getString(R.string.location_settings_loading_app_permission_stats);
|
sSummary = mContext.getString(
|
||||||
|
R.string.location_settings_loading_app_permission_stats);
|
||||||
}
|
}
|
||||||
return mContext.getResources().getQuantityString(
|
return sSummary;
|
||||||
R.plurals.location_settings_summary_location_on,
|
|
||||||
mNumTotal, mNumTotal);
|
|
||||||
} else {
|
} else {
|
||||||
return mContext.getString(R.string.location_settings_summary_location_off);
|
return mContext.getString(R.string.location_settings_summary_location_off);
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,8 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setLocationAppCount(int numApps) {
|
void setLocationAppCount(int numApps) {
|
||||||
mNumTotal = numApps;
|
sSummary = mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.location_settings_summary_location_on, numApps, numApps);
|
||||||
refreshSummary(mPreference);
|
refreshSummary(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,29 +106,20 @@ public class NotificationBackend {
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppRow loadAppRow(Context context, PackageManager pm,
|
public AppRow loadAppRow(Context context, PackageManager pm, PackageInfo app) {
|
||||||
RoleManager roleManager, PackageInfo app) {
|
|
||||||
final AppRow row = loadAppRow(context, pm, app.applicationInfo);
|
final AppRow row = loadAppRow(context, pm, app.applicationInfo);
|
||||||
recordCanBeBlocked(context, pm, roleManager, app, row);
|
recordCanBeBlocked(app, row);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordCanBeBlocked(Context context, PackageManager pm, RoleManager rm, PackageInfo app,
|
void recordCanBeBlocked(PackageInfo app, AppRow row) {
|
||||||
AppRow row) {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
row.systemApp = row.lockedImportance =
|
row.systemApp = row.lockedImportance =
|
||||||
sINM.isPermissionFixed(app.packageName, row.userId);
|
sINM.isImportanceLocked(app.packageName, app.applicationInfo.uid);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "Error calling NMS", e);
|
Log.w(TAG, "Error calling NMS", e);
|
||||||
}
|
}
|
||||||
// The permission system cannot make role permissions 'fixed', so check for these
|
|
||||||
// roles explicitly
|
|
||||||
List<String> roles = rm.getHeldRolesFromController(app.packageName);
|
|
||||||
if (roles.contains(RoleManager.ROLE_DIALER)
|
|
||||||
|| roles.contains(RoleManager.ROLE_EMERGENCY)) {
|
|
||||||
row.systemApp = row.lockedImportance = true;
|
|
||||||
}
|
|
||||||
// if the app targets T but has not requested the permission, we cannot change the
|
// if the app targets T but has not requested the permission, we cannot change the
|
||||||
// permission state
|
// permission state
|
||||||
if (app.applicationInfo.targetSdkVersion > Build.VERSION_CODES.S_V2) {
|
if (app.applicationInfo.targetSdkVersion > Build.VERSION_CODES.S_V2) {
|
||||||
@@ -139,24 +130,6 @@ public class NotificationBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting static void markAppRowWithBlockables(String[] nonBlockablePkgs, AppRow row,
|
|
||||||
String packageName) {
|
|
||||||
if (nonBlockablePkgs != null) {
|
|
||||||
int N = nonBlockablePkgs.length;
|
|
||||||
for (int i = 0; i < N; i++) {
|
|
||||||
String pkg = nonBlockablePkgs[i];
|
|
||||||
if (pkg == null) {
|
|
||||||
continue;
|
|
||||||
} else if (pkg.contains(":")) {
|
|
||||||
// handled by NotificationChannel.isImportanceLockedByOEM()
|
|
||||||
continue;
|
|
||||||
} else if (packageName.equals(nonBlockablePkgs[i])) {
|
|
||||||
row.systemApp = row.lockedImportance = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static public CharSequence getDeviceList(ICompanionDeviceManager cdm, LocalBluetoothManager lbm,
|
static public CharSequence getDeviceList(ICompanionDeviceManager cdm, LocalBluetoothManager lbm,
|
||||||
String pkg, int userId) {
|
String pkg, int userId) {
|
||||||
boolean multiple = false;
|
boolean multiple = false;
|
||||||
@@ -191,10 +164,9 @@ public class NotificationBackend {
|
|||||||
public boolean enableSwitch(Context context, ApplicationInfo app) {
|
public boolean enableSwitch(Context context, ApplicationInfo app) {
|
||||||
try {
|
try {
|
||||||
PackageInfo info = context.getPackageManager().getPackageInfo(
|
PackageInfo info = context.getPackageManager().getPackageInfo(
|
||||||
app.packageName, PackageManager.GET_SIGNATURES);
|
app.packageName, PackageManager.GET_PERMISSIONS);
|
||||||
RoleManager rm = context.getSystemService(RoleManager.class);
|
|
||||||
final AppRow row = new AppRow();
|
final AppRow row = new AppRow();
|
||||||
recordCanBeBlocked(context, context.getPackageManager(), rm, info, row);
|
recordCanBeBlocked(info, row);
|
||||||
boolean systemBlockable = !row.systemApp || (row.systemApp && row.banned);
|
boolean systemBlockable = !row.systemApp || (row.systemApp && row.banned);
|
||||||
return systemBlockable && !row.lockedImportance;
|
return systemBlockable && !row.lockedImportance;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.app.NotificationChannel;
|
|||||||
import android.app.NotificationChannelGroup;
|
import android.app.NotificationChannelGroup;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -171,7 +172,8 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
|||||||
return overrideCanConfigureValue;
|
return overrideCanConfigureValue;
|
||||||
}
|
}
|
||||||
if (mAppRow != null) {
|
if (mAppRow != null) {
|
||||||
return !mAppRow.systemApp && !mAppRow.lockedImportance;
|
boolean systemBlockable = !mAppRow.systemApp || (mAppRow.systemApp && mAppRow.banned);
|
||||||
|
return systemBlockable && !mAppRow.lockedImportance;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.app.Notification;
|
|||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationChannelGroup;
|
import android.app.NotificationChannelGroup;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.role.RoleManager;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -69,7 +68,6 @@ abstract public class NotificationSettings extends DashboardFragment {
|
|||||||
protected PackageManager mPm;
|
protected PackageManager mPm;
|
||||||
protected NotificationBackend mBackend = new NotificationBackend();
|
protected NotificationBackend mBackend = new NotificationBackend();
|
||||||
protected NotificationManager mNm;
|
protected NotificationManager mNm;
|
||||||
protected RoleManager mRm;
|
|
||||||
protected Context mContext;
|
protected Context mContext;
|
||||||
|
|
||||||
protected int mUid;
|
protected int mUid;
|
||||||
@@ -116,7 +114,6 @@ abstract public class NotificationSettings extends DashboardFragment {
|
|||||||
|
|
||||||
mPm = getPackageManager();
|
mPm = getPackageManager();
|
||||||
mNm = NotificationManager.from(mContext);
|
mNm = NotificationManager.from(mContext);
|
||||||
mRm = mContext.getSystemService(RoleManager.class);
|
|
||||||
|
|
||||||
mPkg = mArgs != null && mArgs.containsKey(AppInfoBase.ARG_PACKAGE_NAME)
|
mPkg = mArgs != null && mArgs.containsKey(AppInfoBase.ARG_PACKAGE_NAME)
|
||||||
? mArgs.getString(AppInfoBase.ARG_PACKAGE_NAME)
|
? mArgs.getString(AppInfoBase.ARG_PACKAGE_NAME)
|
||||||
@@ -290,7 +287,7 @@ abstract public class NotificationSettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadAppRow() {
|
private void loadAppRow() {
|
||||||
mAppRow = mBackend.loadAppRow(mContext, mPm, mRm, mPkgInfo);
|
mAppRow = mBackend.loadAppRow(mContext, mPm, mPkgInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadChannelGroup() {
|
private void loadChannelGroup() {
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ package com.android.settings.applications.appinfo;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
@@ -72,6 +74,21 @@ public class ButtonActionDialogFragmentTest {
|
|||||||
verify(mTargetFragment).handleDialogClick(anyInt());
|
verify(mTargetFragment).handleDialogClick(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnClick_forceStop_dismissDialog() {
|
||||||
|
ButtonActionDialogFragment fragment =
|
||||||
|
spy(ButtonActionDialogFragment.newInstance(FORCE_STOP_ID));
|
||||||
|
FragmentController.setupFragment(fragment, FragmentActivity.class, 0 /* containerViewId */,
|
||||||
|
null /* bundle */);
|
||||||
|
doReturn(mTargetFragment).when(fragment).getTargetFragment();
|
||||||
|
doNothing().when(mTargetFragment).handleDialogClick(anyInt());
|
||||||
|
final AlertDialog dialog = mock(AlertDialog.class);
|
||||||
|
|
||||||
|
fragment.onClick(dialog, 0);
|
||||||
|
|
||||||
|
verify(dialog).dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnCreateDialog_forceStopDialog() {
|
public void testOnCreateDialog_forceStopDialog() {
|
||||||
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(FORCE_STOP_ID);
|
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(FORCE_STOP_ID);
|
||||||
|
|||||||
@@ -56,31 +56,41 @@ public class TopLevelLocationPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_whenLocationIsOn_shouldShowLoadingString() {
|
public void getSummary_whenLocationIsOn_shouldPreservePreviousText() {
|
||||||
|
final int locationAppCount = 5;
|
||||||
|
// Retrieve summary text once.
|
||||||
|
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
||||||
|
mController.setLocationAppCount(locationAppCount);
|
||||||
|
mController.getSummary();
|
||||||
|
// Turn off location.
|
||||||
|
mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle());
|
||||||
|
// Turn on location again and check if the previous summary text is still cached.
|
||||||
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getString(R.string.location_settings_loading_app_permission_stats));
|
mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.location_settings_summary_location_on, locationAppCount,
|
||||||
|
locationAppCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_whenLocationAppCountIsOne_shouldShowSingularString() {
|
public void getSummary_whenLocationAppCountIsOne_shouldShowSingularString() {
|
||||||
final int LOCATION_APP_COUNT = 1;
|
final int locationAppCount = 1;
|
||||||
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
||||||
mController.setLocationAppCount(LOCATION_APP_COUNT);
|
mController.setLocationAppCount(locationAppCount);
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getResources().getQuantityString(
|
mContext.getResources().getQuantityString(
|
||||||
R.plurals.location_settings_summary_location_on,
|
R.plurals.location_settings_summary_location_on,
|
||||||
LOCATION_APP_COUNT, LOCATION_APP_COUNT));
|
locationAppCount, locationAppCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_whenLocationAppCountIsGreaterThanOne_shouldShowPluralString() {
|
public void getSummary_whenLocationAppCountIsGreaterThanOne_shouldShowPluralString() {
|
||||||
final int LOCATION_APP_COUNT = 5;
|
final int locationAppCount = 5;
|
||||||
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
|
||||||
mController.setLocationAppCount(LOCATION_APP_COUNT);
|
mController.setLocationAppCount(locationAppCount);
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getResources().getQuantityString(
|
mContext.getResources().getQuantityString(
|
||||||
R.plurals.location_settings_summary_location_on,
|
R.plurals.location_settings_summary_location_on,
|
||||||
LOCATION_APP_COUNT, LOCATION_APP_COUNT));
|
locationAppCount, locationAppCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -80,69 +81,17 @@ public class NotificationBackendTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMarkAppRow_unblockablePackage() {
|
public void testMarkAppRow_fixedImportance() throws Exception {
|
||||||
AppRow appRow = new AppRow();
|
|
||||||
String packageName = "foo.bar.unblockable";
|
|
||||||
appRow.pkg = packageName;
|
|
||||||
String[] nonBlockablePkgs = new String[2];
|
|
||||||
nonBlockablePkgs[0] = packageName;
|
|
||||||
nonBlockablePkgs[1] = "some.other.package";
|
|
||||||
NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, appRow, packageName);
|
|
||||||
|
|
||||||
// This package has a package lock but no locked channels
|
|
||||||
assertTrue(appRow.lockedImportance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMarkAppRow_defaultPackage() {
|
|
||||||
PackageInfo pi = new PackageInfo();
|
|
||||||
pi.packageName = "test";
|
|
||||||
pi.applicationInfo = new ApplicationInfo();
|
|
||||||
pi.applicationInfo.packageName = "test";
|
|
||||||
List<String> roles = new ArrayList<>();
|
|
||||||
roles.add(RoleManager.ROLE_DIALER);
|
|
||||||
RoleManager rm = mock(RoleManager.class);
|
|
||||||
when(rm.getHeldRolesFromController(anyString())).thenReturn(roles);
|
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
|
||||||
mock(PackageManager.class), rm, pi);
|
|
||||||
|
|
||||||
assertTrue(appRow.systemApp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMarkAppRow_fixedPermission_withRole() throws Exception {
|
|
||||||
PackageInfo pi = new PackageInfo();
|
PackageInfo pi = new PackageInfo();
|
||||||
pi.packageName = "test";
|
pi.packageName = "test";
|
||||||
pi.applicationInfo = new ApplicationInfo();
|
pi.applicationInfo = new ApplicationInfo();
|
||||||
pi.applicationInfo.packageName = "test";
|
pi.applicationInfo.packageName = "test";
|
||||||
pi.applicationInfo.uid = 123;
|
pi.applicationInfo.uid = 123;
|
||||||
|
|
||||||
List<String> roles = new ArrayList<>();
|
when(mInm.isImportanceLocked(pi.packageName, 123)).thenReturn(true);
|
||||||
roles.add(RoleManager.ROLE_DIALER);
|
|
||||||
RoleManager rm = mock(RoleManager.class);
|
|
||||||
when(rm.getHeldRolesFromController(anyString())).thenReturn(roles);
|
|
||||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||||
mock(PackageManager.class), rm, pi);
|
mock(PackageManager.class), pi);
|
||||||
|
|
||||||
assertTrue(appRow.systemApp);
|
|
||||||
assertTrue(appRow.lockedImportance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMarkAppRow_fixedPermission() throws Exception {
|
|
||||||
PackageInfo pi = new PackageInfo();
|
|
||||||
pi.packageName = "test";
|
|
||||||
pi.applicationInfo = new ApplicationInfo();
|
|
||||||
pi.applicationInfo.packageName = "test";
|
|
||||||
pi.applicationInfo.uid = 123;
|
|
||||||
|
|
||||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(true);
|
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
|
||||||
mock(PackageManager.class), mock(RoleManager.class), pi);
|
|
||||||
|
|
||||||
assertTrue(appRow.systemApp);
|
assertTrue(appRow.systemApp);
|
||||||
assertTrue(appRow.lockedImportance);
|
assertTrue(appRow.lockedImportance);
|
||||||
@@ -156,10 +105,10 @@ public class NotificationBackendTest {
|
|||||||
pi.applicationInfo.packageName = "test";
|
pi.applicationInfo.packageName = "test";
|
||||||
pi.applicationInfo.uid = 123;
|
pi.applicationInfo.uid = 123;
|
||||||
|
|
||||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
when(mInm.isImportanceLocked(anyString(), anyInt())).thenReturn(false);
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||||
mock(PackageManager.class), mock(RoleManager.class), pi);
|
mock(PackageManager.class), pi);
|
||||||
|
|
||||||
assertFalse(appRow.systemApp);
|
assertFalse(appRow.systemApp);
|
||||||
assertFalse(appRow.lockedImportance);
|
assertFalse(appRow.lockedImportance);
|
||||||
@@ -178,7 +127,7 @@ public class NotificationBackendTest {
|
|||||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||||
mock(PackageManager.class), mock(RoleManager.class), pi);
|
mock(PackageManager.class), pi);
|
||||||
|
|
||||||
assertFalse(appRow.systemApp);
|
assertFalse(appRow.systemApp);
|
||||||
assertTrue(appRow.lockedImportance);
|
assertTrue(appRow.lockedImportance);
|
||||||
@@ -198,29 +147,12 @@ public class NotificationBackendTest {
|
|||||||
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false);
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
||||||
mock(PackageManager.class), mock(RoleManager.class), pi);
|
mock(PackageManager.class), pi);
|
||||||
|
|
||||||
assertFalse(appRow.systemApp);
|
assertFalse(appRow.systemApp);
|
||||||
assertFalse(appRow.lockedImportance);
|
assertFalse(appRow.lockedImportance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMarkAppRow_notDefaultPackage() {
|
|
||||||
PackageInfo pi = new PackageInfo();
|
|
||||||
pi.packageName = "test";
|
|
||||||
pi.applicationInfo = new ApplicationInfo();
|
|
||||||
pi.applicationInfo.packageName = "test";
|
|
||||||
List<String> roles = new ArrayList<>();
|
|
||||||
roles.add(RoleManager.ROLE_HOME);
|
|
||||||
RoleManager rm = mock(RoleManager.class);
|
|
||||||
when(rm.getHeldRolesFromController(anyString())).thenReturn(roles);
|
|
||||||
|
|
||||||
AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application,
|
|
||||||
mock(PackageManager.class), rm, pi);
|
|
||||||
|
|
||||||
assertFalse(appRow.systemApp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAggregatedUsageEvents_multipleEventsAgg() {
|
public void testGetAggregatedUsageEvents_multipleEventsAgg() {
|
||||||
List<UsageEvents.Event> events = new ArrayList<>();
|
List<UsageEvents.Event> events = new ArrayList<>();
|
||||||
|
|||||||
@@ -284,24 +284,36 @@ public class NotificationPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAppBlockable_postMigration_locked() {
|
public void testIsAppBlockable_fixedPermission() {
|
||||||
mController = new TestPreferenceController(mContext, mBackend);
|
mController = new TestPreferenceController(mContext, mBackend);
|
||||||
|
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
appRow.lockedImportance = true;
|
appRow.systemApp = true;
|
||||||
appRow.banned = false;
|
appRow.banned = false;
|
||||||
mController.onResume(appRow, null, null, null, null, null, null);
|
mController.onResume(appRow, null, null, null, null, null, null);
|
||||||
assertFalse(mController.isAppBlockable());
|
assertFalse(mController.isAppBlockable());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAppBlockable_postMigration_locked_butAppOff() {
|
public void testIsAppBlockable_fixedPermission_butAppOff() {
|
||||||
mController = new TestPreferenceController(mContext, mBackend);
|
mController = new TestPreferenceController(mContext, mBackend);
|
||||||
|
|
||||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
appRow.lockedImportance = true;
|
appRow.systemApp = true;
|
||||||
appRow.banned = true;
|
appRow.banned = true;
|
||||||
mController.onResume(appRow, null, null, null, null, null, null);
|
mController.onResume(appRow, null, null, null, null, null, null);
|
||||||
|
assertTrue(mController.isAppBlockable());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsAppBlockable_notFixedButAppInBadState() {
|
||||||
|
mController = new TestPreferenceController(mContext, mBackend);
|
||||||
|
|
||||||
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
|
appRow.systemApp = false;
|
||||||
|
appRow.banned = true;
|
||||||
|
appRow.lockedImportance = true;
|
||||||
|
mController.onResume(appRow, null, null, null, null, null, null);
|
||||||
assertFalse(mController.isAppBlockable());
|
assertFalse(mController.isAppBlockable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ public class VolumeOptionMenuControllerTest {
|
|||||||
mController.onPrepareOptionsMenu(mMenu);
|
mController.onPrepareOptionsMenu(mMenu);
|
||||||
|
|
||||||
verify(mController.mRename, atLeastOnce()).setVisible(true);
|
verify(mController.mRename, atLeastOnce()).setVisible(true);
|
||||||
verify(mController.mUnmount, atLeastOnce()).setVisible(true);
|
|
||||||
verify(mController.mFormatAsPortable, atLeastOnce()).setVisible(true);
|
verify(mController.mFormatAsPortable, atLeastOnce()).setVisible(true);
|
||||||
verify(mController.mMount, never()).setVisible(true);
|
verify(mController.mMount, never()).setVisible(true);
|
||||||
verify(mController.mFormat, never()).setVisible(true);
|
verify(mController.mFormat, never()).setVisible(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user