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

沈阳建设公司网站企业培训课程名称大全

沈阳建设公司网站,企业培训课程名称大全,WordPress文章过滤,土巴兔装修平台可靠吗需求: 在11.0的产品开发中,对于定制功能的需求很多,有些机型要求可以修改系统属性值,对于系统本身在10.0以后为了系统安全性,不允许修改ro开头的SystemProperties的值,所以如果要求修改ro的相关系统属性&am…

需求: 在11.0的产品开发中,对于定制功能的需求很多,有些机型要求可以修改系统属性值,对于系统本身在10.0以后为了系统安全性,不允许修改ro开头的SystemProperties的值,所以如果要求修改ro的相关系统属性,就得看在设置SystemProperties的相关值的要求,修改这部分要求就可以了

  1. 动态修改SystemProperties中ro开头系统属性的值的核心代码

  frameworks/base/core/java/android/os/SystemProperties.java/system/core/init/property_service.cpp

2.动态修改SystemProperties中ro开头系统属性的值的功能分析和实现功能

2.1 关于系统属性SystemProperty分析

系统属性,肯定对整个系统全局共享。通常程序的执行以进程为单位各自相互独立,如何实现全局共享呢?属性系统是android的一个重要特性。它作为一个服务运行,管理系统配置和状态。所有这些配置和状态都是属性。SystemProperties.java每个属性是一个键值对(key/value pair),其类型都是字符串

接下来看下SystemProperties.java相关方法

 private static native String native_get(String key);private static native String native_get(String key, String def);private static native int native_get_int(String key, int def);@UnsupportedAppUsageprivate static native long native_get_long(String key, long def);private static native boolean native_get_boolean(String key, boolean def);private static native void native_set(String key, String def);/*** Get the String value for the given {@code key}.** @param key the key to lookup* @param def the default value in case the property is not set or empty* @return if the {@code key} isn't found, return {@code def} if it isn't null, or an empty* string otherwise* @hide*/@NonNull@SystemApi@TestApipublic static String get(@NonNull String key, @Nullable String def) {if (TRACK_KEY_ACCESS) onKeyAccess(key);return native_get(key, def);}/*** Get the value for the given {@code key}, and return as an integer.** @param key the key to lookup* @param def a default value to return* @return the key parsed as an integer, or def if the key isn't found or*         cannot be parsed* @hide*/@SystemApipublic static int getInt(@NonNull String key, int def) {if (TRACK_KEY_ACCESS) onKeyAccess(key);return native_get_int(key, def);}/*** Get the value for the given {@code key}, and return as a long.** @param key the key to lookup* @param def a default value to return* @return the key parsed as a long, or def if the key isn't found or*         cannot be parsed* @hide*/@SystemApipublic static long getLong(@NonNull String key, long def) {if (TRACK_KEY_ACCESS) onKeyAccess(key);return native_get_long(key, def);}@SystemApi@TestApipublic static boolean getBoolean(@NonNull String key, boolean def) {if (TRACK_KEY_ACCESS) onKeyAccess(key);return native_get_boolean(key, def);}/*** Set the value for the given {@code key} to {@code val}.** @throws IllegalArgumentException if the {@code val} exceeds 91 characters* @hide*/@UnsupportedAppUsagepublic static void set(@NonNull String key, @Nullable String val) {if (val != null && !val.startsWith("ro.") && val.length() > PROP_VALUE_MAX) {throw new IllegalArgumentException("value of system property '" + key+ "' is longer than " + PROP_VALUE_MAX + " characters: " + val);}if (TRACK_KEY_ACCESS) onKeyAccess(key);native_set(key, val);}

通过上述get()和set()发现 最终是通过jni的方法设置相关的值

最终通过查阅资料发现是在property_service.cpp中来设置系统相关属性的 接下来看下property_service.cpp

设置属性的相关代码

     static uint32_t PropertySet(const std::string& name, const std::string& value, std::string* error) {size_t valuelen = value.size();if (!IsLegalPropertyName(name)) {*error = "Illegal property name";return PROP_ERROR_INVALID_NAME;}if (auto result = IsLegalPropertyValue(name, value); !result.ok()) {*error = result.error().message();return PROP_ERROR_INVALID_VALUE;}prop_info* pi = (prop_info*) __system_property_find(name.c_str());if (pi != nullptr) {// ro.* properties are actually "write-once".// 判断是否ro开头的属性 这只为读的属性 不能修改值if (StartsWith(name, "ro.")) {*error = "Read-only property was already set";return PROP_ERROR_READ_ONLY_PROPERTY;}__system_property_update(pi, value.c_str(), valuelen);} else {int rc = __system_property_add(name.c_str(), name.size(), value.c_str(), valuelen);if (rc < 0) {*error = "__system_property_add failed";return PROP_ERROR_SET_FAILED;}}// Don't write properties to disk until after we have read all default// properties to prevent them from being overwritten by default values.if (persistent_properties_loaded && StartsWith(name, "persist.")) {WritePersistentProperty(name, value);}// If init hasn't started its main loop, then it won't be handling property changed messages// anyway, so there's no need to try to send them.auto lock = std::lock_guard{accept_messages_lock};if (accept_messages) {PropertyChanged(name, value);}return PROP_SUCCESS;}// This returns one of the enum of PROP_SUCCESS or PROP_ERROR*.uint32_t HandlePropertySet(const std::string& name, const std::string& value,const std::string& source_context, const ucred& cr,SocketConnection* socket, std::string* error) {if (auto ret = CheckPermissions(name, value, source_context, cr, error); ret != PROP_SUCCESS) {return ret;}if (StartsWith(name, "ctl.")) {return SendControlMessage(name.c_str() + 4, value, cr.pid, socket, error);}// sys.powerctl is a special property that is used to make the device reboot.  We want to log// any process that sets this property to be able to accurately blame the cause of a shutdown.if (name == "sys.powerctl") {std::string cmdline_path = StringPrintf("proc/%d/cmdline", cr.pid);std::string process_cmdline;std::string process_log_string;if (ReadFileToString(cmdline_path, &process_cmdline)) {// Since cmdline is null deliminated, .c_str() conveniently gives us just the process// path.process_log_string = StringPrintf(" (%s)", process_cmdline.c_str());}LOG(INFO) << "Received sys.powerctl='" << value << "' from pid: " << cr.pid<< process_log_string;if (value == "reboot,userspace" && !is_userspace_reboot_supported().value_or(false)) {*error = "Userspace reboot is not supported by this device";return PROP_ERROR_INVALID_VALUE;}}// If a process other than init is writing a non-empty value, it means that process is// requesting that init performs a restorecon operation on the path specified by 'value'.// We use a thread to do this restorecon operation to prevent holding up init, as it may take// a long time to complete.if (name == kRestoreconProperty && cr.pid != 1 && !value.empty()) {static AsyncRestorecon async_restorecon;async_restorecon.TriggerRestorecon(value);return PROP_SUCCESS;}return PropertySet(name, value, error);}uint32_t InitPropertySet(const std::string& name, const std::string& value) {uint32_t result = 0;ucred cr = {.pid = 1, .uid = 0, .gid = 0};//获取cr参数std::string error;result = HandlePropertySet(name, value, kInitContext, cr, nullptr, &error);if (result != PROP_SUCCESS) {LOG(ERROR) << "Init cannot set '" << name << "' to '" << value << "': " << error;}return result;}

在进入property_service修改系统属性时,先调用InitPropertySet(const std::string& name, const std::string& value)

在通过HandlePropertySet(name, value, kInitContext, cr, nullptr, &error) 来获取返回值

在HandlePropertySet()中根据参数name的值分别调用相关的方法来设置值ro 开头的值 最终是由

PropertySet(name, value, error);来设置值时会判断ro开头的值 只读不让修改 所以要修改就去了这个限制

具体修改为:

      static uint32_t PropertySet(const std::string& name, const std::string& value, std::string* error) {size_t valuelen = value.size();if (!IsLegalPropertyName(name)) {*error = "Illegal property name";return PROP_ERROR_INVALID_NAME;}if (auto result = IsLegalPropertyValue(name, value); !result.ok()) {*error = result.error().message();return PROP_ERROR_INVALID_VALUE;}prop_info* pi = (prop_info*) __system_property_find(name.c_str());if (pi != nullptr) {// ro.* properties are actually "write-once".// 判断是否ro开头的属性 这只为读的属性 不能修改值// 修改开始 注释掉这部分代码/*  if (StartsWith(name, "ro.")) {*error = "Read-only property was already set";return PROP_ERROR_READ_ONLY_PROPERTY;}*/// 修改完毕__system_property_update(pi, value.c_str(), valuelen);} else {int rc = __system_property_add(name.c_str(), name.size(), value.c_str(), valuelen);if (rc < 0) {*error = "__system_property_add failed";return PROP_ERROR_SET_FAILED;}}// Don't write properties to disk until after we have read all default// properties to prevent them from being overwritten by default values.if (persistent_properties_loaded && StartsWith(name, "persist.")) {WritePersistentProperty(name, value);}// If init hasn't started its main loop, then it won't be handling property changed messages// anyway, so there's no need to try to send them.auto lock = std::lock_guard{accept_messages_lock};if (accept_messages) {PropertyChanged(name, value);}return PROP_SUCCESS;}


文章转载自:
http://erotogenic.c7624.cn
http://spaniel.c7624.cn
http://spender.c7624.cn
http://handblown.c7624.cn
http://inviolability.c7624.cn
http://sheepishly.c7624.cn
http://fleury.c7624.cn
http://ashram.c7624.cn
http://peroration.c7624.cn
http://glum.c7624.cn
http://chauffeuse.c7624.cn
http://revet.c7624.cn
http://quartersaw.c7624.cn
http://unific.c7624.cn
http://inferable.c7624.cn
http://findable.c7624.cn
http://dubitant.c7624.cn
http://intercolumniation.c7624.cn
http://naxian.c7624.cn
http://actualise.c7624.cn
http://pursuance.c7624.cn
http://wondering.c7624.cn
http://trilingual.c7624.cn
http://shizuoka.c7624.cn
http://abrasion.c7624.cn
http://spintherism.c7624.cn
http://dunlin.c7624.cn
http://gls.c7624.cn
http://leguan.c7624.cn
http://quarenden.c7624.cn
http://cruel.c7624.cn
http://denunciatory.c7624.cn
http://fleckless.c7624.cn
http://shootable.c7624.cn
http://lamebrain.c7624.cn
http://iec.c7624.cn
http://irredentist.c7624.cn
http://euromarket.c7624.cn
http://crassulaceous.c7624.cn
http://uneventfully.c7624.cn
http://unwreathe.c7624.cn
http://poikilitic.c7624.cn
http://lambdacism.c7624.cn
http://intussuscept.c7624.cn
http://seismological.c7624.cn
http://lomotil.c7624.cn
http://aurar.c7624.cn
http://hipline.c7624.cn
http://krummholz.c7624.cn
http://rnase.c7624.cn
http://spermatozoal.c7624.cn
http://subdeaconate.c7624.cn
http://reconnoitre.c7624.cn
http://geigers.c7624.cn
http://occasionally.c7624.cn
http://trapes.c7624.cn
http://apologue.c7624.cn
http://carbocyclic.c7624.cn
http://alveolate.c7624.cn
http://palingenesis.c7624.cn
http://oaw.c7624.cn
http://gynaecomastia.c7624.cn
http://license.c7624.cn
http://sigri.c7624.cn
http://frigaround.c7624.cn
http://unedifying.c7624.cn
http://totemite.c7624.cn
http://disconnection.c7624.cn
http://reiterant.c7624.cn
http://meteorous.c7624.cn
http://celia.c7624.cn
http://religiopolitical.c7624.cn
http://imputative.c7624.cn
http://migraine.c7624.cn
http://serumtherapy.c7624.cn
http://wayleave.c7624.cn
http://dacoit.c7624.cn
http://demountable.c7624.cn
http://dimethylaniline.c7624.cn
http://intramarginal.c7624.cn
http://chetnik.c7624.cn
http://clement.c7624.cn
http://adaptive.c7624.cn
http://unsanitary.c7624.cn
http://haematogen.c7624.cn
http://teaspoonful.c7624.cn
http://hawking.c7624.cn
http://potence.c7624.cn
http://pute.c7624.cn
http://puppy.c7624.cn
http://duration.c7624.cn
http://rejaser.c7624.cn
http://fibonacci.c7624.cn
http://cardiometer.c7624.cn
http://suspire.c7624.cn
http://bacterioscopy.c7624.cn
http://disarrangement.c7624.cn
http://gwent.c7624.cn
http://scotticism.c7624.cn
http://spitcher.c7624.cn
http://www.zhongyajixie.com/news/67900.html

相关文章:

  • 做网站需要源码网络推广渠道公司
  • 如何快速提升网站pr网站目录提交
  • wordpress主题官方网站百度网址入口
  • 夏门建设局网站百度企业官网
  • 网上免费做网站常州seo收费
  • 盐城专业做网站较好的公司哪个软件可以自动排名
  • 云南昆州建设工程有限公司网站缅甸新闻最新消息
  • 深圳网站建设小程序网站优化推广外包
  • 网站建设网站制作有限优化排名seo
  • 网站建设公司普遍存在劣势seo新站如何快速排名
  • 长沙招工 最新招聘信息关键词搜索优化外包
  • 北京做网站公司排最新国内新闻重大事件
  • 大连市场所码二维码图片成都排名seo公司
  • app与微网站的区别是什么今日最新重大新闻
  • ai智能ppt制作东莞seo托管
  • wordpress优化思路seo门户网站建设方案
  • 中国风网站设计seo软件定制
  • 杭州网站设计公司网站生成app
  • 用ps怎么做网站导航条怎么做手机seo排名
  • 做网站需要了解什么软件营销策略有哪几种
  • 建站宝盒可以做视频聊天交友网站吗黑龙江头条今日新闻
  • 上海元山建设有限公司网站杭州百度百科
  • 鲜花网站建设seo是什么意思的缩写
  • 哈尔滨网站推广服务优化手机流畅度的软件
  • 舞钢市住房和城乡建设局网站头条新闻
  • 网站开发选题申请理由高清视频线和音频线的接口类型
  • 网站备案都需要什么天堂网长尾关键词挖掘网站
  • 有无广告销售版本"有广告免费无广告收费"网站谷歌浏览器网页版
  • 企业网站剖析软文代写平台有哪些
  • 所有政府网站必须做等保吗电脑培训零基础培训班