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

Commit 7bb6a24e authored by Mark Renouf's avatar Mark Renouf
Browse files

Refactoring to extract method for better readability

This pulls out a block which handles setting up remote animations
and actually sending the notification intent.

Following changes will branch around this code, so this will
help keep control flow easier to follow.

Test: manually
Bug: 123710619
Change-Id: I1701525bb9e3e454f10a4cd5d2a4cffa7d2d6338
parent 6d9f995c
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
@@ -248,7 +248,6 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
            ActivityManager.getService().resumeAppSwitches();
        } catch (RemoteException e) {
        }
        int launchResult;
        // If we are launching a work activity and require to launch
        // separate work challenge, we defer the activity action and cancel
        // notification until work challenge is unlocked.
@@ -277,24 +276,7 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
            fillInIntent = new Intent().putExtra(Notification.EXTRA_REMOTE_INPUT_DRAFT,
                    remoteInputText.toString());
        }
        RemoteAnimationAdapter adapter = mActivityLaunchAnimator.getLaunchAnimation(
                row, wasOccluded);
        try {
            if (adapter != null) {
                ActivityTaskManager.getService()
                        .registerRemoteAnimationForNextActivityStart(
                                intent.getCreatorPackage(), adapter);
            }
            launchResult = intent.sendAndReturnResult(mContext, 0, fillInIntent, null,
                    null, null, getActivityOptions(adapter));
            mActivityLaunchAnimator.setLaunchResult(launchResult, isActivityIntent);
        } catch (RemoteException | PendingIntent.CanceledException e) {
            // the stack trace isn't very helpful here.
            // Just log the exception message.
            Log.w(TAG, "Sending contentIntent failed: " + e);

            // TODO: Dismiss Keyguard.
        }
        startNotificationIntent(intent, fillInIntent, row, wasOccluded, isActivityIntent);
        if (isActivityIntent) {
            mAssistManager.hideAssist();
        }
@@ -327,6 +309,27 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit
        mIsCollapsingToShowActivityOverLockscreen = false;
    }

    private void startNotificationIntent(PendingIntent intent, Intent fillInIntent,
            ExpandableNotificationRow row, boolean wasOccluded, boolean isActivityIntent) {
        RemoteAnimationAdapter adapter = mActivityLaunchAnimator.getLaunchAnimation(row,
                wasOccluded);
        try {
            if (adapter != null) {
                ActivityTaskManager.getService()
                        .registerRemoteAnimationForNextActivityStart(
                                intent.getCreatorPackage(), adapter);
            }
            int launchResult = intent.sendAndReturnResult(mContext, 0, fillInIntent, null,
                    null, null, getActivityOptions(adapter));
            mActivityLaunchAnimator.setLaunchResult(launchResult, isActivityIntent);
        } catch (RemoteException | PendingIntent.CanceledException e) {
            // the stack trace isn't very helpful here.
            // Just log the exception message.
            Log.w(TAG, "Sending contentIntent failed: " + e);
            // TODO: Dismiss Keyguard.
        }
    }

    @Override
    public void startNotificationGutsIntent(final Intent intent, final int appUid,
            ExpandableNotificationRow row) {