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

Commit cbb15a99 authored by Winson Chung's avatar Winson Chung
Browse files

Revert "Revert "4/ Update SysUI shared lib for Recents transition""

This reverts commit f6401c02.

Reason for revert: Testing relanding changes with ag/3515280

Change-Id: Ibb8d4868fe2cc1053b528ed757bd3ec1f9c10355
parent a89ffeda
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -29,4 +29,9 @@ interface ISystemUiProxy {
     */
    GraphicBufferCompat screenshot(in Rect sourceCrop, int width, int height, int minLayer,
            int maxLayer, boolean useIdentityTransform, int rotation);

    /**
     * Called when the overview service has started the recents animation.
     */
    void onRecentsAnimationStarted();
}
+24 −5
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.app.AppGlobals;
import android.app.IAssistDataReceiver;
import android.app.WindowConfiguration.ActivityType;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -48,7 +49,10 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.IRecentsAnimationController;
import android.view.IRecentsAnimationRunner;

import android.view.RemoteAnimationTarget;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task.TaskKey;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -243,10 +247,9 @@ public class ActivityManagerWrapper {
    /**
     * Starts the recents activity. The caller should manage the thread on which this is called.
     */
    public void startRecentsActivity(AssistDataReceiverCompat assistDataReceiver, Bundle options,
            ActivityOptions opts, int userId, Consumer<Boolean> resultCallback,
    public void startRecentsActivity(Intent intent, AssistDataReceiver assistDataReceiver,
            RecentsAnimationListener animationHandler, Consumer<Boolean> resultCallback,
            Handler resultCallbackHandler) {
        Bundle activityOptions = opts != null ? opts.toBundle() : null;
        try {
            IAssistDataReceiver receiver = null;
            if (assistDataReceiver != null) {
@@ -259,8 +262,24 @@ public class ActivityManagerWrapper {
                    }
                };
            }
            ActivityManager.getService().startRecentsActivity(receiver, options, activityOptions,
                    userId);
            IRecentsAnimationRunner runner = null;
            if (animationHandler != null) {
                runner = new IRecentsAnimationRunner.Stub() {
                    public void onAnimationStart(IRecentsAnimationController controller,
                            RemoteAnimationTarget[] apps) {
                        final RecentsAnimationControllerCompat controllerCompat =
                                new RecentsAnimationControllerCompat(controller);
                        final RemoteAnimationTargetCompat[] appsCompat =
                                RemoteAnimationTargetCompat.wrap(apps);
                        animationHandler.onAnimationStart(controllerCompat, appsCompat);
                    }

                    public void onAnimationCanceled() {
                        animationHandler.onAnimationCanceled();
                    }
                };
            }
            ActivityManager.getService().startRecentsActivity(intent, receiver, runner);
            if (resultCallback != null) {
                resultCallbackHandler.post(new Runnable() {
                    @Override
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.os.Bundle;
/**
 * Abstract class for assist data receivers.
 */
public abstract class AssistDataReceiverCompat {
    public abstract void onHandleAssistData(Bundle resultData);
    public abstract void onHandleAssistScreenshot(Bitmap screenshot);
public abstract class AssistDataReceiver {
    public void onHandleAssistData(Bundle resultData) {}
    public void onHandleAssistScreenshot(Bitmap screenshot) {}
}
+36 −15
Original line number Diff line number Diff line
@@ -14,9 +14,10 @@
 * limitations under the License.
 */

package com.android.systemui.pip.phone;
package com.android.systemui.shared.system;

import static android.view.WindowManager.INPUT_CONSUMER_PIP;
import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION;

import android.os.Binder;
import android.os.IBinder;
@@ -29,11 +30,12 @@ import android.view.InputChannel;
import android.view.InputEvent;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.WindowManagerGlobal;

import java.io.PrintWriter;

/**
 * Manages the input consumer that allows the SystemUI to control the PiP.
 * Manages the input consumer that allows the SystemUI to directly receive touch input.
 */
public class InputConsumerController {

@@ -55,12 +57,12 @@ public class InputConsumerController {
    }

    /**
     * Input handler used for the PiP input consumer. Input events are batched and consumed with the
     * Input handler used for the input consumer. Input events are batched and consumed with the
     * SurfaceFlinger vsync.
     */
    private final class PipInputEventReceiver extends BatchedInputEventReceiver {
    private final class InputEventReceiver extends BatchedInputEventReceiver {

        public PipInputEventReceiver(InputChannel inputChannel, Looper looper) {
        public InputEventReceiver(InputChannel inputChannel, Looper looper) {
            super(inputChannel, looper, Choreographer.getSfInstance());
        }

@@ -68,7 +70,6 @@ public class InputConsumerController {
        public void onInputEvent(InputEvent event, int displayId) {
            boolean handled = true;
            try {
                // To be implemented for input handling over Pip windows
                if (mListener != null && event instanceof MotionEvent) {
                    MotionEvent ev = (MotionEvent) event;
                    handled = mListener.onTouchEvent(ev);
@@ -81,15 +82,35 @@ public class InputConsumerController {

    private final IWindowManager mWindowManager;
    private final IBinder mToken;
    private final String mName;

    private PipInputEventReceiver mInputEventReceiver;
    private InputEventReceiver mInputEventReceiver;
    private TouchListener mListener;
    private RegistrationListener mRegistrationListener;

    public InputConsumerController(IWindowManager windowManager) {
    /**
     * @param name the name corresponding to the input consumer that is defined in the system.
     */
    public InputConsumerController(IWindowManager windowManager, String name) {
        mWindowManager = windowManager;
        mToken = new Binder();
        registerInputConsumer();
        mName = name;
    }

    /**
     * @return A controller for the pip input consumer.
     */
    public static InputConsumerController getPipInputConsumer() {
        return new InputConsumerController(WindowManagerGlobal.getWindowManagerService(),
                INPUT_CONSUMER_PIP);
    }

    /**
     * @return A controller for the recents animation input consumer.
     */
    public static InputConsumerController getRecentsAnimationInputConsumer() {
        return new InputConsumerController(WindowManagerGlobal.getWindowManagerService(),
                INPUT_CONSUMER_RECENTS_ANIMATION);
    }

    /**
@@ -125,12 +146,12 @@ public class InputConsumerController {
        if (mInputEventReceiver == null) {
            final InputChannel inputChannel = new InputChannel();
            try {
                mWindowManager.destroyInputConsumer(INPUT_CONSUMER_PIP);
                mWindowManager.createInputConsumer(mToken, INPUT_CONSUMER_PIP, inputChannel);
                mWindowManager.destroyInputConsumer(mName);
                mWindowManager.createInputConsumer(mToken, mName, inputChannel);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to create PIP input consumer", e);
                Log.e(TAG, "Failed to create input consumer", e);
            }
            mInputEventReceiver = new PipInputEventReceiver(inputChannel, Looper.myLooper());
            mInputEventReceiver = new InputEventReceiver(inputChannel, Looper.myLooper());
            if (mRegistrationListener != null) {
                mRegistrationListener.onRegistrationChanged(true /* isRegistered */);
            }
@@ -143,9 +164,9 @@ public class InputConsumerController {
    public void unregisterInputConsumer() {
        if (mInputEventReceiver != null) {
            try {
                mWindowManager.destroyInputConsumer(INPUT_CONSUMER_PIP);
                mWindowManager.destroyInputConsumer(mName);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to destroy PIP input consumer", e);
                Log.e(TAG, "Failed to destroy input consumer", e);
            }
            mInputEventReceiver.dispose();
            mInputEventReceiver = null;
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.shared.system;

import android.app.ActivityManager.TaskSnapshot;
import android.os.RemoteException;
import android.util.Log;
import android.view.IRecentsAnimationController;

import com.android.systemui.shared.recents.model.ThumbnailData;

public class RecentsAnimationControllerCompat {

    private static final String TAG = RecentsAnimationControllerCompat.class.getSimpleName();

    private IRecentsAnimationController mAnimationController;

    public RecentsAnimationControllerCompat(IRecentsAnimationController animationController) {
        mAnimationController = animationController;
    }

    public ThumbnailData screenshotTask(int taskId) {
        try {
            TaskSnapshot snapshot = mAnimationController.screenshotTask(taskId);
            return snapshot != null ? new ThumbnailData(snapshot) : new ThumbnailData();
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to screenshot task", e);
            return new ThumbnailData();
        }
    }

    public void setInputConsumerEnabled(boolean enabled) {
        try {
            mAnimationController.setInputConsumerEnabled(enabled);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to set input consumer enabled state", e);
        }
    }

    public void finish(boolean toHome) {
        try {
            mAnimationController.finish(toHome);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to finish recents animation", e);
        }
    }
}
 No newline at end of file
Loading