Merge "Fix null executor in TaskView with bubbles"
This commit is contained in:
@@ -252,8 +252,7 @@ public class BubbleExpandedView extends LinearLayout {
|
||||
|
||||
mPositioner = mBubbles.getPositioner();
|
||||
|
||||
mTaskView = new TaskView(mContext, mBubbles.getTaskOrganizer(),
|
||||
new HandlerExecutor(getHandler()));
|
||||
mTaskView = new TaskView(mContext, mBubbles.getTaskOrganizer());
|
||||
// Set ActivityView's alpha value as zero, since there is no view content to be shown.
|
||||
setContentVisibility(false);
|
||||
|
||||
@@ -310,6 +309,12 @@ public class BubbleExpandedView extends LinearLayout {
|
||||
setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mTaskView.setExecutor(new HandlerExecutor(getHandler()));
|
||||
}
|
||||
|
||||
void updateDimensions() {
|
||||
Resources res = getResources();
|
||||
mMinHeight = res.getDimensionPixelSize(R.dimen.bubble_expanded_default_height);
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.content.pm.LauncherApps;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
@@ -82,21 +81,25 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
private boolean mSurfaceCreated;
|
||||
private boolean mIsInitialized;
|
||||
private Listener mListener;
|
||||
private final Executor mExecutor;
|
||||
private Executor mExecutor;
|
||||
|
||||
private final Rect mTmpRect = new Rect();
|
||||
private final Rect mTmpRootRect = new Rect();
|
||||
|
||||
public TaskView(Context context, ShellTaskOrganizer organizer, Executor executor) {
|
||||
public TaskView(Context context, ShellTaskOrganizer organizer) {
|
||||
super(context, null, 0, 0, true /* disableBackgroundLayer */);
|
||||
|
||||
mExecutor = executor;
|
||||
mTaskOrganizer = organizer;
|
||||
setUseAlpha();
|
||||
getHolder().addCallback(this);
|
||||
mGuard.open("release");
|
||||
}
|
||||
|
||||
// TODO: Use TaskOrganizer executor when part of wmshell proper
|
||||
public void setExecutor(Executor executor) {
|
||||
mExecutor = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only one listener may be set on the view, throws an exception otherwise.
|
||||
*/
|
||||
@@ -225,6 +228,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
@Override
|
||||
public void onTaskAppeared(ActivityManager.RunningTaskInfo taskInfo,
|
||||
SurfaceControl leash) {
|
||||
if (mExecutor == null) return;
|
||||
mExecutor.execute(() -> {
|
||||
mTaskInfo = taskInfo;
|
||||
mTaskToken = taskInfo.token;
|
||||
@@ -253,6 +257,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
|
||||
@Override
|
||||
public void onTaskVanished(ActivityManager.RunningTaskInfo taskInfo) {
|
||||
if (mExecutor == null) return;
|
||||
mExecutor.execute(() -> {
|
||||
if (mTaskToken == null || !mTaskToken.equals(taskInfo.token)) return;
|
||||
|
||||
@@ -268,6 +273,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
|
||||
@Override
|
||||
public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) {
|
||||
if (mExecutor == null) return;
|
||||
mExecutor.execute(() -> {
|
||||
mTaskInfo.taskDescription = taskInfo.taskDescription;
|
||||
setResizeBackgroundColor(taskInfo.taskDescription.getBackgroundColor());
|
||||
@@ -276,6 +282,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
|
||||
@Override
|
||||
public void onBackPressedOnTaskRoot(ActivityManager.RunningTaskInfo taskInfo) {
|
||||
if (mExecutor == null) return;
|
||||
mExecutor.execute(() -> {
|
||||
if (mTaskToken == null || !mTaskToken.equals(taskInfo.token)) return;
|
||||
if (mListener != null) {
|
||||
|
||||
@@ -36,7 +36,6 @@ import android.app.ActivityManager;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.view.SurfaceControl;
|
||||
@@ -101,7 +100,8 @@ public class TaskViewTest extends SysuiTestCase {
|
||||
return null;
|
||||
}).when(mExecutor).execute(any());
|
||||
|
||||
mTaskView = new TaskView(mContext, mOrganizer, mExecutor);
|
||||
mTaskView = new TaskView(mContext, mOrganizer);
|
||||
mTaskView.setExecutor(mExecutor);
|
||||
mTaskView.setListener(mViewListener);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,8 @@ public class TaskViewTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testSetPendingListener_throwsException() {
|
||||
TaskView taskView = new TaskView(mContext, mOrganizer, mExecutor);
|
||||
TaskView taskView = new TaskView(mContext, mOrganizer);
|
||||
mTaskView.setExecutor(mExecutor);
|
||||
taskView.setListener(mViewListener);
|
||||
try {
|
||||
taskView.setListener(mViewListener);
|
||||
|
||||
Reference in New Issue
Block a user