大丰做网站哪家公司好,网站的专题图怎么做,磁力链接搜索引擎2021,网站快速建设入门教程Android 9上有了binder_calls_stats服务#xff0c;提供了java层的binder统计#xff0c;
Android中的Binder Call Stats#xff08;Binder调用统计#xff09;是一项用于监控和记录Android系统中Binder通信的统计信息的功能。Binder是Android中的一种进程间通信#xff…Android 9上有了binder_calls_stats服务提供了java层的binder统计
Android中的Binder Call StatsBinder调用统计是一项用于监控和记录Android系统中Binder通信的统计信息的功能。Binder是Android中的一种进程间通信IPC机制用于在不同的进程之间传递数据和调用方法。
Binder Call Stats提供了有关Binder调用的性能和统计数据帮助开发人员分析和优化系统的性能。它可以提供以下信息 Binder调用次数统计Binder方法被调用的次数包括进程间的远程调用和本地调用。 Binder调用耗时记录Binder方法的执行时间包括调用传输数据的时间和远程进程执行方法的时间。 Binder调用堆栈跟踪跟踪Binder调用的堆栈信息可以帮助开发人员确定调用路径和定位性能瓶颈。 Binder调用的进程和线程信息记录Binder调用发生的进程和线程信息有助于分析系统中不同组件之间的通信情况。
通过分析Binder Call Stats开发人员可以识别性能瓶颈、优化IPC通信改进应用程序的响应性能和资源利用率。
要收集Binder Call Stats开发人员可以使用Android系统提供的工具和API例如使用adb shell命令进行监测或者使用Trace类和Debug类提供的方法进行手动埋点和记录统计数据。
需要注意的是Binder Call Stats对于普通应用程序开发人员来说可能并不常用主要用于系统级开发和性能调优。
public class BinderCallsStatsService extends Binder {
30
31 private static final String TAG BinderCallsStatsService;
32
33 private static final String PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING
34 persist.sys.binder_calls_detailed_tracking;
35
36 public static void start() {
37 BinderCallsStatsService service new BinderCallsStatsService();
38 ServiceManager.addService(binder_calls_stats, service);
39 boolean detailedTrackingEnabled SystemProperties.getBoolean(
40 PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, false);
41
42 if (detailedTrackingEnabled) {
43 Slog.i(TAG, Enabled CPU usage tracking for binder calls. Controlled by
44 PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING
45 or via dumpsys binder_calls_stats --enable-detailed-tracking);
46 BinderCallsStats.getInstance().setDetailedTracking(true);
47 }
48 }
49
50 public static void reset() {
51 Slog.i(TAG, Resetting stats);
52 BinderCallsStats.getInstance().reset();
53 }
54
55 Override
56 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
57 if (args ! null) {
58 for (final String arg : args) {
59 if (-a.equals(arg)) {
60 // We currently dump all information by default
61 continue;
62 } else if (--reset.equals(arg)) {
63 reset();
64 pw.println(binder_calls_stats reset.);
65 return;
66 } else if (--enable-detailed-tracking.equals(arg)) {
67 SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, 1);
68 BinderCallsStats.getInstance().setDetailedTracking(true);
69 pw.println(Detailed tracking enabled);
70 return;
71 } else if (--disable-detailed-tracking.equals(arg)) {
72 SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, );
73 BinderCallsStats.getInstance().setDetailedTracking(false);
74 pw.println(Detailed tracking disabled);
75 return;
76 } else if (-h.equals(arg)) {
77 pw.println(binder_calls_stats commands:);
78 pw.println( --reset: Reset stats);
79 pw.println( --enable-detailed-tracking: Enables detailed tracking);
80 pw.println( --disable-detailed-tracking: Disables detailed tracking);
81 return;
82 } else {
83 pw.println(Unknown option: arg);
84 }
85 }
86 }
87 BinderCallsStats.getInstance().dump(pw);
88 }
89}
90
可以看到是通过BinderCallsStats来进行统计的而BinderCallsStats通过在Java层Binder对象中的使用来进行记录
frameworks/base/core/java/android/os/Binder.java // Entry point from android_util_Binder.cpps onTransact
714 private boolean execTransact(int code, long dataObj, long replyObj,
715 int flags) {
716 BinderCallsStats binderCallsStats BinderCallsStats.getInstance();
717 BinderCallsStats.CallSession callSession binderCallsStats.callStarted(this, code);
718 Parcel data Parcel.obtain(dataObj);
719 Parcel reply Parcel.obtain(replyObj);
720 // theoretically, we should call transact, which will call onTransact,
721 // but all that does is rewind it, and we just got these from an IPC,
722 // so well just call it directly.
723 boolean res;
724 // Log any exceptions as warnings, dont silently suppress them.
725 // If the call was FLAG_ONEWAY then these exceptions disappear into the ether.
726 final boolean tracingEnabled Binder.isTracingEnabled();
727 try {
728 if (tracingEnabled) {
729 Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, getClass().getName() : code);
730 }
731 res onTransact(code, data, reply, flags);
732 } catch (RemoteException|RuntimeException e) {
733 if (LOG_RUNTIME_EXCEPTION) {
734 Log.w(TAG, Caught a RuntimeException from the binder stub implementation., e);
735 }
736 if ((flags FLAG_ONEWAY) ! 0) {
737 if (e instanceof RemoteException) {
738 Log.w(TAG, Binder call failed., e);
739 } else {
740 Log.w(TAG, Caught a RuntimeException from the binder stub implementation., e);
741 }
742 } else {
743 reply.setDataPosition(0);
744 reply.writeException(e);
745 }
746 res true;
747 } finally {
748 if (tracingEnabled) {
749 Trace.traceEnd(Trace.TRACE_TAG_ALWAYS);
750 }
751 }
752 checkParcel(this, code, reply, Unreasonably large binder reply buffer);
753 reply.recycle();
754 data.recycle();
755
756 // Just in case -- we are done with the IPC, so there should be no more strict
757 // mode violations that have gathered for this thread. Either they have been
758 // parceled and are now in transport off to the caller, or we are returning back
759 // to the main transaction loop to wait for another incoming transaction. Either
760 // way, strict mode begone!
761 StrictMode.clearGatheredViolations();
762 binderCallsStats.callEnded(callSession);
763
764 return res;
765 }
而更加底层的统计可以查看/dev/binder 里面的binder_status
binder_status是Android系统中的一个特殊文件用于提供有关Binder驱动程序状态的信息。该文件位于/proc/binder/status路径下只有在具有root权限或系统签名的设备上才能访问。
binder_status文件提供了有关Binder驱动程序的各种统计和状态信息包括 总体信息包括Binder线程池的大小、当前正在等待的线程数等。 事务计数显示有关Binder事务包括进程间通信和本地调用的计数信息例如总事务数、活动事务数、等待事务数等。 线程信息列出了所有活动的Binder线程的详细信息包括线程ID、所属进程、线程状态等。 回收信息显示已回收的Binder对象和节点的数量。
通过读取binder_status文件您可以获取有关Binder驱动程序的运行状况和性能指标的信息这对于调试和分析Binder相关问题非常有用。然而由于它提供的信息非常底层和详细需要一定的理解和背景知识才能正确解读和使用这些数据。
请注意访问binder_status文件需要root权限或系统签名并且在正常情况下一般用户不需要直接访问或操作该文件。 文章转载自: http://www.morning.rkck.cn.gov.cn.rkck.cn http://www.morning.huxinzuche.cn.gov.cn.huxinzuche.cn http://www.morning.kqkmx.cn.gov.cn.kqkmx.cn http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.rdlong.com.gov.cn.rdlong.com http://www.morning.dblfl.cn.gov.cn.dblfl.cn http://www.morning.jfymz.cn.gov.cn.jfymz.cn http://www.morning.zylzk.cn.gov.cn.zylzk.cn http://www.morning.kzrg.cn.gov.cn.kzrg.cn http://www.morning.twmp.cn.gov.cn.twmp.cn http://www.morning.nypgb.cn.gov.cn.nypgb.cn http://www.morning.wbxtx.cn.gov.cn.wbxtx.cn http://www.morning.ndlww.cn.gov.cn.ndlww.cn http://www.morning.dqzcf.cn.gov.cn.dqzcf.cn http://www.morning.yqmmh.cn.gov.cn.yqmmh.cn http://www.morning.rnrwq.cn.gov.cn.rnrwq.cn http://www.morning.nypgb.cn.gov.cn.nypgb.cn http://www.morning.jcfdk.cn.gov.cn.jcfdk.cn http://www.morning.fbbpj.cn.gov.cn.fbbpj.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.nd-test.com.gov.cn.nd-test.com http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.pypbz.cn.gov.cn.pypbz.cn http://www.morning.plxhq.cn.gov.cn.plxhq.cn http://www.morning.pcgmw.cn.gov.cn.pcgmw.cn http://www.morning.jftl.cn.gov.cn.jftl.cn http://www.morning.qjlkp.cn.gov.cn.qjlkp.cn http://www.morning.skrh.cn.gov.cn.skrh.cn http://www.morning.rflcy.cn.gov.cn.rflcy.cn http://www.morning.zbkdm.cn.gov.cn.zbkdm.cn http://www.morning.xhgcr.cn.gov.cn.xhgcr.cn http://www.morning.rkck.cn.gov.cn.rkck.cn http://www.morning.qdscb.cn.gov.cn.qdscb.cn http://www.morning.mysmz.cn.gov.cn.mysmz.cn http://www.morning.3dcb8231.cn.gov.cn.3dcb8231.cn http://www.morning.ccjhr.cn.gov.cn.ccjhr.cn http://www.morning.fnczn.cn.gov.cn.fnczn.cn http://www.morning.ggqcg.cn.gov.cn.ggqcg.cn http://www.morning.ttcmdsg.cn.gov.cn.ttcmdsg.cn http://www.morning.tgts.cn.gov.cn.tgts.cn http://www.morning.sbrjj.cn.gov.cn.sbrjj.cn http://www.morning.nwrzf.cn.gov.cn.nwrzf.cn http://www.morning.fglxh.cn.gov.cn.fglxh.cn http://www.morning.tlnbg.cn.gov.cn.tlnbg.cn http://www.morning.nlysd.cn.gov.cn.nlysd.cn http://www.morning.nchsz.cn.gov.cn.nchsz.cn http://www.morning.elsemon.com.gov.cn.elsemon.com http://www.morning.wztnh.cn.gov.cn.wztnh.cn http://www.morning.wkkqw.cn.gov.cn.wkkqw.cn http://www.morning.wklyk.cn.gov.cn.wklyk.cn http://www.morning.kgqpx.cn.gov.cn.kgqpx.cn http://www.morning.jhgxh.cn.gov.cn.jhgxh.cn http://www.morning.hdlhh.cn.gov.cn.hdlhh.cn http://www.morning.kzyr.cn.gov.cn.kzyr.cn http://www.morning.yydzk.cn.gov.cn.yydzk.cn http://www.morning.lgznf.cn.gov.cn.lgznf.cn http://www.morning.mnlk.cn.gov.cn.mnlk.cn http://www.morning.mdwtm.cn.gov.cn.mdwtm.cn http://www.morning.cjmmt.cn.gov.cn.cjmmt.cn http://www.morning.gxtbn.cn.gov.cn.gxtbn.cn http://www.morning.wqrdx.cn.gov.cn.wqrdx.cn http://www.morning.bxqpl.cn.gov.cn.bxqpl.cn http://www.morning.yptwn.cn.gov.cn.yptwn.cn http://www.morning.pbmkh.cn.gov.cn.pbmkh.cn http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn http://www.morning.24vy.com.gov.cn.24vy.com http://www.morning.sflnx.cn.gov.cn.sflnx.cn http://www.morning.rdsst.cn.gov.cn.rdsst.cn http://www.morning.jxgyg.cn.gov.cn.jxgyg.cn http://www.morning.i-bins.com.gov.cn.i-bins.com http://www.morning.tgyqq.cn.gov.cn.tgyqq.cn http://www.morning.dqrpz.cn.gov.cn.dqrpz.cn http://www.morning.nnwmd.cn.gov.cn.nnwmd.cn http://www.morning.qpntn.cn.gov.cn.qpntn.cn http://www.morning.htfnz.cn.gov.cn.htfnz.cn http://www.morning.gygfx.cn.gov.cn.gygfx.cn http://www.morning.knlgk.cn.gov.cn.knlgk.cn http://www.morning.ljdd.cn.gov.cn.ljdd.cn http://www.morning.wmdbn.cn.gov.cn.wmdbn.cn http://www.morning.jfmjq.cn.gov.cn.jfmjq.cn