Skip to content

Commit fa387ad

Browse files
Craig MautnerJose Ricardo Lima
authored andcommitted
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
1 parent b46dea5 commit fa387ad

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

services/core/java/com/android/server/am/ActivityStack.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,51 @@ private void setVisibile(ActivityRecord r, boolean visible) {
10991099
}
11001100
}
11011101

1102+
// Find the first visible activity above the passed activity and if it is translucent return it
1103+
// otherwise return null;
1104+
ActivityRecord findNextTranslucentActivity(ActivityRecord r) {
1105+
TaskRecord task = r.task;
1106+
if (task == null) {
1107+
return null;
1108+
}
1109+
1110+
ActivityStack stack = task.stack;
1111+
if (stack == null) {
1112+
return null;
1113+
}
1114+
1115+
int stackNdx = mStacks.indexOf(stack);
1116+
1117+
ArrayList<TaskRecord> tasks = stack.mTaskHistory;
1118+
int taskNdx = tasks.indexOf(task);
1119+
1120+
ArrayList<ActivityRecord> activities = task.mActivities;
1121+
int activityNdx = activities.indexOf(r) + 1;
1122+
1123+
final int numStacks = mStacks.size();
1124+
while (stackNdx < numStacks) {
1125+
tasks = mStacks.get(stackNdx).mTaskHistory;
1126+
final int numTasks = tasks.size();
1127+
while (taskNdx < numTasks) {
1128+
activities = tasks.get(taskNdx).mActivities;
1129+
final int numActivities = activities.size();
1130+
while (activityNdx < numActivities) {
1131+
final ActivityRecord activity = activities.get(activityNdx);
1132+
if (!activity.finishing) {
1133+
return activity.fullscreen ? null : activity;
1134+
}
1135+
++activityNdx;
1136+
}
1137+
activityNdx = 0;
1138+
++taskNdx;
1139+
}
1140+
taskNdx = 0;
1141+
++stackNdx;
1142+
}
1143+
1144+
return null;
1145+
}
1146+
11021147
// Checks if any of the stacks above this one has a fullscreen activity behind it.
11031148
// If so, this stack is hidden, otherwise it is visible.
11041149
private boolean isStackVisible() {

services/core/java/com/android/server/am/ActivityStackSupervisor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,13 @@ boolean setMediaPlayingLocked(ActivityRecord r, boolean playing) {
26802680
}
26812681

26822682
stack.setMediaPlayer(playing ? r : null);
2683+
if (!playing) {
2684+
// Make the activity immediately above r opaque.
2685+
final ActivityRecord next = stack.findNextTranslucentActivity(r);
2686+
if (next != null) {
2687+
mService.convertFromTranslucent(next.appToken);
2688+
}
2689+
}
26832690
try {
26842691
top.app.thread.scheduleBackgroundMediaPlayingChanged(top.appToken, playing);
26852692
} catch (RemoteException e) {

0 commit comments

Comments
 (0)