diff --git a/res/layout/master_clear.xml b/res/layout/master_clear.xml index d40de2467a1..5ad921a99fe 100644 --- a/res/layout/master_clear.xml +++ b/res/layout/master_clear.xml @@ -57,6 +57,12 @@ + "This will erase all data from your phone\'s internal storage, including:\n\n
  • Your Google account
  • \n
  • System and app data and settings
  • \n
  • Downloaded apps"
  • "\n\nYou are currently signed into the following accounts:\n" + + "\n\nThere are other users present on this device.\n" "
  • Music
  • \n
  • Photos
  • \n
  • Other user data
  • "
    diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java index 1c9fe5cff58..aba2c3d5d65 100644 --- a/src/com/android/settings/MasterClear.java +++ b/src/com/android/settings/MasterClear.java @@ -24,15 +24,19 @@ import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.content.pm.UserInfo; import android.content.res.Resources; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Environment; import android.os.Process; import android.os.SystemProperties; +import android.os.UserHandle; import android.os.UserManager; import android.preference.Preference; import android.util.Log; +import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -41,6 +45,8 @@ import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.TextView; +import java.util.List; + /** * Confirm and execute a reset of the device to a clean "just out of the box" * state. Multiple confirmations are required: first, a general "are you sure @@ -164,7 +170,8 @@ public class MasterClear extends Fragment { }); } - loadAccountList(); + final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); + loadAccountList(um); } private boolean isExtStorageEncrypted() { @@ -172,63 +179,85 @@ public class MasterClear extends Fragment { return !"".equals(state); } - private void loadAccountList() { + private void loadAccountList(final UserManager um) { View accountsLabel = mContentView.findViewById(R.id.accounts_label); LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts); contents.removeAllViews(); Context context = getActivity(); + final List profiles = um.getProfiles(UserHandle.myUserId()); + final int profilesSize = profiles.size(); AccountManager mgr = AccountManager.get(context); - Account[] accounts = mgr.getAccounts(); - final int N = accounts.length; - if (N == 0) { - accountsLabel.setVisibility(View.GONE); - contents.setVisibility(View.GONE); - return; - } LayoutInflater inflater = (LayoutInflater)context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); - AuthenticatorDescription[] descs = AccountManager.get(context).getAuthenticatorTypes(); - final int M = descs.length; - - for (int i=0; i 0) { + accountsLabel.setVisibility(View.VISIBLE); + contents.setVisibility(View.VISIBLE); + } + // Checking for all other users and their profiles if any. + View otherUsers = mContentView.findViewById(R.id.other_users_present); + final boolean hasOtherUsers = (um.getUserCount() - profilesSize) > 0; + otherUsers.setVisibility(hasOtherUsers ? View.VISIBLE : View.GONE); } @Override @@ -245,4 +274,13 @@ public class MasterClear extends Fragment { establishInitialState(); return mContentView; } + + private View newTitleView(ViewGroup parent, LayoutInflater inflater) { + final TypedArray a = inflater.getContext().obtainStyledAttributes(null, + com.android.internal.R.styleable.Preference, + com.android.internal.R.attr.preferenceCategoryStyle, 0); + final int resId = a.getResourceId(com.android.internal.R.styleable.Preference_layout, + 0); + return inflater.inflate(resId, parent, false); + } }