Refactor Reset options Settings

Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Test: robotest & manual
Change-Id: I94969f6903d047b9bc41b1e8c14096c92c460b38
This commit is contained in:
Edgar Wang
2020-08-04 23:13:05 +08:00
parent 867e9db69d
commit 21f8cb3a44
21 changed files with 254 additions and 259 deletions

View File

@@ -77,7 +77,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="32dip"
android:text="@string/master_clear_button_text"
android:text="@string/main_clear_button_text"
android:visibility="gone"
/>
</LinearLayout>

View File

@@ -100,7 +100,7 @@
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dip"
android:layout_marginEnd="16dip"
android:text="@string/master_clear_button_text"
android:text="@string/main_clear_button_text"
android:visibility="gone"
/>

View File

@@ -73,7 +73,7 @@
android:layout_height="wrap_content"
android:layout_margin="32dip"
android:layout_gravity="center"
android:text="@string/master_clear_button_text"
android:text="@string/main_clear_button_text"
android:visibility="gone"
/>

View File

@@ -23,17 +23,17 @@
android:orientation="vertical"
android:theme="@style/GlifV3Theme.Footer"
android:icon="@drawable/ic_delete_accent"
app:sucHeaderText="@string/master_clear_title">
app:sucHeaderText="@string/main_clear_title">
<ScrollView
android:id="@+id/master_clear_scrollview"
android:id="@+id/main_clear_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/reset_master_clear_margin_start"
android:layout_marginEnd="@dimen/reset_master_clear_margin_end">
android:layout_marginStart="@dimen/reset_main_clear_margin_start"
android:layout_marginEnd="@dimen/reset_main_clear_margin_end">
<LinearLayout
android:id="@+id/master_clear_container"
android:id="@+id/main_clear_container"
style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -44,35 +44,35 @@
android:id="@+id/sud_layout_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/master_clear_desc"/>
android:text="@string/main_clear_desc"/>
<TextView
android:id="@+id/also_erases_external"
style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_also_erases_external"/>
android:text="@string/main_clear_desc_also_erases_external"/>
<TextView
android:id="@+id/also_erases_esim"
style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_also_erases_esim"/>
android:text="@string/main_clear_desc_also_erases_esim"/>
<TextView
android:id="@+id/accounts_label"
style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_accounts"/>
android:text="@string/main_clear_accounts"/>
<LinearLayout
android:id="@+id/accounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<!-- 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 MainClear.java
code. A list of accounts will be inserted programmatically. -->
</LinearLayout>
<TextView
@@ -81,20 +81,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_other_users_present"/>
android:text="@string/main_clear_other_users_present"/>
<TextView
android:id="@+id/no_cancel_mobile_plan"
style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_no_cancel_mobile_plan"/>
android:text="@string/main_clear_desc_no_cancel_mobile_plan"/>
<TextView
android:id="@+id/erase_external_option_text"
style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/master_clear_desc_erase_external_storage"/>
android:text="@string/main_clear_desc_erase_external_storage"/>
<LinearLayout
android:id="@+id/erase_external_container"
android:layout_width="match_parent"

View File

@@ -22,7 +22,7 @@
android:theme="@style/SudThemeGlifV3.DayNight"
android:id="@+id/setup_wizard_layout"
android:icon="@drawable/ic_delete_accent"
app:sucHeaderText="@string/master_clear_confirm_title">
app:sucHeaderText="@string/main_clear_confirm_title">
<LinearLayout
style="@style/SudContentFrame"
@@ -35,6 +35,6 @@
style="@style/SudItemTitle.GlifDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_clear_final_desc"/>
android:text="@string/main_clear_final_desc"/>
</LinearLayout>
</com.google.android.setupdesign.GlifLayout>

View File

@@ -34,6 +34,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/master_clear_not_available"
android:text="@string/main_clear_not_available"
android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>

View File

@@ -326,8 +326,8 @@
<!-- Margin for the reset screens -->
<dimen name="reset_network_margin_start">72dp</dimen>
<dimen name="reset_network_margin_end">12dp</dimen>
<dimen name="reset_master_clear_margin_start">32dp</dimen>
<dimen name="reset_master_clear_margin_end">12dp</dimen>
<dimen name="reset_main_clear_margin_start">32dp</dimen>
<dimen name="reset_main_clear_margin_end">12dp</dimen>
<!-- Padding for the reset screens -->
<dimen name="reset_checkbox_padding_end">8dp</dimen>

View File

@@ -2341,7 +2341,7 @@
<!-- Label for Wifi hotspot name. -->
<string name="wifi_hotspot_name_title">Hotspot name</string>
<!-- Summary for Wifi hotspot name when connection is in progress. -->
<string name="wifi_hotspot_name_summary_connecting">Turning on <xliff:g id="wifi_hotspot_name">%1$s</xliff:g>...</string>
<string name="wifi_hotspot_name_summary_connecting">Turning on <xliff:g id="wifi_hotspot_name">%1$s</xliff:g>\u2026</string>
<!-- Summary for Wifi hotspot name when connected. -->
<string name="wifi_hotspot_name_summary_connected">Other devices can connect to <xliff:g id="wifi_hotspot_name">%1$s</xliff:g></string>
<!-- Label for Wifi hotspot password. -->
@@ -3715,29 +3715,29 @@
<!-- Message of the error message shown when error happens during erase eSIM data [CHAR LIMIT=NONE] -->
<string name="reset_esim_error_msg">Downloaded SIMs can\u2019t be erased due to an error.\n\nRestart your device and try again.</string>
<!-- Master Clear -->
<!-- Button title to factory data reset the entire device -->
<string name="master_clear_title">Erase all data (factory reset)</string>
<!-- Main Clear -->
<!-- Button title to factory data reset the entire device [CHAR LIMIT=NONE] -->
<string name="main_clear_title">Erase all data (factory reset)</string>
<!-- Button title to factory data reset the entire device. The "(factory reset)" part is optional for translation. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=3531267871084279512]-->
<string name="master_clear_short_title">Erase all data (factory reset)</string>
<string name="main_clear_short_title">Erase all data (factory reset)</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
<string name="master_clear_desc" product="tablet">"This will erase all data from your tablet\u2019s <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="main_clear_desc" product="tablet">"This will erase all data from your tablet\u2019s <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, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
<string name="master_clear_desc" product="default">"This will erase all data from your phone\u2019s <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="main_clear_desc" product="default">"This will erase all data from your phone\u2019s <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] -->
<string name="master_clear_accounts" product="default">"\n\nYou are currently signed into the following accounts:\n"</string>
<string name="main_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>
<string name="main_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] -->
<string name="master_clear_desc_also_erases_external">"<li>Music</li>\n<li>Photos</li>\n<li>Other user data</li>"</string>
<string name="main_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, list of items on an eSIM (embedded SIM) that will be erased during this operation [CHAR LIMIT=NONE] -->
<string name="master_clear_desc_also_erases_esim">"<li>eSIMs</li>"</string>
<string name="main_clear_desc_also_erases_esim">"<li>eSIMs</li>"</string>
<!-- SD card & phone storage settings screen, notification if there are eSIM (embedded SIM) profiles present that the user's mobile service plan will not be canceled [CHAR LIMIT=NONE] -->
<string name="master_clear_desc_no_cancel_mobile_plan">"\n\nThis will not cancel your mobile service plan.</string>
<string name="main_clear_desc_no_cancel_mobile_plan">"\n\nThis will not cancel your mobile service plan.</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] -->
<string name="master_clear_desc_erase_external_storage" product="nosdcard">"\n\nTo clear music, pictures, and other user data, the <b>USB storage</b> needs to be erased."</string>
<string name="main_clear_desc_erase_external_storage" product="nosdcard">"\n\nTo clear music, pictures, and other user data, the <b>USB storage</b> needs to be erased."</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] -->
<string name="master_clear_desc_erase_external_storage" product="default">"\n\nTo clear music, pictures, and other user data, the <b>SD card</b> needs to be erased."</string>
<string name="main_clear_desc_erase_external_storage" product="default">"\n\nTo clear music, pictures, and other user data, the <b>SD card</b> needs to be erased."</string>
<!-- SD card & phone storage settings screen, label for check box to erase USB storage [CHAR LIMIT=30] -->
<string name="erase_external_storage" product="nosdcard">Erase USB storage</string>
<!-- SD card & phone storage settings screen, label for check box to erase SD card [CHAR LIMIT=30] -->
@@ -3746,26 +3746,22 @@
<string name="erase_external_storage_description" product="nosdcard">Erase all the data on the internal USB storage, such as music or photos</string>
<!-- SD card & phone storage settings screen, description for check box to erase USB storage [CHAR LIMIT=NONE] -->
<string name="erase_external_storage_description" product="default">Erase all the data on the SD card, such as music or photos</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
<string name="master_clear_button_text" product="tablet">Erase all data</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
<string name="master_clear_button_text" product="default">Erase all data</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button -->
<string name="master_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
<string name="main_clear_button_text" product="tablet">Erase all data</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
<string name="main_clear_button_text" product="default">Erase all data</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button [CHAR LIMIT=NONE] -->
<string name="master_clear_final_desc_esim">All of your personal information, including downloaded apps &amp; SIMs, will be deleted. You can\u2019t undo this action.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset phone button -->
<string name="master_clear_final_button_text">Erase everything</string>
<!-- Master clear failed message -->
<string name="master_clear_failed">No reset was performed because the System Clear service isn\u2019t available.</string>
<!-- Master clear confirmation screen title [CHAR LIMIT=33] -->
<string name="master_clear_confirm_title">Erase all data?</string>
<string name="main_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action.</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button [CHAR LIMIT=NONE] -->
<string name="main_clear_final_desc_esim">All of your personal information, including downloaded apps &amp; SIMs, will be deleted. You can\u2019t undo this action.</string>
<!-- Main clear confirmation screen title [CHAR LIMIT=33] -->
<string name="main_clear_confirm_title">Erase all data?</string>
<!-- Error message for users that aren't allowed to factory reset [CHAR LIMIT=none] -->
<string name="master_clear_not_available">Factory reset is not available for this user</string>
<!-- Master clear progress screen title [CHAR LIMIT=30] -->
<string name="master_clear_progress_title" >Erasing</string>
<!-- Master clear progress screen text [CHAR LIMIT=75] -->
<string name="master_clear_progress_text">Please wait...</string>
<string name="main_clear_not_available">Factory reset is not available for this user</string>
<!-- Main clear progress screen title [CHAR LIMIT=30] -->
<string name="main_clear_progress_title" >Erasing</string>
<!-- Main clear progress screen text [CHAR LIMIT=75] -->
<string name="main_clear_progress_text">Please wait\u2026</string>
<!-- Main settings screen, Call settings title for item to go into the call settings -->
<string name="call_settings_title">Call settings</string>
@@ -5124,8 +5120,8 @@
<string name="accessibility_ring_vibration_title">Ring vibration</string>
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the accessibility service settings to control turning on/off the service entirely -->
<string name="accessibility_service_master_switch_title">Use <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the accessibility service settings to control turning on/off the service entirely [CHAR LIMIT=60] -->
<string name="accessibility_service_primary_switch_title">Use <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the accessibility service settings to open the activity. [CHAR LIMIT=NONE] -->
<string name="accessibility_service_master_open_title">Open <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
@@ -7058,7 +7054,7 @@
<!-- Button the users can click to indicate they understood and dismiss the screen -->
<string name="nfc_how_it_works_got_it">Got it</string>
<!-- NFC More... title. [CHAR LIMIT=40] -->
<string name="nfc_more_title">More...</string>
<string name="nfc_more_title">More\u2026</string>
<!-- Label for the dialog that is shown when the user is asked to set a
preferred payment application -->
<string name="nfc_payment_set_default_label">Set default payment app</string>
@@ -7418,7 +7414,7 @@
<!-- Message for selecting sim for SMS in settings. [CHAR LIMIT=40] -->
<string name="select_sim_for_sms">Select a SIM for SMS</string>
<!-- Message for switching data SIM; switching takes a while -->
<string name="data_switch_started">Switching data SIM, this may take up to a minute...</string>
<string name="data_switch_started">Switching data SIM, this may take up to a minute\u2026</string>
<!-- Message for selecting sim for call in settings. [CHAR LIMIT=40] -->
<string name="select_sim_for_calls">Call with</string>
<!-- Title for selecting a SIM card. [CHAR LIMIT=40] -->
@@ -8781,7 +8777,7 @@
<string name="zen_access_empty_text">No installed apps have requested Do Not Disturb access</string>
<!-- [CHAR LIMIT=NONE] Text when loading app list in notification settings -->
<string name="loading_notification_apps">Loading apps...</string>
<string name="loading_notification_apps">Loading apps\u2026</string>
<!-- [CHAR LIMIT=NONE] Text appearing when app notifications are off -->
<string name="app_notifications_off_desc">At your request, Android is blocking this app\'s notifications from appearing on this device</string>
@@ -9846,7 +9842,7 @@
<string name="usb_control_device">This device</string>
<!-- The summary text that appears under a USB control option while it is in the process of
switching control or power. -->
<string name="usb_switching">Switching...</string>
<string name="usb_switching">Switching\u2026</string>
<!-- The summary text that appears under a USB control option when switching control or power has
failed. -->
<string name="usb_switching_failed">Couldn\'t switch</string>
@@ -12067,7 +12063,7 @@
<!-- DSU Loader Description. Do not translate. -->
<string name="dsu_loader_description" translatable="false">Load a Dynamic System Update Image</string>
<!-- DSU Loader Loading. Do not translate. -->
<string name="dsu_loader_loading" translatable="false">Loading...</string>
<string name="dsu_loader_loading" translatable="false">Loading\u2026</string>
<!-- DSU Loader. Do not translate. -->
<string name="dsu_is_running" translatable="false">DSU is running</string>

View File

@@ -36,9 +36,9 @@
<!-- Factory reset -->
<com.android.settingslib.RestrictedPreference
android:key="factory_reset"
android:title="@string/master_clear_title"
android:title="@string/main_clear_title"
settings:keywords="@string/keywords_factory_data_reset"
settings:userRestriction="no_factory_reset"
settings:useAdminDisabledSummary="true"
android:fragment="com.android.settings.MasterClear" />
android:fragment="com.android.settings.MainClear" />
</PreferenceScreen>

View File

@@ -83,16 +83,16 @@ import java.util.List;
*
* This is the initial screen.
*/
public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutListener {
private static final String TAG = "MasterClear";
public class MainClear extends InstrumentedFragment implements OnGlobalLayoutListener {
private static final String TAG = "MainClear";
@VisibleForTesting
static final int KEYGUARD_REQUEST = 55;
@VisibleForTesting
static final int CREDENTIAL_CONFIRM_REQUEST = 56;
private static final String KEY_SHOW_ESIM_RESET_CHECKBOX
= "masterclear.allow_retain_esim_profiles_after_fdr";
private static final String KEY_SHOW_ESIM_RESET_CHECKBOX =
"masterclear.allow_retain_esim_profiles_after_fdr";
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
static final String ERASE_ESIMS_EXTRA = "erase_esim";
@@ -142,7 +142,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
final ChooseLockSettingsHelper.Builder builder =
new ChooseLockSettingsHelper.Builder(getActivity(), this);
return builder.setRequestCode(request)
.setTitle(res.getText(R.string.master_clear_short_title))
.setTitle(res.getText(R.string.main_clear_short_title))
.show();
}
@@ -188,9 +188,9 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
args.putBoolean(ERASE_EXTERNAL_EXTRA, mExternalStorage.isChecked());
args.putBoolean(ERASE_ESIMS_EXTRA, mEsimStorage.isChecked());
new SubSettingLauncher(getContext())
.setDestination(MasterClearConfirm.class.getName())
.setDestination(MainClearConfirm.class.getName())
.setArguments(args)
.setTitleRes(R.string.master_clear_confirm_title)
.setTitleRes(R.string.main_clear_confirm_title)
.setSourceMetricsCategory(getMetricsCategory())
.launch();
}
@@ -296,7 +296,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
if (mScrollView != null) {
mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
mScrollView = mContentView.findViewById(R.id.master_clear_scrollview);
mScrollView = mContentView.findViewById(R.id.main_clear_scrollview);
/*
* If the external storage is emulated, it will be erased with a factory
@@ -354,9 +354,9 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
loadAccountList(um);
final StringBuffer contentDescription = new StringBuffer();
final View masterClearContainer = mContentView.findViewById(R.id.master_clear_container);
getContentDescription(masterClearContainer, contentDescription);
masterClearContainer.setContentDescription(contentDescription);
final View mainClearContainer = mContentView.findViewById(R.id.main_clear_container);
getContentDescription(mainClearContainer, contentDescription);
mainClearContainer.setContentDescription(contentDescription);
// Set the status of initiateButton based on scrollview
mScrollView.setOnScrollChangeListener(new OnScrollChangeListener() {
@@ -424,7 +424,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
new FooterButton.Builder(getActivity())
.setText(R.string.master_clear_button_text)
.setText(R.string.main_clear_button_text)
.setListener(mInitiateListener)
.setButtonType(ButtonType.OTHER)
.setTheme(R.style.SudGlifButton_Primary)
@@ -475,15 +475,15 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
final int profileId = userInfo.id;
final UserHandle userHandle = new UserHandle(profileId);
Account[] accounts = mgr.getAccountsAsUser(profileId);
final int N = accounts.length;
if (N == 0) {
final int accountLength = accounts.length;
if (accountLength == 0) {
continue;
}
accountsCount += N;
accountsCount += accountLength;
AuthenticatorDescription[] descs = AccountManager.get(context)
.getAuthenticatorTypesAsUser(profileId);
final int M = descs.length;
final int descLength = descs.length;
if (profilesSize > 1) {
View titleView = Utils.inflateCategoryHeader(inflater, contents);
@@ -493,10 +493,10 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
contents.addView(titleView);
}
for (int i = 0; i < N; i++) {
for (int i = 0; i < accountLength; i++) {
Account account = accounts[i];
AuthenticatorDescription desc = null;
for (int j = 0; j < M; j++) {
for (int j = 0; j < descLength; j++) {
if (account.type.equals(descs[j].type)) {
desc = descs[j];
break;
@@ -524,7 +524,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
icon = context.getPackageManager().getDefaultActivityIcon();
}
View child = inflater.inflate(R.layout.master_clear_account, contents, false);
View child = inflater.inflate(R.layout.main_clear_account, contents, false);
((ImageView) child.findViewById(android.R.id.icon)).setImageDrawable(icon);
((TextView) child.findViewById(android.R.id.title)).setText(account.name);
contents.addView(child);
@@ -552,7 +552,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
.hasBaseUserRestriction(context, UserManager.DISALLOW_FACTORY_RESET,
UserHandle.myUserId());
if (disallow && !Utils.isDemoUser(context)) {
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
return inflater.inflate(R.layout.main_clear_disallowed_screen, null);
} else if (admin != null) {
new ActionDisabledByAdminDialogHelper(getActivity())
.prepareDialogBuilder(UserManager.DISALLOW_FACTORY_RESET, admin)
@@ -561,7 +561,7 @@ public class MasterClear extends InstrumentedFragment implements OnGlobalLayoutL
return new View(getContext());
}
mContentView = inflater.inflate(R.layout.master_clear, null);
mContentView = inflater.inflate(R.layout.main_clear, null);
establishInitialState();
return mContentView;

View File

@@ -64,8 +64,8 @@ import com.google.android.setupdesign.GlifLayout;
*
* This is the confirmation screen.
*/
public class MasterClearConfirm extends InstrumentedFragment {
private final static String TAG = "MasterClearConfirm";
public class MainClearConfirm extends InstrumentedFragment {
private static final String TAG = "MainClearConfirm";
@VisibleForTesting View mContentView;
private boolean mEraseSdCard;
@@ -103,7 +103,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
mProgressDialog.hide();
if (getActivity() != null) {
getActivity().setRequestedOrientation(mOldOrientation);
doMasterClear();
doMainClear();
}
}
@@ -121,7 +121,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
}
}.execute();
} else {
doMasterClear();
doMainClear();
}
}
@@ -130,9 +130,9 @@ public class MasterClearConfirm extends InstrumentedFragment {
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.setTitle(
getActivity().getString(R.string.master_clear_progress_title));
getActivity().getString(R.string.main_clear_progress_title));
progressDialog.setMessage(
getActivity().getString(R.string.master_clear_progress_text));
getActivity().getString(R.string.main_clear_progress_text));
return progressDialog;
}
};
@@ -180,11 +180,11 @@ public class MasterClearConfirm extends InstrumentedFragment {
return !WizardManagerHelper.isDeviceProvisioned(getActivity());
}
private void doMasterClear() {
private void doMainClear() {
Intent intent = new Intent(Intent.ACTION_FACTORY_RESET);
intent.setPackage("android");
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON, "MasterClearConfirm");
intent.putExtra(Intent.EXTRA_REASON, "MainClearConfirm");
intent.putExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, mEraseSdCard);
intent.putExtra(Intent.EXTRA_WIPE_ESIMS, mEraseEsims);
getActivity().sendBroadcast(intent);
@@ -200,7 +200,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
new FooterButton.Builder(getActivity())
.setText(R.string.master_clear_button_text)
.setText(R.string.main_clear_button_text)
.setListener(mFinalClickListener)
.setButtonType(ButtonType.OTHER)
.setTheme(R.style.SudGlifButton_Primary)
@@ -230,7 +230,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
getActivity(), UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId());
if (RestrictedLockUtilsInternal.hasBaseUserRestriction(getActivity(),
UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
return inflater.inflate(R.layout.master_clear_disallowed_screen, null);
return inflater.inflate(R.layout.main_clear_disallowed_screen, null);
} else if (admin != null) {
new ActionDisabledByAdminDialogHelper(getActivity())
.prepareDialogBuilder(UserManager.DISALLOW_FACTORY_RESET, admin)
@@ -238,7 +238,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
.show();
return new View(getActivity());
}
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
mContentView = inflater.inflate(R.layout.main_clear_confirm, null);
setUpActionBarAndTitle();
establishFinalConfirmationState();
setAccessibilityTitle();
@@ -260,7 +260,7 @@ public class MasterClearConfirm extends InstrumentedFragment {
void setSubtitle() {
if (mEraseEsims) {
((TextView) mContentView.findViewById(R.id.sud_layout_description))
.setText(R.string.master_clear_final_desc_esim);
.setText(R.string.main_clear_final_desc_esim);
}
}
@@ -270,9 +270,9 @@ public class MasterClearConfirm extends InstrumentedFragment {
Bundle args = getArguments();
mEraseSdCard = args != null
&& args.getBoolean(MasterClear.ERASE_EXTERNAL_EXTRA);
&& args.getBoolean(MainClear.ERASE_EXTERNAL_EXTRA);
mEraseEsims = args != null
&& args.getBoolean(MasterClear.ERASE_ESIMS_EXTRA);
&& args.getBoolean(MainClear.ERASE_ESIMS_EXTRA);
}
@Override

View File

@@ -125,7 +125,7 @@ public class ResetNetwork extends InstrumentedFragment {
args.putInt(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
subscription.getSubscriptionId());
}
args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA,
args.putBoolean(MainClear.ERASE_ESIMS_EXTRA,
mEsimContainer.getVisibility() == View.VISIBLE && mEsimCheckbox.isChecked());
new SubSettingLauncher(getContext())
.setDestination(ResetNetworkConfirm.class.getName())

View File

@@ -188,7 +188,7 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.setMessage(
context.getString(R.string.master_clear_progress_text));
context.getString(R.string.main_clear_progress_text));
return progressDialog;
}
@@ -251,7 +251,7 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
if (args != null) {
mSubId = args.getInt(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mEraseEsim = args.getBoolean(MasterClear.ERASE_ESIMS_EXTRA);
mEraseEsim = args.getBoolean(MainClear.ERASE_ESIMS_EXTRA);
}
mActivity = getActivity();

View File

@@ -200,7 +200,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
final String switchBarText = (info == null) ? "" :
getString(R.string.accessibility_service_master_switch_title,
getString(R.string.accessibility_service_primary_switch_title,
info.getResolveInfo().loadLabel(getPackageManager()));
switchPreference.setTitle(switchBarText);
}

View File

@@ -365,7 +365,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
abstract int getUserShortcutTypes();
protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
switchPreference.setTitle(R.string.accessibility_service_master_switch_title);
switchPreference.setTitle(R.string.accessibility_service_primary_switch_title);
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);

View File

@@ -19,7 +19,7 @@ package com.android.settings.core.gateway;
import com.android.settings.AllInOneTetherSettings;
import com.android.settings.DisplaySettings;
import com.android.settings.IccLockSettings;
import com.android.settings.MasterClear;
import com.android.settings.MainClear;
import com.android.settings.Settings;
import com.android.settings.TestingSettings;
import com.android.settings.TetherSettings;
@@ -273,7 +273,7 @@ public class SettingsGateway {
TestingSettings.class.getName(),
WifiAPITest.class.getName(),
WifiInfo.class.getName(),
MasterClear.class.getName(),
MainClear.class.getName(),
ResetDashboardFragment.class.getName(),
NightDisplaySettings.class.getName(),
ManageDomainUrls.class.getName(),

View File

@@ -42,7 +42,7 @@ import org.robolectric.RobolectricTestRunner;
import java.util.ArrayList;
@RunWith(RobolectricTestRunner.class)
public class MasterClearConfirmTest {
public class MainClearConfirmTest {
private FragmentActivity mActivity;
@@ -55,85 +55,85 @@ public class MasterClearConfirmTest {
@Mock
private PersistentDataBlockManager mPersistentDataBlockManager;
private MasterClearConfirm mMasterClearConfirm;
private MainClearConfirm mMainClearConfirm;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mActivity = Robolectric.setupActivity(FragmentActivity.class);
mMasterClearConfirm = spy(new MasterClearConfirm());
mMainClearConfirm = spy(new MainClearConfirm());
}
@Test
public void setSubtitle_eraseEsim() {
MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
masterClearConfirm.mEraseEsims = true;
masterClearConfirm.mContentView =
LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
MainClearConfirm mainClearConfirm = new MainClearConfirm();
mainClearConfirm.mEraseEsims = true;
mainClearConfirm.mContentView =
LayoutInflater.from(mActivity).inflate(R.layout.main_clear_confirm, null);
masterClearConfirm.setSubtitle();
mainClearConfirm.setSubtitle();
assertThat(((TextView) masterClearConfirm.mContentView
assertThat(((TextView) mainClearConfirm.mContentView
.findViewById(R.id.sud_layout_description)).getText())
.isEqualTo(mActivity.getString(R.string.master_clear_final_desc_esim));
.isEqualTo(mActivity.getString(R.string.main_clear_final_desc_esim));
}
@Test
public void setSubtitle_notEraseEsim() {
MasterClearConfirm masterClearConfirm = new MasterClearConfirm();
masterClearConfirm.mEraseEsims = false;
masterClearConfirm.mContentView =
LayoutInflater.from(mActivity).inflate(R.layout.master_clear_confirm, null);
MainClearConfirm mainClearConfirm = new MainClearConfirm();
mainClearConfirm.mEraseEsims = false;
mainClearConfirm.mContentView =
LayoutInflater.from(mActivity).inflate(R.layout.main_clear_confirm, null);
masterClearConfirm.setSubtitle();
mainClearConfirm.setSubtitle();
assertThat(((TextView) masterClearConfirm.mContentView
assertThat(((TextView) mainClearConfirm.mContentView
.findViewById(R.id.sud_layout_description)).getText())
.isEqualTo(mActivity.getString(R.string.master_clear_final_desc));
.isEqualTo(mActivity.getString(R.string.main_clear_final_desc));
}
@Test
public void shouldWipePersistentDataBlock_noPersistentDataBlockManager_shouldReturnFalse() {
assertThat(mMasterClearConfirm.shouldWipePersistentDataBlock(null)).isFalse();
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(null)).isFalse();
}
@Test
public void shouldWipePersistentDataBlock_deviceIsStillBeingProvisioned_shouldReturnFalse() {
doReturn(true).when(mMasterClearConfirm).isDeviceStillBeingProvisioned();
doReturn(true).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
assertThat(mMasterClearConfirm.shouldWipePersistentDataBlock(
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(
mPersistentDataBlockManager)).isFalse();
}
@Test
public void shouldWipePersistentDataBlock_oemUnlockAllowed_shouldReturnFalse() {
doReturn(false).when(mMasterClearConfirm).isDeviceStillBeingProvisioned();
doReturn(true).when(mMasterClearConfirm).isOemUnlockedAllowed();
doReturn(false).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
doReturn(true).when(mMainClearConfirm).isOemUnlockedAllowed();
assertThat(mMasterClearConfirm.shouldWipePersistentDataBlock(
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(
mPersistentDataBlockManager)).isFalse();
}
@Test
public void shouldWipePersistentDataBlock_frpPolicyNotSupported_shouldReturnFalse() {
when(mMasterClearConfirm.getActivity()).thenReturn(mMockActivity);
when(mMainClearConfirm.getActivity()).thenReturn(mMockActivity);
doReturn(false).when(mMasterClearConfirm).isDeviceStillBeingProvisioned();
doReturn(false).when(mMasterClearConfirm).isOemUnlockedAllowed();
doReturn(false).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
doReturn(false).when(mMainClearConfirm).isOemUnlockedAllowed();
when(mMockActivity.getSystemService(Context.DEVICE_POLICY_SERVICE))
.thenReturn(mDevicePolicyManager);
when(mDevicePolicyManager.isFactoryResetProtectionPolicySupported()).thenReturn(false);
assertThat(mMasterClearConfirm.shouldWipePersistentDataBlock(
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(
mPersistentDataBlockManager)).isFalse();
}
@Test
public void shouldWipePersistentDataBlock_hasFactoryResetProtectionPolicy_shouldReturnFalse() {
when(mMasterClearConfirm.getActivity()).thenReturn(mMockActivity);
when(mMainClearConfirm.getActivity()).thenReturn(mMockActivity);
doReturn(false).when(mMasterClearConfirm).isDeviceStillBeingProvisioned();
doReturn(false).when(mMasterClearConfirm).isOemUnlockedAllowed();
doReturn(false).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
doReturn(false).when(mMainClearConfirm).isOemUnlockedAllowed();
ArrayList<String> accounts = new ArrayList<>();
accounts.add("test");
FactoryResetProtectionPolicy frp = new FactoryResetProtectionPolicy.Builder()
@@ -146,16 +146,16 @@ public class MasterClearConfirmTest {
when(mDevicePolicyManager.getFactoryResetProtectionPolicy(null)).thenReturn(frp);
when(mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile()).thenReturn(true);
assertThat(mMasterClearConfirm.shouldWipePersistentDataBlock(
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(
mPersistentDataBlockManager)).isFalse();
}
@Test
public void shouldWipePersistentDataBlock_isNotOrganizationOwnedDevice_shouldReturnTrue() {
when(mMasterClearConfirm.getActivity()).thenReturn(mMockActivity);
when(mMainClearConfirm.getActivity()).thenReturn(mMockActivity);
doReturn(false).when(mMasterClearConfirm).isDeviceStillBeingProvisioned();
doReturn(false).when(mMasterClearConfirm).isOemUnlockedAllowed();
doReturn(false).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
doReturn(false).when(mMainClearConfirm).isOemUnlockedAllowed();
when(mMockActivity.getSystemService(Context.DEVICE_POLICY_SERVICE))
.thenReturn(mDevicePolicyManager);
@@ -163,7 +163,7 @@ public class MasterClearConfirmTest {
when(mDevicePolicyManager.getFactoryResetProtectionPolicy(null)).thenReturn(null);
when(mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile()).thenReturn(false);
assertThat(mMasterClearConfirm.shouldWipePersistentDataBlock(
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(
mPersistentDataBlockManager)).isTrue();
}
}

View File

@@ -11,7 +11,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
* limitations under the License.
*/
package com.android.settings;
@@ -69,7 +69,7 @@ import org.robolectric.shadows.ShadowUserManager;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowUtils.class)
public class MasterClearTest {
public class MainClearTest {
private static final String TEST_ACCOUNT_TYPE = "android.test.account.type";
private static final String TEST_CONFIRMATION_PACKAGE = "android.test.conf.pkg";
@@ -93,7 +93,7 @@ public class MasterClearTest {
@Mock
private Intent mMockIntent;
private MasterClear mMasterClear;
private MainClear mMainClear;
private ShadowActivity mShadowActivity;
private FragmentActivity mActivity;
private ShadowUserManager mShadowUserManager;
@@ -102,13 +102,13 @@ public class MasterClearTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mMasterClear = spy(new MasterClear());
mMainClear = spy(new MainClear());
mActivity = Robolectric.setupActivity(FragmentActivity.class);
mShadowActivity = Shadows.shadowOf(mActivity);
UserManager userManager = mActivity.getSystemService(UserManager.class);
mShadowUserManager = Shadows.shadowOf(userManager);
mShadowUserManager.setIsAdminUser(true);
mContentView = LayoutInflater.from(mActivity).inflate(R.layout.master_clear, null);
mContentView = LayoutInflater.from(mActivity).inflate(R.layout.main_clear, null);
// Make scrollView only have one child
when(mScrollView.getChildAt(0)).thenReturn(mLinearLayout);
@@ -123,78 +123,78 @@ public class MasterClearTest {
@Test
public void testShowFinalConfirmation_eraseEsimVisible_eraseEsimChecked() {
final Context context = mock(Context.class);
when(mMasterClear.getContext()).thenReturn(context);
when(mMainClear.getContext()).thenReturn(context);
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMasterClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
mMasterClear.mEsimStorage.setChecked(true);
mMasterClear.showFinalConfirmation();
mMainClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMainClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMainClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMainClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
mMainClear.mEsimStorage.setChecked(true);
mMainClear.showFinalConfirmation();
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
verify(context).startActivity(intent.capture());
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false))
.isTrue();
}
@Test
public void testShowFinalConfirmation_eraseEsimVisible_eraseEsimUnchecked() {
final Context context = mock(Context.class);
when(mMasterClear.getContext()).thenReturn(context);
when(mMainClear.getContext()).thenReturn(context);
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMasterClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
mMasterClear.mEsimStorage.setChecked(false);
mMasterClear.showFinalConfirmation();
mMainClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMainClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMainClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMainClear.mEsimStorageContainer.setVisibility(View.VISIBLE);
mMainClear.mEsimStorage.setChecked(false);
mMainClear.showFinalConfirmation();
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
verify(context).startActivity(intent.capture());
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false))
.isFalse();
}
@Test
public void testShowFinalConfirmation_eraseEsimGone_eraseEsimChecked() {
final Context context = mock(Context.class);
when(mMasterClear.getContext()).thenReturn(context);
when(mMainClear.getContext()).thenReturn(context);
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMasterClear.mEsimStorageContainer.setVisibility(View.GONE);
mMasterClear.mEsimStorage.setChecked(true);
mMasterClear.showFinalConfirmation();
mMainClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMainClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMainClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMainClear.mEsimStorageContainer.setVisibility(View.GONE);
mMainClear.mEsimStorage.setChecked(true);
mMainClear.showFinalConfirmation();
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
verify(context).startActivity(intent.capture());
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false))
.isTrue();
}
@Test
public void testShowFinalConfirmation_eraseEsimGone_eraseEsimUnchecked() {
final Context context = mock(Context.class);
when(mMasterClear.getContext()).thenReturn(context);
when(mMainClear.getContext()).thenReturn(context);
mMasterClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMasterClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMasterClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMasterClear.mEsimStorageContainer.setVisibility(View.GONE);
mMasterClear.mEsimStorage.setChecked(false);
mMasterClear.showFinalConfirmation();
mMainClear.mEsimStorage = mContentView.findViewById(R.id.erase_esim);
mMainClear.mExternalStorage = mContentView.findViewById(R.id.erase_external);
mMainClear.mEsimStorageContainer = mContentView.findViewById(R.id.erase_esim_container);
mMainClear.mEsimStorageContainer.setVisibility(View.GONE);
mMainClear.mEsimStorage.setChecked(false);
mMainClear.showFinalConfirmation();
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
verify(context).startActivity(intent.capture());
assertThat(intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false))
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false))
.isFalse();
}
@@ -204,7 +204,7 @@ public class MasterClearTest {
false /* isEuiccEnabled */,
true /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
assertThat(mMainClear.showWipeEuicc()).isFalse();
}
@Test
@@ -213,7 +213,7 @@ public class MasterClearTest {
true /* isEuiccEnabled */,
false /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isFalse();
assertThat(mMainClear.showWipeEuicc()).isFalse();
}
@Test
@@ -222,7 +222,7 @@ public class MasterClearTest {
true /* isEuiccEnabled */,
true /* isEuiccProvisioned */,
false /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
assertThat(mMainClear.showWipeEuicc()).isTrue();
}
@Test
@@ -231,7 +231,7 @@ public class MasterClearTest {
true /* isEuiccEnabled */,
false /* isEuiccProvisioned */,
true /* isDeveloper */);
assertThat(mMasterClear.showWipeEuicc()).isTrue();
assertThat(mMainClear.showWipeEuicc()).isTrue();
}
@Test
@@ -243,32 +243,32 @@ public class MasterClearTest {
public void testHasReachedBottom_NotScrollDown_returnFalse() {
initScrollView(100, 0, 200);
assertThat(mMasterClear.hasReachedBottom(mScrollView)).isFalse();
assertThat(mMainClear.hasReachedBottom(mScrollView)).isFalse();
}
@Test
public void testHasReachedBottom_CanNotScroll_returnTrue() {
initScrollView(100, 0, 80);
assertThat(mMasterClear.hasReachedBottom(mScrollView)).isTrue();
assertThat(mMainClear.hasReachedBottom(mScrollView)).isTrue();
}
@Test
public void testHasReachedBottom_ScrollToBottom_returnTrue() {
initScrollView(100, 100, 200);
assertThat(mMasterClear.hasReachedBottom(mScrollView)).isTrue();
assertThat(mMainClear.hasReachedBottom(mScrollView)).isTrue();
}
@Test
public void testInitiateMasterClear_inDemoMode_sendsIntent() {
public void testInitiateMainClear_inDemoMode_sendsIntent() {
ShadowUtils.setIsDemoUser(true);
final ComponentName componentName =
ComponentName.unflattenFromString("com.android.retaildemo/.DeviceAdminReceiver");
ShadowUtils.setDeviceOwnerComponent(componentName);
mMasterClear.mInitiateListener.onClick(mContentView);
mMainClear.mInitiateListener.onClick(mContentView);
final Intent intent = mShadowActivity.getNextStartedActivity();
assertThat(Intent.ACTION_FACTORY_RESET).isEqualTo(intent.getAction());
assertThat(componentName).isNotNull();
@@ -278,87 +278,87 @@ public class MasterClearTest {
@Test
public void testOnActivityResultInternal_invalideRequest() {
int invalidRequestCode = -1;
doReturn(false).when(mMasterClear).isValidRequestCode(eq(invalidRequestCode));
doReturn(false).when(mMainClear).isValidRequestCode(eq(invalidRequestCode));
mMasterClear.onActivityResultInternal(invalidRequestCode, Activity.RESULT_OK, null);
mMainClear.onActivityResultInternal(invalidRequestCode, Activity.RESULT_OK, null);
verify(mMasterClear, times(1)).isValidRequestCode(eq(invalidRequestCode));
verify(mMasterClear, times(0)).establishInitialState();
verify(mMasterClear, times(0)).getAccountConfirmationIntent();
verify(mMasterClear, times(0)).showFinalConfirmation();
verify(mMainClear, times(1)).isValidRequestCode(eq(invalidRequestCode));
verify(mMainClear, times(0)).establishInitialState();
verify(mMainClear, times(0)).getAccountConfirmationIntent();
verify(mMainClear, times(0)).showFinalConfirmation();
}
@Test
public void testOnActivityResultInternal_resultCanceled() {
doReturn(true).when(mMasterClear).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
doNothing().when(mMasterClear).establishInitialState();
doReturn(true).when(mMainClear).isValidRequestCode(eq(MainClear.KEYGUARD_REQUEST));
doNothing().when(mMainClear).establishInitialState();
mMasterClear
.onActivityResultInternal(MasterClear.KEYGUARD_REQUEST, Activity.RESULT_CANCELED,
mMainClear
.onActivityResultInternal(MainClear.KEYGUARD_REQUEST, Activity.RESULT_CANCELED,
null);
verify(mMasterClear, times(1)).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
verify(mMasterClear, times(1)).establishInitialState();
verify(mMasterClear, times(0)).getAccountConfirmationIntent();
verify(mMasterClear, times(0)).showFinalConfirmation();
verify(mMainClear, times(1)).isValidRequestCode(eq(MainClear.KEYGUARD_REQUEST));
verify(mMainClear, times(1)).establishInitialState();
verify(mMainClear, times(0)).getAccountConfirmationIntent();
verify(mMainClear, times(0)).showFinalConfirmation();
}
@Test
public void testOnActivityResultInternal_keyguardRequestTriggeringConfirmAccount() {
doReturn(true).when(mMasterClear).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
doReturn(mMockIntent).when(mMasterClear).getAccountConfirmationIntent();
doNothing().when(mMasterClear).showAccountCredentialConfirmation(eq(mMockIntent));
doReturn(true).when(mMainClear).isValidRequestCode(eq(MainClear.KEYGUARD_REQUEST));
doReturn(mMockIntent).when(mMainClear).getAccountConfirmationIntent();
doNothing().when(mMainClear).showAccountCredentialConfirmation(eq(mMockIntent));
mMasterClear
.onActivityResultInternal(MasterClear.KEYGUARD_REQUEST, Activity.RESULT_OK, null);
mMainClear
.onActivityResultInternal(MainClear.KEYGUARD_REQUEST, Activity.RESULT_OK, null);
verify(mMasterClear, times(1)).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
verify(mMasterClear, times(0)).establishInitialState();
verify(mMasterClear, times(1)).getAccountConfirmationIntent();
verify(mMasterClear, times(1)).showAccountCredentialConfirmation(eq(mMockIntent));
verify(mMainClear, times(1)).isValidRequestCode(eq(MainClear.KEYGUARD_REQUEST));
verify(mMainClear, times(0)).establishInitialState();
verify(mMainClear, times(1)).getAccountConfirmationIntent();
verify(mMainClear, times(1)).showAccountCredentialConfirmation(eq(mMockIntent));
}
@Test
public void testOnActivityResultInternal_keyguardRequestTriggeringShowFinal() {
doReturn(true).when(mMasterClear).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
doReturn(null).when(mMasterClear).getAccountConfirmationIntent();
doNothing().when(mMasterClear).showFinalConfirmation();
doReturn(true).when(mMainClear).isValidRequestCode(eq(MainClear.KEYGUARD_REQUEST));
doReturn(null).when(mMainClear).getAccountConfirmationIntent();
doNothing().when(mMainClear).showFinalConfirmation();
mMasterClear
.onActivityResultInternal(MasterClear.KEYGUARD_REQUEST, Activity.RESULT_OK, null);
mMainClear
.onActivityResultInternal(MainClear.KEYGUARD_REQUEST, Activity.RESULT_OK, null);
verify(mMasterClear, times(1)).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
verify(mMasterClear, times(0)).establishInitialState();
verify(mMasterClear, times(1)).getAccountConfirmationIntent();
verify(mMasterClear, times(1)).showFinalConfirmation();
verify(mMainClear, times(1)).isValidRequestCode(eq(MainClear.KEYGUARD_REQUEST));
verify(mMainClear, times(0)).establishInitialState();
verify(mMainClear, times(1)).getAccountConfirmationIntent();
verify(mMainClear, times(1)).showFinalConfirmation();
}
@Test
public void testOnActivityResultInternal_confirmRequestTriggeringShowFinal() {
doReturn(true).when(mMasterClear)
.isValidRequestCode(eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
doNothing().when(mMasterClear).showFinalConfirmation();
doReturn(true).when(mMainClear)
.isValidRequestCode(eq(MainClear.CREDENTIAL_CONFIRM_REQUEST));
doNothing().when(mMainClear).showFinalConfirmation();
mMasterClear.onActivityResultInternal(
MasterClear.CREDENTIAL_CONFIRM_REQUEST, Activity.RESULT_OK, null);
mMainClear.onActivityResultInternal(
MainClear.CREDENTIAL_CONFIRM_REQUEST, Activity.RESULT_OK, null);
verify(mMasterClear, times(1))
.isValidRequestCode(eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
verify(mMasterClear, times(0)).establishInitialState();
verify(mMasterClear, times(0)).getAccountConfirmationIntent();
verify(mMasterClear, times(1)).showFinalConfirmation();
verify(mMainClear, times(1))
.isValidRequestCode(eq(MainClear.CREDENTIAL_CONFIRM_REQUEST));
verify(mMainClear, times(0)).establishInitialState();
verify(mMainClear, times(0)).getAccountConfirmationIntent();
verify(mMainClear, times(1)).showFinalConfirmation();
}
@Test
public void testGetAccountConfirmationIntent_unsupported() {
when(mMasterClear.getActivity()).thenReturn(mActivity);
when(mMainClear.getActivity()).thenReturn(mActivity);
/* Using the default resources, account confirmation shouldn't trigger */
assertThat(mMasterClear.getAccountConfirmationIntent()).isNull();
assertThat(mMainClear.getAccountConfirmationIntent()).isNull();
}
@Test
public void testGetAccountConfirmationIntent_no_relevant_accounts() {
when(mMasterClear.getActivity()).thenReturn(mMockActivity);
when(mMainClear.getActivity()).thenReturn(mMockActivity);
when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
when(mMockActivity.getString(R.string.account_confirmation_package))
.thenReturn(TEST_CONFIRMATION_PACKAGE);
@@ -368,12 +368,12 @@ public class MasterClearTest {
Account[] accounts = new Account[0];
when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)).thenReturn(accounts);
assertThat(mMasterClear.getAccountConfirmationIntent()).isNull();
assertThat(mMainClear.getAccountConfirmationIntent()).isNull();
}
@Test
public void testGetAccountConfirmationIntent_unresolved() {
when(mMasterClear.getActivity()).thenReturn(mMockActivity);
when(mMainClear.getActivity()).thenReturn(mMockActivity);
when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
when(mMockActivity.getString(R.string.account_confirmation_package))
.thenReturn(TEST_CONFIRMATION_PACKAGE);
@@ -385,12 +385,12 @@ public class MasterClearTest {
// The package manager should not resolve the confirmation intent targeting the non-existent
// confirmation package.
when(mMockActivity.getPackageManager()).thenReturn(mPackageManager);
assertThat(mMasterClear.getAccountConfirmationIntent()).isNull();
assertThat(mMainClear.getAccountConfirmationIntent()).isNull();
}
@Test
public void testTryShowAccountConfirmation_ok() {
when(mMasterClear.getActivity()).thenReturn(mMockActivity);
when(mMainClear.getActivity()).thenReturn(mMockActivity);
// Only try to show account confirmation if the appropriate resource overlays are available.
when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
when(mMockActivity.getString(R.string.account_confirmation_package))
@@ -411,7 +411,7 @@ public class MasterClearTest {
resolveInfo.activityInfo = activityInfo;
when(mPackageManager.resolveActivity(any(), eq(0))).thenReturn(resolveInfo);
Intent actualIntent = mMasterClear.getAccountConfirmationIntent();
Intent actualIntent = mMainClear.getAccountConfirmationIntent();
assertThat(TEST_CONFIRMATION_PACKAGE).isEqualTo(
actualIntent.getComponent().getPackageName());
assertThat(TEST_CONFIRMATION_CLASS).isEqualTo(actualIntent.getComponent().getClassName());
@@ -420,40 +420,40 @@ public class MasterClearTest {
@Test
public void testShowAccountCredentialConfirmation() {
// Finally mock out the startActivityForResultCall
doNothing().when(mMasterClear)
doNothing().when(mMainClear)
.startActivityForResult(eq(mMockIntent),
eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
mMasterClear.showAccountCredentialConfirmation(mMockIntent);
verify(mMasterClear, times(1))
eq(MainClear.CREDENTIAL_CONFIRM_REQUEST));
mMainClear.showAccountCredentialConfirmation(mMockIntent);
verify(mMainClear, times(1))
.startActivityForResult(eq(mMockIntent),
eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
eq(MainClear.CREDENTIAL_CONFIRM_REQUEST));
}
@Test
public void testIsValidRequestCode() {
assertThat(mMasterClear.isValidRequestCode(MasterClear.KEYGUARD_REQUEST)).isTrue();
assertThat(mMasterClear.isValidRequestCode(MasterClear.CREDENTIAL_CONFIRM_REQUEST))
assertThat(mMainClear.isValidRequestCode(MainClear.KEYGUARD_REQUEST)).isTrue();
assertThat(mMainClear.isValidRequestCode(MainClear.CREDENTIAL_CONFIRM_REQUEST))
.isTrue();
assertThat(mMasterClear.isValidRequestCode(0)).isFalse();
assertThat(mMainClear.isValidRequestCode(0)).isFalse();
}
@Test
public void testOnGlobalLayout_shouldNotRemoveListener() {
final ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class);
mMasterClear.mScrollView = mScrollView;
doNothing().when(mMasterClear).onGlobalLayout();
doReturn(true).when(mMasterClear).hasReachedBottom(any());
mMainClear.mScrollView = mScrollView;
doNothing().when(mMainClear).onGlobalLayout();
doReturn(true).when(mMainClear).hasReachedBottom(any());
when(mScrollView.getViewTreeObserver()).thenReturn(viewTreeObserver);
mMasterClear.onGlobalLayout();
mMainClear.onGlobalLayout();
verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMasterClear);
verify(viewTreeObserver, never()).removeOnGlobalLayoutListener(mMainClear);
}
private void prepareEuiccState(
boolean isEuiccEnabled, boolean isEuiccProvisioned, boolean isDeveloper) {
doReturn(mActivity).when(mMasterClear).getContext();
doReturn(isEuiccEnabled).when(mMasterClear).isEuiccEnabled(any());
doReturn(mActivity).when(mMainClear).getContext();
doReturn(isEuiccEnabled).when(mMainClear).isEuiccEnabled(any());
ContentResolver cr = mActivity.getContentResolver();
Settings.Global.putInt(cr, Settings.Global.EUICC_PROVISIONED, isEuiccProvisioned ? 1 : 0);
DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(mActivity, isDeveloper);

View File

@@ -18,10 +18,9 @@ package com.android.settings;
import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.Shadows.shadowOf;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
import android.content.Intent;
@@ -57,7 +56,7 @@ public class ResetNetworkTest {
Intent intent = shadowOf(mActivity).getNextStartedActivity();
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isTrue();
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false)).isTrue();
}
@Test
@@ -69,7 +68,7 @@ public class ResetNetworkTest {
Intent intent = shadowOf(mActivity).getNextStartedActivity();
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false)).isFalse();
}
@Test
@@ -81,7 +80,7 @@ public class ResetNetworkTest {
Intent intent = shadowOf(mActivity).getNextStartedActivity();
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false)).isFalse();
}
@Test
@@ -93,6 +92,6 @@ public class ResetNetworkTest {
Intent intent = shadowOf(mActivity).getNextStartedActivity();
assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
.getBoolean(MasterClear.ERASE_ESIMS_EXTRA, false)).isFalse();
.getBoolean(MainClear.ERASE_ESIMS_EXTRA, false)).isFalse();
}
}

View File

@@ -70,7 +70,7 @@ public class SwitchBarTest {
@Test
public void cycleChecked_customLabel_shouldUpdateTextAndBackground() {
final int onText = R.string.master_clear_progress_text;
final int onText = R.string.main_clear_progress_text;
final int offText = R.string.manage_space_text;
mBar.setSwitchBarText(onText, offText);
@@ -87,9 +87,9 @@ public class SwitchBarTest {
@Test
public void setCheck_customLabelWithStringType_shouldUpdateTextAndBackground() {
final String onText = mContext.getString(
R.string.accessibility_service_master_switch_title);
R.string.accessibility_service_primary_switch_title);
final String offText = mContext.getString(
R.string.accessibility_service_master_switch_title);
R.string.accessibility_service_primary_switch_title);
final TextView switchBarTextView = ((TextView) mBar.findViewById(R.id.switch_text));
mBar.setSwitchBarText(onText, offText);