blob: ddf0bd0cbab408c394537c1485505bba470e3a3e [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
27import java.io.FileDescriptor;
28import java.io.PrintWriter;
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040029
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050030import com.android.internal.os.BinderInternal;
31
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040032public class SystemUIService extends Service {
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040033
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040034 @Override
Jorim Jaggi3beffdf2014-04-03 17:37:37 +020035 public void onCreate() {
36 super.onCreate();
37 ((SystemUIApplication) getApplication()).startServicesIfNeeded();
Jeff Sharkeyfe6f85c2017-01-20 10:42:57 -070038
39 // For debugging RescueParty
40 if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) {
41 throw new RuntimeException();
42 }
Dan Sandlerdc2ddd72018-01-24 16:09:53 -050043
44 if (Build.IS_DEBUGGABLE) {
45 // b/71353150 - looking for leaked binder proxies
46 BinderInternal.nSetBinderProxyCountEnabled(true);
47 BinderInternal.nSetBinderProxyCountWatermarks(1000,900);
48 BinderInternal.setBinderProxyCountCallback(
49 new BinderInternal.BinderProxyLimitListener() {
50 @Override
51 public void onLimitReached(int uid) {
52 Slog.w(SystemUIApplication.TAG,
53 "uid " + uid + " sent too many Binder proxies to uid "
54 + Process.myUid());
55 }
56 }, Dependency.get(Dependency.MAIN_HANDLER));
57 }
Jorim Jaggi3beffdf2014-04-03 17:37:37 +020058 }
59
60 @Override
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040061 public IBinder onBind(Intent intent) {
62 return null;
63 }
64
65 @Override
66 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +020067 SystemUI[] services = ((SystemUIApplication) getApplication()).getServices();
Joe Onorato10523b4d2010-10-25 10:42:46 -070068 if (args == null || args.length == 0) {
Jorim Jaggicff0acb2014-03-31 16:35:15 +020069 for (SystemUI ui: services) {
Joe Onorato10523b4d2010-10-25 10:42:46 -070070 pw.println("dumping service: " + ui.getClass().getName());
71 ui.dump(fd, pw, args);
72 }
73 } else {
74 String svc = args[0];
Jorim Jaggicff0acb2014-03-31 16:35:15 +020075 for (SystemUI ui: services) {
Joe Onorato10523b4d2010-10-25 10:42:46 -070076 String name = ui.getClass().getName();
77 if (name.endsWith(svc)) {
78 ui.dump(fd, pw, args);
79 }
80 }
Joe Onoratof3c3c4f2010-10-21 11:09:02 -040081 }
82 }
83}
84