Android中的android.provider.Settings.System系统属性设定

Android Settings和SettingsProvider源码分析与修改,Android外包是如何转正网易的 由于本文罗列的知识点是根据我自身总结出来的,并且由于本人水平有限,无法全部提及,欢迎大神们能补充~将来我会对上面的知识点一个一个深入学习,也希望有童鞋跟我一起学习,一起进阶。提升架构认知不是一蹴而就的,它离不开刻意学习和思考。**这里,笔者分享一份从架构哲学的层面来剖析的视频及资料分享给大家,**梳理了多年的架构经验,筹备近1个月最新录制的,相信这份视频能给你带来不一样的启发、收获。,第一时间获取最新知识点Android架构师之路很漫长,一起共勉吧! 阅读详情

Content Provider中的Setting.System表格内存储了很多系统属性的值,以键值对的形式存在!

可以对如下的变量进行设置

Constants
StringACCELEROMETER_ROTATIONControl whether the accelerometer will be used to change screen orientation.
StringADB_ENABLEDThis constant is deprecated. Use ADB_ENABLED instead
StringAIRPLANE_MODE_ONWhether Airplane Mode is on.
StringAIRPLANE_MODE_RADIOSA comma separated list of radios that need to be disabled when airplane mode is on.
StringALARM_ALERTPersistent store for the system-wide default alarm alert.
StringALWAYS_FINISH_ACTIVITIESIf 1, the activity manager will aggressively finish activities and processes as soon as they are no longer needed.
StringANDROID_IDThis constant is deprecated. Use ANDROID_ID instead
StringAPPEND_FOR_LAST_AUDIBLEAppended to various volume related settings to record the previous values before they the settings were affected by a silent/vibrate ringer mode change.
StringAUTO_TIMEValue to specify if the user prefers the date, time and time zone to be automatically fetched from the network (NITZ).
StringAUTO_TIME_ZONEValue to specify if the user prefers the time zone to be automatically fetched from the network (NITZ).
StringBLUETOOTH_DISCOVERABILITYDetermines whether remote devices may discover and/or connect to this device.
StringBLUETOOTH_DISCOVERABILITY_TIMEOUTBluetooth discoverability timeout.
StringBLUETOOTH_ONThis constant is deprecated. Use BLUETOOTH_ON instead
StringDATA_ROAMINGThis constant is deprecated. Use DATA_ROAMING instead
StringDATE_FORMATDate format string mm/dd/yyyy dd/mm/yyyy yyyy/mm/dd
StringDEBUG_APPName of an application package to be debugged.
StringDEVICE_PROVISIONEDThis constant is deprecated. Use DEVICE_PROVISIONED instead
StringDIM_SCREENWhether or not to dim the screen.
StringDTMF_TONE_WHEN_DIALINGWhether the audible DTMF tones are played by the dialer when dialing.
StringEND_BUTTON_BEHAVIORWhat happens when the user presses the end call button if they're not on a call.
StringFONT_SCALEScaling factor for fonts, float.
StringHAPTIC_FEEDBACK_ENABLEDWhether the haptic feedback (long presses, ...) are enabled.
StringHTTP_PROXYThis constant is deprecated. Use HTTP_PROXY instead
StringINSTALL_NON_MARKET_APPSThis constant is deprecated. Use INSTALL_NON_MARKET_APPS instead
StringLOCATION_PROVIDERS_ALLOWEDThis constant is deprecated. Use LOCATION_PROVIDERS_ALLOWED instead
StringLOCK_PATTERN_ENABLEDThis constant is deprecated. Use LOCK_PATTERN_ENABLED instead
StringLOCK_PATTERN_TACTILE_FEEDBACK_ENABLEDThis constant is deprecated. Use LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED instead
StringLOCK_PATTERN_VISIBLEThis constant is deprecated. Use LOCK_PATTERN_VISIBLE instead
StringLOGGING_IDThis constant is deprecated. Use LOGGING_ID instead
StringMODE_RINGERRinger mode.
StringMODE_RINGER_STREAMS_AFFECTEDDetermines which streams are affected by ringer mode changes.
StringMUTE_STREAMS_AFFECTEDDetermines which streams are affected by mute.
StringNETWORK_PREFERENCEThis constant is deprecated. Use NETWORK_PREFERENCE instead
StringNEXT_ALARM_FORMATTEDA formatted string of the next alarm that is set, or the empty string if there is no alarm set.
StringNOTIFICATION_SOUNDPersistent store for the system-wide default notification sound.
StringPARENTAL_CONTROL_ENABLEDThis constant is deprecated. Use PARENTAL_CONTROL_ENABLED instead
StringPARENTAL_CONTROL_LAST_UPDATEThis constant is deprecated. Use PARENTAL_CONTROL_LAST_UPDATE instead
StringPARENTAL_CONTROL_REDIRECT_URLThis constant is deprecated. Use PARENTAL_CONTROL_REDIRECT_URL instead
StringRADIO_BLUETOOTHConstant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
StringRADIO_CELLConstant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
StringRADIO_NFCConstant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
StringRADIO_WIFIConstant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
StringRINGTONEPersistent store for the system-wide default ringtone URI.
StringSCREEN_BRIGHTNESSThe screen backlight brightness between 0 and 255.
StringSCREEN_BRIGHTNESS_MODEControl whether to enable automatic brightness mode.
intSCREEN_BRIGHTNESS_MODE_AUTOMATICSCREEN_BRIGHTNESS_MODE value for automatic mode.
intSCREEN_BRIGHTNESS_MODE_MANUALSCREEN_BRIGHTNESS_MODE value for manual mode.
StringSCREEN_OFF_TIMEOUTThe timeout before the screen turns off.
StringSETTINGS_CLASSNAMEThis constant is deprecated. Use SETTINGS_CLASSNAME instead
StringSETUP_WIZARD_HAS_RUNWhether the setup wizard has been run before (on first boot), or if it still needs to be run.
StringSHOW_GTALK_SERVICE_STATUS 
StringSHOW_PROCESSESControl whether the process CPU usage meter should be shown.
StringSHOW_WEB_SUGGESTIONSThis constant is deprecated. Each application that shows web suggestions should have its own setting for this.
StringSOUND_EFFECTS_ENABLEDWhether the sounds effects (key clicks, lid open ...) are enabled.
StringSTAY_ON_WHILE_PLUGGED_INWhether we keep the device on while the device is plugged in.
StringSYS_PROP_SETTING_VERSION 
StringTEXT_AUTO_CAPSSetting to enable Auto Caps in text editors.
StringTEXT_AUTO_PUNCTUATESetting to enable Auto Punctuate in text editors.
StringTEXT_AUTO_REPLACESetting to enable Auto Replace (AutoText) in text editors.
StringTEXT_SHOW_PASSWORDSetting to showing password characters in text editors.
StringTIME_12_24Display times as 12 or 24 hours 12 24
StringTRANSITION_ANIMATION_SCALEScaling factor for activity transition animations.
StringUSB_MASS_STORAGE_ENABLEDThis constant is deprecated. Use USB_MASS_STORAGE_ENABLED instead
StringUSER_ROTATIONDefault screen rotation when no other policy applies.
StringUSE_GOOGLE_MAILThis constant is deprecated. Use USE_GOOGLE_MAIL instead
StringVIBRATE_ONWhether vibrate is on for different events.
StringVOLUME_ALARMAlarm volume.
StringVOLUME_BLUETOOTH_SCOBluetooth Headset volume.
StringVOLUME_MUSICMusic/media/gaming volume.
StringVOLUME_NOTIFICATIONNotification volume.
StringVOLUME_RINGRinger volume.
StringVOLUME_SYSTEMSystem/notifications volume.
StringVOLUME_VOICEVoice call volume.
StringWAIT_FOR_DEBUGGERIf 1, when launching DEBUG_APP it will wait for the debugger before starting user code.
StringWALLPAPER_ACTIVITYName of activity to use for wallpaper on the home screen.
StringWIFI_MAX_DHCP_RETRY_COUNTThis constant is deprecated. Use WIFI_MAX_DHCP_RETRY_COUNT instead
StringWIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MSThis constant is deprecated. Use WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS instead
StringWIFI_NETWORKS_AVAILABLE_NOTIFICATION_ONThis constant is deprecated. Use WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON instead
StringWIFI_NETWORKS_AVAILABLE_REPEAT_DELAYThis constant is deprecated. Use WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY instead
StringWIFI_NUM_OPEN_NETWORKS_KEPTThis constant is deprecated. Use WIFI_NUM_OPEN_NETWORKS_KEPT instead
StringWIFI_ONThis constant is deprecated. Use WIFI_ON instead
StringWIFI_SLEEP_POLICYThe policy for deciding when Wi-Fi should go to sleep (which will in turn switch to using the mobile data as an Internet connection).
intWIFI_SLEEP_POLICY_DEFAULTValue for WIFI_SLEEP_POLICY to use the default Wi-Fi sleep policy, which is to sleep shortly after the turning off according to the STAY_ON_WHILE_PLUGGED_IN setting.
intWIFI_SLEEP_POLICY_NEVERValue for WIFI_SLEEP_POLICY to never go to sleep.
intWIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGEDValue for WIFI_SLEEP_POLICY to use the default policy when the device is on battery, and never go to sleep when the device is plugged in.
StringWIFI_STATIC_DNS1If using static IP, the primary DNS's IP address.
StringWIFI_STATIC_DNS2If using static IP, the secondary DNS's IP address.
StringWIFI_STATIC_GATEWAYIf using static IP, the gateway's IP address.
StringWIFI_STATIC_IPThe static IP address.
StringWIFI_STATIC_NETMASKIf using static IP, the net mask.
StringWIFI_USE_STATIC_IPWhether to use static IP and other static network attributes.
StringWIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGEThis constant is deprecated. Use WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE instead
StringWIFI_WATCHDOG_AP_COUNTThis constant is deprecated. Use WIFI_WATCHDOG_AP_COUNT instead
StringWIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MSThis constant is deprecated. Use WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS instead
StringWIFI_WATCHDOG_BACKGROUND_CHECK_ENABLEDThis constant is deprecated. Use WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED instead
StringWIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MSThis constant is deprecated. Use WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS instead
StringWIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNTThis constant is deprecated. Use WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT instead
StringWIFI_WATCHDOG_MAX_AP_CHECKSThis constant is deprecated. Use WIFI_WATCHDOG_MAX_AP_CHECKS instead
StringWIFI_WATCHDOG_ONThis constant is deprecated. Use WIFI_WATCHDOG_ON instead
StringWIFI_WATCHDOG_PING_COUNTThis constant is deprecated. Use WIFI_WATCHDOG_PING_COUNT instead
StringWIFI_WATCHDOG_PING_DELAY_MSThis constant is deprecated. Use WIFI_WATCHDOG_PING_DELAY_MS instead
StringWIFI_WATCHDOG_PING_TIMEOUT_MSThis constant is deprecated. Use WIFI_WATCHDOG_PING_TIMEOUT_MS instead
StringWINDOW_ANIMATION_SCALEScaling factor for normal window animations.

通过如下的函数可以对其进行读写:

static void getConfiguration( ContentResolver cr, Configuration outConfig)
Convenience function to read all of the current configuration-related settings into a Configuration object.
static float getFloat( ContentResolver cr, String name, float def)
Convenience function for retrieving a single system settings value as a floating point number.
static float getFloat( ContentResolver cr, String name)
Convenience function for retrieving a single system settings value as a float.
static int getInt( ContentResolver cr, String name)
Convenience function for retrieving a single system settings value as an integer.
static int getInt( ContentResolver cr, String name, int def)
Convenience function for retrieving a single system settings value as an integer.
static long getLong( ContentResolver cr, String name, long def)
Convenience function for retrieving a single system settings value as a long.
static long getLong( ContentResolver cr, String name)
Convenience function for retrieving a single system settings value as a long.
static boolean getShowGTalkServiceStatus( ContentResolver cr)
synchronized static String getString( ContentResolver resolver, String name)
Look up a name in the database.
static Uri getUriFor( String name)
Construct the content URI for a particular name/value pair, useful for monitoring changes with a ContentObserver.
static boolean putConfiguration( ContentResolver cr, Configuration config)
Convenience function to write a batch of configuration-related settings from a Configuration object.
static boolean putFloat( ContentResolver cr, String name, float value)
Convenience function for updating a single settings value as a floating point number.
static boolean putInt( ContentResolver cr, String name, int value)
Convenience function for updating a single settings value as an integer.
static boolean putLong( ContentResolver cr, String name, long value)
Convenience function for updating a single settings value as a long integer.
static boolean putString( ContentResolver resolver, String name, String value)
Store a name/value pair into the database.
static void setShowGTalkServiceStatus( ContentResolver cr, boolean flag)


注意,应用程序中应加入: <uses-permission android:name="android.permission.WRITE_SETTINGS" />


Android中的SettingsProvider SettingsProvider用来提供,主要用来存放一些Android系统的默认初始值。在Android 6.0版本时,SettingsProvider被重构,Android从性能、安全等方面考虑,把SettingsProvider中原本保存在settings.db中的数据,目前改为全部保存在下的对应中。用一句话概括SettingsProvider的作用,SettingsProvider包含全局性、系统级别的用户编好设置。 阅读详情

相关推荐

Android Settings 存储机制详解:System、Global、Secure 的区别与应用场景

在 Android 开发中,数据持久化是应用设计的核心环节,开发者通常从 SharedPreferences 或 SQLite 数据库等应用层存储方案入手。这些方案基于文件或数据库原理,为应用提供了私有数据存储能力,但其进程隔离性和抗系统清理能力存在局限。为了满足跨进程配置同步、系统级设置管理等高级需求,Android 框架提供了更为底层的 Settings 系统作为技术解决方案。Settings 系统通过 ContentProvider 机制,以键值对形式集中管理设备与用户的配置信息,其技术价值在于提供了

weixin_34234721的博客 431

Android-Setting 保存数据分析

1、Settings Settings主要要三个了System,Global和Secure来保存设置的值 System-putString保存值 保存数据是,先判断设置的数据key值是否在MOVED_TO_SECURE、MOVED_TO_GLOBAL或者MOVED_TO_SECURE_THEN_GLOBAL数组中,如果在则直接返回false.如果存在则调用sNameValueCache...

nilingxi的专栏 4151

深入解析Android Framework层Settings存储机制:System、Secure与Global的实战应用

本文深入解析Android Framework层Settings存储机制,详细探讨System、Secure与Global三种设置的应用场景与实战技巧。通过代码示例和ADB操作指南,帮助开发者掌握权限管理、数据存储及跨版本兼容等关键技术,提升系统级功能开发效率。重点分析存储机制在系统设置管理中的核心作用。

weixin_29292431的博客 383

Androi系统设置Table

Settings.System extends Settings.NameValueTable java.lang.Object    ↳ android.provider.Settings.NameValueTable      ↳ android.provider.Settings.System Class Overview S

1636

深入解析Android Framework层Settings存储机制:Global、Secure与System的实战应用

本文深入解析Android Framework层Settings存储机制,详细阐述了Settings.Global、Settings.Secure与Settings.System三大核心存储区域的区别、权限边界及实战应用。通过代码示例与ADB调试技巧,指导开发者正确进行读写操作、监听变化并实现跨进程通信与状态持久化,有效解决系统配置重启失效等常见问题。

weixin_29309475的博客 226

解决Android系统应用(android.uid.system)使用FileProvider安装APK的权限问题

本文深入分析了Android系统应用(android.uid.system)在使用FileProvider安装APK时遭遇“解析软件包时出现问题”的根源。通过解读关键日志与追踪AOSP源码,揭示了ActivityManagerService(AMS)对系统UID应用授予URI权限的安全限制,并提供了放弃系统UID、修改系统白名单、伪装授权等多种针对性解决方案,帮助开发者彻底解决这一权限难题。

lg888的博客 896

SettingsProvider之System内部类

转载请注明出处: 1、字段转移 MOVED_TO_SECURE = new HashSet(30);             MOVED_TO_SECURE.add(Secure.ANDROID_ID);             MOVED_TO_SECURE.add(Secure.HTTP_PROXY); MOVED_TO_GLOBAL = new HashSet();

hailushijie的专栏 5637

小红书UID泄露风险揭秘:如何防止你的手机号被社工库关联(附防护指南)

本文揭示了小红书UID泄露的严重风险,详细解析了UID与手机号关联后被社工库利用的完整链条。通过分析黑产的数据整合技术,提供从基础到进阶的防护策略,包括密码管理、账号隔离和应急响应措施,帮助用户有效防范个人信息泄露风险。

ol789012345的博客 1511

【Android FrameWork】第三十四天:系统设置项(Settings)与系统属性(System Properties)

Android系统配置管理存在两个核心维度:系统设置项(Settings)和系统属性(System Properties)。系统设置项面向应用层,通过SettingsProvider和SQLite数据库实现持久化配置,支持权限分级和监听机制;系统属性面向底层,通过init进程维护内存哈希表和持久化文件,提供轻量级运行时配置。二者在设计目标、存储机制和访问权限上存在显著差异,前者适合用户可感知的持久化配置,后者适合系统底层的运行时状态管理。

u012739527的博客 2703

天线学习笔记——HFSS简单阵列天线

在HFSS15.0版本中使用 Radiation --> Antenna Array Setup 设置天线阵列的参数时的设计列表如下: 值得注意的是,在该版本中所定义的是:第一个阵元的位置坐标(First Cell Position)、阵元之间的间距(Directions)和阵元的数量(Number of Cells) 这些参数。 在ANSYS中的HFSS仿真中定义天线阵列如下: 与老版本不同的是:中心点坐标(Center Position)和布局设置(Layout Setting)。在布局设置中

Ethan的博客 1万+

KEIL-MDK代码美化神器:AStyle配置全攻略(附常用参数详解)

本文详细介绍了如何在KEIL-MDK中配置和使用AStyle代码格式化工具,包括基础参数设置、高级格式控制、团队协作方案以及KEIL深度集成技巧。通过合理的AStyle配置,开发者可以显著提升代码风格一致性,优化团队协作效率,特别适合嵌入式开发项目。

weixin_30505225的博客 146

给android添加系统属性:Settings.system和SystemProperties

android源码开发中,常常要用到一些全局标志或者说变量,这时候我们可以给android系统添加自己想要的属性。 1.Settings.system 这种系统属性我们经常用到,例如飞行模式的开启和关闭,我们就是去改变Settings.system.AIRPLANE_MODE_ON 的值。 下面就介绍下我们怎样去定义一个系统属性。例如要添加一个属性名为“SILVAN_LIU” 路径:fra

vrix的专栏 1492

电镀技术:微型制造的原子级加法工艺与核心优势

电镀是一种利用电解原理在基材表面沉积金属层的表面处理技术,其本质是通过电场控制溶液中金属离子的迁移与还原,实现原子级的可控沉积。这一过程的核心在于对电流密度、温度、添加剂等参数的精密调控,从而实现对镀层结晶结构、性能的“编程”。从技术价值看,电镀作为一种“加法制造”工艺,在微观尺度上具有无与伦比的保形性和材料灵活性,能够实现复杂三维结构的均匀覆盖与功能复合。在应用场景上,它尤其契合现代微型化制造的需求,例如在集成电路的铜互连填充、高密度PCB板微孔金属化、MEMS传感器电极制备以及柔性电子器件制造中发挥着不

weixin_42524842的博客 528

Android 12系统源码_系统设置(一)Settings介绍

结合Android12系统源码梳理设备设置关键类Settings的相关代码。

AfinalStone的专栏 3506

LPDDR6 Efficiency Mode 技术探讨

LPDDR6 Efficiency Mode 技术探讨

zilan23的博客 1159

修改Windows hosts文件的解决方案

本文主要介绍了修改Windows hosts文件解决方案,希望能对新手有所帮助。 文章目录 1. 问题描述 2. 解决方案 2.1 安装软件 2.2 修改hosts文件

weixin_43178406的博客 1万+

Android SystemProperties和Settings.System介绍

Android SystemProperties和Settings.System介绍,不同应用间传递信息 1 使用 SystemProperties.get 这中方法在framework里面 经常见到。 特别属性 如果属性名称以“ro.”开头,那么这个属性被视为只读属性。一旦设置,属性值不能改变。 如果属性名称以“persist.”开头,当设置这个属性时,其值也将写入/d

dylancao的专栏 865

安装Office程序时无法安装的解决方案

本文主要介绍了安装Office程序时无法安装的解决方案,希望能对安装Office的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案 2.1 前置步骤 2.2 方法一 2.3 方法二

weixin_43178406的博客 15万+

使用adb查看Settings Provider的值

        使用adb查看Settings Provider的值    在Android的ROM开发中,经常会遇到一些修改系统默认的Settings Provider的值要求,那么修改以后,怎么验证呢。本篇文章介绍一种方法,通过adb查看。 Settings Provider简介    SettingsProvider顾名思义是一个提供设置数据共享的Provider,里面存放...

IT先森 1万+

YOLO11改进:轻量级改进 | 通用倒瓶颈(UIB)搜索块结合C3k2二次创新 | 轻量化之王MobileNetV4

通用倒瓶颈(UIB)搜索块替代YOLO11的C3k2

会AI的学姐 293

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

安卓Settings数据库修改追踪与调试技巧

在安卓系统开发中,数据库操作追踪是调试系统设置异常修改的关键技术。通过ContentProvider机制,系统设置(Settings)数据存储在SQLite数据库中,包括system、secure和global三个表。dumpsys命令可以获取Settings Provider的操作记录,结合logcat时间戳分析,开发者能够精准定位异常修改的调用方进程。这项技术在系统权限管理、应用行为监控等场景具有重要价值,特别是在处理自动亮度异常、GPS设置被篡改等典型问题时尤为有效。通过adb shell命令和gre

weixin_30698527的博客 319

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

android 系统属性 或 自定义属性

if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_HDMI_CEC)) { traceBeginAndSlog("StartHdmiControlService"); mSystemServiceManager.startService(HdmiControlSer...

蚁人日记 2474

Android settings命令讲解和实战

1,简介 在Android系统中,settings命令用于管理设备设置。这些命令可以与`Settings`提供者(`Settings provider`)交互,后者是一个用于存储和检索系统设置的系统服务。Settings provider在Android系统中可以被看作是一个特殊的数据库,它用于存储和检索系...

weixin_42602368的博客 708

Android系统属性实战:从adb命令到代码调用的完整指南(附常见属性列表)

本文全面解析Android系统属性的双轨机制(SystemProperties与Settings Provider),提供从adb命令行操作到Java代码调用的实战指南。涵盖属性读取/修改、权限管理、性能优化等核心技巧,并附开发者必备的常见属性清单,帮助开发者高效管理系统配置。

efc1234567的博客 989

Android 使用系统限制的权限的apk应安装到 /system/app 目录下

在 Android 中,如果要使用系统限制的权限(比如 android.permission.WRITE_SECURE_SETTINGS),我们需要把程序安装到 /system/app/ 下     比如,我写了一个APK ,其中的主 Activity中用到以

xiaogeng的专栏 3万+

查询/设置Settings的值

按计划每周更新一篇技术博文,第四篇:《查询/设置Settings的值》     通常很多定制系统或者与系统相关的应用都需要查询/设置Settings(设置)里边的值,比如系统亮度,休眠时间,锁屏之类的系统设置等,主要通过SettingsProvider来查询/设置,前提是要知道所要修改的值的数据类型与字符串代表的name。     对应的name值与数据类型在./ics/framewo

钟秀 2万+
上一篇: Android中关于Audio库的知识
下一篇: Android 在一个程序中启动另一个程序
shareCode
博客等级 码龄15年 125粉丝 40原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值