Fixing MainThreadInitializedObject
> Making SafeCloseable implementation mandatory, to prevent leaks during test and preview > Removing getNoCreate method and defining executeIfCreated to avoid null pointer exceptions > Fixing sandbox value leaking into main, by Checking sandbox against App context > Converting sanbox to an interface instead a class Bug: 335280439 Test: Presubmit Flag: None Change-Id: I951dcde871898e745ff6490a1c4f8fd1512888f5
This commit is contained in:
@@ -33,7 +33,8 @@ import com.android.systemui.plugins.ResourceProvider;
|
||||
*
|
||||
* To allow customization for a particular resource, add them to dynamic_resources.xml
|
||||
*/
|
||||
public class DynamicResource implements ResourceProvider, PluginListener<ResourceProvider> {
|
||||
public class DynamicResource implements
|
||||
ResourceProvider, PluginListener<ResourceProvider>, SafeCloseable {
|
||||
|
||||
private static final MainThreadInitializedObject<DynamicResource> INSTANCE =
|
||||
new MainThreadInitializedObject<>(DynamicResource::new);
|
||||
@@ -47,6 +48,11 @@ public class DynamicResource implements ResourceProvider, PluginListener<Resourc
|
||||
ResourceProvider.class, false /* allowedMultiple */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
PluginManagerWrapper.INSTANCE.get(mContext).removePluginListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(@IntegerRes int resId) {
|
||||
return mContext.getResources().getInteger(resId);
|
||||
|
||||
Reference in New Issue
Block a user