Android 在frameworks中修改Setting中的默认值 (二)

修改设置->关于手机->法律信息 下有一些Item,如开放源代码许可、Google法律信息等,这里分析的是Android 4.4的代码

如下图所示,想添加“Google法律信息”选项

查看Settings的源码在/Settings/src/com/android/settings/DeviceInfoSettings.java文件初始化时有这样一段代码

@Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        addPreferencesFromResource(R.xml.device_info_settings);

        //............................................省略

        /*
         * Settings is a generic app and should not contain any device-specific
         * info.
         */
        final Activity act = getActivity();
        // These are contained in the "container" preference group
        PreferenceGroup parentPreference = (PreferenceGroup) findPreference(KEY_CONTAINER);
        Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_TERMS,
                Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
        Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_LICENSE,
                Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
        Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_COPYRIGHT,
                Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
        Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_TEAM,
                Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);

        //..............................................省略
    }
看加载的资源文件device_info_settings.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project Licensed under the 
	Apache License, Version 2.0 (the "License"); you may not use this file except 
	in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
	Unless required by applicable law or agreed to in writing, software distributed 
	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
	OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
	the specific language governing permissions and limitations under the License. -->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
	android:title="@string/about_settings">

	<!-- System update settings - launches activity -->
	<PreferenceScreen android:key="system_update_settings"
		android:title="@string/system_update_settings_list_item_title"
		android:summary="@string/system_update_settings_list_item_summary">
		<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS" />
	</PreferenceScreen>
	<PreferenceScreen android:key="software_update"
		android:title="@string/software_update">
	</PreferenceScreen>
	<PreferenceScreen android:key="mdm_fumo"
		android:title="@string/software_update">
	</PreferenceScreen>
	<!-- MOTA -->
        <PreferenceScreen android:key="mtk_system_update">
		<intent android:action="com.mediatek.intent.System_Update_Entry" />
	</PreferenceScreen>

	<!-- software update service -->
	<PreferenceScreen android:key="scomo"
		android:title="@string/scomo_settings_title" android:summary="@string/software_updates_scomo_summary">
		<intent android:action="android.intent.action.MAIN"
			android:targetPackage="com.mediatek.dm" android:targetClass="com.mediatek.dm.scomo.DmScomoActivity" />
	</PreferenceScreen>
	<PreferenceScreen android:key="mdm_scomo"
		android:summary="@st
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值