blob: dc1218d3349848cf26c8de89e267341423236505 [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;
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050023import android.os.Process;
Jeff Sharkeyfe6f85c2017-01-20 10:42:57 -070024import android.os.SystemProperties;
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050025import android.util.Slog;
John Spurlockb0e49fc2013-06-12 15:50:50 -040026
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050027import com.android.internal.os.BinderInternal;
Tony Wickham023cb192018-09-13 15:23:04 -070028import com.android.systemui.shared.plugins.PluginManager;
29import com.android.systemui.shared.plugins.PluginManagerImpl;
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050030
Gus Prevasab336792018-11-14 13:52:20 -050031import java.io.FileDescriptor;
32import java.io.PrintWriter;
33
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040034public class SystemUIService extends Service {
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040035
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040036 @Override
Jorim Jaggi3beffdf2014-04-03 17:37:37 +020037 public void onCreate() {
38 super.onCreate();
39 ((SystemUIApplication) getApplication()).startServicesIfNeeded();
Jeff Sharkeyfe6f85c2017-01-20 10:42:57 -070040
41 // For debugging RescueParty
42 if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) {
43 throw new RuntimeException();
44 }
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050045
46 if (Build.IS_DEBUGGABLE) {
47 // b/71353150 - looking for leaked binder proxies
48 BinderInternal.nSetBinderProxyCountEnabled(true);
49 BinderInternal.nSetBinderProxyCountWatermarks(1000,900);
50 BinderInternal.setBinderProxyCountCallback(
51 new BinderInternal.BinderProxyLimitListener() {
52 @Override
53 public void onLimitReached(int uid) {
54 Slog.w(SystemUIApplication.TAG,
55 "uid " + uid + " sent too many Binder proxies to uid "
56 + Process.myUid());
57 }
58 }, Dependency.get(Dependency.MAIN_HANDLER));
59 }
Jorim Jaggi3beffdf2014-04-03 17:37:37 +020060 }
61
62 @Override
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040063 public IBinder onBind(Intent intent) {
64 return null;
65 }
66
67 @Override
68 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +020069 SystemUI[] services = ((SystemUIApplication) getApplication()).getServices();
Joe Onorato10523b4d2010-10-25 10:42:46 -070070 if (args == null || args.length == 0) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +020071 for (SystemUI ui: services) {
Joe Onorato10523b4d2010-10-25 10:42:46 -070072 pw.println("dumping service: " + ui.getClass().getName());
73 ui.dump(fd, pw, args);
74 }
Dan Sandlerc6dff3d2018-02-14 22:46:25 -050075 if (Build.IS_DEBUGGABLE) {
76 pw.println("dumping plugins:");
77 ((PluginManagerImpl) Dependency.get(PluginManager.class)).dump(fd, pw, args);
78 }
Joe Onorato10523b4d2010-10-25 10:42:46 -070079 } else {
Winson Chunge8e4bdb2019-04-17 15:42:40 -070080 String svc = args[0].toLowerCase();
Jorim Jaggicff0acb2014-03-31 16:35:15 +020081 for (SystemUI ui: services) {
Winson Chunge8e4bdb2019-04-17 15:42:40 -070082 String name = ui.getClass().getName().toLowerCase();
Joe Onorato10523b4d2010-10-25 10:42:46 -070083 if (name.endsWith(svc)) {
84 ui.dump(fd, pw, args);
85 }
86 }
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040087 }
88 }
89}
90