Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 777d2424 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Pass full SDK version (w/ minor) to AssetManager"

This reverts commit 06fee9d5.

Reason for revert: Droidmonitor created revert due to b/411172424. Will be verifying via ABTD before submission.

Bug: 383177182
Change-Id: I17ab5d79a586025ae293c3e8a1a54cc49f246c09
parent 06fee9d5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1457,7 +1457,7 @@ public class PackageParser {
    private static AssetManager newConfiguredAssetManager() {
        AssetManager assetManager = new AssetManager();
        assetManager.setConfiguration(0, 0, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, Build.VERSION.RESOURCES_SDK_INT_FULL);
                0, 0, 0, Build.VERSION.RESOURCES_SDK_INT);
        return assetManager;
    }

@@ -9017,7 +9017,7 @@ public class PackageParser {

            AssetManager assets = new AssetManager();
            assets.setConfiguration(0, 0, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, Build.VERSION.RESOURCES_SDK_INT_FULL);
                    0, 0, 0, Build.VERSION.RESOURCES_SDK_INT);
            assets.setApkAssets(apkAssets, false /*invalidateCaches*/);

            mCachedAssetManager = assets;
@@ -9092,7 +9092,7 @@ public class PackageParser {
        private static AssetManager createAssetManagerWithAssets(ApkAssets[] apkAssets) {
            final AssetManager assets = new AssetManager();
            assets.setConfiguration(0, 0, null, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, Build.VERSION.RESOURCES_SDK_INT_FULL);
                    0, 0, 0, Build.VERSION.RESOURCES_SDK_INT);
            assets.setApkAssets(apkAssets, false /*invalidateCaches*/);
            return assets;
        }
+28 −10
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.content.res;

import static android.app.ResourcesManager.ApkKey;
import static android.content.res.Flags.resourcesMinorVersionSupport;
import static android.content.res.Resources.ID_NULL;

import android.annotation.AnyRes;
@@ -34,7 +33,6 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration.NativeConfig;
import android.content.res.loader.ResourcesLoader;
import android.os.Build;
import android.os.Build.SdkIntFull;
import android.os.ParcelFileDescriptor;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.ravenwood.annotation.RavenwoodReplace;
@@ -1575,15 +1573,38 @@ public final class AssetManager implements AutoCloseable {
     * @hide
     */
    @UnsupportedAppUsage
    public void setConfiguration(int mcc, int mnc, @Nullable String locale, int orientation,
            int touchscreen, int density, int keyboard, int keyboardHidden, int navigation,
            int screenWidth, int screenHeight, int smallestScreenWidthDp, int screenWidthDp,
            int screenHeightDp, int screenLayout, int uiMode, int colorMode, int grammaticalGender,
            int majorVersion) {
        if (locale != null) {
            setConfiguration(mcc, mnc, null, new String[]{locale}, orientation, touchscreen,
                    density, keyboard, keyboardHidden, navigation, screenWidth, screenHeight,
                    smallestScreenWidthDp, screenWidthDp, screenHeightDp, screenLayout, uiMode,
                    colorMode, grammaticalGender, majorVersion);
        } else {
            setConfiguration(mcc, mnc, null, null, orientation, touchscreen, density,
                    keyboard, keyboardHidden, navigation, screenWidth, screenHeight,
                    smallestScreenWidthDp, screenWidthDp, screenHeightDp, screenLayout, uiMode,
                    colorMode, grammaticalGender, majorVersion);
        }
    }

    /**
     * Change the configuration used when retrieving resources.  Not for use by
     * applications.
     * @hide
     */
    public void setConfiguration(int mcc, int mnc, String defaultLocale, String[] locales,
            int orientation, int touchscreen, int density, int keyboard, int keyboardHidden,
            int navigation, int screenWidth, int screenHeight, int smallestScreenWidthDp,
            int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode, int colorMode,
            int grammaticalGender, @SdkIntFull int sdkVersionFull) {
            int grammaticalGender, int majorVersion) {
        setConfigurationInternal(mcc, mnc, defaultLocale, locales, orientation,
                touchscreen, density, keyboard, keyboardHidden, navigation, screenWidth,
                screenHeight, smallestScreenWidthDp, screenWidthDp, screenHeightDp,
                screenLayout, uiMode, colorMode, grammaticalGender, sdkVersionFull, false);
                screenLayout, uiMode, colorMode, grammaticalGender, majorVersion, false);
    }

    /**
@@ -1595,16 +1616,13 @@ public final class AssetManager implements AutoCloseable {
            int orientation, int touchscreen, int density, int keyboard, int keyboardHidden,
            int navigation, int screenWidth, int screenHeight, int smallestScreenWidthDp,
            int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode, int colorMode,
            int grammaticalGender, @SdkIntFull int sdkVersionFull, boolean forceRefresh) {
            int grammaticalGender, int majorVersion, boolean forceRefresh) {
        synchronized (this) {
            ensureValidLocked();
            final int majorVersion = Build.getMajorSdkVersion(sdkVersionFull);
            final int minorVersion = resourcesMinorVersionSupport()
                    ? Build.getMinorSdkVersion(sdkVersionFull) : 0;
            nativeSetConfiguration(mObject, mcc, mnc, defaultLocale, locales, orientation,
                    touchscreen, density, keyboard, keyboardHidden, navigation, screenWidth,
                    screenHeight, smallestScreenWidthDp, screenWidthDp, screenHeightDp,
                    screenLayout, uiMode, colorMode, grammaticalGender, majorVersion, minorVersion,
                    screenLayout, uiMode, colorMode, grammaticalGender, majorVersion,
                    forceRefresh);
        }
    }
@@ -1718,7 +1736,7 @@ public final class AssetManager implements AutoCloseable {
            int touchscreen, int density, int keyboard, int keyboardHidden, int navigation,
            int screenWidth, int screenHeight, int smallestScreenWidthDp, int screenWidthDp,
            int screenHeightDp, int screenLayout, int uiMode, int colorMode, int grammaticalGender,
            int majorVersion, int minorVersion, boolean forceRefresh);
            int majorVersion, boolean forceRefresh);
    private static native void nativeSetOverlayConstraints(long ptr, int displayId, int deviceId);
    private static native @NonNull SparseArray<String> nativeGetAssignedPackageIdentifiers(
            long ptr, boolean includeOverlays, boolean includeLoaders);
+4 −19
Original line number Diff line number Diff line
@@ -229,8 +229,7 @@ public class ResourcesImpl {
        mMetrics.setToDefaults();
        mDisplayAdjustments = displayAdjustments;
        mConfiguration.setToDefaults();
        updateConfigurationImpl(config, metrics, displayAdjustments.getCompatibilityInfo(), true,
                Build.VERSION.RESOURCES_SDK_INT_FULL);
        updateConfigurationImpl(config, metrics, displayAdjustments.getCompatibilityInfo(), true);
    }

    /**
@@ -452,27 +451,13 @@ public class ResourcesImpl {
        return mStateListAnimatorCache;
    }

    /**
     * Set the SDK version used for resource lookup. Not for use outside of tests.
     *
     * @param sdkVersionFull The SDK version, with minor version encoded
     */
    @VisibleForTesting
    public void updateResourcesSdkVersion(int sdkVersionFull) {
        Configuration config = new Configuration();
        config.setTo(mConfiguration);
        updateConfigurationImpl(config, null, null, true, sdkVersionFull);
    }

    public void updateConfiguration(Configuration config, DisplayMetrics metrics,
            CompatibilityInfo compat) {
        updateConfigurationImpl(config, metrics, compat, false,
                Build.VERSION.RESOURCES_SDK_INT_FULL);
        updateConfigurationImpl(config, metrics, compat, false);
    }

    private void updateConfigurationImpl(Configuration config, DisplayMetrics metrics,
                                         CompatibilityInfo compat, boolean forceAssetsRefresh,
                                         int sdkVersionFull) {
                                    CompatibilityInfo compat, boolean forceAssetsRefresh) {
        Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "ResourcesImpl#updateConfiguration");
        try {
            synchronized (mAccessLock) {
@@ -613,7 +598,7 @@ public class ResourcesImpl {
                        mConfiguration.screenWidthDp, mConfiguration.screenHeightDp,
                        mConfiguration.screenLayout, mConfiguration.uiMode,
                        mConfiguration.colorMode, mConfiguration.getGrammaticalGender(),
                        sdkVersionFull, forceAssetsRefresh);
                        Build.VERSION.RESOURCES_SDK_INT, forceAssetsRefresh);

                if (DEBUG_CONFIG) {
                    Slog.i(TAG, "**** Updating config of " + this + ": final config is "
+0 −9
Original line number Diff line number Diff line
@@ -533,15 +533,6 @@ public class Build {
        @TestApi
        public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length;

        /**
         * The SDK version to use when accessing resources, with minor version encoded.
         * Use the current SDK version code.  For every active development codename
         * we are operating under, we bump the assumed resource platform major version by 1.
         * @hide
         */
        public static final int RESOURCES_SDK_INT_FULL = SDK_INT_FULL
                + (ACTIVE_CODENAMES.length * VERSION_CODES_FULL.SDK_INT_MULTIPLIER);

        /**
         * The current lowest supported value of app target SDK. Applications targeting
         * lower values may not function on devices running this SDK version. Its possible
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public class DefaultSplitAssetLoader implements SplitAssetLoader {

        AssetManager assets = new AssetManager();
        assets.setConfiguration(0, 0, null, new String[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, Build.VERSION.RESOURCES_SDK_INT_FULL);
                0, 0, Build.VERSION.RESOURCES_SDK_INT);
        assets.setApkAssets(apkAssets, false /*invalidateCaches*/);

        mCachedAssetManager = assets;
Loading