android下batteryService服务及客户端分析
2021-04-12 20:36:06 0 举报
android下batteryService服务及客户端程序流程分析
作者其他创作
大纲/内容
ContextImpl.java
IBatteryPropertiesRegistrar
- registerListener()- unregisterListener()- getProperty()
healthd-main()
内部类
RefBase
+ mRefs:weakref_impl = defaultValue
+ incStrong()- decStrong()- forceIncStrong()- getStrongCount()
android.os.IBatteryPropertiesListener[aidl]
用来生成java代码
IInterface
+ asBinder():sp
android.os.IBatteryPropertiesRegistrar.Stub.Proxy(internal)
+ 由aidl生成,是Stub的私有内部类,外部不可见+ mRemote:IBinder
BatteryPropertiesRegistrar
+ mRegistrationLock+ mListeners
+ publish()+ notifyListeners()- registerListener()- unregisterListener()- getProperty()- dump()- binderDied()
同一个
android.os.IBinder
+ getInterfaceDescriptor()+ pingBinder()+ isBinderActive()+ queryLocalInterface()+ dump()+ dumpAsync()+ transact()+ linkToDeath()+ unlinkToDeath()
android.os.IBatteryPropertiesListener.Stub.Proxy(internal)
+ construct Proxy(android.os.IBinder remote)+ asBinder()+ getInterfaceDescriptor()+ batteryPropertiesChanged(android.os.BatteryProperties props)
android.os.Binder
+ native getCallingPid()+ native getCallingUid()- getCallingUserHandle()- native clearCallingIdentity()- native restoreCallingIdentity()+ native setThreadStrictModePolicy()+ native getThreadStrictModePolicy()+ native flushPendingCommands()+ native joinThreadPool()+ isProxy()+ attachInterface()+ setDumpDisable()+ onTransact()+ finalize()+ checkParcel()
BBinder
+ localBinder()- onTransact()
healthd_mode_ops=&android_ops
templateBnInterface
service与client分割线
IBinder
+ queryLocalInterface()- getInterfaceDescriptor()- isBinderAlive()- pingBinder()- dump()- transact()- linkToDeath()- unlinkToDeath()- checkSubsclass()- attachObject()- findObject()- detachObject()- localBinder(): BBinder*- remoteBinder(): BpBinder*
android.os.IBatteryPropertiesRegistrar.Stub(internal)
+ 由aidl生成
+ asInterface(android.os.IBinder):android.os.IBatteryPropertiesRegistrar+ asBinder()+ onTransact()
healthd_mode_ops-init()
android.os.IBatteryPropertiesListener
由aidl生成+ batteryPropertiesChanged(android.os.BatteryProperties props)
Android Native Service 程序结构(batteryproperties为例,在healthd中)
android.os.IBatteryPropertiesRegistrar
android.os.IInterface
+ asBinder():IBinder
ProcessState::self()-setThreadPoolMaxThreadCount(0);IPCThreadState::self()-disableBackgroundScheduling(true);IPCThreadState::self()-setupPolling(&gBinderFd);gBatteryPropertiesRegistrar = new BatteryPropertiesRegistrar();gBatteryPropertiesRegistrar-publish();
android.os.IBatteryPropertiesListener.Stub(internal)
+ asInterface(android.os.IBinder):android.os.IBatteryPropertiesListener+ asBinder() + onTransact()
android.os.IBinder.DeathRecipient
+ binderDied()
healthd_mode_android_init()
android.os.IBatteryPropertiesRegistrar[aidl]
defaultServiceManager()-addService(String16(\"batteryproperties\
healthd_init()
IBatteryPropertiesListener
- batteryPropertiesChanged()
IBinder::DeathRecipient
IBinder内部类
+ binderDied(params)
getIntProperty()----queryProperty()
BatteryManager.java
INTERFACE
被BnInterface派生
如:IBatteryPropertiesRegistrar
BnBatteryPropertiesRegistrar
+ onTransact(params)
0 条评论
下一页