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 19 import android.app.Service; 20 import android.content.Intent; 21 import android.os.Build; 22 import android.os.IBinder; 23 import android.os.Process; 24 import android.os.SystemProperties; 25 import android.util.Slog; 26 27 import java.io.FileDescriptor; 28 import java.io.PrintWriter; 29 30 import com.android.internal.os.BinderInternal; 31 import com.android.systemui.plugins.PluginManager; 32 import com.android.systemui.plugins.PluginManagerImpl; 33 34 public class SystemUIService extends Service { 35 36 @Override 37 public void onCreate() { 38 super.onCreate(); 39 ((SystemUIApplication) getApplication()).startServicesIfNeeded(); 40 41 // For debugging RescueParty 42 if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) { 43 throw new RuntimeException(); 44 } 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 } 60 } 61 62 @Override 63 public IBinder onBind(Intent intent) { 64 return null; 65 } 66 67 @Override 68 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 69 SystemUI[] services = ((SystemUIApplication) getApplication()).getServices(); 70 if (args == null || args.length == 0) { 71 for (SystemUI ui: services) { 72 pw.println("dumping service: " + ui.getClass().getName()); 73 ui.dump(fd, pw, args); 74 } 75 if (Build.IS_DEBUGGABLE) { 76 pw.println("dumping plugins:"); 77 ((PluginManagerImpl) Dependency.get(PluginManager.class)).dump(fd, pw, args); 78 } 79 } else { 80 String svc = args[0]; 81 for (SystemUI ui: services) { 82 String name = ui.getClass().getName(); 83 if (name.endsWith(svc)) { 84 ui.dump(fd, pw, args); 85 } 86 } 87 } 88 } 89 } 90 91