Snap for 8657279 from 46ccb94e38 to udc-release

Change-Id: I4019a84c6204b2eb2fa2aa4ba036e25b6ec616af
This commit is contained in:
Android Build Coastguard Worker
2022-05-28 05:30:59 +00:00
14 changed files with 119 additions and 43 deletions

View File

@@ -1108,10 +1108,6 @@
android:label="@string/wallpaper_settings_fragment_title"
android:icon="@drawable/ic_wallpaper"
android:exported="true">
<intent-filter>
<action android:name="android.settings.WALLPAPER_SETTINGS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
@@ -1124,15 +1120,19 @@
android:exported="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
<action android:name="android.settings.WALLPAPER_SETTINGS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.PERSONALIZE" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="com.android.settings.suggested.category.PERSONALIZE"/>
</intent-filter>
<meta-data android:name="com.android.settings.title"
android:resource="@string/wallpaper_suggestion_title" />
android:resource="@string/wallpaper_suggestion_title"/>
<meta-data android:name="com.android.settings.summary"
android:resource="@string/wallpaper_suggestion_summary" />
<meta-data android:name="com.android.settings.dismiss"

View File

@@ -21,6 +21,7 @@
<style name="GlifTheme.DayNight" parent="GlifTheme" />
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme" />
<style name="GlifV3Theme.DayNight" parent="GlifV3Theme" />
<style name="GlifV4Theme.DayNight" parent="GlifV4Theme" />
<style name="GlifV3Theme.DayNight.NoActionBar" parent="GlifV3Theme.NoActionBar" />
<style name="GlifV2Theme.DayNight.Transparent" parent="GlifV2Theme.Transparent" />
<style name="GlifV3Theme.DayNight.Transparent" parent="GlifV3Theme.Transparent" />

View File

@@ -2967,7 +2967,7 @@
<!-- Display settings screen, "QHD+" screen resolution summary [CHAR LIMIT=NONE] -->
<string name="screen_resolution_summary_highest">1440p QHD+</string>
<!-- The footer message for switch screen resolution [CHAR LIMIT=NONE] -->
<string name="screen_resolution_footer">Full resolution uses more of your battery. Switching to full resolution may cause some apps to restart.</string>
<string name="screen_resolution_footer">Full resolution uses more of your battery. Switching your resolution may cause some apps to restart.</string>
<!-- Display settings screen, Color mode settings title [CHAR LIMIT=30] -->
<string name="color_mode_title">Colors</string>

View File

@@ -133,6 +133,43 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle</item>
</style>
<style name="GlifV4Theme" parent="SudThemeGlifV4.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
<item name="wifi_friction">@drawable/wifi_friction</item>
<item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
<item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
<!-- LockPatternView colors -->
<item name="*android:lockPatternStyle">@style/LockPatternStyle</item>
</style>
<style name="GlifV4Theme.Light" parent="SudThemeGlifV4.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
<item name="side_margin">0dip</item>
<item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
<item name="wifi_signal">@drawable/wifi_signal</item>
<item name="wifi_friction">@drawable/wifi_friction</item>
<item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
<item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
<item name="*android:lockPatternStyle">@style/LockPatternStyle</item>
</style>
<style name="GlifV3Theme.Light.NoActionBar" parent="GlifV3Theme.Light">
<item name="android:windowActionBar">false</item>
</style>
@@ -238,6 +275,7 @@
<style name="GlifTheme.DayNight" parent="GlifTheme.Light" />
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme.Light" />
<style name="GlifV3Theme.DayNight" parent="GlifV3Theme.Light" />
<style name="GlifV4Theme.DayNight" parent="GlifV4Theme.Light" />
<style name="GlifV3Theme.DayNight.NoActionBar" parent="GlifV3Theme.Light.NoActionBar" />
<style name="GlifV2Theme.DayNight.Transparent" parent="GlifV2Theme.Light.Transparent" />
<style name="GlifV3Theme.DayNight.Transparent" parent="GlifV3Theme.Light.Transparent" />

View File

@@ -51,7 +51,7 @@ public class DefaultRingtonePreference extends RingtonePreference {
return;
}
String mimeType = getContext().getContentResolver().getType(ringtoneUri);
String mimeType = mUserContext.getContentResolver().getType(ringtoneUri);
if (mimeType == null) {
Log.e(TAG, "onSaveRingtone for URI:" + ringtoneUri
+ " ignored: failure to find mimeType (no access from this context?)");

View File

@@ -466,6 +466,15 @@ public class SettingsActivity extends SettingsBaseActivity
return false;
}
// If the activity's launch mode is "singleInstance", it can't be embedded in Settings since
// it will be created in a new task.
ActivityInfo info = intent.resolveActivityInfo(getPackageManager(),
PackageManager.MATCH_DEFAULT_ONLY);
if (info.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
Log.w(LOG_TAG, "launchMode: singleInstance");
return false;
}
if (intent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
// Slice deep link starts the Intent using SubSettingLauncher. Returns true to show
// 2-pane deep link.

View File

@@ -48,9 +48,9 @@ public class SetupWizardUtils {
if (WizardManagerHelper.isAnySetupWizard(intent)) {
if (ThemeHelper.isSetupWizardDayNightEnabled(context)) {
switch (theme) {
// TODO(b/233032365): Create glif v4 theme for this case.
case ThemeHelper.THEME_GLIF_V4_LIGHT:
case ThemeHelper.THEME_GLIF_V4:
return R.style.GlifV4Theme_DayNight;
case ThemeHelper.THEME_GLIF_V3_LIGHT:
case ThemeHelper.THEME_GLIF_V3:
return R.style.GlifV3Theme_DayNight;
@@ -63,11 +63,12 @@ public class SetupWizardUtils {
}
} else {
switch (theme) {
// TODO(b/233032365): Create glif v4 theme for this case.
case ThemeHelper.THEME_GLIF_V4_LIGHT:
return R.style.GlifV4Theme_Light;
case ThemeHelper.THEME_GLIF_V4:
return R.style.GlifV4Theme;
case ThemeHelper.THEME_GLIF_V3_LIGHT:
return R.style.GlifV3Theme_Light;
case ThemeHelper.THEME_GLIF_V4:
case ThemeHelper.THEME_GLIF_V3:
return R.style.GlifV3Theme;
case ThemeHelper.THEME_GLIF_V2_LIGHT:
@@ -82,9 +83,9 @@ public class SetupWizardUtils {
}
} else {
switch (theme) {
// TODO(b/233032365): Create glif v4 theme for this case.
case ThemeHelper.THEME_GLIF_V4_LIGHT:
case ThemeHelper.THEME_GLIF_V4:
return R.style.GlifV4Theme;
case ThemeHelper.THEME_GLIF_V3_LIGHT:
case ThemeHelper.THEME_GLIF_V3:
return R.style.GlifV3Theme;

View File

@@ -33,13 +33,9 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.permission.PermissionControllerManager;
import android.provider.DeviceConfig;
import android.text.TextUtils;
import android.util.Slog;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
@@ -49,8 +45,7 @@ import com.google.common.annotations.VisibleForTesting;
* A PreferenceController handling the logic for exempting hibernation of app
*/
public final class HibernationSwitchPreferenceController extends AppInfoPreferenceControllerBase
implements LifecycleObserver, AppOpsManager.OnOpChangedListener,
Preference.OnPreferenceChangeListener {
implements Preference.OnPreferenceChangeListener {
private static final String TAG = "HibernationSwitchPrefController";
private String mPackageName;
private final AppOpsManager mAppOpsManager;
@@ -69,19 +64,6 @@ public final class HibernationSwitchPreferenceController extends AppInfoPreferen
mPermissionControllerManager = context.getSystemService(PermissionControllerManager.class);
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
if (mIsPackageSet) {
mAppOpsManager.startWatchingMode(
OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED, mPackageName, this);
}
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void onPause() {
mAppOpsManager.stopWatchingMode(this);
}
@Override
public int getAvailabilityStatus() {
return isHibernationEnabled() && mIsPackageSet ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
@@ -148,14 +130,6 @@ public final class HibernationSwitchPreferenceController extends AppInfoPreferen
return mode == MODE_DEFAULT ? mIsPackageExemptByDefault : mode != MODE_ALLOWED;
}
@Override
public void onOpChanged(String op, String packageName) {
if (OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED.equals(op)
&& TextUtils.equals(mPackageName, packageName)) {
updateState(mPreference);
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object isChecked) {
try {

View File

@@ -40,6 +40,8 @@ import androidx.loader.content.Loader;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceCategory;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
import com.android.settings.applications.AppInfoBase;
@@ -105,6 +107,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
private Context mContext;
private ArrayList<Long> mCycles;
private long mSelectedCycle;
private boolean mIsLoading;
@Override
public void onCreate(Bundle icicle) {
@@ -226,6 +229,16 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
@Override
public void onResume() {
super.onResume();
// No animations will occur before:
// - LOADER_APP_USAGE_DATA initially updates the cycle
// - updatePrefs() initially updates the preference visibility
// This is mainly for the cycle spinner, because when the page is entered from the
// AppInfoDashboardFragment, there is no way to know whether the cycle data is available
// before finished the async loading.
// The animator will be set back if any page updates happens after loading, in
// setBackPreferenceListAnimatorIfLoaded().
mIsLoading = true;
getListView().setItemAnimator(null);
if (mDataSaverBackend != null) {
mDataSaverBackend.addListener(this);
}
@@ -297,7 +310,25 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
}
}
/**
* Sets back the preference list's animator if the loading is finished.
*
* The preference list's animator was temporarily removed before loading in onResume().
* When need to update the preference visibility in this page after the loading, adding the
* animator back to keeping the usual animations.
*/
private void setBackPreferenceListAnimatorIfLoaded() {
if (mIsLoading) {
return;
}
RecyclerView recyclerView = getListView();
if (recyclerView.getItemAnimator() == null) {
recyclerView.setItemAnimator(new DefaultItemAnimator());
}
}
private void updatePrefs(boolean restrictBackground, boolean unrestrictData) {
setBackPreferenceListAnimatorIfLoaded();
final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMeteredDataRestricted(
mContext, mPackageName, UserHandle.getUserId(mAppItem.key));
if (mRestrictBackground != null) {
@@ -448,6 +479,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
} else {
bindData(0 /* position */);
}
mIsLoading = false;
}
@Override

View File

@@ -20,6 +20,7 @@ import android.widget.ProgressBar;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settingslib.AppItem;
import com.android.settingslib.net.UidDetail;
import com.android.settingslib.net.UidDetailProvider;
@@ -49,6 +50,9 @@ public class AppDataUsagePreference extends AppPreference {
if (mDetail != null) {
setAppInfo();
} else {
// Set a placeholder title before starting to fetch real title, this is necessary
// to avoid preference height change.
setTitle(R.string.summary_placeholder);
ThreadUtils.postOnBackgroundThread(() -> {
mDetail = provider.getUidDetail(mItem.key, true /* blocking */);
ThreadUtils.postOnMainThread(() -> setAppInfo());

View File

@@ -193,7 +193,7 @@ public class UiccSlotUtil {
if (slotInfo == null) {
return false;
}
return !slotInfo.isRemovable();
return slotInfo.getIsEuicc();
})
.findFirst().orElse(-1);

View File

@@ -48,6 +48,7 @@ import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -240,6 +241,7 @@ public class AppDataUsageTest {
ReflectionHelpers.setField(mFragment, "mUnrestrictedData", unrestrictedDataPref);
ReflectionHelpers.setField(mFragment, "mDataSaverBackend", dataSaverBackend);
ReflectionHelpers.setField(mFragment.services, "mPolicyManager", networkPolicyManager);
when(mFragment.getListView()).thenReturn(mock(RecyclerView.class));
ShadowRestrictedLockUtilsInternal.setRestricted(true);
doReturn(NetworkPolicyManager.POLICY_NONE).when(networkPolicyManager)

View File

@@ -59,6 +59,7 @@ public class DefaultRingtonePreferenceTest {
when(mDefaultRingtonePreference.getRingtoneType())
.thenReturn(RingtoneManager.TYPE_RINGTONE);
mDefaultRingtonePreference.setUserId(1);
mDefaultRingtonePreference.mUserContext = context;
}
@Test

View File

@@ -92,6 +92,14 @@ public class UiccSlotUtilTest {
assertThat(testSlot).isEqualTo(0);
}
@Test
public void getEsimSlotId_twoSimSlotsDeviceAndRemovableEsimIsSlot1_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
twoSimSlotsDeviceActivePsimActiveRemovableEsim());
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
assertThat(testSlot).isEqualTo(1);
}
@Test
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
@@ -729,6 +737,12 @@ public class UiccSlotUtilTest {
createUiccSlotInfo(true, false, 1, true)};
}
private UiccSlotInfo[] twoSimSlotsDeviceActivePsimActiveRemovableEsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(false, true, 0, true),
createUiccSlotInfo(true, true, 1, true)};
}
private UiccSlotInfo[] twoSimSlotsDeviceActiveEsimActivePsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(true, false, 0, true),