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

Commit c40b465f authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Displaying the base activity's icon and app label in app header

We are currently using the top activity to get the icon and app label to
display on the task header. When another activity corresponding to
another application opens in the task, when we create the header, it
will display that information rather than the information of the base
application. This change gets and derives the info from the base
application instead.

Test: Open better bug and transition to freeform. header should have
name and icon of the better bug app.
Bug: 341992887
Flag: EXEMPT bugfix

Change-Id: I171c1113ceebdcfe594554eeef5679c651047fe8
parent b54a7bb9
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.getResiz
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.WindowConfiguration.WindowingMode;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
@@ -600,12 +601,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            if (mAppIconBitmap != null && mAppName != null) {
                return;
            }
            final ActivityInfo activityInfo = mTaskInfo.topActivityInfo;
            if (activityInfo == null) {
                Log.e(TAG, "Top activity info not found in task");
            final ComponentName baseActivity = mTaskInfo.baseActivity;
            if (baseActivity == null) {
                Log.e(TAG, "Base activity component not found in task");
                return;
            }
            PackageManager pm = mContext.getApplicationContext().getPackageManager();
            final PackageManager pm = mContext.getApplicationContext().getPackageManager();
            final ActivityInfo activityInfo = pm.getActivityInfo(baseActivity, 0 /* flags */);
            final IconProvider provider = new IconProvider(mContext);
            final Drawable appIconDrawable = provider.getIcon(activityInfo);
            final BaseIconFactory headerIconFactory = createIconFactory(mContext,
@@ -619,6 +621,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin

            final ApplicationInfo applicationInfo = activityInfo.applicationInfo;
            mAppName = pm.getApplicationLabel(applicationInfo);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Base activity's component name cannot be found on the system");
        } finally {
            Trace.endSection();
        }
+4 −3
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    }

    @Before
    public void setUp() {
    public void setUp() throws PackageManager.NameNotFoundException {
        mMockitoSession = mockitoSession()
                .strictness(Strictness.LENIENT)
                .spyStatic(DesktopModeStatus.class)
@@ -186,6 +186,9 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
        mTestableContext.ensureTestableResources();
        mContext.setMockPackageManager(mMockPackageManager);
        when(mMockPackageManager.getApplicationLabel(any())).thenReturn("applicationLabel");
        final ActivityInfo activityInfo = new ActivityInfo();
        activityInfo.applicationInfo = new ApplicationInfo();
        when(mMockPackageManager.getActivityInfo(any(), anyInt())).thenReturn(activityInfo);
        final Display defaultDisplay = mock(Display.class);
        doReturn(defaultDisplay).when(mMockDisplayController).getDisplay(Display.DEFAULT_DISPLAY);
        doReturn(mInsetsState).when(mMockDisplayController).getInsetsState(anyInt());
@@ -608,8 +611,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
                .setTaskDescriptionBuilder(taskDescriptionBuilder)
                .setVisible(visible)
                .build();
        taskInfo.topActivityInfo = new ActivityInfo();
        taskInfo.topActivityInfo.applicationInfo = new ApplicationInfo();
        taskInfo.realActivity = new ComponentName("com.android.wm.shell.windowdecor",
                "DesktopModeWindowDecorationTests");
        taskInfo.baseActivity = new ComponentName("com.android.wm.shell.windowdecor",