Android 的一些功能开关配置

一些常用的开关
Config.xml
路径指向位置为framework/base/core/res/res/valuse/configs.xml
最近因为要移除通话相关的模块。除了改改字符串这些的,有些东西用一些value配置了
。所以如果需要移除通话,短信这块的UI显示还有功能相关的。找了找几个简单的做了一个汇总

 
    <string-array translatable="false" name="networkAttributes">
        <item>"wifi,1,1,1,-1,true"</item>     <!--wifi是否支持  -->
       <!-- <item>"mobile,0,0,0,-1,true"</item>-->    <!--数据连接是否支持 比如设置里面的第一项的summary和手机数据连接相关的都是通过这个东西控制的-->
        <item>"wifi_p2p,13,1,0,-1,true"</item>
        <item>"bluetooth,7,7,1,60000,true"</item>
        <item>"ethernet,9,9,2,-1,true"</item>
    </string-array>
    <!-- 语音通话是否支持 -->
    <bool name="config_voice_capable">false</bool>
     <!-- 短信是否支持 -->
    <bool name="config_sms_capable">false</bool>

PackageManager.hasSystemFeature(XXXX)
这些是偏向一些硬件(sensor)功能的 当然还有一些系统服务,比如GPS位置信息/多点触摸/屏幕旋转/闪光灯这块的// 具体的呢是看 system|vendor|odm|oem 下的etc/sysconfig中的一些xml列表
这个xml的读取是在SystemConfig.java中的,godir 去找位置看看是怎么个read法的就行了
这里面还有很多一些关于权限的配置。补充一个xml吧

<permissions>
    <!-- This is Android and fully CTS compatible.  Basically this is for CTS tests to use. -->
    <feature name="android.software.cts" />

    <!-- basic hardware feature for tablet -->
    <feature name="android.hardware.audio.output" />
    <feature name="android.hardware.location" />
    <feature name="android.hardware.location.network" />
    <feature name="android.hardware.sensor.accelerometer" />
    <feature name="android.hardware.touchscreen" />
    <feature name="android.hardware.touchscreen.multitouch" />
    <feature name="android.hardware.touchscreen.multitouch.distinct" />
    <feature name="android.hardware.faketouch" />
    <feature name="android.hardware.microphone" />
    <feature name="android.hardware.screen.landscape" />
    <feature name="android.hardware.screen.portrait" />

    <!-- basic system services -->
    <feature name="android.software.app_widgets" />
    <feature name="android.software.connectionservice" />
    <feature name="android.software.voice_recognizers" />
    <feature name="android.software.backup" />
    <feature name="android.software.home_screen" />
    <feature name="android.software.input_methods" />
    <!-- Feature to specify if the device supports adding device admins. -->
    <feature name="android.software.device_admin" />

</permissions>
设置中的默认开关
SettingsProvider里面 就不详细赘述了

SystemProperties
emmm 这个也是一些开关 有些可以set 有些不可以,ro开头的一般是写死固定的 persit开头的是可以修改的。重启也会保存的,昨天遇到一个问题,是问了一下朋友才解决的
在Gallery2中 我import android.os.SystemProperties;的时候始终找不到这个类。编译报错,想了想可能是makefile的原因,但是一时半会想不出,然后请教了一下朋友。是因为LOCAL_SDK_VERSION := current 引起的,这个是不编译隐藏api 很遗憾 我们的SystemProperties 就是隐藏的API,还要加个LOCAL_PRIVATE_PLATFORM_APIS := true 使用SDK的隐藏API进行编译。就可以了

SystemUI QSTile的一些默认展示项
frameworks/base/packages/SystemUi/src/com/android/systemui/qs/QSTileHost.java

    protected List<String> loadTileSpecs(Context context, String tileList) {
        final Resources res = context.getResources();
        final String defaultTileList = res.getString(R.string.quick_settings_tiles_default);//这里是默认配置项
        if (tileList == null) {
            tileList = res.getString(R.string.quick_settings_tiles);
            if (DEBUG) Log.d(TAG, "Loaded tile specs from config: " + tileList);
        } else {
            if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList);//注意此LOG信息
        }
        final ArrayList<String> tiles = new ArrayList<String>();
        boolean addedDefault = false;
        for (String tile : tileList.split(",")) {
            tile = tile.trim();
            if (tile.isEmpty()) continue;
            if (tile.equals("default")) {
                if (!addedDefault) {
                    tiles.addAll(Arrays.asList(defaultTileList.split(",")));
                    addedDefault = true;
                }
            } else {
                tiles.add(tile);
            }
        }
        return tiles;
    }

Android O 新增了一个TileService 可以通过Tileservice去新增部分自定义的QStiles。按照以前的修改方式就是修改configs.xml中的

    <string name="quick_settings_tiles_default" translatable="false">
        wifi,bt,dnd,flashlight,battery,cell,airplane,cast
    </string>

但是我们不知道这些wifi bt dnd 是有在QSFactoryImpl.java中的createTile函数中对应的

public QSTile createTile(String tileSpec) {
        if (tileSpec.equals("wifi")) return new WifiTile(mHost);
        else if (tileSpec.equals("bt")) return new BluetoothTile(mHost);
        else if (tileSpec.equals("cell")) return new CellularTile(mHost);
        else if (tileSpec.equals("dnd")) return new DndTile(mHost);
        else if (tileSpec.equals("inversion")) return new ColorInversionTile(mHost);
        else if (tileSpec.equals("airplane")) return new AirplaneModeTile(mHost);
        else if (tileSpec.equals("work")) return new WorkModeTile(mHost);
        else if (tileSpec.equals("rotation")) return new RotationLockTile(mHost);
        else if (tileSpec.equals("flashlight")) return new FlashlightTile(mHost);
        else if (tileSpec.equals("location")) return new LocationTile(mHost);
        else if (tileSpec.equals("cast")) return new CastTile(mHost);
        else if (tileSpec.equals("hotspot")) return new HotspotTile(mHost);
        else if (tileSpec.equals("user")) return new UserTile(mHost);
        else if (tileSpec.equals("battery")) return new BatterySaverTile(mHost);
        else if (tileSpec.equals("saver")) return new DataSaverTile(mHost);
        else if (tileSpec.equals("night")) return new NightDisplayTile(mHost);
        else if (tileSpec.equals("nfc")) return new NfcTile(mHost);
        // Intent tiles.
        else if (tileSpec.startsWith(IntentTile.PREFIX)) return IntentTile.create(mHost, tileSpec);
        else if (tileSpec.startsWith(CustomTile.PREFIX)) return CustomTile.create(mHost, tileSpec);
        else {
            Log.w(TAG, "Bad tile spec: " + tileSpec);
            return null;
        }
    }

所以想新增一些第三方tileview的话,建议还是在QSTileHost中打开开关DEBUG,重新编译push
然后自己手动添加想要的tileview 然后这里 会打印出来的 要注意的LOG信息是
if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList); 输出这句LOG

Example:

Loaded tile specs from setting: wifi,bt,dnd,battery,airplane,cast,custom(com.android.systemui/com.softwinner.screenshot.ScreenshotTileService),custom(com.android.systemui/com.softwinner.screenrecord.ScreenrecordTileService)
 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值