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

Commit fb9d78af authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Add a listener when task snapshots change

Since we start recents before we take the snapshot, we need to add
a mechanism to inform recents about task snapshots changes.

We add a new method to TaskStackChangedListener,
onTaskSnapshotChanged, which gets called whenever a task snapshot
changes. Then, SystemUI registers such a listener and updates the
task thumbnail view for the specific task.

Test: Open app, press recents, make sure thumbnail is up-to-date
Bug: 31339431
Change-Id: I01e81b9cd11886da734da671c68d5732aa51009f
parent 10abe2fe
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@ import android.app.IStopUserCallback;
import android.app.ITaskStackListener;
import android.app.ITaskStackListener;
import android.app.IUiAutomationConnection;
import android.app.IUiAutomationConnection;
import android.app.IUidObserver;
import android.app.IUidObserver;

import android.app.IUserSwitchObserver;
import android.app.IUserSwitchObserver;
import android.app.Notification;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.PendingIntent;
+5 −0
Original line number Original line Diff line number Diff line
@@ -102,4 +102,9 @@ oneway interface ITaskStackListener {
     * been locked.
     * been locked.
     */
     */
    void onTaskProfileLocked(int taskId, int userId);
    void onTaskProfileLocked(int taskId, int userId);

    /**
     * Called when a task snapshot got updated.
     */
    void onTaskSnapshotChanged(int taskId, in ActivityManager.TaskSnapshot snapshot);
}
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app;
package android.app;


import android.app.ActivityManager.TaskSnapshot;
import android.content.ComponentName;
import android.content.ComponentName;
import android.os.RemoteException;
import android.os.RemoteException;


@@ -78,4 +79,9 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @Override
    @Override
    public void onTaskProfileLocked(int taskId, int userId) {
    public void onTaskProfileLocked(int taskId, int userId) {
    }
    }

    @Override
    public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot)
            throws RemoteException {
    }
}
}
+7 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.app.ActivityManager.StackId.isHomeOrRecentsStack;
import static android.view.View.MeasureSpec;
import static android.view.View.MeasureSpec;


import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityManager.TaskSnapshot;
import android.app.ActivityOptions;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Context;
@@ -60,6 +61,7 @@ import com.android.systemui.recents.events.component.RecentsVisibilityChangedEve
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEvent;
import com.android.systemui.recents.events.ui.TaskSnapshotChangedEvent;
import com.android.systemui.recents.misc.DozeTrigger;
import com.android.systemui.recents.misc.DozeTrigger;
import com.android.systemui.recents.misc.ForegroundThread;
import com.android.systemui.recents.misc.ForegroundThread;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.SystemServicesProxy;
@@ -131,6 +133,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
                loader.loadTasks(mContext, plan, launchOpts);
                loader.loadTasks(mContext, plan, launchOpts);
            }
            }
        }
        }

        @Override
        public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) {
            EventBus.getDefault().send(new TaskSnapshotChangedEvent(taskId, snapshot));
        }
    }
    }


    protected static RecentsTaskLoadPlan sInstanceLoadPlan;
    protected static RecentsTaskLoadPlan sInstanceLoadPlan;
+35 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.recents.events.ui;

import android.app.ActivityManager.TaskSnapshot;

import com.android.systemui.recents.events.EventBus;

/**
 * Sent when a task snapshot has changed.
 */
public class TaskSnapshotChangedEvent extends EventBus.Event {

    public final int taskId;
    public final TaskSnapshot taskSnapshot;

    public TaskSnapshotChangedEvent(int taskId, TaskSnapshot taskSnapshot) {
        this.taskId = taskId;
        this.taskSnapshot = taskSnapshot;
    }
}
Loading