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

am: b0a5fd0384

Change-Id: I964d23b0daad2326989ece5f8ffc086b6286cb44
This commit is contained in:
Adam Lesinski
2017-06-20 01:11:19 +00:00
committed by android-build-merger

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() {