首页 > 编程知识 正文

决策分析过程,过程分析

时间:2023-05-05 01:00:48 阅读:157660 作者:4999

安卓定位交换机流程分析

一位同事发现当前汽车location的位置位于刷机(在线刷之后),每次的location初始值(在settings中看到的)不一致。 因为以前一点也没有涉及过这个,所以今天拿出去研究收集博客。

位置的三种工作模式?

从settings-location界面来看,location主要有三种工作模式:

high _ accuracy battery _ saving sensors _ only

对应于代码:

//packages/apps/settings/src/com/Android/settings/location/location mode.javaintmode=settings.secure . }elseif(Emiter==mbatterysaving ) mode=settings.secure.location _ mode _ battery _ saving; }elseif(Emiter==msensorsonly ) mode=settings.secure.location _ mode _ sensors _ only; } setlocationmode (模式; 快速找到setLocationMode

//packages/apps/settings/src/com/Android/settings/location/locationsettingsbase.javapublicvoidsetlocationmase locationtogglingdisabledbyuserrestriction.readthecurrentlocationmodeto/modeto updatethelocationmasterswitch.if (log.info () log.I ) tag,' Restricted user,not setting location mode ' ); } mode=settings.secure.getint (get content resolver (,Settings.Secure.LOCATION_MODE,settings.secure.location ) } return; } intent intent=new intent (mode _ changing _ action ); intent.put extra (current _ mode _ key,mCurrentMode ); intent.putextra(new_mode_key,mode; getActivity ().sendbroadcast(intent,Android.manifest.permission.write _ secure _ settings ); settings.secure.putint (get content resolver (,Settings.Secure.LOCATION_MODE,mode ) ); refreshLocationMode (; 你看起来像在操作Settings.Secure数据库呢。 直接找到吧:

私有状态缓存模式(contentresolvercr,int mode,int userId ) . switch )缓存缓存黑; case location _ mode _ battery _ saving : network=true; 黑; case location _ mode _ high _ accuracy : GPS=true; 网络=true; 黑; 默认:图形封装模式(invalidlocationmode : ); //noteit ' simportantthatwesetthenlpmodefirst.thegoogleimplementation//ofnlpclearsitsnlpconsentsettinganytimeitreceiver location manager.providers _ changed _ actionbroadcastandnlpisdisabled.aled/itshowsannlpconsentdialoganytimeitreceiive NLP is//enabled,and the NLP consent is not set. If 1 ) we were to enable GPS first, //2 ) asetupwizardhasitsownlpconsentuithatsetsthenlpconsentsetting, //and 3) thereceiverhappenedtocompletebeforeweenabler thenthegoogle//nlpwoulddetecttheattempttoenablenlpandshowaredundantnttne dialog.thenthepeoplewhowrotethesetupwizardwouldbesad.booleannlpsuccess=settings.setlocationproviderenabledfored settings.secure.setlocationproviderenabledforuserid (Cr,LocationManager.GPS_PROVIDER,GPS,user return GPS success ns ) } publicstaticfinalbooleansetlocationproviderenabledforuser (contentresolvercr,String provider,boolean enabled, intuserid(synchronized ) mlocationsettingslock ) { //to ensure thread safety, wewritetheprovidernamewitha ' ' or '-'//andletthesettingsproviderhandleitratherthanreadingandmodifying//thelistofenablenabled }returnputstringforuser(Cr,settings.secure.location _ providers _ allowed,provider,userId ); }是,字段为: settings.secure.location _ providers _ allowed

让我们看看实际的机器测试:

旧规则,一条命令就可以了

adbshellsettingsgetsecurelocation _ providers _ allowed

关闭位置:

结果为空

打开位置,high_accuracy模式

网络、gps

打开位置,电池_保存模式

网络

打开location,sensors_only模式

gps

这样.也学到了科普的东西!

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。