Follow config overlay's order of aspect ratio options
Fix flaky UserAspectRatioAppsPageProviderTest by using advanceUntilIdle to make sure all coroutines are finished before asserting. Bug: 325911424 Test: atest UserAspectRatioDetailsTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:32815ad699448c5c5b1f38df6d2d2a881d4251c1) Merged-In: I83e9a7f31536c1a006789722b0310f3364d14337 Change-Id: I83e9a7f31536c1a006789722b0310f3364d14337
This commit is contained in:
committed by
Cherrypicker Worker
parent
a6f283382a
commit
a0f573a35e
@@ -66,7 +66,8 @@ public class UserAspectRatioDetails extends AppInfoBase implements
|
||||
private static final String TAG = UserAspectRatioDetails.class.getSimpleName();
|
||||
|
||||
private static final String KEY_HEADER_SUMMARY = "app_aspect_ratio_summary";
|
||||
private static final String KEY_HEADER_BUTTONS = "header_view";
|
||||
@VisibleForTesting
|
||||
static final String KEY_HEADER_BUTTONS = "header_view";
|
||||
|
||||
private static final String KEY_PREF_HALF_SCREEN = "half_screen_pref";
|
||||
private static final String KEY_PREF_DISPLAY_SIZE = "display_size_pref";
|
||||
@@ -237,6 +238,7 @@ public class UserAspectRatioDetails extends AppInfoBase implements
|
||||
return;
|
||||
}
|
||||
pref.setTitle(mUserAspectRatioManager.getAccessibleEntry(aspectRatio, mPackageName));
|
||||
pref.setOrder(getAspectRatioManager().getUserMinAspectRatioOrder(aspectRatio));
|
||||
pref.setOnClickListener(this);
|
||||
mKeyToAspectRatioMap.put(key, aspectRatio);
|
||||
mAspectRatioPreferences.add(pref);
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -76,6 +77,7 @@ public class UserAspectRatioManager {
|
||||
/** Apps that have launcher entry defined in manifest */
|
||||
private final Map<Integer, String> mUserAspectRatioMap;
|
||||
private final Map<Integer, CharSequence> mUserAspectRatioA11yMap;
|
||||
private final SparseIntArray mUserAspectRatioOrder;
|
||||
|
||||
public UserAspectRatioManager(@NonNull Context context) {
|
||||
this(context, AppGlobals.getPackageManager());
|
||||
@@ -86,6 +88,7 @@ public class UserAspectRatioManager {
|
||||
mContext = context;
|
||||
mIPm = pm;
|
||||
mUserAspectRatioA11yMap = new ArrayMap<>();
|
||||
mUserAspectRatioOrder = new SparseIntArray();
|
||||
mUserAspectRatioMap = getUserMinAspectRatioMapping();
|
||||
}
|
||||
|
||||
@@ -152,6 +155,14 @@ public class UserAspectRatioManager {
|
||||
return getUserMinAspectRatioEntry(aspectRatio, packageName, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the order of the aspect ratio option corresponding to
|
||||
* config_userAspectRatioOverrideValues
|
||||
*/
|
||||
int getUserMinAspectRatioOrder(@PackageManager.UserMinAspectRatio int option) {
|
||||
return mUserAspectRatioOrder.get(option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether user aspect ratio option is specified in
|
||||
* {@link R.array.config_userAspectRatioOverrideValues}
|
||||
@@ -224,7 +235,6 @@ public class UserAspectRatioManager {
|
||||
&& isFullscreenCompatChangeEnabled(pkgName, userId);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isFullscreenCompatChangeEnabled(String pkgName, int userId) {
|
||||
return CompatChanges.isChangeEnabled(
|
||||
OVERRIDE_ANY_ORIENTATION_TO_USER, pkgName, UserHandle.of(userId));
|
||||
@@ -281,6 +291,7 @@ public class UserAspectRatioManager {
|
||||
mUserAspectRatioA11yMap.put(aspectRatioVal, accessibleSequence);
|
||||
}
|
||||
userMinAspectRatioMap.put(aspectRatioVal, aspectRatioString);
|
||||
mUserAspectRatioOrder.put(aspectRatioVal, i);
|
||||
}
|
||||
}
|
||||
if (!userMinAspectRatioMap.containsKey(USER_MIN_ASPECT_RATIO_UNSET)) {
|
||||
@@ -290,6 +301,8 @@ public class UserAspectRatioManager {
|
||||
if (mIsUserMinAspectRatioAppDefaultFlagEnabled) {
|
||||
userMinAspectRatioMap.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
||||
userMinAspectRatioMap.get(USER_MIN_ASPECT_RATIO_UNSET));
|
||||
mUserAspectRatioOrder.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
||||
mUserAspectRatioOrder.get(USER_MIN_ASPECT_RATIO_UNSET));
|
||||
if (mUserAspectRatioA11yMap.containsKey(USER_MIN_ASPECT_RATIO_UNSET)) {
|
||||
mUserAspectRatioA11yMap.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
||||
mUserAspectRatioA11yMap.get(USER_MIN_ASPECT_RATIO_UNSET));
|
||||
|
||||
@@ -62,6 +62,7 @@ import com.android.settingslib.spaprivileged.template.app.AppListItem
|
||||
import com.android.settingslib.spaprivileged.template.app.AppListItemModel
|
||||
import com.android.settingslib.spaprivileged.template.app.AppListPage
|
||||
import com.google.common.annotations.VisibleForTesting
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
@@ -130,8 +131,10 @@ data class UserAspectRatioAppListItemModel(
|
||||
val canDisplay: Boolean,
|
||||
) : AppRecord
|
||||
|
||||
class UserAspectRatioAppListModel(private val context: Context)
|
||||
: AppListModel<UserAspectRatioAppListItemModel> {
|
||||
class UserAspectRatioAppListModel(
|
||||
private val context: Context,
|
||||
private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO
|
||||
) : AppListModel<UserAspectRatioAppListItemModel> {
|
||||
|
||||
private val packageManager = context.packageManager
|
||||
private val userAspectRatioManager = UserAspectRatioManager(context)
|
||||
@@ -203,7 +206,7 @@ class UserAspectRatioAppListModel(private val context: Context)
|
||||
flow {
|
||||
emit(userAspectRatioManager.getUserMinAspectRatioEntry(record.userOverride,
|
||||
record.app.packageName, record.app.userId))
|
||||
}.flowOn(Dispatchers.IO)
|
||||
}.flowOn(ioDispatcher)
|
||||
}.collectAsStateWithLifecycle(initialValue = stringResource(R.string.summary_placeholder))
|
||||
return { summary }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user