blob: ca5f7d1f03a48d84f163d514fdac0a9ea3e13aed [file] [log] [blame]
Joe Onoratof3c3c4f2010-10-21 11:09:02 -04001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui;
18
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040019import android.app.Service;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040020import android.content.Intent;
Daniel Sandler0ad460b2010-12-14 12:14:53 -050021import android.content.res.Configuration;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040022import android.os.IBinder;
John Spurlockcd686b52013-06-05 10:13:46 -040023import android.util.Log;
John Spurlockb0e49fc2013-06-12 15:50:50 -040024
25import java.io.FileDescriptor;
26import java.io.PrintWriter;
John Spurlockd08de372013-06-24 13:06:08 -040027import java.util.HashMap;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040028
29public class SystemUIService extends Service {
John Spurlock5c454122013-06-17 07:35:46 -040030 private static final String TAG = "SystemUIService";
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040031
32 /**
John Spurlock5c454122013-06-17 07:35:46 -040033 * The classes of the stuff to start.
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040034 */
John Spurlock5c454122013-06-17 07:35:46 -040035 private final Class<?>[] SERVICES = new Class[] {
John Spurlockd08de372013-06-24 13:06:08 -040036 com.android.systemui.recent.Recents.class,
John Spurlock5c454122013-06-17 07:35:46 -040037 com.android.systemui.statusbar.SystemBars.class,
John Spurlock3e309b22013-06-25 11:01:29 -040038 com.android.systemui.usb.StorageNotification.class,
Joe Onorato10523b4d2010-10-25 10:42:46 -070039 com.android.systemui.power.PowerUI.class,
Jeff Sharkey098d5802012-04-26 17:30:34 -070040 com.android.systemui.media.RingtonePlayer.class,
Michael Wright0087a142013-02-05 16:29:39 -080041 com.android.systemui.settings.SettingsUI.class,
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040042 };
43
44 /**
45 * Hold a reference on the stuff we start.
46 */
John Spurlock5c454122013-06-17 07:35:46 -040047 private final SystemUI[] mServices = new SystemUI[SERVICES.length];
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040048
49 @Override
50 public void onCreate() {
John Spurlockd08de372013-06-24 13:06:08 -040051 HashMap<Class<?>, Object> components = new HashMap<Class<?>, Object>();
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040052 final int N = SERVICES.length;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040053 for (int i=0; i<N; i++) {
John Spurlock5c454122013-06-17 07:35:46 -040054 Class<?> cl = SERVICES[i];
John Spurlockcd686b52013-06-05 10:13:46 -040055 Log.d(TAG, "loading: " + cl);
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040056 try {
57 mServices[i] = (SystemUI)cl.newInstance();
58 } catch (IllegalAccessException ex) {
59 throw new RuntimeException(ex);
60 } catch (InstantiationException ex) {
61 throw new RuntimeException(ex);
62 }
63 mServices[i].mContext = this;
John Spurlockd08de372013-06-24 13:06:08 -040064 mServices[i].mComponents = components;
John Spurlockcd686b52013-06-05 10:13:46 -040065 Log.d(TAG, "running: " + mServices[i]);
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040066 mServices[i].start();
67 }
68 }
69
Daniel Sandler0ad460b2010-12-14 12:14:53 -050070 @Override
71 public void onConfigurationChanged(Configuration newConfig) {
72 for (SystemUI ui: mServices) {
73 ui.onConfigurationChanged(newConfig);
74 }
75 }
76
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040077 /**
78 * Nobody binds to us.
79 */
80 @Override
81 public IBinder onBind(Intent intent) {
82 return null;
83 }
84
85 @Override
86 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
Joe Onorato10523b4d2010-10-25 10:42:46 -070087 if (args == null || args.length == 0) {
88 for (SystemUI ui: mServices) {
89 pw.println("dumping service: " + ui.getClass().getName());
90 ui.dump(fd, pw, args);
91 }
92 } else {
93 String svc = args[0];
94 for (SystemUI ui: mServices) {
95 String name = ui.getClass().getName();
96 if (name.endsWith(svc)) {
97 ui.dump(fd, pw, args);
98 }
99 }
Joe Onoratof3c3c4f2010-10-21 11:09:02 -0400100 }
101 }
102}
103