Merge "Fix potential race in Theme creation" into oc-dev

This commit is contained in:
Adam Lesinski
2017-06-20 01:07:06 +00:00
committed by Android (Google) Code Review

View File

@@ -256,28 +256,34 @@ class ContextImpl extends Context {
@Override
public void setTheme(int resId) {
if (mThemeResource != resId) {
mThemeResource = resId;
initializeTheme();
synchronized (mSync) {
if (mThemeResource != resId) {
mThemeResource = resId;
initializeTheme();
}
}
}
@Override
public int getThemeResId() {
return mThemeResource;
synchronized (mSync) {
return mThemeResource;
}
}
@Override
public Resources.Theme getTheme() {
if (mTheme != null) {
synchronized (mSync) {
if (mTheme != null) {
return mTheme;
}
mThemeResource = Resources.selectDefaultTheme(mThemeResource,
getOuterContext().getApplicationInfo().targetSdkVersion);
initializeTheme();
return mTheme;
}
mThemeResource = Resources.selectDefaultTheme(mThemeResource,
getOuterContext().getApplicationInfo().targetSdkVersion);
initializeTheme();
return mTheme;
}
private void initializeTheme() {