修改删除Google账号之后,点击设置->位置信息->Google 位置信息分享,Google应用报错的问题
2018-02-05 09:46
603 查看
BUG:删除google账号后,进入设置->位置信息->google位置信息分享,google应用报错
平台:Android 7.0
修改path:alps/packages/apps/Settings/src/com/android/settings/location/SettingsInjector.java
--- a/alps/packages/apps/Settings/src/com/android/settings/location/SettingsInjector.java
+++ b/alps/packages/apps/Settings/src/com/android/settings/location/SettingsInjector.java
@@ -52,6 +52,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+//add 20170706
+import android.accounts.Account;
+import android.accounts.AccountManager;
+
/**
* Adds the preferences specified by the {@link InjectedSetting} objects to a preference group.
*
@@ -299,7 +303,7 @@ class SettingsInjector {
// that "android.settings.LOCATION_SOURCE_SETTINGS" brings user back to
// Settings > Location.
Intent settingIntent = new Intent();
- settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
+
// Sometimes the user may navigate back to "Settings" and launch another different
// injected setting after one injected setting has been launched.
//
@@ -310,6 +314,28 @@ class SettingsInjector {
// In order to avoid such confusion, we use FLAG_ACTIVITY_CLEAR_TASK, which always clear
// up all existing injected settings and make sure that "back" button always brings the
// user back to "Settings" directly.
+
+ //add 20170706 fix bug
+ AccountManager accountManager = AccountManager.get(mContext);
+ Account[] mAccounts = accountManager.getAccounts();
+ boolean isGoogleAccount=false;
+ for(Account mAccount:mAccounts){
+ if("com.google".equals(mAccount.type)){
+ isGoogleAccount=true;
+ break;
+ }
+
+ }
+ if(!isGoogleAccount){
+ if("com.google.android.gms.locationsharing.activity.LocationSharingRedirectActivity".equals(mInfo.settingsActivity)){
+ settingIntent.setClassName("com.google.android.gms","com.google.android.location.settings.LocationHistorySettingsActivity");
+ } else{
+ settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
+ }
+ }else{
+ settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
+ }
+ //end
settingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mContext.startActivityAsUser(settingIntent, mInfo.mUserHandle);
return true;
平台:Android 7.0
修改path:alps/packages/apps/Settings/src/com/android/settings/location/SettingsInjector.java
--- a/alps/packages/apps/Settings/src/com/android/settings/location/SettingsInjector.java
+++ b/alps/packages/apps/Settings/src/com/android/settings/location/SettingsInjector.java
@@ -52,6 +52,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+//add 20170706
+import android.accounts.Account;
+import android.accounts.AccountManager;
+
/**
* Adds the preferences specified by the {@link InjectedSetting} objects to a preference group.
*
@@ -299,7 +303,7 @@ class SettingsInjector {
// that "android.settings.LOCATION_SOURCE_SETTINGS" brings user back to
// Settings > Location.
Intent settingIntent = new Intent();
- settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
+
// Sometimes the user may navigate back to "Settings" and launch another different
// injected setting after one injected setting has been launched.
//
@@ -310,6 +314,28 @@ class SettingsInjector {
// In order to avoid such confusion, we use FLAG_ACTIVITY_CLEAR_TASK, which always clear
// up all existing injected settings and make sure that "back" button always brings the
// user back to "Settings" directly.
+
+ //add 20170706 fix bug
+ AccountManager accountManager = AccountManager.get(mContext);
+ Account[] mAccounts = accountManager.getAccounts();
+ boolean isGoogleAccount=false;
+ for(Account mAccount:mAccounts){
+ if("com.google".equals(mAccount.type)){
+ isGoogleAccount=true;
+ break;
+ }
+
+ }
+ if(!isGoogleAccount){
+ if("com.google.android.gms.locationsharing.activity.LocationSharingRedirectActivity".equals(mInfo.settingsActivity)){
+ settingIntent.setClassName("com.google.android.gms","com.google.android.location.settings.LocationHistorySettingsActivity");
+ } else{
+ settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
+ }
+ }else{
+ settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
+ }
+ //end
settingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
mContext.startActivityAsUser(settingIntent, mInfo.mUserHandle);
return true;
相关文章推荐
- 修改设置->关于手机->法律信息 下有一些Item,如开放源代码许可、Google法律信息等,这里分析的是Android 4.4的代码
- 应用程序信息 -> “清除默认设置” 信息的保存位置
- 修改删除目录操作之后,Session失效问题解决方案
- 29-Menu菜单,主菜单和子菜单,点击菜单选项之后,对文本信息进行排版设置
- iPhone手机上的GPS位置信息采集与分享应用
- 【JavaScript】验证码点击刷新、点击超链接,问是否删除、点击鼠标左键,修改文本框信息
- Android中设置字体大小出现的问题(操作位置:Settings->Display->Font size)
- Windows 设置了文件夹共享,删除默认Everyone共享,设置其他用户共享之后打不开的问题
- crawler_java应用集锦9:httpclient4.2.2的几个常用方法,登录之后访问页面问题,下载文件_设置代理
- Win8.1设置修改DNS服务器地址解决无法打开应用商店问题
- iOS 定位 点击设置->隐私->定位 闪退的问题
- 进入'我的电脑'窗口后,左边显示的‘系统任务,其它位置,详细信息’菜单条到删除和出现的问题解决
- 修改删除目录操作之后,Session失效问题
- 黄聪:如何删除wordpress登录之后wp_footer、wp_head自行加载的Open Sans字体、fonts.googleapis.com连接导致卡死的问题
- iPhone手机上的GPS位置信息采集与分享应用
- 关于iOS地图定位中点击设置->隐私->定位服务 闪退问题
- 写一个方法进行各种属性的更新,而不要每个界面设置改变都改变一个属性。就是点击应用或确定按钮时调用这个更新属性的方法,遍历所有(控制对象属性的)界面控件的状态(值),进行属性修改和刷新。
- iOS8在隐私中打开某应用的位置服务时设置会crash的问题
- Ubuntu中初步安装好MYSQL后,无法登陆问题及mysql添加、删除账号和修改密码操作
- 位置采集[置顶] iPhone手机上的GPS位置信息采集与分享应用