2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.systemui;
19 import java.io.FileDescriptor;
20 import java.io.PrintWriter;
22 import android.app.Service;
23 import android.content.BroadcastReceiver;
24 import android.content.Context;
25 import android.content.Intent;
26 import android.content.pm.PackageManager;
27 import android.content.res.Configuration;
28 import android.os.Binder;
29 import android.os.IBinder;
30 import android.util.Slog;
32 public class SystemUIService extends Service {
33 static final String TAG = "SystemUIService";
36 * The class names of the stuff to start.
38 final Object[] SERVICES = new Object[] {
39 R.string.config_statusBarComponent,
40 com.android.systemui.power.PowerUI.class,
44 * Hold a reference on the stuff we start.
48 private Class chooseClass(Object o) {
49 if (o instanceof Integer) {
50 final String cl = getString((Integer)o);
52 return getClassLoader().loadClass(cl);
53 } catch (ClassNotFoundException ex) {
54 throw new RuntimeException(ex);
56 } else if (o instanceof Class) {
59 throw new RuntimeException("Unknown system ui service: " + o);
64 public void onCreate() {
65 final int N = SERVICES.length;
66 mServices = new SystemUI[N];
67 for (int i=0; i<N; i++) {
68 Class cl = chooseClass(SERVICES[i]);
69 Slog.d(TAG, "loading: " + cl);
71 mServices[i] = (SystemUI)cl.newInstance();
72 } catch (IllegalAccessException ex) {
73 throw new RuntimeException(ex);
74 } catch (InstantiationException ex) {
75 throw new RuntimeException(ex);
77 mServices[i].mContext = this;
78 Slog.d(TAG, "running: " + mServices[i]);
84 public void onConfigurationChanged(Configuration newConfig) {
85 for (SystemUI ui: mServices) {
86 ui.onConfigurationChanged(newConfig);
94 public IBinder onBind(Intent intent) {
99 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
100 if (checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
101 != PackageManager.PERMISSION_GRANTED) {
102 pw.println("Permission Denial: can't dump StatusBar from from pid="
103 + Binder.getCallingPid()
104 + ", uid=" + Binder.getCallingUid());
108 if (args == null || args.length == 0) {
109 for (SystemUI ui: mServices) {
110 pw.println("dumping service: " + ui.getClass().getName());
111 ui.dump(fd, pw, args);
114 String svc = args[0];
115 for (SystemUI ui: mServices) {
116 String name = ui.getClass().getName();
117 if (name.endsWith(svc)) {
118 ui.dump(fd, pw, args);