am ead7991d
: am 548460bd
: Merge "Show managed profile accounts on Settings > Factory Reset" into lmp-mr1-dev automerge: 72b1985
* commit 'ead7991dead5f2c5886778ac4d9b31f0ac300101': Show managed profile accounts on Settings > Factory Reset
This commit is contained in:
committed by
Android Git Automerger
commit
2a7a9f6b9e
@@ -57,6 +57,12 @@
|
|||||||
<!-- Do not add any children here as they will be removed in the MasterClear.java
|
<!-- Do not add any children here as they will be removed in the MasterClear.java
|
||||||
code. A list of accounts will be inserted programmatically. -->
|
code. A list of accounts will be inserted programmatically. -->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<TextView android:id="@+id/other_users_present"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:text="@string/master_clear_other_users_present" />
|
||||||
<TextView android:id="@+id/erase_external_option_text"
|
<TextView android:id="@+id/erase_external_option_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@@ -2431,6 +2431,8 @@
|
|||||||
<string name="master_clear_desc" product="default">"This will erase all data from your phone\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps"</li></string>
|
<string name="master_clear_desc" product="default">"This will erase all data from your phone\'s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps"</li></string>
|
||||||
<!-- SD card & phone storage settings screen, instructions and list of current accounts. The list of accounts follows this text[CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, instructions and list of current accounts. The list of accounts follows this text[CHAR LIMIT=NONE] -->
|
||||||
<string name="master_clear_accounts" product="default">"\n\nYou are currently signed into the following accounts:\n"</string>
|
<string name="master_clear_accounts" product="default">"\n\nYou are currently signed into the following accounts:\n"</string>
|
||||||
|
<!-- SD card & phone storage settings screen, notification if other users are present on the device [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="master_clear_other_users_present" product="default">"\n\nThere are other users present on this device.\n"</string>
|
||||||
<!-- SD card & phone storage settings screen, list of items in user data storage (USB storage or SD card) that will be erased during this operation [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, list of items in user data storage (USB storage or SD card) that will be erased during this operation [CHAR LIMIT=NONE] -->
|
||||||
<string name="master_clear_desc_also_erases_external">"<li>Music</li>\n<li>Photos</li>\n<li>Other user data</li>"</string>
|
<string name="master_clear_desc_also_erases_external">"<li>Music</li>\n<li>Photos</li>\n<li>Other user data</li>"</string>
|
||||||
<!-- SD card & phone storage settings screen, instructions about whether to also erase the external storage (SD card) when erasing the internal storage [CHAR LIMIT=NONE] -->
|
<!-- SD card & phone storage settings screen, instructions about whether to also erase the external storage (SD card) when erasing the internal storage [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -24,15 +24,19 @@ import android.app.Fragment;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -41,6 +45,8 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Confirm and execute a reset of the device to a clean "just out of the box"
|
* 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
|
* 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() {
|
private boolean isExtStorageEncrypted() {
|
||||||
@@ -172,28 +179,42 @@ public class MasterClear extends Fragment {
|
|||||||
return !"".equals(state);
|
return !"".equals(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAccountList() {
|
private void loadAccountList(final UserManager um) {
|
||||||
View accountsLabel = mContentView.findViewById(R.id.accounts_label);
|
View accountsLabel = mContentView.findViewById(R.id.accounts_label);
|
||||||
LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts);
|
LinearLayout contents = (LinearLayout)mContentView.findViewById(R.id.accounts);
|
||||||
contents.removeAllViews();
|
contents.removeAllViews();
|
||||||
|
|
||||||
Context context = getActivity();
|
Context context = getActivity();
|
||||||
|
final List<UserInfo> profiles = um.getProfiles(UserHandle.myUserId());
|
||||||
|
final int profilesSize = profiles.size();
|
||||||
|
|
||||||
AccountManager mgr = AccountManager.get(context);
|
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(
|
LayoutInflater inflater = (LayoutInflater)context.getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
AuthenticatorDescription[] descs = AccountManager.get(context).getAuthenticatorTypes();
|
int accountsCount = 0;
|
||||||
|
for (int profileIndex = 0; profileIndex < profilesSize; profileIndex++) {
|
||||||
|
final UserInfo userInfo = profiles.get(profileIndex);
|
||||||
|
final int profileId = userInfo.id;
|
||||||
|
final UserHandle userHandle = new UserHandle(profileId);
|
||||||
|
Account[] accounts = mgr.getAccountsAsUser(profileId);
|
||||||
|
final int N = accounts.length;
|
||||||
|
if (N == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
accountsCount += N;
|
||||||
|
|
||||||
|
AuthenticatorDescription[] descs = AccountManager.get(context)
|
||||||
|
.getAuthenticatorTypesAsUser(profileId);
|
||||||
final int M = descs.length;
|
final int M = descs.length;
|
||||||
|
|
||||||
|
View titleView = newTitleView(contents, inflater);
|
||||||
|
final TextView titleText = (TextView) titleView.findViewById(android.R.id.title);
|
||||||
|
titleText.setText(userInfo.isManagedProfile() ? R.string.category_work
|
||||||
|
: R.string.category_personal);
|
||||||
|
contents.addView(titleView);
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
Account account = accounts[i];
|
Account account = accounts[i];
|
||||||
AuthenticatorDescription desc = null;
|
AuthenticatorDescription desc = null;
|
||||||
@@ -212,7 +233,8 @@ public class MasterClear extends Fragment {
|
|||||||
try {
|
try {
|
||||||
if (desc.iconId != 0) {
|
if (desc.iconId != 0) {
|
||||||
Context authContext = context.createPackageContext(desc.packageName, 0);
|
Context authContext = context.createPackageContext(desc.packageName, 0);
|
||||||
icon = authContext.getDrawable(desc.iconId);
|
icon = context.getPackageManager().getUserBadgedIcon(
|
||||||
|
authContext.getDrawable(desc.iconId), userHandle);
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
Log.w(TAG, "No icon for account type " + desc.type);
|
Log.w(TAG, "No icon for account type " + desc.type);
|
||||||
@@ -226,10 +248,17 @@ public class MasterClear extends Fragment {
|
|||||||
}
|
}
|
||||||
contents.addView(child);
|
contents.addView(child);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accountsCount > 0) {
|
||||||
accountsLabel.setVisibility(View.VISIBLE);
|
accountsLabel.setVisibility(View.VISIBLE);
|
||||||
contents.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
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
@@ -245,4 +274,13 @@ public class MasterClear extends Fragment {
|
|||||||
establishInitialState();
|
establishInitialState();
|
||||||
return mContentView;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user