Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui; |
| 18 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 19 | import android.app.Service; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 20 | import android.content.Intent; |
Jeff Sharkey | fe6f85c | 2017-01-20 10:42:57 -0700 | [diff] [blame] | 21 | import android.os.Build; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 22 | import android.os.IBinder; |
Dan Sandler | dc2ddd7 | 2018-01-24 16:09:53 -0500 | [diff] [blame] | 23 | import android.os.Process; |
Jeff Sharkey | fe6f85c | 2017-01-20 10:42:57 -0700 | [diff] [blame] | 24 | import android.os.SystemProperties; |
Dan Sandler | dc2ddd7 | 2018-01-24 16:09:53 -0500 | [diff] [blame] | 25 | import android.util.Slog; |
John Spurlock | b0e49fc | 2013-06-12 15:50:50 -0400 | [diff] [blame] | 26 | |
Dan Sandler | dc2ddd7 | 2018-01-24 16:09:53 -0500 | [diff] [blame] | 27 | import com.android.internal.os.BinderInternal; |
Tony Wickham | 023cb19 | 2018-09-13 15:23:04 -0700 | [diff] [blame] | 28 | import com.android.systemui.shared.plugins.PluginManager; |
| 29 | import com.android.systemui.shared.plugins.PluginManagerImpl; |
Dan Sandler | dc2ddd7 | 2018-01-24 16:09:53 -0500 | [diff] [blame] | 30 | |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 31 | import java.io.FileDescriptor; |
| 32 | import java.io.PrintWriter; |
| 33 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 34 | public class SystemUIService extends Service { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 35 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 36 | @Override |
Jorim Jaggi | 3beffdf | 2014-04-03 17:37:37 +0200 | [diff] [blame] | 37 | public void onCreate() { |
| 38 | super.onCreate(); |
| 39 | ((SystemUIApplication) getApplication()).startServicesIfNeeded(); |
Jeff Sharkey | fe6f85c | 2017-01-20 10:42:57 -0700 | [diff] [blame] | 40 | |
| 41 | // For debugging RescueParty |
| 42 | if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) { |
| 43 | throw new RuntimeException(); |
| 44 | } |
Dan Sandler | dc2ddd7 | 2018-01-24 16:09:53 -0500 | [diff] [blame] | 45 | |
| 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 Jaggi | 3beffdf | 2014-04-03 17:37:37 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 63 | public IBinder onBind(Intent intent) { |
| 64 | return null; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Dave Mankoff | 037d9fc | 2019-08-09 11:08:52 -0400 | [diff] [blame] | 69 | dumpServices(((SystemUIApplication) getApplication()).getServices(), fd, pw, args); |
| 70 | } |
| 71 | |
| 72 | static void dumpServices( |
| 73 | SystemUI[] services, FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 74 | if (args == null || args.length == 0) { |
Dave Mankoff | 037d9fc | 2019-08-09 11:08:52 -0400 | [diff] [blame] | 75 | pw.println("dumping service: " + Dependency.class.getName()); |
| 76 | Dependency.staticDump(fd, pw, args); |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 77 | for (SystemUI ui: services) { |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 78 | pw.println("dumping service: " + ui.getClass().getName()); |
| 79 | ui.dump(fd, pw, args); |
| 80 | } |
Dan Sandler | c6dff3d | 2018-02-14 22:46:25 -0500 | [diff] [blame] | 81 | if (Build.IS_DEBUGGABLE) { |
| 82 | pw.println("dumping plugins:"); |
| 83 | ((PluginManagerImpl) Dependency.get(PluginManager.class)).dump(fd, pw, args); |
| 84 | } |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 85 | } else { |
Winson Chung | e8e4bdb | 2019-04-17 15:42:40 -0700 | [diff] [blame] | 86 | String svc = args[0].toLowerCase(); |
Dave Mankoff | 037d9fc | 2019-08-09 11:08:52 -0400 | [diff] [blame] | 87 | if (Dependency.class.getName().endsWith(svc)) { |
| 88 | Dependency.staticDump(fd, pw, args); |
| 89 | } |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 90 | for (SystemUI ui: services) { |
Winson Chung | e8e4bdb | 2019-04-17 15:42:40 -0700 | [diff] [blame] | 91 | String name = ui.getClass().getName().toLowerCase(); |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 92 | if (name.endsWith(svc)) { |
| 93 | ui.dump(fd, pw, args); |
| 94 | } |
| 95 | } |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
| 99 | |