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

Commit 8a362bb9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix mStringBlocks race in the AssetManager"

parents 82449894 22723ffa
Loading
Loading
Loading
Loading
+29 −23
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ public final class AssetManager implements AutoCloseable {
     */
    final boolean getResourceValue(@AnyRes int resId, int densityDpi, @NonNull TypedValue outValue,
            boolean resolveRefs) {
        synchronized (this) {
            final int block = loadResourceValue(resId, (short) densityDpi, outValue, resolveRefs);
            if (block < 0) {
                return false;
@@ -236,6 +237,7 @@ public final class AssetManager implements AutoCloseable {
            }
            return true;
        }
    }

    /**
     * Retrieve the text array associated with a particular resource
@@ -244,6 +246,7 @@ public final class AssetManager implements AutoCloseable {
     * @param resId the resource id of the string array
     */
    final CharSequence[] getResourceTextArray(@ArrayRes int resId) {
        synchronized (this) {
            final int[] rawInfoArray = getArrayStringInfo(resId);
            final int rawInfoArrayLen = rawInfoArray.length;
            final int infoArrayLen = rawInfoArrayLen / 2;
@@ -257,6 +260,7 @@ public final class AssetManager implements AutoCloseable {
            }
            return retArray;
        }
    }

    /**
     * Populates {@code outValue} with the data associated with a particular
@@ -320,9 +324,11 @@ public final class AssetManager implements AutoCloseable {
    }

    /*package*/ final CharSequence getPooledStringForCookie(int cookie, int id) {
        synchronized (this) {
            // Cookies map to string blocks starting at 1.
            return mStringBlocks[cookie - 1].get(id);
        }
    }

    /**
     * Open an asset using ACCESS_STREAMING mode.  This provides access to