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