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

Commit d2ff5562 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Preemptively clear buffer reference if snapshot is unused" into qt-dev

parents 76d9f441 67b09024
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityManager.TaskSnapshot;
import android.content.ComponentName;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;

@@ -155,6 +156,11 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @Override
    @UnsupportedAppUsage
    public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) throws RemoteException {
        if (Binder.getCallingPid() != android.os.Process.myPid()
                && snapshot != null && snapshot.getSnapshot() != null) {
            // Preemptively clear any reference to the buffer
            snapshot.getSnapshot().destroy();
        }
    }

    @Override
+9 −0
Original line number Diff line number Diff line
@@ -70,6 +70,15 @@ public class TaskStackChangeListeners extends TaskStackListener {

    public void removeListener(TaskStackChangeListener listener) {
        mTaskStackListeners.remove(listener);
        if (mTaskStackListeners.isEmpty() && mRegistered) {
            // Unregister mTaskStackListener once we have no more listeners
            try {
                ActivityTaskManager.getService().unregisterTaskStackListener(this);
                mRegistered = false;
            } catch (Exception e) {
                Log.w(TAG, "Failed to call unregisterTaskStackListener", e);
            }
        }
    }

    @Override