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

Commit 5f2cf8e6 authored by Kunhung Li's avatar Kunhung Li
Browse files

Clear WallpaperPicker task before launch

There are different launch sources to start WallpaperPicker, clear
previous task to prevent keeping old activity.

Bug: 177638480
Test: make RunSettingsRoboTests
Change-Id: Ia4d3d5c7e5df4a5d3acb137f644939c079d5028f
parent 45726b93
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
            final Intent intent = new Intent().setComponent(
                    getComponentName()).putExtra(mWallpaperLaunchExtra, LAUNCHED_SETTINGS);
            if (areStylesAvailable()) {
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            }
            preference.getContext().startActivity(intent);
            return true;
+16 −0
Original line number Diff line number Diff line
@@ -202,4 +202,20 @@ public class TopLevelWallpaperPreferenceControllerTest {
        assertThat(Shadows.shadowOf(mContext).getNextStartedActivityForResult()
                .intent.hasExtra("com.android.wallpaper.LAUNCH_SOURCE")).isTrue();
    }

    @Test
    public void handlePreferenceTreeClick_launchClearTask() {
        mShadowPackageManager.setResolveInfosForIntent(
                mWallpaperIntent, Lists.newArrayList());
        mShadowPackageManager.setResolveInfosForIntent(
                mStylesAndWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));

        Preference preference = new Preference(mContext);
        preference.setKey(TEST_KEY);

        mController.handlePreferenceTreeClick(preference);

        assertThat((Shadows.shadowOf(mContext).getNextStartedActivityForResult()
                .intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TASK) != 0).isTrue();
    }
}