summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2016-03-30 23:03:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-03-30 23:03:18 +0000
commit7d4ed2f5aba19a6b1efb7dc0772f7debfa8a7299 (patch)
tree4f997e5a676a3f61517db29026415935073a3913 /core/java
parent69fccd629b3eac9b692ab2699aeaaa0f04f14e6d (diff)
parent0ad9ab07fa0a106e55a423c837d306327045befe (diff)
Merge "Avoid null app context in StaticApplicationContextServiceFetcher." into nyc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/SystemServiceRegistry.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 2987fbc4f33d..bdc4404057e5 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -882,7 +882,12 @@ final class SystemServiceRegistry {
public final T getService(ContextImpl ctx) {
synchronized (StaticApplicationContextServiceFetcher.this) {
if (mCachedInstance == null) {
- mCachedInstance = createService(ctx.getApplicationContext());
+ Context appContext = ctx.getApplicationContext();
+ // If the application context is null, we're either in the system process or
+ // it's the application context very early in app initialization. In both these
+ // cases, the passed-in ContextImpl will not be freed, so it's safe to pass it
+ // to the service. http://b/27532714 .
+ mCachedInstance = createService(appContext != null ? appContext : ctx);
}
return mCachedInstance;
}