From b51886d0a7efe2efa0ba53267ba1ada6ec7626b2 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Mon, 8 Nov 2010 18:25:51 -0800 Subject: Show the accounts on the factory reset screen. Bug: 2823530 Change-Id: Idbf46aa59f3c529a3a3ef2d7d4e607822b34f51d --- src/com/android/settings/MasterClear.java | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'src') diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java index a2ef7f4..3060d3e 100644 --- a/src/com/android/settings/MasterClear.java +++ b/src/com/android/settings/MasterClear.java @@ -18,18 +18,27 @@ package com.android.settings; import com.android.settings.R; +import android.accounts.Account; +import android.accounts.AccountManager; +import android.accounts.AuthenticatorDescription; import android.app.Activity; import android.app.Fragment; +import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; +import android.widget.LinearLayout; +import android.widget.TextView; /** * Confirm and execute a reset of the device to a clean "just out of the box" @@ -42,6 +51,7 @@ import android.widget.CheckBox; * This is the initial screen. */ public class MasterClear extends Fragment { + private static final String TAG = "MasterClear"; private static final int KEYGUARD_REQUEST = 55; @@ -130,12 +140,72 @@ public class MasterClear extends Fragment { mExternalStorage.toggle(); } }); + + loadAccountList(); + } + + private void loadAccountList() { + View accountsLabel = mContentView.findViewById(R.id.accounts_label); + LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts); + + Context context = getActivity(); + + 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