FileDocCategorySizeDatePackage
SystemUIApplication.javaAPI DocAndroid 5.1 API5268Thu Mar 12 22:22:42 GMT 2015com.android.systemui

SystemUIApplication

public class SystemUIApplication extends android.app.Application
Application class for SystemUI.

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
private final Class[]
SERVICES
The classes of the stuff to start.
private final SystemUI[]
mServices
Hold a reference on the stuff we start.
private boolean
mServicesStarted
private boolean
mBootCompleted
private final Map
mComponents
Constructors Summary
Methods Summary
public TgetComponent(java.lang.Class interfaceType)

        return (T) mComponents.get(interfaceType);
    
public SystemUI[]getServices()

        return mServices;
    
public voidonConfigurationChanged(android.content.res.Configuration newConfig)

        if (mServicesStarted) {
            int len = mServices.length;
            for (int i = 0; i < len; i++) {
                mServices[i].onConfigurationChanged(newConfig);
            }
        }
    
public voidonCreate()


    
       
        super.onCreate();
        // Set the application theme that is inherited by all services. Note that setting the
        // application theme in the manifest does only work for activities. Keep this in sync with
        // the theme set there.
        setTheme(R.style.systemui_theme);

        IntentFilter filter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
        filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (mBootCompleted) return;

                if (DEBUG) Log.v(TAG, "BOOT_COMPLETED received");
                unregisterReceiver(this);
                mBootCompleted = true;
                if (mServicesStarted) {
                    final int N = mServices.length;
                    for (int i = 0; i < N; i++) {
                        mServices[i].onBootCompleted();
                    }
                }
            }
        }, filter);
    
public voidstartServicesIfNeeded()
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.

This method must only be called from the main thread.

        if (mServicesStarted) {
            return;
        }

        if (!mBootCompleted) {
            // check to see if maybe it was already completed long before we began
            // see ActivityManagerService.finishBooting()
            if ("1".equals(SystemProperties.get("sys.boot_completed"))) {
                mBootCompleted = true;
                if (DEBUG) Log.v(TAG, "BOOT_COMPLETED was already sent");
            }
        }

        Log.v(TAG, "Starting SystemUI services.");
        final int N = SERVICES.length;
        for (int i=0; i<N; i++) {
            Class<?> cl = SERVICES[i];
            if (DEBUG) Log.d(TAG, "loading: " + cl);
            try {
                mServices[i] = (SystemUI)cl.newInstance();
            } catch (IllegalAccessException ex) {
                throw new RuntimeException(ex);
            } catch (InstantiationException ex) {
                throw new RuntimeException(ex);
            }
            mServices[i].mContext = this;
            mServices[i].mComponents = mComponents;
            if (DEBUG) Log.d(TAG, "running: " + mServices[i]);
            mServices[i].start();

            if (mBootCompleted) {
                mServices[i].onBootCompleted();
            }
        }
        mServicesStarted = true;