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

Commit 629dcc36 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Load enterprise thumbnail drawable only if needed

It can save ~30% to construct an ActivityRecord.
Especially since shell transition is enabled, it will be handled
in DefaultTransitionHandler#mEnterpriseThumbnailDrawable, then
the drawable in ActivityRecord is never used.

Bug: 297502610
Test: Launch app of profile user by
      CrossProfileApps#startMainActivity
Change-Id: I0ecc1732c902ef53a7f16b4e90bcdfc75a6c1c73
parent 7b193950
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -581,20 +581,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // Tracking splash screen status from previous activity
    boolean mSplashScreenStyleSolidColor = false;

    Drawable mEnterpriseThumbnailDrawable;

    boolean mPauseSchedulePendingForPip = false;

    // Gets set to indicate that the activity is currently being auto-pipped.
    boolean mAutoEnteringPip = false;

    private void updateEnterpriseThumbnailDrawable(Context context) {
        DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
        mEnterpriseThumbnailDrawable = dpm.getResources().getDrawable(
                WORK_PROFILE_ICON, OUTLINE, PROFILE_SWITCH_ANIMATION,
                () -> context.getDrawable(R.drawable.ic_corp_badge));
    }

    static final int LAUNCH_SOURCE_TYPE_SYSTEM = 1;
    static final int LAUNCH_SOURCE_TYPE_HOME = 2;
    static final int LAUNCH_SOURCE_TYPE_SYSTEMUI = 3;
@@ -2209,8 +2200,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        mActivityRecordInputSink = new ActivityRecordInputSink(this, sourceRecord);

        updateEnterpriseThumbnailDrawable(mAtmService.getUiContext());

        boolean appActivityEmbeddingEnabled = false;
        try {
            appActivityEmbeddingEnabled = WindowManager.hasWindowExtensionsEnabled()
@@ -7695,9 +7684,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }
        final Rect frame = win.getRelativeFrame();
        final Drawable thumbnailDrawable = task.mUserId == mWmService.mCurrentUserId
                ? mAtmService.getUiContext().getDrawable(R.drawable.ic_account_circle)
                : mEnterpriseThumbnailDrawable;
        final Context context = mAtmService.getUiContext();
        final Drawable thumbnailDrawable;
        if (task.mUserId == mWmService.mCurrentUserId) {
            thumbnailDrawable = context.getDrawable(R.drawable.ic_account_circle);
        } else {
            final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
            thumbnailDrawable = dpm.getResources().getDrawable(
                    WORK_PROFILE_ICON, OUTLINE, PROFILE_SWITCH_ANIMATION,
                    () -> context.getDrawable(R.drawable.ic_corp_badge));
        }
        final HardwareBuffer thumbnail = getDisplayContent().mAppTransition
                .createCrossProfileAppsThumbnail(thumbnailDrawable, frame);
        if (thumbnail == null) {