Snap for 7468789 from fb359d18ff to sc-release
Change-Id: Ib01f800505cf41cd0c5a08e7f1b98352afa893aa
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -57,6 +57,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layoutDirection="ltr"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.android.settings.accessibility.BalanceSeekBar
|
<com.android.settings.accessibility.BalanceSeekBar
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
||||||
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
|
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
|
||||||
<item name="android:colorBackground">?androidprv:attr/colorSurface</item>
|
<item name="android:colorError">@color/settings_dialog_colorError</item>
|
||||||
|
<item name="android:colorBackground">@*android:color/surface_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Material theme for the pages containing TabLayout and ViewPager -->
|
<!-- Material theme for the pages containing TabLayout and ViewPager -->
|
||||||
|
|||||||
@@ -5598,6 +5598,10 @@
|
|||||||
</string>
|
</string>
|
||||||
<!-- Title for setting the brightness intensity of the display using Reduce Brightness. [CHAR LIMIT=NONE] -->
|
<!-- Title for setting the brightness intensity of the display using Reduce Brightness. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_intensity_preference_title">Intensity</string>
|
<string name="reduce_bright_colors_intensity_preference_title">Intensity</string>
|
||||||
|
<!-- Start label for slider that reduces the brightness intensity of the display using Extra Dim. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="reduce_bright_colors_intensity_start_label">Dimmer</string>
|
||||||
|
<!-- End label for slider that reduces the brightness intensity of the display using Extra Dim. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="reduce_bright_colors_intensity_end_label">Brighter</string>
|
||||||
<!-- Title for setting whether the Reduce Brightness activation state persists across reboots. [CHAR LIMIT=NONE] -->
|
<!-- Title for setting whether the Reduce Brightness activation state persists across reboots. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_persist_preference_title">Keep on after device restarts</string>
|
<string name="reduce_bright_colors_persist_preference_title">Keep on after device restarts</string>
|
||||||
|
|
||||||
@@ -9100,9 +9104,12 @@
|
|||||||
<!-- [CHAR LIMIT=60] button title -->
|
<!-- [CHAR LIMIT=60] button title -->
|
||||||
<string name="conversation_settings_clear_recents">Clear recent conversations</string>
|
<string name="conversation_settings_clear_recents">Clear recent conversations</string>
|
||||||
|
|
||||||
<!-- a11y feedeback for 'clear recents' button' -->
|
<!-- a11y feedback for 'clear recents' button' -->
|
||||||
<string name="recent_convos_removed">Recent conversations removed</string>
|
<string name="recent_convos_removed">Recent conversations removed</string>
|
||||||
|
|
||||||
|
<!-- a11y feedback for 'clear recent conversation' button' -->
|
||||||
|
<string name="recent_convo_removed">Conversation removed</string>
|
||||||
|
|
||||||
<!-- a11y string -->
|
<!-- a11y string -->
|
||||||
<string name="clear">Clear</string>
|
<string name="clear">Clear</string>
|
||||||
|
|
||||||
@@ -10133,7 +10140,7 @@
|
|||||||
<!-- Preference title for Add link [CHAR LIMIT=60] -->
|
<!-- Preference title for Add link [CHAR LIMIT=60] -->
|
||||||
<string name="app_launch_add_link">Add link</string>
|
<string name="app_launch_add_link">Add link</string>
|
||||||
<!-- Footer for Open by default. [CHAR LIMIT=NONE] -->
|
<!-- Footer for Open by default. [CHAR LIMIT=NONE] -->
|
||||||
<string name="app_launch_footer">An app can verify links to automatically open in the app. <annotation id="url">Learn more</annotation></string>
|
<string name="app_launch_footer">An app can verify links to automatically open in the app.</string>
|
||||||
|
|
||||||
<!-- Title, message and button for verified links dialog. -->
|
<!-- Title, message and button for verified links dialog. -->
|
||||||
<plurals name="app_launch_verified_links_title">
|
<plurals name="app_launch_verified_links_title">
|
||||||
@@ -10956,6 +10963,10 @@
|
|||||||
<string name="disabled_by_policy_title_suspend_packages">Can’t open this app</string>
|
<string name="disabled_by_policy_title_suspend_packages">Can’t open this app</string>
|
||||||
<!-- Dialog title. This dialog lets a user know that a specific setting is blocked by their credit provider. Since the user purchased the device from the credit provider, the credit provider controls what they can access. [CHAR LIMIT=50] -->
|
<!-- Dialog title. This dialog lets a user know that a specific setting is blocked by their credit provider. Since the user purchased the device from the credit provider, the credit provider controls what they can access. [CHAR LIMIT=50] -->
|
||||||
<string name="disabled_by_policy_title_financed_device">Blocked by your credit provider</string>
|
<string name="disabled_by_policy_title_financed_device">Blocked by your credit provider</string>
|
||||||
|
<!-- Dialog title shown when parental consent is required for the child to set up biometric authentication. [CHAR LIMIT=30] -->
|
||||||
|
<string name="disabled_by_policy_title_biometric_parental_consent">Parent needed</string>
|
||||||
|
<!-- Dialog content shown when parental consent is required for the child to set up biometric authentication. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="disabled_by_policy_content_biometric_parental_consent">Hand the phone to your parent to start setting this up</string>
|
||||||
<!-- Shown when the user tries to change phone settings that are blocked by their IT admin [CHAR LIMIT=200] -->
|
<!-- Shown when the user tries to change phone settings that are blocked by their IT admin [CHAR LIMIT=200] -->
|
||||||
<string name="default_admin_support_msg">If you have questions, contact your IT admin</string>
|
<string name="default_admin_support_msg">If you have questions, contact your IT admin</string>
|
||||||
<!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
|
<!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
|
||||||
|
|||||||
@@ -130,7 +130,7 @@
|
|||||||
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
|
||||||
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
||||||
<item name="android:colorError">@color/settings_dialog_colorError</item>
|
<item name="android:colorError">@color/settings_dialog_colorError</item>
|
||||||
<item name="android:colorBackground">?androidprv:attr/colorSurface</item>
|
<item name="android:colorBackground">@*android:color/surface_light</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">
|
<style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="time_spent_in_app"
|
android:key="time_spent_in_app"
|
||||||
android:title="@string/time_spent_in_app_pref_title"
|
android:title="@string/time_spent_in_app_pref_title"
|
||||||
|
android:summary="@string/summary_placeholder"
|
||||||
settings:controller="com.android.settings.applications.appinfo.TimeSpentInAppPreferenceController" />
|
settings:controller="com.android.settings.applications.appinfo.TimeSpentInAppPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
|||||||
@@ -63,7 +63,6 @@
|
|||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:key="open_by_default_footer"
|
android:key="open_by_default_footer"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
settings:searchable="false"/>
|
settings:searchable="false"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|||||||
@@ -17,13 +17,18 @@
|
|||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/reduce_bright_colors_preference_title">
|
android:title="@string/reduce_bright_colors_preference_title">
|
||||||
|
|
||||||
<com.android.settings.widget.SeekBarPreference
|
<com.android.settings.widget.LabeledSeekBarPreference
|
||||||
android:key="rbc_intensity"
|
android:key="rbc_intensity"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/reduce_bright_colors_intensity_preference_title"/>
|
android:title="@string/reduce_bright_colors_intensity_preference_title"
|
||||||
|
settings:textStart="@string/reduce_bright_colors_intensity_start_label"
|
||||||
|
settings:textEnd="@string/reduce_bright_colors_intensity_end_label"
|
||||||
|
settings:tickMark="@android:color/transparent"
|
||||||
|
/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="rbc_persist"
|
android:key="rbc_persist"
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.android.settings.widget.SeekBarPreference;
|
|||||||
/** PreferenceController for feature intensity. */
|
/** PreferenceController for feature intensity. */
|
||||||
public class ReduceBrightColorsIntensityPreferenceController extends SliderPreferenceController {
|
public class ReduceBrightColorsIntensityPreferenceController extends SliderPreferenceController {
|
||||||
|
|
||||||
|
private static final int INVERSE_PERCENTAGE_BASE = 100;
|
||||||
private final ColorDisplayManager mColorDisplayManager;
|
private final ColorDisplayManager mColorDisplayManager;
|
||||||
|
|
||||||
public ReduceBrightColorsIntensityPreferenceController(Context context, String key) {
|
public ReduceBrightColorsIntensityPreferenceController(Context context, String key) {
|
||||||
@@ -66,21 +67,24 @@ public class ReduceBrightColorsIntensityPreferenceController extends SliderPrefe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSliderPosition() {
|
public int getSliderPosition() {
|
||||||
return mColorDisplayManager.getReduceBrightColorsStrength();
|
return INVERSE_PERCENTAGE_BASE - mColorDisplayManager.getReduceBrightColorsStrength();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setSliderPosition(int position) {
|
public boolean setSliderPosition(int position) {
|
||||||
return mColorDisplayManager.setReduceBrightColorsStrength(position);
|
return mColorDisplayManager.setReduceBrightColorsStrength(
|
||||||
|
INVERSE_PERCENTAGE_BASE - position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMax() {
|
public int getMax() {
|
||||||
return ColorDisplayManager.getMaximumReduceBrightColorsStrength(mContext);
|
return INVERSE_PERCENTAGE_BASE
|
||||||
|
- ColorDisplayManager.getMinimumReduceBrightColorsStrength(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
return ColorDisplayManager.getMinimumReduceBrightColorsStrength(mContext);
|
return INVERSE_PERCENTAGE_BASE
|
||||||
|
- ColorDisplayManager.getMaximumReduceBrightColorsStrength(mContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import androidx.lifecycle.OnLifecycleEvent;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@@ -59,6 +58,7 @@ public class AvatarViewMixin implements LifecycleObserver {
|
|||||||
private static final String METHOD_GET_ACCOUNT_AVATAR = "getAccountAvatar";
|
private static final String METHOD_GET_ACCOUNT_AVATAR = "getAccountAvatar";
|
||||||
private static final String KEY_AVATAR_BITMAP = "account_avatar";
|
private static final String KEY_AVATAR_BITMAP = "account_avatar";
|
||||||
private static final String KEY_ACCOUNT_NAME = "account_name";
|
private static final String KEY_ACCOUNT_NAME = "account_name";
|
||||||
|
private static final String KEY_AVATAR_ICON = "avatar_icon";
|
||||||
private static final String EXTRA_ACCOUNT_NAME = "extra.accountName";
|
private static final String EXTRA_ACCOUNT_NAME = "extra.accountName";
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -105,11 +105,8 @@ public class AvatarViewMixin implements LifecycleObserver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(
|
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider()
|
||||||
mContext).getMetricsFeatureProvider();
|
.logSettingsTileClick(KEY_AVATAR_ICON, SettingsEnums.SETTINGS_HOMEPAGE);
|
||||||
metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN,
|
|
||||||
SettingsEnums.CLICK_ACCOUNT_AVATAR, SettingsEnums.SETTINGS_HOMEPAGE,
|
|
||||||
null /* key */, Integer.MIN_VALUE /* value */);
|
|
||||||
|
|
||||||
// Here may have two different UI while start the activity.
|
// Here may have two different UI while start the activity.
|
||||||
// It will display adding account UI when device has no any account.
|
// It will display adding account UI when device has no any account.
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont
|
|||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
private int mUnusedCount = 0;
|
private int mUnusedCount = 0;
|
||||||
private boolean mLoadingUnusedApps;
|
private boolean mLoadingUnusedApps;
|
||||||
|
private boolean mLoadedUnusedCount;
|
||||||
private final Executor mBackgroundExecutor;
|
private final Executor mBackgroundExecutor;
|
||||||
private final Executor mMainExecutor;
|
private final Executor mMainExecutor;
|
||||||
|
|
||||||
@@ -79,14 +80,15 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return isHibernationEnabled() && mUnusedCount > 0
|
return isHibernationEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
return mContext.getResources().getQuantityString(
|
return mLoadedUnusedCount
|
||||||
R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount);
|
? mContext.getResources().getQuantityString(
|
||||||
|
R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount)
|
||||||
|
: mContext.getResources().getString(R.string.summary_placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,8 +113,8 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont
|
|||||||
loadUnusedCount(unusedCount -> {
|
loadUnusedCount(unusedCount -> {
|
||||||
mUnusedCount = unusedCount;
|
mUnusedCount = unusedCount;
|
||||||
mLoadingUnusedApps = false;
|
mLoadingUnusedApps = false;
|
||||||
|
mLoadedUnusedCount = true;
|
||||||
mMainExecutor.execute(() -> {
|
mMainExecutor.execute(() -> {
|
||||||
super.displayPreference(mScreen);
|
|
||||||
Preference pref = mScreen.findPreference(mPreferenceKey);
|
Preference pref = mScreen.findPreference(mPreferenceKey);
|
||||||
refreshSummary(pref);
|
refreshSummary(pref);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.applications.AppInfoBase;
|
import com.android.settings.applications.AppInfoBase;
|
||||||
import com.android.settings.applications.ClearDefaultsPreference;
|
import com.android.settings.applications.ClearDefaultsPreference;
|
||||||
import com.android.settings.utils.AnnotationSpan;
|
|
||||||
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.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
@@ -73,8 +72,6 @@ public class AppLaunchSettings extends AppInfoBase implements
|
|||||||
"open_by_default_selected_links_category";
|
"open_by_default_selected_links_category";
|
||||||
private static final String OTHER_DETAILS_PREF_CATEGORY_KEY = "app_launch_other_defaults";
|
private static final String OTHER_DETAILS_PREF_CATEGORY_KEY = "app_launch_other_defaults";
|
||||||
|
|
||||||
// Url and Uri
|
|
||||||
private static final String ANNOTATION_URL = "url";
|
|
||||||
private static final String LEARN_MORE_URI =
|
private static final String LEARN_MORE_URI =
|
||||||
"https://developer.android.com/training/app-links/verify-site-associations";
|
"https://developer.android.com/training/app-links/verify-site-associations";
|
||||||
|
|
||||||
@@ -356,16 +353,22 @@ public class AppLaunchSettings extends AppInfoBase implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initFooter() {
|
private void initFooter() {
|
||||||
// learn more
|
|
||||||
final AnnotationSpan.LinkInfo linkInfo =
|
|
||||||
new AnnotationSpan.LinkInfo(ANNOTATION_URL, v -> {
|
|
||||||
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(LEARN_MORE_URI));
|
|
||||||
mContext.startActivity(intent);
|
|
||||||
});
|
|
||||||
final CharSequence footerText = mContext.getText(R.string.app_launch_footer);
|
final CharSequence footerText = mContext.getText(R.string.app_launch_footer);
|
||||||
final FooterPreference footerPreference = (FooterPreference) findPreference(
|
final FooterPreference footerPreference = (FooterPreference) findPreference(
|
||||||
FOOTER_PREF_KEY);
|
FOOTER_PREF_KEY);
|
||||||
footerPreference.setTitle(AnnotationSpan.linkify(footerText, linkInfo));
|
footerPreference.setTitle(footerText);
|
||||||
|
// learn more
|
||||||
|
footerPreference.setLearnMoreAction(view -> {
|
||||||
|
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(LEARN_MORE_URI));
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
});
|
||||||
|
final String learnMoreContentDescription = mContext.getString(
|
||||||
|
R.string.footer_learn_more_content_description, getLabelName());
|
||||||
|
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLabelName() {
|
||||||
|
return mContext.getString(R.string.launch_by_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isClearDefaultsEnabled() {
|
private boolean isClearDefaultsEnabled() {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.content.Context;
|
|||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
import android.hardware.biometrics.BiometricAuthenticator;
|
||||||
import android.hardware.biometrics.ParentalControlsUtilsInternal;
|
import android.hardware.biometrics.ParentalControlsUtilsInternal;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -49,7 +50,8 @@ public class ParentalControlsUtils {
|
|||||||
final UserHandle userHandle = new UserHandle(UserHandle.myUserId());
|
final UserHandle userHandle = new UserHandle(UserHandle.myUserId());
|
||||||
if (ParentalControlsUtilsInternal.isTestModeEnabled(context)) {
|
if (ParentalControlsUtilsInternal.isTestModeEnabled(context)) {
|
||||||
Log.d(TAG, "Requiring consent for test flow");
|
Log.d(TAG, "Requiring consent for test flow");
|
||||||
return new RestrictedLockUtils.EnforcedAdmin(null /* ComponentName */, userHandle);
|
return new RestrictedLockUtils.EnforcedAdmin(null /* ComponentName */,
|
||||||
|
UserManager.DISALLOW_BIOMETRIC, userHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
|
final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
|
||||||
@@ -69,7 +71,8 @@ public class ParentalControlsUtils {
|
|||||||
userHandle)) {
|
userHandle)) {
|
||||||
final ComponentName cn =
|
final ComponentName cn =
|
||||||
ParentalControlsUtilsInternal.getSupervisionComponentName(dpm, userHandle);
|
ParentalControlsUtilsInternal.getSupervisionComponentName(dpm, userHandle);
|
||||||
return new RestrictedLockUtils.EnforcedAdmin(cn, userHandle);
|
return new RestrictedLockUtils.EnforcedAdmin(cn, UserManager.DISALLOW_BIOMETRIC,
|
||||||
|
userHandle);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -57,6 +58,7 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i
|
|||||||
private static final String TAG = "MoreSettingsPrefCtrl";
|
private static final String TAG = "MoreSettingsPrefCtrl";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Intent mIntent;
|
Intent mIntent;
|
||||||
|
private LayoutPreference mPreference;
|
||||||
|
|
||||||
public MoreSettingsPreferenceController(Context context, String preferenceKey) {
|
public MoreSettingsPreferenceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
@@ -82,8 +84,8 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i
|
|||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
final LayoutPreference pref = screen.findPreference(getPreferenceKey());
|
mPreference = screen.findPreference(getPreferenceKey());
|
||||||
final Button button = pref.findViewById(R.id.button);
|
final Button button = mPreference.findViewById(R.id.button);
|
||||||
final Drawable icon = getIcon();
|
final Drawable icon = getIcon();
|
||||||
button.setText(getButtonText());
|
button.setText(getButtonText());
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
@@ -109,6 +111,8 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider()
|
||||||
|
.logClickedPreference(mPreference, getMetricsCategory());
|
||||||
final Intent intent = new Intent(mIntent)
|
final Intent intent = new Intent(mIntent)
|
||||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
@@ -170,5 +174,4 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i
|
|||||||
icon.draw(canvas);
|
icon.draw(canvas);
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ActionDisabledByAdminDialog extends Activity
|
|||||||
final RestrictedLockUtils.EnforcedAdmin enforcedAdmin =
|
final RestrictedLockUtils.EnforcedAdmin enforcedAdmin =
|
||||||
getAdminDetailsFromIntent(getIntent());
|
getAdminDetailsFromIntent(getIntent());
|
||||||
final String restriction = getRestrictionFromIntent(getIntent());
|
final String restriction = getRestrictionFromIntent(getIntent());
|
||||||
mDialogHelper = new ActionDisabledByAdminDialogHelper(this);
|
mDialogHelper = new ActionDisabledByAdminDialogHelper(this, restriction);
|
||||||
mDialogHelper.prepareDialogBuilder(restriction, enforcedAdmin)
|
mDialogHelper.prepareDialogBuilder(restriction, enforcedAdmin)
|
||||||
.setOnDismissListener(this)
|
.setOnDismissListener(this)
|
||||||
.show();
|
.show();
|
||||||
|
|||||||
@@ -56,11 +56,16 @@ public final class ActionDisabledByAdminDialogHelper {
|
|||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
|
|
||||||
public ActionDisabledByAdminDialogHelper(Activity activity) {
|
public ActionDisabledByAdminDialogHelper(Activity activity) {
|
||||||
|
this(activity, null /* restriction */);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionDisabledByAdminDialogHelper(Activity activity, String restriction) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
|
mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
|
||||||
R.layout.admin_support_details_dialog, null);
|
R.layout.admin_support_details_dialog, null);
|
||||||
mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
|
mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
|
||||||
.createInstance(mActivity, new DeviceAdminStringProviderImpl(mActivity));
|
.createInstance(mActivity, restriction,
|
||||||
|
new DeviceAdminStringProviderImpl(mActivity));
|
||||||
}
|
}
|
||||||
|
|
||||||
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
|
private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
|
||||||
@@ -74,7 +79,9 @@ public final class ActionDisabledByAdminDialogHelper {
|
|||||||
public AlertDialog.Builder prepareDialogBuilder(String restriction,
|
public AlertDialog.Builder prepareDialogBuilder(String restriction,
|
||||||
EnforcedAdmin enforcedAdmin) {
|
EnforcedAdmin enforcedAdmin) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
|
||||||
.setPositiveButton(R.string.okay, null)
|
.setPositiveButton(R.string.okay,
|
||||||
|
mActionDisabledByAdminController
|
||||||
|
.getPositiveButtonListener(mActivity, enforcedAdmin))
|
||||||
.setView(mDialogView);
|
.setView(mDialogView);
|
||||||
prepareDialogBuilder(builder, restriction, enforcedAdmin);
|
prepareDialogBuilder(builder, restriction, enforcedAdmin);
|
||||||
return builder;
|
return builder;
|
||||||
|
|||||||
@@ -79,4 +79,14 @@ class DeviceAdminStringProviderImpl implements DeviceAdminStringProvider {
|
|||||||
public String getDisabledByPolicyTitleForFinancedDevice() {
|
public String getDisabledByPolicyTitleForFinancedDevice() {
|
||||||
return mContext.getString(R.string.disabled_by_policy_title_financed_device);
|
return mContext.getString(R.string.disabled_by_policy_title_financed_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisabledBiometricsParentConsentTitle() {
|
||||||
|
return mContext.getString(R.string.disabled_by_policy_title_biometric_parental_consent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisabledBiometricsParentConsentContent() {
|
||||||
|
return mContext.getString(R.string.disabled_by_policy_content_biometric_parental_consent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,30 @@
|
|||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.widget.SettingsMainSwitchPreferenceController;
|
import com.android.settings.widget.SettingsMainSwitchPreferenceController;
|
||||||
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
|
import com.android.settingslib.widget.MainSwitchPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller to handle one-handed mode main switch enable or disable state.
|
* The controller to handle one-handed mode main switch enable or disable state.
|
||||||
**/
|
**/
|
||||||
public class OneHandedMainSwitchPreferenceController extends
|
public class OneHandedMainSwitchPreferenceController extends
|
||||||
SettingsMainSwitchPreferenceController {
|
SettingsMainSwitchPreferenceController implements OneHandedSettingsUtils.TogglesCallback,
|
||||||
|
LifecycleObserver, OnStart, OnStop {
|
||||||
|
|
||||||
|
private final OneHandedSettingsUtils mUtils;
|
||||||
|
|
||||||
|
private MainSwitchPreference mPreference;
|
||||||
|
|
||||||
public OneHandedMainSwitchPreferenceController(Context context, String preferenceKey) {
|
public OneHandedMainSwitchPreferenceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
|
mUtils = new OneHandedSettingsUtils(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,4 +66,30 @@ public class OneHandedMainSwitchPreferenceController extends
|
|||||||
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, isChecked);
|
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, isChecked);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
mPreference = screen.findPreference(getPreferenceKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
mUtils.registerToggleAwareObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
mUtils.unregisterToggleAwareObserver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(Uri uri) {
|
||||||
|
if (mPreference == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)) {
|
||||||
|
mPreference.setChecked(isChecked());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,11 @@ package com.android.settings.homepage;
|
|||||||
|
|
||||||
import android.animation.LayoutTransition;
|
import android.animation.LayoutTransition;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityOptions;
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
@@ -36,13 +33,11 @@ import androidx.fragment.app.FragmentManager;
|
|||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.accounts.AvatarViewMixin;
|
import com.android.settings.accounts.AvatarViewMixin;
|
||||||
import com.android.settings.core.FeatureFlags;
|
import com.android.settings.core.FeatureFlags;
|
||||||
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
|
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
||||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
|
||||||
|
|
||||||
public class SettingsHomepageActivity extends FragmentActivity {
|
public class SettingsHomepageActivity extends FragmentActivity {
|
||||||
|
|
||||||
@@ -69,12 +64,6 @@ public class SettingsHomepageActivity extends FragmentActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
if (Utils.isPageTransitionEnabled(this)) {
|
|
||||||
// Enable Activity transitions
|
|
||||||
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
|
|
||||||
SettingsTransitionHelper.applyForwardTransition(this);
|
|
||||||
SettingsTransitionHelper.applyBackwardTransition(this);
|
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings_homepage_container);
|
setContentView(R.layout.settings_homepage_container);
|
||||||
|
|
||||||
@@ -107,16 +96,6 @@ public class SettingsHomepageActivity extends FragmentActivity {
|
|||||||
.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startActivity(Intent intent) {
|
|
||||||
if (Utils.isPageTransitionEnabled(this)) {
|
|
||||||
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle();
|
|
||||||
super.startActivity(intent, bundle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showSuggestionFragment() {
|
private void showSuggestionFragment() {
|
||||||
final Class<? extends Fragment> fragment = FeatureFactory.getFactory(this)
|
final Class<? extends Fragment> fragment = FeatureFactory.getFactory(this)
|
||||||
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment();
|
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment();
|
||||||
|
|||||||
@@ -88,6 +88,13 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
Telephony.Carriers.EDITED_STATUS,
|
Telephony.Carriers.EDITED_STATUS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Copied from {@code com.android.internal.telephony.TelephonyIntents} */
|
||||||
|
private static final String ACTION_SIM_STATE_CHANGED =
|
||||||
|
"android.intent.action.SIM_STATE_CHANGED";
|
||||||
|
/** Copied from {@code com.android.internal.telephony.IccCardConstants} */
|
||||||
|
public static final String INTENT_KEY_ICC_STATE = "ss";
|
||||||
|
public static final String INTENT_VALUE_ICC_ABSENT = "ABSENT";
|
||||||
|
|
||||||
private static final int ID_INDEX = 0;
|
private static final int ID_INDEX = 0;
|
||||||
private static final int NAME_INDEX = 1;
|
private static final int NAME_INDEX = 1;
|
||||||
private static final int APN_INDEX = 2;
|
private static final int APN_INDEX = 2;
|
||||||
@@ -151,7 +158,16 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction().equals(
|
String action = intent.getAction();
|
||||||
|
if (ACTION_SIM_STATE_CHANGED.equals(action)
|
||||||
|
&& intent.getStringExtra(INTENT_KEY_ICC_STATE)
|
||||||
|
.equals(INTENT_VALUE_ICC_ABSENT)) {
|
||||||
|
final SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
|
||||||
|
if (sm != null && !sm.isActiveSubscriptionId(mSubId)) {
|
||||||
|
Log.d(TAG, "Due to SIM absent, closes APN settings page");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else if (intent.getAction().equals(
|
||||||
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
|
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
|
||||||
if (mRestoreDefaultApnMode) {
|
if (mRestoreDefaultApnMode) {
|
||||||
return;
|
return;
|
||||||
@@ -201,8 +217,9 @@ public class ApnSettings extends RestrictedSettingsFragment
|
|||||||
mSubId = activity.getIntent().getIntExtra(SUB_ID,
|
mSubId = activity.getIntent().getIntExtra(SUB_ID,
|
||||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
|
mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
|
||||||
mIntentFilter = new IntentFilter(
|
mIntentFilter = new IntentFilter();
|
||||||
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
|
mIntentFilter.addAction(TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
|
||||||
|
mIntentFilter.addAction(ACTION_SIM_STATE_CHANGED);
|
||||||
|
|
||||||
setIfOnlyAvailableForAdmins(true);
|
setIfOnlyAvailableForAdmins(true);
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,8 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
|
|||||||
pref.setOnClearClickListener(() -> {
|
pref.setOnClearClickListener(() -> {
|
||||||
try {
|
try {
|
||||||
mPs.removeRecentConversation(pkg, UserHandle.getUserId(uid), conversationId);
|
mPs.removeRecentConversation(pkg, UserHandle.getUserId(uid), conversationId);
|
||||||
|
pref.getClearView().announceForAccessibility(
|
||||||
|
mContext.getString(R.string.recent_convo_removed));
|
||||||
parent.removePreference(pref);
|
parent.removePreference(pref);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Could not clear recent", e);
|
Slog.w(TAG, "Could not clear recent", e);
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.pm.ComponentInfo;
|
import android.content.pm.ComponentInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.os.Binder;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.ConditionProviderService;
|
import android.service.notification.ConditionProviderService;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Slog;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -36,6 +39,7 @@ import com.android.settings.core.PreferenceControllerMixin;
|
|||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
||||||
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
||||||
@@ -92,7 +96,7 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
|||||||
? ci.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE)
|
? ci.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE)
|
||||||
: ci.metaData.getString(NotificationManager.META_DATA_AUTOMATIC_RULE_TYPE);
|
: ci.metaData.getString(NotificationManager.META_DATA_AUTOMATIC_RULE_TYPE);
|
||||||
|
|
||||||
final ComponentName configurationActivity = getSettingsActivity(null, ci);
|
final ComponentName configurationActivity = getSettingsActivity(pm, null, ci);
|
||||||
if (ruleType != null && !ruleType.trim().isEmpty() && configurationActivity != null) {
|
if (ruleType != null && !ruleType.trim().isEmpty() && configurationActivity != null) {
|
||||||
final ZenRuleInfo ri = new ZenRuleInfo();
|
final ZenRuleInfo ri = new ZenRuleInfo();
|
||||||
ri.serviceComponent =
|
ri.serviceComponent =
|
||||||
@@ -110,28 +114,44 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ComponentName getSettingsActivity(AutomaticZenRule rule, ComponentInfo ci) {
|
protected static ComponentName getSettingsActivity(PackageManager pm, AutomaticZenRule rule,
|
||||||
|
ComponentInfo ci) {
|
||||||
|
String owner = rule != null ? rule.getPackageName() : ci.packageName;
|
||||||
|
ComponentName settingsActivity = null;
|
||||||
// prefer config activity on the rule itself; fallback to manifest definition
|
// prefer config activity on the rule itself; fallback to manifest definition
|
||||||
if (rule != null && rule.getConfigurationActivity() != null) {
|
if (rule != null && rule.getConfigurationActivity() != null) {
|
||||||
return rule.getConfigurationActivity();
|
settingsActivity = rule.getConfigurationActivity();
|
||||||
}
|
} else {
|
||||||
if (ci == null) {
|
if (ci == null) {
|
||||||
return null;
|
settingsActivity = null;
|
||||||
}
|
} else if (ci instanceof ActivityInfo) {
|
||||||
// new activity backed rule
|
// new activity backed rule
|
||||||
if (ci instanceof ActivityInfo) {
|
settingsActivity = new ComponentName(ci.packageName, ci.name);
|
||||||
return new ComponentName(ci.packageName, ci.name);
|
} else if (ci.metaData != null) {
|
||||||
}
|
// old service backed rule
|
||||||
// old service backed rule
|
final String configurationActivity = ci.metaData.getString(
|
||||||
if (ci.metaData != null) {
|
ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY);
|
||||||
final String configurationActivity = ci.metaData.getString(
|
if (configurationActivity != null) {
|
||||||
ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY);
|
settingsActivity = ComponentName.unflattenFromString(configurationActivity);
|
||||||
if (configurationActivity != null) {
|
}
|
||||||
return ComponentName.unflattenFromString(configurationActivity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (settingsActivity == null || owner == null) {
|
||||||
return null;
|
return settingsActivity;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int ownerUid = pm.getPackageUid(owner, 0);
|
||||||
|
int configActivityOwnerUid = pm.getPackageUid(settingsActivity.getPackageName(), 0);
|
||||||
|
if (ownerUid == configActivityOwnerUid) {
|
||||||
|
return settingsActivity;
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Config activity not in owner package for " + rule.getName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.e(TAG, "Failed to find config activity");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RuleNameChangeListener implements ZenRuleNameDialog.PositiveClickListener {
|
public class RuleNameChangeListener implements ZenRuleNameDialog.PositiveClickListener {
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ public class ZenRulePreference extends TwoTargetPreference {
|
|||||||
: isEvent ? ZenModeEventRuleSettings.ACTION : "";
|
: isEvent ? ZenModeEventRuleSettings.ACTION : "";
|
||||||
ComponentInfo si = mServiceListing.findService(rule.getOwner());
|
ComponentInfo si = mServiceListing.findService(rule.getOwner());
|
||||||
ComponentName settingsActivity = AbstractZenModeAutomaticRulePreferenceController.
|
ComponentName settingsActivity = AbstractZenModeAutomaticRulePreferenceController.
|
||||||
getSettingsActivity(rule, si);
|
getSettingsActivity(mPm, rule, si);
|
||||||
mIntent = AbstractZenModeAutomaticRulePreferenceController.getRuleIntent(action,
|
mIntent = AbstractZenModeAutomaticRulePreferenceController.getRuleIntent(action,
|
||||||
settingsActivity, mId);
|
settingsActivity, mId);
|
||||||
if (mIntent.resolveActivity(mPm) == null) {
|
if (mIntent.resolveActivity(mPm) == null) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -43,6 +42,7 @@ import com.google.android.setupcompat.util.WizardManagerHelper;
|
|||||||
*/
|
*/
|
||||||
public interface SearchFeatureProvider {
|
public interface SearchFeatureProvider {
|
||||||
|
|
||||||
|
String KEY_HOMEPAGE_SEARCH_BAR = "homepage_search_bar";
|
||||||
int REQUEST_CODE = 501;
|
int REQUEST_CODE = 501;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +100,9 @@ public interface SearchFeatureProvider {
|
|||||||
|
|
||||||
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
FeatureFactory.getFactory(context).getSlicesFeatureProvider()
|
||||||
.indexSliceDataAsync(context);
|
.indexSliceDataAsync(context);
|
||||||
|
|
||||||
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
|
||||||
.action(context, SettingsEnums.ACTION_SEARCH_RESULTS);
|
.logSettingsTileClick(KEY_HOMEPAGE_SEARCH_BAR, pageId);
|
||||||
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle();
|
final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle();
|
||||||
activity.startActivityForResult(intent, REQUEST_CODE, bundle);
|
activity.startActivityForResult(intent, REQUEST_CODE, bundle);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -56,6 +56,15 @@ public class OneHandedMainSwitchPreferenceControllerTest {
|
|||||||
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isTrue();
|
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isChecked_setOneHandedModeEnabled_shouldReturnTrue() {
|
||||||
|
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
|
||||||
|
mUtils.setNavigationBarMode(mContext, "2" /* fully gestural */);
|
||||||
|
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, true);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() {
|
public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() {
|
||||||
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
|
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
|
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
|
||||||
import com.android.settings.homepage.contextualcards.slices.BatteryFixSliceTest;
|
import com.android.settings.homepage.contextualcards.slices.BatteryFixSliceTest;
|
||||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
|
||||||
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -59,13 +58,12 @@ import org.robolectric.util.ReflectionHelpers;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowUserManager.class,
|
@Config(shadows = {ShadowUserManager.class,
|
||||||
SettingsHomepageActivityTest.ShadowSuggestionFeatureProviderImpl.class, ShadowUtils.class})
|
SettingsHomepageActivityTest.ShadowSuggestionFeatureProviderImpl.class})
|
||||||
public class SettingsHomepageActivityTest {
|
public class SettingsHomepageActivityTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
ShadowUtils.setIsPageTransitionEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 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.notification.zen;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.AutomaticZenRule;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.ComponentInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.service.notification.ConditionProviderService;
|
||||||
|
import android.service.notification.ZenPolicy;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class AbstractZenModeAutomaticRulePreferenceControllerTest {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPm;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSettingsActivity_configActivity() 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);
|
||||||
|
|
||||||
|
ComponentName actual = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getSettingsActivity(mPm, rule, null);
|
||||||
|
|
||||||
|
assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSettingsActivity_configActivity_wrongPackage() throws Exception {
|
||||||
|
AutomaticZenRule rule = new AutomaticZenRule("name", null,
|
||||||
|
new ComponentName("another", "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);
|
||||||
|
|
||||||
|
ComponentName actual = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getSettingsActivity(mPm, rule, null);
|
||||||
|
|
||||||
|
assertThat(actual).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSettingsActivity_configActivity_unspecifiedOwner() throws Exception {
|
||||||
|
AutomaticZenRule rule = new AutomaticZenRule("name", null,
|
||||||
|
new ComponentName("another", "test"), Uri.EMPTY,
|
||||||
|
new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
|
||||||
|
|
||||||
|
when(mPm.getPackageUid(null, 0)).thenReturn(-1);
|
||||||
|
when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1);
|
||||||
|
|
||||||
|
ComponentName actual = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getSettingsActivity(mPm, rule, null);
|
||||||
|
|
||||||
|
assertThat(actual).isEqualTo(new ComponentName("another", "test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSettingsActivity_cps() throws Exception {
|
||||||
|
AutomaticZenRule rule = new AutomaticZenRule("name",
|
||||||
|
new ComponentName(mContext.getPackageName(), "service"), null, Uri.EMPTY,
|
||||||
|
new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
|
||||||
|
rule.setPackageName(mContext.getPackageName());
|
||||||
|
|
||||||
|
ComponentInfo ci = new ComponentInfo();
|
||||||
|
ci.packageName = mContext.getPackageName();
|
||||||
|
ci.metaData = new Bundle();
|
||||||
|
ci.metaData.putString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY,
|
||||||
|
ComponentName.flattenToShortString(
|
||||||
|
new ComponentName(mContext.getPackageName(), "activity")));
|
||||||
|
|
||||||
|
when(mPm.getPackageUid(null, 0)).thenReturn(-1);
|
||||||
|
when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1);
|
||||||
|
|
||||||
|
ComponentName actual = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getSettingsActivity(mPm, rule, ci);
|
||||||
|
|
||||||
|
assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "activity"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSettingsActivity_cps_wrongPackage() throws Exception {
|
||||||
|
AutomaticZenRule rule = new AutomaticZenRule("name",
|
||||||
|
new ComponentName(mContext.getPackageName(), "service"), null, Uri.EMPTY,
|
||||||
|
new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
|
||||||
|
rule.setPackageName("other");
|
||||||
|
|
||||||
|
ComponentInfo ci = new ComponentInfo();
|
||||||
|
ci.packageName = mContext.getPackageName();
|
||||||
|
ci.metaData = new Bundle();
|
||||||
|
ci.metaData.putString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY,
|
||||||
|
ComponentName.flattenToShortString(
|
||||||
|
new ComponentName(mContext.getPackageName(), "activity")));
|
||||||
|
|
||||||
|
when(mPm.getPackageUid(null, 0)).thenReturn(-1);
|
||||||
|
when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1);
|
||||||
|
|
||||||
|
ComponentName actual = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getSettingsActivity(mPm, rule, ci);
|
||||||
|
|
||||||
|
assertThat(actual).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSettingsActivity_cps_unspecifiedPackage() throws Exception {
|
||||||
|
AutomaticZenRule rule = new AutomaticZenRule("name",
|
||||||
|
new ComponentName(mContext.getPackageName(), "service"), null, Uri.EMPTY,
|
||||||
|
new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
|
||||||
|
|
||||||
|
ComponentInfo ci = new ComponentInfo();
|
||||||
|
ci.packageName = mContext.getPackageName();
|
||||||
|
ci.metaData = new Bundle();
|
||||||
|
ci.metaData.putString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY,
|
||||||
|
ComponentName.flattenToShortString(
|
||||||
|
new ComponentName(mContext.getPackageName(), "activity")));
|
||||||
|
|
||||||
|
when(mPm.getPackageUid(null, 0)).thenReturn(-1);
|
||||||
|
when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1);
|
||||||
|
|
||||||
|
ComponentName actual = AbstractZenModeAutomaticRulePreferenceController
|
||||||
|
.getSettingsActivity(mPm, rule, ci);
|
||||||
|
|
||||||
|
assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "activity"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,7 +84,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest {
|
|||||||
assertThat(
|
assertThat(
|
||||||
Settings.Secure.getInt(mContext.getContentResolver(),
|
Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.REDUCE_BRIGHT_COLORS_LEVEL, 0))
|
Settings.Secure.REDUCE_BRIGHT_COLORS_LEVEL, 0))
|
||||||
.isEqualTo(20);
|
.isEqualTo(80);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -92,8 +92,10 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest {
|
|||||||
when(mResources.getInteger(
|
when(mResources.getInteger(
|
||||||
R.integer.config_reduceBrightColorsStrengthMax)).thenReturn(90);
|
R.integer.config_reduceBrightColorsStrengthMax)).thenReturn(90);
|
||||||
when(mResources.getInteger(
|
when(mResources.getInteger(
|
||||||
R.integer.config_reduceBrightColorsStrengthMin)).thenReturn(10);
|
R.integer.config_reduceBrightColorsStrengthMin)).thenReturn(15);
|
||||||
|
assertThat(mPreferenceController.getMax()).isEqualTo(85);
|
||||||
|
assertThat(mPreferenceController.getMin()).isEqualTo(10);
|
||||||
assertThat(mPreferenceController.getMax() - mPreferenceController.getMin())
|
assertThat(mPreferenceController.getMax() - mPreferenceController.getMin())
|
||||||
.isEqualTo(80);
|
.isEqualTo(75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS;
|
|||||||
|
|
||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
import android.hardware.biometrics.BiometricAuthenticator;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
@@ -92,6 +93,7 @@ public class ParentalControlsUtilsTest {
|
|||||||
mSupervisionComponentName, tests[i][0] /* modality */,
|
mSupervisionComponentName, tests[i][0] /* modality */,
|
||||||
tests[i][1] /* keyguardDisableFlags */);
|
tests[i][1] /* keyguardDisableFlags */);
|
||||||
assertNotNull(admin);
|
assertNotNull(admin);
|
||||||
|
assertEquals(UserManager.DISALLOW_BIOMETRIC, admin.enforcedRestriction);
|
||||||
assertEquals(mSupervisionComponentName, admin.component);
|
assertEquals(mSupervisionComponentName, admin.component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user