Do not start account setup screen in limited user mode.
Check for modify account ability before sending user to account setup screen.
In limited user mode, you cannot add accounts so there is no point trying
to send users there. In fact, this caused the app to abort.
Bug: 8647306
Change-Id: If20a5f3b9d4e0689a1d884d9106877b1d561294d
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index ebdfe3b..3fbd89f 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -27,6 +27,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
+import android.os.UserManager;
import android.preference.PreferenceActivity;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
@@ -1047,7 +1048,13 @@
// If there are no accounts on the device and we should show the "no account" prompt
// (based on {@link SharedPreferences}), then launch the account setup activity so the
// user can sign-in or create an account.
- if (!areContactWritableAccountsAvailable() &&
+ //
+ // Also check for ability to modify accounts. In limited user mode, you can't modify
+ // accounts so there is no point sending users to account setup activity.
+ final UserManager userManager = UserManager.get(this);
+ final boolean disallowModifyAccounts = userManager.getUserRestrictions().getBoolean(
+ UserManager.DISALLOW_MODIFY_ACCOUNTS);
+ if (!disallowModifyAccounts && !areContactWritableAccountsAvailable() &&
AccountPromptUtils.shouldShowAccountPrompt(this)) {
AccountPromptUtils.launchAccountPrompt(this);
return;