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;