AssetManager: use locking

This commit is contained in:
Mis012
2025-03-05 17:29:27 +01:00
parent 74f2e9f308
commit 2e9099baed
3 changed files with 79 additions and 20 deletions

View File

@@ -709,12 +709,12 @@ public final class AssetManager {
/*package*/ static final int STYLE_DENSITY = 5;
/*package*/ static final int STYLE_SOURCE_RESOURCE_ID = 6;
/*package*/ native static final void applyStyle(long theme, long parser,
/*package*/ native final void applyStyle(long theme, long parser,
int defStyleAttr, int defStyleRes,
int[] inAttrs, int length,
long outValuesAddress, long outIndicesAddress);
/*package*/ native static final boolean resolveAttrs(long theme, int defStyleAttr,
/*package*/ native final boolean resolveAttrs(long theme, int defStyleAttr,
int defStyleRes, int[] inValues,
int[] inAttrs, int[] outValues,
int[] outIndices);
@@ -749,8 +749,8 @@ public final class AssetManager {
private native final long newTheme();
private native final void deleteTheme(long theme);
/*package*/ native static final void applyThemeStyle(long theme, int styleRes, boolean force);
/*package*/ native static final void copyTheme(long dest, long source);
/*package*/ native final void applyThemeStyle(long theme, int styleRes, boolean force);
/*package*/ native final void copyTheme(long dest, long source);
/*package*/ native final int loadThemeAttributeValue(long theme, int ident,
TypedValue outValue,
boolean resolve);

View File

@@ -1246,7 +1246,7 @@ public class Resources {
* @param other The existing Theme to copy from.
*/
public void setTo(Theme other) {
AssetManager.copyTheme(this.theme, other.theme);
getAssets().copyTheme(this.theme, other.theme);
}
/**
@@ -1355,7 +1355,7 @@ public class Resources {
// out the attributes from the XML file (applying type information
// contained in the resources and such).
XmlResourceParser parser = (XmlResourceParser)set;
AssetManager.applyStyle(theme, set != null ? ((XmlBlock.Parser)set).mParseState : 0,
getAssets().applyStyle(theme, set != null ? ((XmlBlock.Parser)set).mParseState : 0,
defStyleAttr, defStyleRes,
attrs, attrs.length, array.mDataAddress, array.mIndicesAddress);
array.mRsrcs = attrs;
@@ -1418,7 +1418,7 @@ public class Resources {
}
final TypedArray array = TypedArray.obtain(Resources.this, len);
AssetManager.resolveAttrs(theme, 0, 0, values, attrs, array.mData, array.mIndices);
getAssets().resolveAttrs(theme, 0, 0, values, attrs, array.mData, array.mIndices);
array.mTheme = this;
array.mXml = null;