Android GPS 打开流程

Android P平台 :http://androidxref.com/9.0.0_r3/

1. Settings 界面打开,流程大致如下:

http://androidxref.com/9.0.0_r3/xref/packages/apps/Settings/src/com/android/settings/location/LocationSwitchBarController.java#setLocationEnabled

http://androidxref.com/9.0.0_r3/xref/packages/apps/Settings/src/com/android/settings/location/LocationEnabler.java#setLocationEnabled

111    void setLocationEnabled(boolean enabled) {
           // 从数据库拿值,看下此刻的 LOCATION_MODE
112        final int currentMode = Settings.Secure.getInt(mContext.getContentResolver(),
113            Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
114
115        if (isRestricted()) {   ---> 当前用户是否有权限
116            // Location toggling disabled by user restriction. Read the current location mode to
117            // update the location master switch.
118            if (Log.isLoggable(TAG, Log.INFO)) {
119                Log.i(TAG, "Restricted user, not setting location mode");
120            }
121            if (mListener != null) {
122                mListener.onLocationModeChanged(currentMode, true);
123            }
124            return;
125        }
           // 主要看下这个地方
126        updateLocationEnabled(mContext, enabled, UserHandle.myUserId(),
127                Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
128        refreshLocationMode();
129    }

                
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值