blob: 11e0f289e6a46c6a9774851966b78ca480ba8969 [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;
Jeff Sharkeyfe6f85c2017-01-20 10:42:57 -070021import android.os.Build;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040022import android.os.IBinder;
Jeff Sharkeyfe6f85c2017-01-20 10:42:57 -070023import android.os.SystemProperties;
John Spurlockb0e49fc2013-06-12 15:50:50 -040024
25import java.io.FileDescriptor;
26import java.io.PrintWriter;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040027
28public class SystemUIService extends Service {
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040029
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040030 @Override
Jorim Jaggi3beffdf2014-04-03 17:37:37 +020031 public void onCreate() {
32 super.onCreate();
33 ((SystemUIApplication) getApplication()).startServicesIfNeeded();
Jeff Sharkeyfe6f85c2017-01-20 10:42:57 -070034
35 // For debugging RescueParty
36 if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) {
37 throw new RuntimeException();
38 }
Jorim Jaggi3beffdf2014-04-03 17:37:37 +020039 }
40
41 @Override
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040042 public IBinder onBind(Intent intent) {
43 return null;
44 }
45
46 @Override
47 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +020048 SystemUI[] services = ((SystemUIApplication) getApplication()).getServices();
Joe Onorato10523b4d2010-10-25 10:42:46 -070049 if (args == null || args.length == 0) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +020050 for (SystemUI ui: services) {
Joe Onorato10523b4d2010-10-25 10:42:46 -070051 pw.println("dumping service: " + ui.getClass().getName());
52 ui.dump(fd, pw, args);
53 }
54 } else {
55 String svc = args[0];
Jorim Jaggicff0acb2014-03-31 16:35:15 +020056 for (SystemUI ui: services) {
Joe Onorato10523b4d2010-10-25 10:42:46 -070057 String name = ui.getClass().getName();
58 if (name.endsWith(svc)) {
59 ui.dump(fd, pw, args);
60 }
61 }
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040062 }
63 }
64}
65