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

黔东南网站建设河北青山建设集团有限公司网站

黔东南网站建设,河北青山建设集团有限公司网站,设计师培训哪家好,怎样设置个人网站需求#xff1a; 在11.0的产品开发中#xff0c;对于定制功能的需求很多#xff0c;有些机型要求可以修改系统属性值#xff0c;对于系统本身在10.0以后为了系统安全性#xff0c;不允许修改ro开头的SystemProperties的值#xff0c;所以如果要求修改ro的相关系统属性 在11.0的产品开发中对于定制功能的需求很多有些机型要求可以修改系统属性值对于系统本身在10.0以后为了系统安全性不允许修改ro开头的SystemProperties的值所以如果要求修改ro的相关系统属性就得看在设置SystemProperties的相关值的要求修改这部分要求就可以了动态修改SystemProperties中ro开头系统属性的值的核心代码 frameworks/base/core/java/android/os/SystemProperties.java/system/core/init/property_service.cpp2.动态修改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} isnt found, return {code def} if it isnt null, or an empty* string otherwise* hide*/NonNullSystemApiTestApipublic 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 isnt 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 isnt 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);}SystemApiTestApipublic 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;}}// Dont 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 hasnt started its main loop, then it wont be handling property changed messages// anyway, so theres 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;}}// Dont 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 hasnt started its main loop, then it wont be handling property changed messages// anyway, so theres 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://www.hkea.cn/news/14515193/

相关文章:

  • 温州知名网站推广企业服务账号怎么查询
  • 免费自建手机网站野望王维
  • 域名访问网站慧聪网怎样做网站友情链接
  • 阿里巴巴怎么做公司网站免费做自我介绍网站
  • 虎林网站建设成立公司怎么取名
  • 交互网站开发培训做网站犯法了 程序员有责任吗
  • 公司在兰州要做网站怎样选择互联网营销推广服务商
  • 重庆建设银行官方网站首页做采集网站难不
  • 网站开发用什么工具好微信自动加人软件免费
  • 随县住房和城乡建设局网站爱站网排名
  • 南京建设工程质量监督站网站济南企业做网站
  • 网站开发的关键技术有哪些iis网站属性没有asp.net
  • 怎么做网站版面查备案网站备案
  • 湖北省建设银行网站6php开发工具
  • 优秀的网站建设价格苏州网站建设-中国互联
  • 平面设计的网站有哪些网站怎样用代码制作网站
  • 做网站刷QQ会员网站沈阳做网络推广的公司
  • 响应式网站空间服务器要求怎么注册地理位置
  • 南通网站定制企业硬件开发一站式平台
  • 东莞网络网站建设靓号网建站
  • 如何自建网站入口启动互联全网营销推广
  • 企业网站建设一般要素包括哪些php工程师
  • 国家电网网站制作第一次做ppt怎么弄
  • 信阳市网站建设公司网站建设的基本需求有哪些
  • 重庆网站建设招标架构图在什么网站可以做
  • 酉阳网站建设宁波高端网站设计公司
  • 房产网站排行榜收录查询代码
  • 合肥网站 技术支持 上诚科技wordpress 新浪微博插件
  • 工程信息网站排名电脑版微信登录入口
  • 化妆品网站建设目的餐饮加盟网站怎么做