Loading core/java/android/app/ContextImpl.java +0 −25 Original line number Diff line number Diff line Loading @@ -340,14 +340,6 @@ class ContextImpl extends Context { @ContextType private int mContextType; /** * {@code true} to indicate that the {@link Context} owns the {@link #getWindowContextToken()} * and is responsible for detaching the token when the Context is released. * * @see #finalize() */ private boolean mOwnsToken = false; private final Object mDatabasesDirLock = new Object(); @GuardedBy("mDatabasesDirLock") private File mDatabasesDir; Loading Loading @@ -3423,22 +3415,6 @@ class ContextImpl extends Context { mContentCaptureOptions = options; } @Override protected void finalize() throws Throwable { // If mToken is a WindowTokenClient, the Context is usually associated with a // WindowContainer. We should detach from WindowContainer when the Context is finalized // if this Context is not a WindowContext. WindowContext finalization is handled in // WindowContext class. try { if (mToken instanceof WindowTokenClient && mOwnsToken) { WindowTokenClientController.getInstance() .detachIfNeeded((WindowTokenClient) mToken); } } finally { super.finalize(); } } @UnsupportedAppUsage static ContextImpl createSystemContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); Loading Loading @@ -3473,7 +3449,6 @@ class ContextImpl extends Context { // Step 3. Associate the SystemUiContext with the display specified with ID. WindowTokenClientController.getInstance().attachToDisplayContent(token, displayId); context.mContextType = CONTEXT_TYPE_SYSTEM_OR_SYSTEM_UI; context.mOwnsToken = true; return systemUiContext; } Loading core/java/android/window/SystemUiContext.java +14 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.res.Configuration; import java.util.Objects; /** * System Context to be used for UI. This Context has resources that can be themed. * Loading Loading @@ -60,4 +62,16 @@ public class SystemUiContext extends ContextWrapper implements ConfigurationDisp // We should report all config changes to update fields obtained from resources. return true; } @Override protected void finalize() throws Throwable { // We should detach from WindowContainer when the Context is finalized since SystemUiContext // associates the DisplayContent with #getDisplayId(). try { final WindowTokenClient token = (WindowTokenClient) getWindowContextToken(); WindowTokenClientController.getInstance().detachIfNeeded(Objects.requireNonNull(token)); } finally { super.finalize(); } } } Loading
core/java/android/app/ContextImpl.java +0 −25 Original line number Diff line number Diff line Loading @@ -340,14 +340,6 @@ class ContextImpl extends Context { @ContextType private int mContextType; /** * {@code true} to indicate that the {@link Context} owns the {@link #getWindowContextToken()} * and is responsible for detaching the token when the Context is released. * * @see #finalize() */ private boolean mOwnsToken = false; private final Object mDatabasesDirLock = new Object(); @GuardedBy("mDatabasesDirLock") private File mDatabasesDir; Loading Loading @@ -3423,22 +3415,6 @@ class ContextImpl extends Context { mContentCaptureOptions = options; } @Override protected void finalize() throws Throwable { // If mToken is a WindowTokenClient, the Context is usually associated with a // WindowContainer. We should detach from WindowContainer when the Context is finalized // if this Context is not a WindowContext. WindowContext finalization is handled in // WindowContext class. try { if (mToken instanceof WindowTokenClient && mOwnsToken) { WindowTokenClientController.getInstance() .detachIfNeeded((WindowTokenClient) mToken); } } finally { super.finalize(); } } @UnsupportedAppUsage static ContextImpl createSystemContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); Loading Loading @@ -3473,7 +3449,6 @@ class ContextImpl extends Context { // Step 3. Associate the SystemUiContext with the display specified with ID. WindowTokenClientController.getInstance().attachToDisplayContent(token, displayId); context.mContextType = CONTEXT_TYPE_SYSTEM_OR_SYSTEM_UI; context.mOwnsToken = true; return systemUiContext; } Loading
core/java/android/window/SystemUiContext.java +14 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.res.Configuration; import java.util.Objects; /** * System Context to be used for UI. This Context has resources that can be themed. * Loading Loading @@ -60,4 +62,16 @@ public class SystemUiContext extends ContextWrapper implements ConfigurationDisp // We should report all config changes to update fields obtained from resources. return true; } @Override protected void finalize() throws Throwable { // We should detach from WindowContainer when the Context is finalized since SystemUiContext // associates the DisplayContent with #getDisplayId(). try { final WindowTokenClient token = (WindowTokenClient) getWindowContextToken(); WindowTokenClientController.getInstance().detachIfNeeded(Objects.requireNonNull(token)); } finally { super.finalize(); } } }