diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-04-03 17:37:37 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-04-05 17:06:21 +0200 |
commit | 3beffdf4a0081a97356f46d50e10541b1a213153 (patch) | |
tree | 606d855b85568f00c4359129d164c6476f0ca1d3 /packages/SystemUI/src/com/android/systemui/SystemUIApplication.java | |
parent | 0bed7f258ba1fffc10f986ee043b769f1fd40ad3 (diff) | |
download | frameworks_base-3beffdf4a0081a97356f46d50e10541b1a213153.zip frameworks_base-3beffdf4a0081a97356f46d50e10541b1a213153.tar.gz frameworks_base-3beffdf4a0081a97356f46d50e10541b1a213153.tar.bz2 |
Fix crash when taking screenshot.
Start SystemUI services only if needed.
Bug: 13635952
Change-Id: I76a5e3333ed8f51a267e33b2cf172d6c775ac914
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/SystemUIApplication.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/SystemUIApplication.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index 8265c86..4494bb7 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -48,10 +48,20 @@ public class SystemUIApplication extends Application { * Hold a reference on the stuff we start. */ private final SystemUI[] mServices = new SystemUI[SERVICES.length]; + private boolean mServicesStarted; private final Map<Class<?>, Object> mComponents = new HashMap<Class<?>, Object>(); - @Override - public void onCreate() { + /** + * Makes sure that all the SystemUI services are running. If they are already running, this is a + * no-op. This is needed to conditinally start all the services, as we only need to have it in + * the main process. + * + * <p>This method must only be called from the main thread.</p> + */ + public void startServicesIfNeeded() { + if (mServicesStarted) { + return; + } final int N = SERVICES.length; for (int i=0; i<N; i++) { Class<?> cl = SERVICES[i]; @@ -68,13 +78,16 @@ public class SystemUIApplication extends Application { if (DEBUG) Log.d(TAG, "running: " + mServices[i]); mServices[i].start(); } + mServicesStarted = true; } @Override public void onConfigurationChanged(Configuration newConfig) { - int len = mServices.length; - for (int i = 0; i < len; i++) { - mServices[i].onConfigurationChanged(newConfig); + if (mServicesStarted) { + int len = mServices.length; + for (int i = 0; i < len; i++) { + mServices[i].onConfigurationChanged(newConfig); + } } } |