Fix crash when launching about phone v2 through intent

Change-Id: Ife6c24a7127fc9821760f9f5b58a33437711bc25
Fixes: 73971752
Test: atest
This commit is contained in:
Fan Zhang
2018-02-28 10:03:43 -08:00
parent 6a6cc310cf
commit cfd79a9a7a
5 changed files with 14 additions and 16 deletions

View File

@@ -702,16 +702,16 @@ public class SettingsActivity extends SettingsDrawerActivity
|| somethingChanged;
// Enable/disable the Me Card page.
final boolean isMeCardEnabled = featureFactory
final boolean aboutPhoneV2Enabled = featureFactory
.getAccountFeatureProvider()
.isMeCardEnabled(this);
.isAboutPhoneV2Enabled(this);
somethingChanged = setTileEnabled(new ComponentName(packageName,
Settings.MyDeviceInfoActivity.class.getName()),
isMeCardEnabled, isAdmin)
aboutPhoneV2Enabled, isAdmin)
|| somethingChanged;
somethingChanged = setTileEnabled(new ComponentName(packageName,
Settings.DeviceInfoSettingsActivity.class.getName()),
!isMeCardEnabled, isAdmin)
!aboutPhoneV2Enabled, isAdmin)
|| somethingChanged;
if (UserHandle.MU_ENABLED && !isAdmin) {

View File

@@ -28,7 +28,7 @@ public interface AccountFeatureProvider {
/**
* Checks whether or not to display the new About Phone page.
*/
default boolean isMeCardEnabled(Context context) {
default boolean isAboutPhoneV2Enabled(Context context) {
return FeatureFlagUtils.isEnabled(context, FeatureFlags.ABOUT_PHONE_V2);
}
}

View File

@@ -28,6 +28,7 @@ import com.android.settings.Settings;
import com.android.settings.TestingSettings;
import com.android.settings.TetherSettings;
import com.android.settings.TrustedCredentialsSettings;
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.wifi.calling.WifiCallingSettings;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
@@ -154,6 +155,7 @@ public class SettingsGateway {
UserDictionarySettings.class.getName(),
DisplaySettings.class.getName(),
DeviceInfoSettings.class.getName(),
MyDeviceInfoFragment.class.getName(),
ManageApplications.class.getName(),
ManageAssist.class.getName(),
ProcessStatsUi.class.getName(),

View File

@@ -62,7 +62,7 @@ import java.util.Arrays;
import java.util.List;
public class MyDeviceInfoFragment extends DashboardFragment {
private static final String LOG_TAG = "MeCardFragment";
private static final String LOG_TAG = "MyDeviceInfoFragment";
private static final String KEY_MY_DEVICE_INFO_HEADER = "my_device_info_header";
private static final String KEY_LEGAL_CONTAINER = "legal_container";

View File

@@ -52,10 +52,8 @@ public class AboutPhoneSettingsTests {
// TODO: retrieve using name/ids from com.android.settings package
private static final String[] sResourceTexts = {
"Phone number",
"SIM status",
"Model & hardware",
"MEID",
"Android version"
"Legal information",
"Regulatory labels"
};
private UiDevice mDevice;
@@ -94,11 +92,11 @@ public class AboutPhoneSettingsTests {
}
@Test
public void testAllMenuEntriesExist() throws Exception {
public void testAllMenuEntriesExist() {
searchForItemsAndTakeAction(mDevice, sResourceTexts);
}
private void launchAboutPhoneSettings(String aboutSetting) throws Exception {
private void launchAboutPhoneSettings(String aboutSetting) {
Intent aboutIntent = new Intent(aboutSetting);
aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
InstrumentationRegistry.getTargetContext().startActivity(aboutIntent);
@@ -107,8 +105,7 @@ public class AboutPhoneSettingsTests {
/**
* Removes items found in the view and optionally takes some action.
*/
private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind)
throws Exception {
private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind) {
for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
String itemText = iterator.next();
UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
@@ -124,8 +121,7 @@ public class AboutPhoneSettingsTests {
* <p>Will scroll down the screen until it has found all elements or reached the bottom.
* This allows elements to be found and acted on even if they change order.
*/
private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind)
throws Exception {
private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind) {
ArrayList<String> itemsLeftToFind = new ArrayList<>(Arrays.asList(itemsToFind));
assertWithMessage("There must be at least one item to search for on the screen!")