Android S Location Mode 默认开关状态及读取逻辑

发布于:2022-12-02 ⋅ 阅读:(366) ⋅ 点赞:(0)

Android 12 source code 地址:

https://aosp.opersys.com/xref/android-12.0.0_r2/

Android 12 13 定位开关的默认状态存储位置一致

/frameworks/base/packages/SettingsProvider/res/values/defaults.xml

 <!-- 0 == off, 3 == on -->
43    <integer name="def_location_mode">3</integer>

​读取地址:
http://aosp.opersys.com/xref/android-12.0.0_r2/xref/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java

     final SettingsState secureSettings = getSecureSettingsLocked(userId);
4571
4572                    final Setting locationMode = secureSettings.getSettingLocked(
4573                            Secure.LOCATION_MODE);
4574
4575                    if (locationMode.isNull()) {
4576                        final Setting locationProvidersAllowed = secureSettings.getSettingLocked(
4577                                Secure.LOCATION_PROVIDERS_ALLOWED);
4578
4579                        final int defLocationMode;
4580                        if (locationProvidersAllowed.isNull()) {
4581                            defLocationMode = getContext().getResources().getInteger(
4582                                    R.integer.def_location_mode);
4583                        } else {
4584                            defLocationMode =
4585                                    !TextUtils.isEmpty(locationProvidersAllowed.getValue())
4586                                            ? Secure.LOCATION_MODE_ON
4587                                            : Secure.LOCATION_MODE_OFF;
4588                        }
4589                        secureSettings.insertSettingOverrideableByRestoreLocked(
4590                                Secure.LOCATION_MODE, Integer.toString(defLocationMode),
4591                                null, true, SettingsState.SYSTEM_PACKAGE_NAME);
4592                    }
本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到