需求:当前的屏幕亮度是102,要求将默认屏幕改为一半51。
知道这个值是在SettingProvider里设置的,路径在
frameworks/base/packages/SettingsProvider/res/values/defaults.xml下的”def_screen_brightness"。
我们当然可以直接修改这个值,从102改为51,然后重新编译。
我们可以用跟product绑定的方法修改:
在根目录device/product目录下。也就是跟device.mk所在位置的同层目录下,新建
overlay/frameworks/base/packages/SettingsProvidr/res/values.并在这个目录下新建defaults.xml
在这个xml里面,加入内容:
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright (c) 2010, 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.
*/
-->
<resources>
<!-- Default screen brightness, from 0 to 255. 102 is 40%. -->
<integer name="def_screen_brightness">51</integer>
</resources>
这样,重新编译,这个值就会覆盖掉framework里的值。
具体起作用的原因是跟mk文件里的DEVICE_PACKAGE_OVERLAYS这个变量有关系的。
猜想应该是编译每个package的时候,在res资源定义完后,寻找DEVICE_PACKAGE_OVERLAYS目录下跟自己package有关的值,用这个值覆盖原先res定义的旧值,以起到作用。(纯属个人猜想,要理解分析下package.mk和product.mk。