categories) {
final int N = mCategoryListeners.size();
for (int i = 0; i < N; i++) {
diff --git a/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java b/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java
index beef4f30073..5118b277b59 100644
--- a/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java
+++ b/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java
@@ -25,6 +25,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.UserHandle;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.preference.Preference;
@@ -32,6 +33,8 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.homepage.RestrictedHomepagePreference;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedTopLevelPreference;
@@ -89,7 +92,11 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
@Override
public void updateState(Preference preference) {
- disablePreferenceIfManaged((RestrictedTopLevelPreference) preference);
+ if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) {
+ disablePreferenceIfManaged((RestrictedHomepagePreference) preference);
+ } else {
+ disablePreferenceIfManaged((RestrictedTopLevelPreference) preference);
+ }
}
@Override
@@ -133,4 +140,18 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
}
}
}
+
+ private void disablePreferenceIfManaged(RestrictedHomepagePreference pref) {
+ final String restriction = DISALLOW_SET_WALLPAPER;
+ if (pref != null) {
+ pref.setDisabledByAdmin(null);
+ if (RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext,
+ restriction, UserHandle.myUserId())) {
+ // Do not show the admin dialog for system restriction.
+ pref.setEnabled(false);
+ } else {
+ pref.checkRestrictionAndSetDisabled(restriction);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
index 7c7be096841..ca1f1c775b4 100644
--- a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
@@ -20,20 +20,84 @@ import static android.provider.Settings.Secure.VOLUME_HUSH_GESTURE;
import static android.provider.Settings.Secure.VOLUME_HUSH_MUTE;
import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE;
+import android.content.ContentResolver;
import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
import android.provider.Settings;
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
-public class PreventRingingParentPreferenceController extends BasePreferenceController {
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.widget.PrimarySwitchPreference;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+/** The controller manages the behaviour of the Prevent Ringing gesture setting. */
+public class PreventRingingParentPreferenceController extends TogglePreferenceController
+ implements LifecycleObserver, OnStart, OnStop {
final String SECURE_KEY = VOLUME_HUSH_GESTURE;
+ private PrimarySwitchPreference mPreference;
+ private SettingObserver mSettingObserver;
+
public PreventRingingParentPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ mSettingObserver = new SettingObserver(mPreference);
+ }
+
+ @Override
+ public boolean isChecked() {
+ final int preventRinging = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_VIBRATE);
+ return preventRinging != Settings.Secure.VOLUME_HUSH_OFF;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ final int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
+ final int newRingingSetting = preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF
+ ? Settings.Secure.VOLUME_HUSH_VIBRATE
+ : preventRingingSetting;
+
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, isChecked
+ ? newRingingSetting
+ : Settings.Secure.VOLUME_HUSH_OFF);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ final int value = Settings.Secure.getInt(
+ mContext.getContentResolver(), SECURE_KEY, VOLUME_HUSH_VIBRATE);
+ CharSequence summary;
+ switch (value) {
+ case VOLUME_HUSH_VIBRATE:
+ summary = mContext.getText(R.string.prevent_ringing_option_vibrate_summary);
+ break;
+ case VOLUME_HUSH_MUTE:
+ summary = mContext.getText(R.string.prevent_ringing_option_mute_summary);
+ break;
+ default:
+ summary = null;
+ }
+ preference.setSummary(summary);
+ }
+
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
@@ -42,20 +106,45 @@ public class PreventRingingParentPreferenceController extends BasePreferenceCont
}
@Override
- public CharSequence getSummary() {
- int value = Settings.Secure.getInt(
- mContext.getContentResolver(), SECURE_KEY, VOLUME_HUSH_VIBRATE);
- int summary;
- switch (value) {
- case VOLUME_HUSH_VIBRATE:
- summary = R.string.prevent_ringing_option_vibrate_summary;
- break;
- case VOLUME_HUSH_MUTE:
- summary = R.string.prevent_ringing_option_mute_summary;
- break;
- default:
- summary = R.string.prevent_ringing_option_none_summary;
+ public void onStart() {
+ if (mSettingObserver != null) {
+ mSettingObserver.register(mContext.getContentResolver());
+ mSettingObserver.onChange(false, null);
+ }
+ }
+
+ @Override
+ public void onStop() {
+ if (mSettingObserver != null) {
+ mSettingObserver.unregister(mContext.getContentResolver());
+ }
+ }
+
+ private class SettingObserver extends ContentObserver {
+ private final Uri mVolumeHushGestureUri = Settings.Secure.getUriFor(
+ Settings.Secure.VOLUME_HUSH_GESTURE);
+
+ private final Preference mPreference;
+
+ SettingObserver(Preference preference) {
+ super(new Handler());
+ mPreference = preference;
+ }
+
+ public void register(ContentResolver cr) {
+ cr.registerContentObserver(mVolumeHushGestureUri, false, this);
+ }
+
+ public void unregister(ContentResolver cr) {
+ cr.unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (uri == null || mVolumeHushGestureUri.equals(uri)) {
+ updateState(mPreference);
+ }
}
- return mContext.getText(summary);
}
}
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
index 9545939255b..be67b5a4f9e 100644
--- a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -16,11 +16,7 @@
package com.android.settings.gestures;
-import android.content.ContentResolver;
import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
import android.provider.Settings;
import android.widget.Switch;
@@ -39,7 +35,6 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference
private static final String KEY = "gesture_prevent_ringing_switch";
private final Context mContext;
- private SettingObserver mSettingObserver;
@VisibleForTesting
SwitchBar mSwitch;
@@ -60,7 +55,6 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference
if (isAvailable()) {
LayoutPreference pref = screen.findPreference(getPreferenceKey());
if (pref != null) {
- mSettingObserver = new SettingObserver(pref);
pref.setOnPreferenceClickListener(preference -> {
int preventRinging = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE,
@@ -113,32 +107,4 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference
? newRingingSetting
: Settings.Secure.VOLUME_HUSH_OFF);
}
-
- private class SettingObserver extends ContentObserver {
- private final Uri VOLUME_HUSH_GESTURE = Settings.Secure.getUriFor(
- Settings.Secure.VOLUME_HUSH_GESTURE);
-
- private final Preference mPreference;
-
- public SettingObserver(Preference preference) {
- super(new Handler());
- mPreference = preference;
- }
-
- public void register(ContentResolver cr) {
- cr.registerContentObserver(VOLUME_HUSH_GESTURE, false, this);
- }
-
- public void unregister(ContentResolver cr) {
- cr.unregisterContentObserver(this);
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- super.onChange(selfChange, uri);
- if (uri == null || VOLUME_HUSH_GESTURE.equals(uri)) {
- updateState(mPreference);
- }
- }
- }
}
diff --git a/src/com/android/settings/homepage/HomePagePreference.java b/src/com/android/settings/homepage/HomePagePreference.java
new file mode 100644
index 00000000000..41d59b72d29
--- /dev/null
+++ b/src/com/android/settings/homepage/HomePagePreference.java
@@ -0,0 +1,49 @@
+/*
+ * 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.homepage;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+
+/** A customized layout for homepage preference. */
+public class HomePagePreference extends Preference {
+
+ public HomePagePreference(Context context) {
+ super(context);
+ setLayoutResource(R.layout.homepage_preference);
+ }
+
+ public HomePagePreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setLayoutResource(R.layout.homepage_preference);
+ }
+
+ public HomePagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, /* defStyleRes= */ 0);
+ setLayoutResource(R.layout.homepage_preference);
+ }
+
+ public HomePagePreference(Context context, AttributeSet attrs,
+ int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ setLayoutResource(R.layout.homepage_preference);
+ }
+}
diff --git a/src/com/android/settings/homepage/RestrictedHomepagePreference.java b/src/com/android/settings/homepage/RestrictedHomepagePreference.java
new file mode 100644
index 00000000000..47b552c1ee2
--- /dev/null
+++ b/src/com/android/settings/homepage/RestrictedHomepagePreference.java
@@ -0,0 +1,122 @@
+/*
+ * 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.homepage;
+
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.util.AttributeSet;
+
+import androidx.core.content.res.TypedArrayUtils;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+import com.android.settingslib.RestrictedPreferenceHelper;
+
+/** Homepage preference that can be disabled by a device admin using a user restriction. */
+public class RestrictedHomepagePreference extends HomePagePreference {
+ private RestrictedPreferenceHelper mHelper;
+
+ public RestrictedHomepagePreference(Context context, AttributeSet attrs,
+ int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ mHelper = new RestrictedPreferenceHelper(context, /* preference= */ this, attrs);
+ }
+
+ public RestrictedHomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, /* defStyleRes= */ 0);
+ }
+
+ public RestrictedHomepagePreference(Context context, AttributeSet attrs) {
+ this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.preferenceStyle,
+ android.R.attr.preferenceStyle));
+ }
+
+ public RestrictedHomepagePreference(Context context) {
+ this(context, /* attrs= */ null);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ mHelper.onBindViewHolder(holder);
+ }
+
+ @Override
+ public void performClick() {
+ if (!mHelper.performClick()) {
+ super.performClick();
+ }
+ }
+
+ @Override
+ protected void onAttachedToHierarchy(PreferenceManager preferenceManager) {
+ mHelper.onAttachedToHierarchy();
+ super.onAttachedToHierarchy(preferenceManager);
+ }
+
+ /**
+ * Set the user restriction and disable this preference.
+ *
+ * @param userRestriction constant from {@link android.os.UserManager}
+ */
+ public void checkRestrictionAndSetDisabled(String userRestriction) {
+ mHelper.checkRestrictionAndSetDisabled(userRestriction, UserHandle.myUserId());
+ }
+
+ /**
+ * Set the user restriction and disable this preference for the given user.
+ *
+ * @param userRestriction constant from {@link android.os.UserManager}
+ * @param userId user to check the restriction for.
+ */
+ public void checkRestrictionAndSetDisabled(String userRestriction, int userId) {
+ mHelper.checkRestrictionAndSetDisabled(userRestriction, userId);
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ if (enabled && isDisabledByAdmin()) {
+ mHelper.setDisabledByAdmin(/* admin= */ null);
+ return;
+ }
+ super.setEnabled(enabled);
+ }
+
+ /**
+ * Check whether this preference is disabled by admin.
+ *
+ * @return true if this preference is disabled by admin.
+ */
+ public boolean isDisabledByAdmin() {
+ return mHelper.isDisabledByAdmin();
+ }
+
+ /**
+ * Disable preference based on the enforce admin.
+ *
+ * @param admin details of the admin who enforced the restriction. If it is {@code null}, then
+ * this preference will be enabled. Otherwise, it will be disabled.
+ */
+ public void setDisabledByAdmin(EnforcedAdmin admin) {
+ if (mHelper.setDisabledByAdmin(admin)) {
+ notifyChanged();
+ }
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java b/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java
index 0ad241e7431..1b3ee10b233 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/FaceSetupSlice.java
@@ -143,8 +143,8 @@ public class FaceSetupSlice implements CustomSliceable {
private static RowBuilder buildRowBuilder(CharSequence title, CharSequence subTitle,
IconCompat icon, Context context, Intent intent) {
final SliceAction primarySliceAction = SliceAction.createDeeplink(
- PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED), icon, ListBuilder.ICON_IMAGE,
- title);
+ PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE),
+ icon, ListBuilder.ICON_IMAGE, title);
return new RowBuilder()
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
.setTitle(title)
diff --git a/src/com/android/settings/inputmethod/UserDictionarySettings.java b/src/com/android/settings/inputmethod/UserDictionarySettings.java
index 67420a2c5df..5e3e7495359 100644
--- a/src/com/android/settings/inputmethod/UserDictionarySettings.java
+++ b/src/com/android/settings/inputmethod/UserDictionarySettings.java
@@ -26,6 +26,7 @@ import android.database.Cursor;
import android.os.Bundle;
import android.provider.UserDictionary;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -44,6 +45,7 @@ import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
import com.android.settings.R;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.Instrumentable;
@@ -104,6 +106,10 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ // TODO(b/176883483): Remove the title after material component updated
+ if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
+ getActivity().setTitle(R.string.user_dict_settings_title);
+ }
// Show the language as a subtitle of the action bar
final ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
diff --git a/src/com/android/settings/network/telephony/EuiccOperationSidecar.java b/src/com/android/settings/network/telephony/EuiccOperationSidecar.java
index a637cc2339f..0ee6d95fa83 100644
--- a/src/com/android/settings/network/telephony/EuiccOperationSidecar.java
+++ b/src/com/android/settings/network/telephony/EuiccOperationSidecar.java
@@ -99,7 +99,8 @@ public abstract class EuiccOperationSidecar extends SidecarFragment {
Intent intent = new Intent(getReceiverAction());
intent.putExtra(EXTRA_OP_ID, mOpId);
return PendingIntent.getBroadcast(
- getContext(), REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ getContext(), REQUEST_CODE, intent,
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
@Override
diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java
index 7c9bac0cf06..106f3368638 100644
--- a/src/com/android/settings/network/telephony/MobileDataSlice.java
+++ b/src/com/android/settings/network/telephony/MobileDataSlice.java
@@ -172,8 +172,8 @@ public class MobileDataSlice implements CustomSliceable {
private PendingIntent getPrimaryAction() {
final Intent intent = getIntent();
- return PendingIntent.getActivity(mContext, 0 /* requestCode */,
- intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */);
+ return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent,
+ PendingIntent.FLAG_IMMUTABLE);
}
/**
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index b179770d485..92f0054d2e7 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -115,6 +115,9 @@ public class MobileNetworkActivity extends SettingsBaseActivity
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
+ // TODO(b/176882938): Enable title after material component updated
+ // If CollapsingToolbarLayout is applied, the old action bar won't show title.
+ actionBar.setDisplayShowTitleEnabled(mCollapsingToolbarLayout == null);
}
getProxySubscriptionManager().setLifecycle(getLifecycle());
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index a17298f9d79..27e2b726c1f 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -77,6 +77,11 @@ public class RedactionInterstitial extends SettingsActivity {
findViewById(R.id.content_parent).setFitsSystemWindows(false);
}
+ @Override
+ protected boolean isToolbarEnabled() {
+ return false;
+ }
+
/**
* Create an intent for launching RedactionInterstitial.
*
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 1ad093fad35..fc209b8cff3 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -26,6 +26,7 @@ import android.os.Message;
import android.os.UserHandle;
import android.preference.SeekBarVolumizer;
import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
@@ -33,6 +34,7 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
+import com.android.settings.core.FeatureFlags;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -152,6 +154,9 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
@Override
protected int getPreferenceScreenResId() {
+ if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
+ return R.xml.sound_settings_v2;
+ }
return R.xml.sound_settings;
}
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index 312bf75b284..64a4699cda9 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -34,10 +34,6 @@ import java.util.List;
/**
* Represents the Internet Connectivity Panel.
- *
- *
- * Displays Wifi (full Slice) and Airplane mode.
- *
*/
public class InternetConnectivityPanel implements PanelContent {
@@ -78,6 +74,21 @@ public class InternetConnectivityPanel implements PanelContent {
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
+ @Override
+ public boolean isCustomizedButtonUsed() {
+ return Utils.isProviderModelEnabled(mContext);
+ }
+
+ @Override
+ public CharSequence getCustomizedButtonTitle() {
+ return mContext.getText(R.string.settings_button);
+ }
+
+ @Override
+ public void onClickCustomizedButton() {
+ mContext.startActivity(getSeeMoreIntent());
+ }
+
@Override
public int getMetricsCategory() {
return SettingsEnums.PANEL_INTERNET_CONNECTIVITY;
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index cc27683933e..8eec24fa148 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -452,13 +452,13 @@ public class PanelFragment extends Fragment {
View.OnClickListener getSeeMoreListener() {
return (v) -> {
mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
+ final FragmentActivity activity = getActivity();
if (mPanel.isCustomizedButtonUsed()) {
mPanel.onClickCustomizedButton();
} else {
- final FragmentActivity activity = getActivity();
activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
- activity.finish();
}
+ activity.finish();
};
}
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 0c84ba97628..f5e23fa04f2 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -184,6 +184,11 @@ public class ChooseLockPassword extends SettingsActivity {
return false;
}
+ @Override
+ protected boolean isToolbarEnabled() {
+ return false;
+ }
+
/* package */ Class extends Fragment> getFragmentClass() {
return ChooseLockPasswordFragment.class;
}
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 6e9cf981509..c52b4104288 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -194,6 +194,11 @@ public class ChooseLockPattern extends SettingsActivity {
return super.onKeyDown(keyCode, event);
}
+ @Override
+ protected boolean isToolbarEnabled() {
+ return false;
+ }
+
public static class ChooseLockPatternFragment extends InstrumentedFragment
implements SaveAndFinishWorker.Listener {
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index 3ecff580d33..f0b50a1bfec 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -176,6 +176,11 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
}
}
+ @Override
+ protected boolean isToolbarEnabled() {
+ return false;
+ }
+
public void prepareEnterAnimation() {
getFragment().prepareEnterAnimation();
}
diff --git a/src/com/android/settings/password/SetupChooseLockPassword.java b/src/com/android/settings/password/SetupChooseLockPassword.java
index e82dc94e124..25f5a348904 100644
--- a/src/com/android/settings/password/SetupChooseLockPassword.java
+++ b/src/com/android/settings/password/SetupChooseLockPassword.java
@@ -24,7 +24,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
-import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
@@ -65,8 +64,7 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
- LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
- layout.setFitsSystemWindows(false);
+ findViewById(R.id.content_parent).setFitsSystemWindows(false);
}
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index b4bd4096da1..4b46939ace3 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -226,7 +226,7 @@ public class SimSelectNotification extends BroadcastReceiver {
resultIntent.setPackage(SETTINGS_PACKAGE_NAME);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -264,7 +264,7 @@ public class SimSelectNotification extends BroadcastReceiver {
resultIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
// Notify the notification.
@@ -312,7 +312,7 @@ public class SimSelectNotification extends BroadcastReceiver {
resultIntent.putExtra(Intent.EXTRA_TEXT, "help_uri_sim_combination_warning");
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index afab8c3cf77..4467d66e76c 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -18,9 +18,9 @@ package com.android.settings.wifi.calling;
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI;
import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_URI;
-import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
import android.app.PendingIntent;
import android.content.ComponentName;
@@ -539,7 +539,8 @@ public class WifiCallingSliceHelper {
*/
public static PendingIntent getSettingsIntent(Context context) {
final Intent intent = new Intent(Settings.ACTION_SETTINGS);
- return PendingIntent.getActivity(context, 0 /* requestCode */, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */);
+ return PendingIntent.getActivity(context, 0 /* requestCode */, intent,
+ PendingIntent.FLAG_IMMUTABLE);
}
private PendingIntent getBroadcastIntent(String action) {
@@ -547,7 +548,7 @@ public class WifiCallingSliceHelper {
intent.setClass(mContext, SliceBroadcastReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
/**
@@ -557,7 +558,8 @@ public class WifiCallingSliceHelper {
final Intent intent = new Intent(action);
intent.setPackage(SETTINGS_PACKAGE_NAME);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */);
+ return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent,
+ PendingIntent.FLAG_IMMUTABLE);
}
private Resources getResourcesForSubId(int subId) {
diff --git a/tests/robotests/src/com/android/settings/accessibility/TapAssistanceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/TapAssistanceFragmentTest.java
new file mode 100644
index 00000000000..093ea0377f1
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/TapAssistanceFragmentTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settings.testutils.XmlTestUtils;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+/** Tests for {@link TapAssistanceFragment}. */
+public class TapAssistanceFragmentTest {
+
+ private Context mContext = ApplicationProvider.getApplicationContext();
+
+ @Test
+ public void getNonIndexableKeys_existInXmlLayout() {
+ final List niks = TapAssistanceFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(mContext);
+ final List keys =
+ XmlTestUtils.getKeysFromPreferenceXml(mContext, R.xml.accessibility_tap_assistance);
+
+ assertThat(keys).containsAtLeastElementsIn(niks);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
index 15e9bdaddcc..dffd7fb944a 100644
--- a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
@@ -88,14 +88,16 @@ public class PlatformCompatDashboardTest {
public void setUp() throws RemoteException, NameNotFoundException {
MockitoAnnotations.initMocks(this);
mChanges = new CompatibilityChangeInfo[5];
- mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, 0, false, false, "");
- mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, 0, true, false, "");
- mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_Since_SDK_1_1", -1, 1, false, false,
- "");
- mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_Since_SDK_1_2", -1, 1, false, false,
- "");
- mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_Since_SDK_2", -1, 2, false, false,
- "");
+ mChanges[0] = new CompatibilityChangeInfo(
+ 1L, "Default_Enabled", 0, 0, false, false, "", false);
+ mChanges[1] = new CompatibilityChangeInfo(
+ 2L, "Default_Disabled", 0, 0, true, false, "", false);
+ mChanges[2] = new CompatibilityChangeInfo(
+ 3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, "", false);
+ mChanges[3] = new CompatibilityChangeInfo(
+ 4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, "", false);
+ mChanges[4] = new CompatibilityChangeInfo(
+ 5L, "Enabled_Since_SDK_2", -1, 2, false, false, "", false);
when(mPlatformCompat.listUIChanges()).thenReturn(mChanges);
when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
// By default, allow any change
@@ -208,7 +210,8 @@ public class PlatformCompatDashboardTest {
for (int i = 0; i < mChanges.length; ++i) {
changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i].getName(),
-1, mChanges[i].getEnableSinceTargetSdk(), mChanges[i].getDisabled(),
- mChanges[i].getLoggingOnly(), mChanges[i].getDescription()));
+ mChanges[i].getLoggingOnly(), mChanges[i].getDescription(),
+ mChanges[i].getOverridable()));
}
PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd,
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
index c752eb98232..9e4877c954f 100644
--- a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
@@ -32,6 +32,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings;
+import androidx.preference.Preference;
+
import com.android.settings.R;
import org.junit.Before;
@@ -50,12 +52,14 @@ public class PreventRingingParentPreferenceControllerTest {
private Context mContext;
private PreventRingingParentPreferenceController mController;
+ private Preference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
mController = new PreventRingingParentPreferenceController(mContext, "test_key");
+ mPreference = new Preference(mContext);
}
@Test
@@ -80,17 +84,43 @@ public class PreventRingingParentPreferenceControllerTest {
public void updateState_summaryUpdated() {
Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
VOLUME_HUSH_MUTE);
- assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText(
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
R.string.prevent_ringing_option_mute_summary));
Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
VOLUME_HUSH_VIBRATE);
- assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText(
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
R.string.prevent_ringing_option_vibrate_summary));
Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
VOLUME_HUSH_OFF);
- assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getText(
- R.string.prevent_ringing_option_none_summary));
+ mController.updateState(mPreference);
+ assertThat(mPreference.getSummary()).isEqualTo(null);
+ }
+
+ @Test
+ public void isChecked_vibrate_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
+ VOLUME_HUSH_VIBRATE);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_mute_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
+ VOLUME_HUSH_MUTE);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_off_shouldReturnFalse() {
+ Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
+ VOLUME_HUSH_OFF);
+
+ assertThat(mController.isChecked()).isFalse();
}
}
diff --git a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
index d9f56debc02..eb82d31745e 100644
--- a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
@@ -20,10 +20,12 @@ package com.android.settings.panel;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
+import android.os.SystemProperties;
import com.android.settings.network.AirplaneModePreferenceController;
import com.android.settings.slices.CustomSliceRegistry;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,14 +39,25 @@ import java.util.List;
public class InternetConnectivityPanelTest {
private InternetConnectivityPanel mPanel;
+ private static final String SETTINGS_PROVIDER_MODEL =
+ "persist.sys.fflag.override.settings_provider_model";
+ private boolean mSettingsProviderModelState;
@Before
public void setUp() {
mPanel = InternetConnectivityPanel.create(RuntimeEnvironment.application);
+ mSettingsProviderModelState = SystemProperties.getBoolean(SETTINGS_PROVIDER_MODEL, false);
+ }
+
+ @After
+ public void tearDown() {
+ SystemProperties.set(SETTINGS_PROVIDER_MODEL,
+ mSettingsProviderModelState ? "true" : "false");
}
@Test
- public void getSlices_containsNecessarySlices() {
+ public void getSlices_providerModelDisabled_containsNecessarySlices() {
+ SystemProperties.set(SETTINGS_PROVIDER_MODEL, "false");
final List uris = mPanel.getSlices();
assertThat(uris).containsExactly(
@@ -53,6 +66,16 @@ public class InternetConnectivityPanelTest {
CustomSliceRegistry.WIFI_SLICE_URI);
}
+ @Test
+ public void getSlices_providerModelEnabled_containsNecessarySlices() {
+ SystemProperties.set(SETTINGS_PROVIDER_MODEL, "true");
+ final List uris = mPanel.getSlices();
+
+ assertThat(uris).containsExactly(
+ CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
+ CustomSliceRegistry.AIRPLANE_SAFE_NETWORKS_SLICE_URI);
+ }
+
@Test
public void getSeeMoreIntent_notNull() {
assertThat(mPanel.getSeeMoreIntent()).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
index 84e88cb9b4c..e08893bd823 100644
--- a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
+++ b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
@@ -59,6 +59,7 @@ import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.util.DisplayMetrics;
import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
@@ -89,6 +90,8 @@ public class SimSelectNotificationTest {
private Resources mResources;
@Mock
private SubscriptionInfo mSubInfo;
+ @Mock
+ private DisplayMetrics mDisplayMetrics;
private final String mFakeDisplayName = "fake_display_name";
private final CharSequence mFakeNotificationChannelTitle = "fake_notification_channel_title";
@@ -141,6 +144,9 @@ public class SimSelectNotificationTest {
.thenReturn(mFakeDualCdmaWarningTitle);
when(mResources.getString(R.string.dual_cdma_sim_warning_notification_summary,
mSimCombinationName)).thenReturn(mFakeDualCdmaWarningSummary);
+
+ when(mResources.getDisplayMetrics()).thenReturn(mDisplayMetrics);
+ mDisplayMetrics.density = 1.5f;
}
@Test
@@ -275,4 +281,3 @@ public class SimSelectNotificationTest {
assertThat(notification.getValue().contentIntent).isNotNull();
}
}
-
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
index 0dcf6852fad..dbe77189e8f 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
@@ -397,14 +397,15 @@ public class WifiCallingSliceHelperTest {
final Intent intent = new Intent(action);
intent.setClass(mContext, SliceBroadcastReceiver.class);
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
private PendingIntent getActivityIntent(String action) {
final Intent intent = new Intent(action);
intent.setPackage(SETTINGS_PACKAGE_NAME);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED /* flags */);
+ return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent,
+ PendingIntent.FLAG_IMMUTABLE);
}
private void assertTitle(List sliceItems, String title) {