Android 7.0 参照这个博文:https://blog.csdn.net/feelinghappy/article/details/77083585添加GPS模块驱动后,在系统设置的位置信息中的模式多了“高精度”和“仅限设置”选项,也可以选择,但是退出后再次进入,显示的还是“节电”模式。查看Logcat提示:
com.android.settings W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:920 android.content.ContextWrapper.sendBroadcast:426 com.android.settings.location.LocationSettingsBase.setLocationMode:110 com.android.settings.location.LocationMode.onRadioButtonClicked:119 com.android.settings.location.RadioButtonPreference.onClick:64
看来是没有权限,修改packages/apps/Settings/src/com/android/settings/location/LocationSettingsBase.java:
getActivity().sendBroadcastAsUser(intent,UserHandle.ALL, android.Manifest.permission.WRITE_SECURE_SETTINGS);
注意要import android.os.UserHandle;
重新编译系统,ok!