atma怎么修改装备属性去修改setting中的属性

c#修改config中的AppSettings属性
时间: 10:17:02
&&&& 阅读:83
&&&& 评论:
&&&& 收藏:0
标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Configuration cfa =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
cfa.AppSettings.Settings["MAC"].Value =
cfa.Save();标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&原文:/lzh_527/p/3664158.html
&&国之画&&&& &&&&&&
&& &&&&&&&&&&&&&&
鲁ICP备号-4
打开技术之扣,分享程序人生!Android(21)
在Android中,许多的系统属性都在settings应用当中进行设置的,比如wifi、蓝牙状态,当前本机语言,屏幕亮度等等一些相关的系统属性值。这些数据主要是存储在数据库中,对应的URI为:content://settings/system和content://settings/secure,这两个是主要的,目前也只是涉及到这两个数据库表的使用。
&1& 获取和设置一些系统属性,通过一系列的get/set方法
当需要获得当前wifi状态的值,调用已封装的方法如下:
Settings.Secure.getInt(getContentResolver() , Settings.Secure.WIFI_ON);
当需要获得当前时间日期自动获取,调用如下:
修改也是调用对应的setInt方法。
注意:这里修改settings的系统属性值需要有相关的权限。如修改wifi状态需要有android.permission.WRITE_SETTINGS权限,权限问题只要参考sdk下的描述就可以。还有其他属性等等
&2&添加自定义的属性(好处是在缓存中不会被清除)
需要系统app权限 需要加 :
android:sharedUserId="android.uid.system"
&uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /&
还需要用系统签名打包
Settings.Secure.putInt(context.getContentResolver(), key, value)
Settings.Secure.getInt(appContext.getContentResolver(), value)
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:4318次
排名:千里之外
原创:22篇
(5)(4)(1)(1)(12)(2)(2)温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(3576)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'SqlMapConfig.xml中的setting属性',
blogAbstract:'&settingscacheModelsEnabled=\"true\"lazyLoadingEnabled=\"false\"enhancementEnabled=\"true\"maxSessions=\"64\"maxTransactions=\"8\"maxRequests=\"128\"useStatementNamespaces=\"false\"classInfoCacheEnabled=\"true\"errorTracingEnabled=\"true\"defaultStatementTimeout=\"\"statementCachingEnabled=\"true\"/&&!--',
blogTag:'ibatis,settings',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:8,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:true,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}3380人阅读
android(79)
android零碎知识点(99)
android源码开发中,常常要用到一些全局标志或者说变量,这时候我们可以给android系统添加自己想要的属性。
1.Settings.system
这种系统属性我们经常用到,例如飞行模式的开启和关闭,我们就是去改变Settings.system.AIRPLANE_MODE_ON 的值。
下面就介绍下我们怎样去定义一个系统属性。例如要添加一个属性名为“SILVAN_LIU”
路径:frameworks/base/core/java/android/provider/Settings.java
public&static&final&String&SILVAN_LIU&=&&silvan_liu&;&&&public&static&final&String[]&SETTINGS_TO_BACKUP&={&&&&&&&&&&&&&&~&&&&&&&&&+SILVAN_LIU&&&&&&&&&&&&&&&&~&&&&&}&&
public static final String SILVAN_LIU = &silvan_liu&;
public static final String[] SETTINGS_TO_BACKUP ={
+SILVAN_LIU
}这样添加后,你就是可以通过Settings.System.getInt(getContentResolver(), Settings.System.SILVAN_LIU,0) 和Settings.System.getInt(getContentResolver(), Settings.System.SILVAN_LIU,0)去得到和设定SILVAN_LIU的属性值。
2.SystemProperties
创建与修改android属性用Systemproperties.set(name, value),获取android属性用Systemproperties.get(name),需要注意的是android属性的名称是有一定的格式要求的,如下:&前缀必须用system\core\init\property_service.c中定义的前缀&,进行系统属性设置的程序也必须有system或root权限
如果我们要添加一个property:例如:silvan_liu
路径:system/core/rootdir/int.rc
在on post-fs-data 目录下
persist.sys.silvan_liu
1//persist.sys 前缀名; 1为初始值
PS:不同前缀名权限不同,这里就不一一说明;还有为什么要加载on post-fs-data目录下,这和int.rc的语法有关。
以上是我实际项目中运用到的地方,可能认识的不够深刻,还需继续摸索。
===========================================================================================================================
1 使用 SystemProperties.get
这中方法在framework里面 经常见到。
如果属性名称以“ro.”开头,那么这个属性被视为只读属性。一旦设置,属性值不能改变。
如果属性名称以“persist.”开头,当设置这个属性时,其值也将写入/data/property。
在c++中就是对应JAVA的两个函数就是property_set, property_get,其实JAVA是通过JNI调用这两个函数的。
import android.os.SystemP
SystemProperties.set(&persist.sys.language&, zone.getID());
String lang= SystemProperties.get(&persist.sys.language&);
#include &cutils/properties.h&
property_set(&persist.sys.language&, &zh&);
property_get(&persist.sys.language&, propLang, &en&);
在adb shell可以通过以下的命名读取和修改
#getprop& persist.sys.language
#setprop&& persist.sys.language& zh
2 使用 Settings.System.putInt&
这种方式会保存变量到Settings 数据库中,飞行模式等的开关就是用这种方式实现的。
在Manifest.xml中包含权限:
&uses-permission android:name=”android.permission.WRITE_SETTINGS” /&
在需要发送数据的java文件中,包含:
import android.provider.S
import android.content.ContentR
ContentResolver resolver = mContext.getContentResolver();
Settings.System.putInt(resolver,”inputFlag”,1);
同理,在接收数据端:
Settings.System.getInt(resolver,”inputFlag”,3);
mContext为所在应用的上下文。
===========================================================================================================================
& & 通常很多定制系统或者与系统相关的应用都需要查询/设置Settings(设置)里边的值,比如系统亮度,休眠时间,锁屏之类的系统设置等,主要通过SettingsProvider来查询/设置,前提是要知道所要修改的值的数据类型与字符串代表的name。
& & 对应的name值与数据类型在./ics/frameworks/base/core/java/android/provider/Settings.java文件中,例举两个例子如下:
1.查询休眠时间:
&&&&&public&static&String&getTimeOut(ContentResolver&resolver){&&int&timeOut&=&0;&&try&{&&timeOut&=&android.provider.Settings.System.getInt(resolver,&Settings.System.SCREEN_BRIGHTNESS);&&timeOut&/=&1000;&&}&catch&(SettingNotFoundException&e)&{&&e.printStackTrace();&&}&&String&timeOutStr&=&timeOut&+&&&;&&return&timeOutS&&}&&
* 获取系统休眠时间
* @return 秒数(从不待机 返回0)
public static String getTimeOut(ContentResolver resolver){
int timeOut = 0;
timeOut = android.provider.Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS);
timeOut /= 1000;
} catch (SettingNotFoundException e) {
e.printStackTrace();
String timeOutStr = timeOut + &&;
return timeOutS
2.更改系统亮度:
&&&&&&&public&static&void&saveBrightness(ContentResolver&resolver,&float&brightness)&{&&Uri&uri&=&android.provider.Settings.System&&.getUriFor(Settings.System.SCREEN_BRIGHTNESS);&&android.provider.Settings.System.putInt(resolver,&Settings.System.SCREEN_BRIGHTNESS,&&(int)(brightness*255));&&resolver.notifyChange(uri,&null);&&}&&
* 保存亮度设置状态
* 改变setting值
* @param resolver
* @param brightness : 0~1
public static void saveBrightness(ContentResolver resolver, float brightness) {
Uri uri = android.provider.Settings.System
.getUriFor(Settings.System.SCREEN_BRIGHTNESS);
android.provider.Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS,
(int)(brightness*255));
resolver.notifyChange(uri, null);
需要权限:
&android:name=&android.permission.WRITE_SETTINGS&&&&
&uses-permission android:name=&android.permission.WRITE_SETTINGS& /&
a.查询Settings中各个属性所对应的值(Android APIs):
b.ContentResolver Context提供getContentResolver()方法可以获取ContentResolver对象,便可以操作文中前边所提的SettingsProvider所暴露的数据。
c.Android系统提供大量的SettingsProvider,Settings除外,常用的还有管理联系人(ContactsContract)、短信(Telephony)、多媒体数据(MediaStore)等,对应的URI可到这里查看:,源码路径:./ics/frameworks/base/core/java/android/provider/
d.Settings默认初始值的位置(修改之前最好弄明白先,修改后再测试一下):frameworks/base/packages/SettingsProvider/res/values/defaults.xml
=========================================================================
Content Provider中的Setting.System表格内存储了很多系统属性的值,以键值对的形式存在!
可以对如下的变量进行设置
Control whether the accelerometer will be used to change screen orientation.
This constant is deprecated. Use&&instead
Whether Airplane Mode is on.
A comma separated list of radios that need to be disabled when airplane mode is on.
Persistent store for the system-wide default alarm alert.
If 1, the activity manager will aggressively finish activities and processes as soon as they are no longer needed.
This constant is deprecated. Use&&instead
Appended to various volume related settings to record the previous values before they the settings were affected by a silent/vibrate ringer mode change.
Value to specify if the user prefers the date, time and time zone to be automatically fetched from the network (NITZ).
Value to specify if the user prefers the time zone to be automatically fetched from the network (NITZ).
Determines whether remote devices may discover and/or connect to this device.
Bluetooth discoverability timeout.
This constant is deprecated. Use&&instead
This constant is deprecated. Use&&instead
Date format string mm/dd/yyyy dd/mm/yyyy yyyy/mm/dd
Name of an application package to be debugged.
This constant is deprecated. Use&instead
Whether or not to dim the screen.
Whether the audible DTMF tones are played by the dialer when dialing.
What happens when the user presses the end call button if they're not on a call.
Scaling factor for fonts, float.
Whether the haptic feedback (long presses, ...) are enabled.
This constant is deprecated. Use&&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&&instead
Ringer mode.
Determines which streams are affected by ringer mode changes.
Determines which streams are affected by mute.
This constant is deprecated. Use&instead
A formatted string of the next alarm that is set, or the empty string if there is no alarm set.
Persistent store for the system-wide default notification sound.
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio.
Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio.
Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio.
Persistent store for the system-wide default ringtone URI.
The screen backlight brightness between 0 and 255.
Control whether to enable automatic brightness mode.
SCREEN_BRIGHTNESS_MODE value for automatic mode.
SCREEN_BRIGHTNESS_MODE value for manual mode.
The timeout before the screen turns off.
This constant is deprecated. Use&instead
Whether the setup wizard has been run before (on first boot), or if it still needs to be run.
Control whether the process CPU usage meter should be shown.
This constant is deprecated. Each application that shows web suggestions should have its own setting for this.
Whether the sounds effects (key clicks, lid open ...) are enabled.
Whether we keep the device on while the device is plugged in.
Setting to enable Auto Caps in text editors.
Setting to enable Auto Punctuate in text editors.
Setting to enable Auto Replace (AutoText) in text editors.
Setting to showing password characters in text editors.
Display times as 12 or 24 hours 12 24
Scaling factor for activity transition animations.
This constant is deprecated. Use&instead
Default screen rotation when no other policy applies.
This constant is deprecated. Use&instead
Whether vibrate is on for different events.
Alarm volume.
Bluetooth Headset volume.
Music/media/gaming volume.
Notification volume.
Ringer volume.
System/notifications volume.
Voice call volume.
If 1, when launching DEBUG_APP it will wait for the debugger before starting user code.
Name of activity to use for wallpaper on the home screen.
This constant is deprecated. Use&instead
This constant is deprecated. Useinstead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&&instead
The policy for deciding when Wi-Fi should go to sleep (which will in turn switch to using the mobile data as an Internet connection).
Value for&&to
use the default Wi-Fi sleep policy, which is to sleep shortly after the turning off according to the&&setting.
Value for&&to
never go to sleep.
Value for&&to
use the default policy when the device is on battery, and never go to sleep when the device is plugged in.
If using static IP, the primary DNS's IP address.
If using static IP, the secondary DNS's IP address.
If using static IP, the gateway's IP address.
The static IP address.
If using static IP, the net mask.
Whether to use static IP and other static network attributes.
This constant is deprecated. Useinstead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Useinstead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
This constant is deprecated. Use&instead
Scaling factor for normal window animations.
通过如下的函数可以对其进行读写:
static void
(&cr,&&outConfig)
Convenience function to read all of the current configuration-related settings into a&object.
static float
(&cr,&&name,
float def)
Convenience function for retrieving a single system settings value as a floating point number.
static float
(&cr,&&name)
Convenience function for retrieving a single system settings value as a float.
static int
(&cr,&&name)
Convenience function for retrieving a single system settings value as an integer.
static int
(&cr,&&name,
Convenience function for retrieving a single system settings value as an integer.
static long
(&cr,&&name,
Convenience function for retrieving a single system settings value as a&long.
static long
(&cr,&&name)
Convenience function for retrieving a single system settings value as a&long.
static boolean
synchronized static&
(&resolver,&&name)
Look up a name in the database.
Construct the content URI for a particular name/value pair, useful for monitoring changes with a ContentObserver.
static boolean
(&cr,&&config)
Convenience function to write a batch of configuration-related settings from a&object.
static boolean
(&cr,&&name,
float value)
Convenience function for updating a single settings value as a floating point number.
static boolean
(&cr,&&name,
int value)
Convenience function for updating a single settings value as an integer.
static boolean
(&cr,&&name,
long value)
Convenience function for updating a single settings value as a long integer.
static boolean
(&resolver,&&name,&&value)
Store a name/value pair into the database.
static void
boolean flag)
注意,应用程序中应加入:&&uses-permission android:name=&android.permission.WRITE_SETTINGS& /&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:186236次
积分:2818
积分:2818
排名:第10737名
原创:77篇
转载:150篇
(1)(1)(4)(7)(4)(5)(3)(1)(4)(18)(2)(11)(5)(3)(2)(16)(29)(12)(24)(25)(27)(4)(18)(1)

我要回帖

更多关于 sublime 修改setting 的文章

 

随机推荐