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

Commit fa387ad6 authored by Craig Mautner's avatar Craig Mautner Committed by Jose Ricardo Lima
Browse files

Make next activity opaque when media stops

Call convertFromTranslucent on next activity when an activity below
it stops playing media.

Fixes bug 14469711.

Change-Id: I7e4346987cb620cb3a8c09096ff3a639cf344679
parent b46dea56
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -1099,6 +1099,51 @@ final class ActivityStack {
        }
    }

    // Find the first visible activity above the passed activity and if it is translucent return it
    // otherwise return null;
    ActivityRecord findNextTranslucentActivity(ActivityRecord r) {
        TaskRecord task = r.task;
        if (task == null) {
            return null;
        }

        ActivityStack stack = task.stack;
        if (stack == null) {
            return null;
        }

        int stackNdx = mStacks.indexOf(stack);

        ArrayList<TaskRecord> tasks = stack.mTaskHistory;
        int taskNdx = tasks.indexOf(task);

        ArrayList<ActivityRecord> activities = task.mActivities;
        int activityNdx = activities.indexOf(r) + 1;

        final int numStacks = mStacks.size();
        while (stackNdx < numStacks) {
            tasks = mStacks.get(stackNdx).mTaskHistory;
            final int numTasks = tasks.size();
            while (taskNdx < numTasks) {
                activities = tasks.get(taskNdx).mActivities;
                final int numActivities = activities.size();
                while (activityNdx < numActivities) {
                    final ActivityRecord activity = activities.get(activityNdx);
                    if (!activity.finishing) {
                        return activity.fullscreen ? null : activity;
                    }
                    ++activityNdx;
                }
                activityNdx = 0;
                ++taskNdx;
            }
            taskNdx = 0;
            ++stackNdx;
        }

        return null;
    }

    // Checks if any of the stacks above this one has a fullscreen activity behind it.
    // If so, this stack is hidden, otherwise it is visible.
    private boolean isStackVisible() {
+7 −0
Original line number Diff line number Diff line
@@ -2680,6 +2680,13 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }

        stack.setMediaPlayer(playing ? r : null);
        if (!playing) {
            // Make the activity immediately above r opaque.
            final ActivityRecord next = stack.findNextTranslucentActivity(r);
            if (next != null) {
                mService.convertFromTranslucent(next.appToken);
            }
        }
        try {
            top.app.thread.scheduleBackgroundMediaPlayingChanged(top.appToken, playing);
        } catch (RemoteException e) {