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

Commit cb0f0d60 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce a count for registered shared library on ResourcesImpl to...

Merge "Introduce a count for registered shared library on ResourcesImpl to help to fix gmail crash." into main
parents 96808aa1 355d7cd8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -736,7 +736,8 @@ public class ResourcesManager {
    private @Nullable ResourcesImpl findOrCreateResourcesImplForKeyLocked(
            @NonNull ResourcesKey key, @Nullable ApkAssetsSupplier apkSupplier) {
        ResourcesImpl impl = findResourcesImplForKeyLocked(key);
        if (impl == null) {
        // ResourcesImpl also need to be recreated if its shared library count is not up-to-date.
        if (impl == null || impl.getSharedLibCount() != mSharedLibAssetsMap.size()) {
            impl = createResourcesImpl(key, apkSupplier);
            if (impl != null) {
                mResourceImpls.put(key, new WeakReference<>(impl));
+10 −0
Original line number Diff line number Diff line
@@ -146,6 +146,11 @@ public class ResourcesImpl {

    // Cyclical cache used for recently-accessed XML files.
    private int mLastCachedXmlBlockIndex = -1;

    // The number of shared libraries registered within this ResourcesImpl, which is designed to
    // help to determine whether this ResourcesImpl is outdated on shared library information and
    // needs to be replaced.
    private int mSharedLibCount;
    private final int[] mCachedXmlBlockCookies = new int[XML_BLOCK_CACHE_SIZE];
    private final String[] mCachedXmlBlockFiles = new String[XML_BLOCK_CACHE_SIZE];
    private final XmlBlock[] mCachedXmlBlocks = new XmlBlock[XML_BLOCK_CACHE_SIZE];
@@ -206,6 +211,7 @@ public class ResourcesImpl {
            for (int i = 0; i < size; i++) {
                assets.addSharedLibraryPaths(sharedLibMap.valueAt(i).getAllAssetPaths());
            }
            mSharedLibCount = sharedLibMap.size();
        }
        mMetrics.setToDefaults();
        mDisplayAdjustments = displayAdjustments;
@@ -1602,4 +1608,8 @@ public class ResourcesImpl {
            mSize--;
        }
    }

    public int getSharedLibCount() {
        return mSharedLibCount;
    }
}