adb shell service命令与SurfaceFlinger调试

2024-06-05 10:12

本文主要是介绍adb shell service命令与SurfaceFlinger调试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

“ 在Android上有丰富的shell命令便于开发者用来调试程序,非常方便,本文简单说明下service命令的用法。

01 基本用法

  • 首先看一下使用说明,带上参数-h 或 -?

$ adb shell service -h
Usage: service [-h|-?]service listservice check SERVICEservice call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR | null | fd f | nfd n | afd f ] ...
Options:i32: Write the 32-bit integer N into the send parcel.i64: Write the 64-bit integer N into the send parcel.f: Write the 32-bit single-precision number N into the send parcel.d: Write the 64-bit double-precision number N into the send parcel.s16: Write the UTF-16 string STR into the send parcel.null: Write a null binder into the send parcel.fd: Write a file descriptor for the file f into the send parcel.nfd: Write the file descriptor n into the send parcel.afd: Write an ashmem file descriptor for a region containing the data fromfile f into the send parcel.
  • 使用 service list 列出所有系统服务

$ adb shell service list
Found 303 services:
0       DockObserver: []
1       SurfaceFlinger: [android.ui.ISurfaceComposer]
2       SurfaceFlingerAIDL: [android.gui.ISurfaceComposer]
3       accessibility: [android.view.accessibility.IAccessibilityManager]
4       account: [android.accounts.IAccountManager]
5       activity: [android.app.IActivityManager]
6       activity_task: [android.app.IActivityTaskManager]
7       adb: [android.debug.IAdbManager]
8       adservices_manager: [android.app.adservices.IAdServicesManager]
9       alarm: [android.app.IAlarmManager]
....
  • 使用check service 检查服务是否存在

$ adb shell service check SurfaceFlinger
Service SurfaceFlinger: found

  • 使用call service 调用服务

service call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR | null | fd f | nfd n | afd f ] ...
    • SERVICE 就是list查询到的系统服务的名字;

    • CODE就是就是binder机制中,onTransact函数中的第一个参数;

    • 后面是要传递的参数,参数类型+参数值

02 用法举例

我们用一个例子来说明,如何通过service命令和系统服务互动。

打开SurfaceFlinger刷新率并显示在屏幕上,传递一个int32_t类型的参数,值1打开,值0是关闭:

$ adb shell service call SurfaceFlinger 1034 i32 1
Result: Parcel(NULL)

会看到如下效果:

图片

可以看下源码(下面我截取的是Android 14的源码来解析的):

/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* reply,uint32_t flags) {
...case 1034: {auto future = mScheduler->schedule([&]() FTL_FAKE_GUARD(mStateLock) FTL_FAKE_GUARD(kMainThreadContext) {switch (n = data.readInt32()) {case 0:case 1:enableRefreshRateOverlay(static_cast<bool>(n));break;default:reply->writeBool(isRefreshRateOverlayEnabled());}});future.wait();return NO_ERROR;}
...
}

SurfaceFlinger::onTransact函数中,在收到code=1034的请求后,首先会读取参数,然后

点击阅读原文

adb shell service命令与SurfaceFlinger调试

更多Android Graphics知识

全面解读 Android Graphics 图像显示系统_android图像系统-CSDN博客

这篇关于adb shell service命令与SurfaceFlinger调试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1032768

相关文章

Android里面的Service种类以及启动方式

《Android里面的Service种类以及启动方式》Android中的Service分为前台服务和后台服务,前台服务需要亮身份牌并显示通知,后台服务则有启动方式选择,包括startService和b... 目录一句话总结:一、Service 的两种类型:1. 前台服务(必须亮身份牌)2. 后台服务(偷偷干

使用C/C++调用libcurl调试消息的方式

《使用C/C++调用libcurl调试消息的方式》在使用C/C++调用libcurl进行HTTP请求时,有时我们需要查看请求的/应答消息的内容(包括请求头和请求体)以方便调试,libcurl提供了多种... 目录1. libcurl 调试工具简介2. 输出请求消息使用 CURLOPT_VERBOSE使用 C

使用TomCat,service输出台出现乱码的解决

《使用TomCat,service输出台出现乱码的解决》本文介绍了解决Tomcat服务输出台中文乱码问题的两种方法,第一种方法是修改`logging.properties`文件中的`prefix`和`... 目录使用TomCat,service输出台出现乱码问题1解决方案问题2解决方案总结使用TomCat,

Redis的Zset类型及相关命令详细讲解

《Redis的Zset类型及相关命令详细讲解》:本文主要介绍Redis的Zset类型及相关命令的相关资料,有序集合Zset是一种Redis数据结构,它类似于集合Set,但每个元素都有一个关联的分数... 目录Zset简介ZADDZCARDZCOUNTZRANGEZREVRANGEZRANGEBYSCOREZ

Linux中shell解析脚本的通配符、元字符、转义符说明

《Linux中shell解析脚本的通配符、元字符、转义符说明》:本文主要介绍shell通配符、元字符、转义符以及shell解析脚本的过程,通配符用于路径扩展,元字符用于多命令分割,转义符用于将特殊... 目录一、linux shell通配符(wildcard)二、shell元字符(特殊字符 Meta)三、s

Linux使用dd命令来复制和转换数据的操作方法

《Linux使用dd命令来复制和转换数据的操作方法》Linux中的dd命令是一个功能强大的数据复制和转换实用程序,它以较低级别运行,通常用于创建可启动的USB驱动器、克隆磁盘和生成随机数据等任务,本文... 目录简介功能和能力语法常用选项示例用法基础用法创建可启动www.chinasem.cn的 USB 驱动

关于Maven生命周期相关命令演示

《关于Maven生命周期相关命令演示》Maven的生命周期分为Clean、Default和Site三个主要阶段,每个阶段包含多个关键步骤,如清理、编译、测试、打包等,通过执行相应的Maven命令,可以... 目录1. Maven 生命周期概述1.1 Clean Lifecycle1.2 Default Li

解决systemctl reload nginx重启Nginx服务报错:Job for nginx.service invalid问题

《解决systemctlreloadnginx重启Nginx服务报错:Jobfornginx.serviceinvalid问题》文章描述了通过`systemctlstatusnginx.se... 目录systemctl reload nginx重启Nginx服务报错:Job for nginx.javas

C++中实现调试日志输出

《C++中实现调试日志输出》在C++编程中,调试日志对于定位问题和优化代码至关重要,本文将介绍几种常用的调试日志输出方法,并教你如何在日志中添加时间戳,希望对大家有所帮助... 目录1. 使用 #ifdef _DEBUG 宏2. 加入时间戳:精确到毫秒3.Windows 和 MFC 中的调试日志方法MFC

windows系统下shutdown重启关机命令超详细教程

《windows系统下shutdown重启关机命令超详细教程》shutdown命令是一个强大的工具,允许你通过命令行快速完成关机、重启或注销操作,本文将为你详细解析shutdown命令的使用方法,并提... 目录一、shutdown 命令简介二、shutdown 命令的基本用法三、远程关机与重启四、实际应用