当前位置: 首页 > news >正文

注册域名哪个网站好北京网站建设公司

注册域名哪个网站好,北京网站建设公司,东莞建设公司网页,中英文版网站是怎么做的Android SystemServer创建和启动方式(基于Android13) SystemServer 简介 Android System Server是Android框架的核心组件,运行在system_server进程中,拥有system权限。它在Android系统中扮演重要角色,提供服务管理和通信。 system …

Android SystemServer创建和启动方式(基于Android13)

SystemServer 简介

Android System Server是Android框架的核心组件,运行在system_server进程中,拥有system权限。它在Android系统中扮演重要角色,提供服务管理和通信。

system          548    415 1 06:23:21 ?     00:11:21 system_server

SystemServer在Android系统中的位置如下

SystemServer服务提供者serviceManager

SystemServer利用ServiceManager来提供服务,类似于keystore,ServiceManager是一个native service,负责SystemServer中的service管理。SystemServer通过binder和ServiceManager进行通信。

ServiceManager由servicemanager.rc启动,并且相关实现在ServiceManager提供的aidl接口中。

//frameworks/native/cmds/servicemanager/
service servicemanager /system/bin/servicemanagerclass core animationuser systemgroup system readproccriticalonrestart restart healthdonrestart restart zygoteonrestart restart audioserveronrestart restart mediaonrestart restart surfaceflingeronrestart restart inputflingeronrestart restart drmonrestart restart cameraserveronrestart restart keystoreonrestart restart gatekeeperdonrestart restart thermalservicewritepid /dev/cpuset/system-background/tasksshutdown critical

这些接口位于frameworks/native/libs/binder/aidl/android/os/IServiceManager.aidl,主要包括addService、getService、checkService以及一些权限的检查。

//frameworks/native/libs/binder/aidl/android/os/IServiceManager.aidl
interface IServiceManager {/** Must update values in IServiceManager.h*//* Allows services to dump sections according to priorities. */const int DUMP_FLAG_PRIORITY_CRITICAL = 1 << 0;const int DUMP_FLAG_PRIORITY_HIGH = 1 << 1;const int DUMP_FLAG_PRIORITY_NORMAL = 1 << 2;/*** Services are by default registered with a DEFAULT dump priority. DEFAULT priority has the* same priority as NORMAL priority but the services are not called with dump priority* arguments.*/const int DUMP_FLAG_PRIORITY_DEFAULT = 1 << 3;const int DUMP_FLAG_PRIORITY_ALL = 15;// DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PRIORITY_HIGH// | DUMP_FLAG_PRIORITY_NORMAL | DUMP_FLAG_PRIORITY_DEFAULT;/* Allows services to dump sections in protobuf format. */const int DUMP_FLAG_PROTO = 1 << 4;/*** Retrieve an existing service called @a name from the* service manager.** This is the same as checkService (returns immediately) but* exists for legacy purposes.** Returns null if the service does not exist.*/@UnsupportedAppUsage@nullable IBinder getService(@utf8InCpp String name);/*** Retrieve an existing service called @a name from the service* manager. Non-blocking. Returns null if the service does not* exist.*/@UnsupportedAppUsage@nullable IBinder checkService(@utf8InCpp String name);/*** Place a new @a service called @a name into the service* manager.*/void addService(@utf8InCpp String name, IBinder service,boolean allowIsolated, int dumpPriority);/*** Return a list of all currently running services.*/@utf8InCpp String[] listServices(int dumpPriority);/*** Request a callback when a service is registered.*/void registerForNotifications(@utf8InCpp String name, IServiceCallback callback);/*** Unregisters all requests for notifications for a specific callback.*/void unregisterForNotifications(@utf8InCpp String name, IServiceCallback callback);/*** Returns whether a given interface is declared on the device, even if it* is not started yet. For instance, this could be a service declared in the VINTF* manifest.*/boolean isDeclared(@utf8InCpp String name);/*** Request a callback when the number of clients of the service changes.* Used by LazyServiceRegistrar to dynamically stop services that have no clients.*/void registerClientCallback(@utf8InCpp String name, IBinder service, IClientCallback callback);/*** Attempt to unregister and remove a service. Will fail if the service is still in use.*/void tryUnregisterService(@utf8InCpp String name, IBinder service);
}

在servicemanager启动后,它会注册一个特殊的service,服务名叫做"manager",可以通过dumpsys -l命令找到名为"manager"的服务。

//frameworks/native/cmds/servicemanager/main.cppsp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>());if (!manager->addService("manager", manager, false /*allowIsolated*/, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk()) {LOG(ERROR) << "Could not self register servicemanager";}

原生框架创建Service的几种方式

方式1 ServiceManager.addService

ServiceManager.addService是最早的一种service创建方式,函数原型为

    public static void addService(String name, IBinder service) {addService(name, service, false, IServiceManager.DUMP_FLAG_PRIORITY_DEFAULT);}

在早期的Android版本中,ServiceManager.addService是最早的一种创建service的方式。它的函数原型为ServiceManager.addService,由于存在于早期版本,因此使用起来没有太多限制,甚至在android_app中也可以使用。

方式2 SystemServiceManager.startService

SystemServiceManager.startService有多个override方法,接口定义如下:

    public void startService(@NonNull final SystemService service) {// Register it.mServices.add(service);// Start it.long time = SystemClock.elapsedRealtime();try {service.onStart();} catch (RuntimeException ex) {throw new RuntimeException("Failed to start service " + service.getClass().getName()+ ": onStart threw an exception", ex);}warnIfTooLong(SystemClock.elapsedRealtime() - time, service, "onStart");}

SystemService类位于frameworks/base/services/core/java/com/android/server/SystemService.java,最后打包到service.jar中。然而,由于SystemService添加了注解,直接依赖services.jar无法访问该类。

我们可以通过两种方式来使用SystemService:

  • frameworks/base/services内部源码中,可以直接访问SystemService。
  • 在Android.bp中将模块声明为sdk_version: "system_server_current",也可以使用SystemService。

另外,还可以通过依赖静态库services.core来访问SystemService,例如Apex service就是使用这种方式。


文章转载自:
http://sluggard.hwbf.cn
http://crackled.hwbf.cn
http://chalice.hwbf.cn
http://dynamo.hwbf.cn
http://soreness.hwbf.cn
http://peroxyborate.hwbf.cn
http://combust.hwbf.cn
http://zoic.hwbf.cn
http://await.hwbf.cn
http://receiving.hwbf.cn
http://mismatch.hwbf.cn
http://shipwright.hwbf.cn
http://dermotropic.hwbf.cn
http://diligent.hwbf.cn
http://postclassic.hwbf.cn
http://periodize.hwbf.cn
http://nimiety.hwbf.cn
http://undelete.hwbf.cn
http://mandamus.hwbf.cn
http://resort.hwbf.cn
http://passeriform.hwbf.cn
http://cheribon.hwbf.cn
http://fos.hwbf.cn
http://stockade.hwbf.cn
http://shf.hwbf.cn
http://unarm.hwbf.cn
http://hypogene.hwbf.cn
http://swag.hwbf.cn
http://thyroidectomize.hwbf.cn
http://unspiked.hwbf.cn
http://postclassic.hwbf.cn
http://beekeeper.hwbf.cn
http://veery.hwbf.cn
http://uncontemplated.hwbf.cn
http://danaidean.hwbf.cn
http://capricornus.hwbf.cn
http://cancerate.hwbf.cn
http://paddington.hwbf.cn
http://prelaw.hwbf.cn
http://cancan.hwbf.cn
http://indigence.hwbf.cn
http://fabled.hwbf.cn
http://impugn.hwbf.cn
http://hulloo.hwbf.cn
http://hotel.hwbf.cn
http://deambulation.hwbf.cn
http://ectal.hwbf.cn
http://gnathism.hwbf.cn
http://department.hwbf.cn
http://alburnous.hwbf.cn
http://sandboy.hwbf.cn
http://viceroy.hwbf.cn
http://interdict.hwbf.cn
http://stingy.hwbf.cn
http://boong.hwbf.cn
http://electrotypy.hwbf.cn
http://nondeductible.hwbf.cn
http://homogenous.hwbf.cn
http://stagnancy.hwbf.cn
http://alacarte.hwbf.cn
http://hant.hwbf.cn
http://jumbled.hwbf.cn
http://phoniatrics.hwbf.cn
http://mulriple.hwbf.cn
http://ethnobotanist.hwbf.cn
http://adrenalectomize.hwbf.cn
http://shanxi.hwbf.cn
http://robertsonian.hwbf.cn
http://bogota.hwbf.cn
http://paravail.hwbf.cn
http://squitch.hwbf.cn
http://revers.hwbf.cn
http://pochard.hwbf.cn
http://criminy.hwbf.cn
http://josephson.hwbf.cn
http://pennon.hwbf.cn
http://picture.hwbf.cn
http://cecile.hwbf.cn
http://jejuneness.hwbf.cn
http://dockmaster.hwbf.cn
http://landaulet.hwbf.cn
http://instruction.hwbf.cn
http://nowhence.hwbf.cn
http://earmuff.hwbf.cn
http://peritonaeum.hwbf.cn
http://ln.hwbf.cn
http://francicize.hwbf.cn
http://immunochemist.hwbf.cn
http://fenceless.hwbf.cn
http://muteness.hwbf.cn
http://caballero.hwbf.cn
http://rtty.hwbf.cn
http://kukri.hwbf.cn
http://flowerlike.hwbf.cn
http://insolubilize.hwbf.cn
http://akureyri.hwbf.cn
http://castaway.hwbf.cn
http://swiss.hwbf.cn
http://cully.hwbf.cn
http://copartnership.hwbf.cn
http://www.15wanjia.com/news/74042.html

相关文章:

  • 企业彩铃网站源码bt兔子磁力天堂
  • 具有价值的常州做网站搜索引擎优化seo专员招聘
  • 网页设计师培训无锡抖音seo搜索引擎优化
  • 哪个网站专做民宿上海百度推广官方电话
  • 五金制品东莞网站建设技术支持网站推广软文范例
  • 网站商业授权杭州seo顾问
  • wordpress 网站备案号微信搜一搜排名优化
  • 做网站栏目都包括什么网站免费搭建
  • 社团网站建设百度seo优化策略
  • 番禺网站设计游戏推广员平台
  • 做网站都需要用到什么2023新闻大事10条
  • 做网站推广新手销售怎么和客户交流
  • 大连建设网站制作网站建设步骤流程详细介绍
  • 湛江电子商务网站建设广州代运营公司有哪些
  • 做公司 网站建设价格企业网站营销实现方式解读
  • 台州网站制作公司二级子域名ip地址查询
  • 大网站设计日本shopify独立站
  • wordpress自定义页面链接地址百家号关键词seo优化
  • 深圳企业公司苏州seo关键词优化排名
  • 集团网站建设的要求重庆网络seo
  • 58做网站百度关键词热搜
  • 中国建设银行网站怎么交学费seo免费诊断电话
  • 上海简约网站建设公司百度推广开户费用
  • 怎么用手机网站做软件好长春网站优化指导
  • 有没有专门做标书的网站关键词优化的策略
  • 游戏ui设计是什么微博seo营销
  • seo网站排名推广新闻软文范例大全
  • 石家庄桥西网站制作公司天津网络推广seo
  • 帮忙做ppt的网站seo教学
  • 安徽省住房建设厅网站青岛网站seo