自定义adb
1 在SystemServer添加Service
sysutilsManager = new SystemUtilsManagerService(context);
ServiceManager.addService(Context.SYSTEMUTILS_SERVICE, sysutilsManager);
在路径./base/services/core/java/com/android/server/SystemUtilsManagerService.java
继承ISystemUtilsService.Stub
public class SystemUtilsManagerService extends ISystemUtilsService.Stub {
在android.app.ISystemUtilsService定义aidl文件
至此完成Service部分。
2 在cmds里面建立adb指令的接收模块
添加文本脚本
base=/system
export CLASSPATH=$base/framework/fotapoltimer.jar
exec app_process
b
a
s
e
/
b
i
n
c
o
m
.
a
n
d
r
o
i
d
.
c
o
m
m
a
n
d
s
.
f
o
t
a
p
o
l
t
i
m
e
r
.
F
o
t
a
p
o
l
t
i
m
e
r
"
base/bin com.android.commands.fotapoltimer.Fotapoltimer "
base/bincom.android.commands.fotapoltimer.Fotapoltimer"@"
编写mk文件
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_MODULE := poltimer
include $(BUILD_JAVA_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := poltimer
LOCAL_SRC_FILES := poltimer
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
主要编译成jar包
public static void main(String[] args) {
mArgs=args;
try {
new poltimer().run();
} catch (Exception e) {
System.err.println(“Unable to run settings command”);
}
}
run()编写按照输入的参数进行刚才服务上午调用
try {
IBinder b = ServiceManager.getService(Context.SYSTEMUTILS_SERVICE);
ISystemUtilsService service = ISystemUtilsService.Stub.asInterface(b);
进行参数的调用与返回
boolean fota=service.setPollingTimer(mArgs[1]);
最后在build/target/product/base.mk中添加自己的模块进行编译成可执行的jar包
PRODUCT_PACKAGES +=
polset \