Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6eb62e41 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix crash when launching about phone v2 through intent"

parents 49620e85 cfd79a9a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -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(),
+1 −1
Original line number Diff line number Diff line
@@ -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";
+6 −10
Original line number Diff line number Diff line
@@ -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!")