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

Commit 1c5aefff authored by Winson Chung's avatar Winson Chung
Browse files

Exposing a few more methods in the lib

Bug: 67510855
Test: Quickstep builds
Change-Id: I4b46dc2f8494581175971f14d2aef8e396e41cdb
parent e210468a
Loading
Loading
Loading
Loading
+75 −20
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.content.res.Resources.NotFoundException;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -231,6 +232,41 @@ public class ActivityManagerWrapper {
        return label;
    }

    /**
     * Starts the recents activity.
     */
    public void startRecentsActivity(AssistDataReceiver assistDataReceiver, Bundle options,
            ActivityOptions opts, int userId, Consumer<Boolean> resultCallback,
            Handler resultCallbackHandler) {
        Bundle activityOptions = opts != null ? opts.toBundle() : null;
        mBackgroundExecutor.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    ActivityManager.getService().startRecentsActivity(assistDataReceiver, options,
                            activityOptions, userId);
                    if (resultCallback != null) {
                        resultCallbackHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                resultCallback.accept(true);
                            }
                        });
                    }
                } catch (Exception e) {
                    if (resultCallback != null) {
                        resultCallbackHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                resultCallback.accept(false);
                            }
                        });
                    }
                }
            }
        });
    }

    /**
     * Starts a task from Recents.
     *
@@ -270,16 +306,29 @@ public class ActivityManagerWrapper {

        // Execute this from another thread such that we can do other things (like caching the
        // bitmap for the thumbnail) while AM is busy starting our activity.
        mBackgroundExecutor.submit(() -> {
        mBackgroundExecutor.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    ActivityManager.getService().startActivityFromRecents(taskKey.id,
                            finalOptions == null ? null : finalOptions.toBundle());
                    if (resultCallback != null) {
                    resultCallbackHandler.post(() -> resultCallback.accept(true));
                        resultCallbackHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                resultCallback.accept(true);
                            }
                        });
                    }
                } catch (Exception e) {
                    if (resultCallback != null) {
                    resultCallbackHandler.post(() -> resultCallback.accept(false));
                        resultCallbackHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                resultCallback.accept(false);
                            }
                        });
                    }
                }
            }
        });
@@ -289,12 +338,15 @@ public class ActivityManagerWrapper {
     * Requests that the system close any open system windows (including other SystemUI).
     */
    public void closeSystemWindows(String reason) {
        mBackgroundExecutor.submit(() -> {
        mBackgroundExecutor.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    ActivityManager.getService().closeSystemDialogs(reason);
                } catch (RemoteException e) {
                    Log.w(TAG, "Failed to close system windows", e);
                }
            }
        });
    }

@@ -302,12 +354,15 @@ public class ActivityManagerWrapper {
     * Removes a task by id.
     */
    public void removeTask(int taskId) {
        mBackgroundExecutor.submit(() -> {
        mBackgroundExecutor.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    ActivityManager.getService().removeTask(taskId);
                } catch (RemoteException e) {
                    Log.w(TAG, "Failed to remove task=" + taskId, e);
                }
            }
        });
    }

+29 −0
Original line number 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.shared.system;

import android.app.IAssistDataReceiver;
import android.graphics.Bitmap;
import android.os.Bundle;

/**
 * Abstract class for assist data receivers.
 */
public abstract class AssistDataReceiver extends IAssistDataReceiver.Stub {
    public abstract void onHandleAssistData(Bundle resultData);
    public abstract void onHandleAssistScreenshot(Bitmap screenshot);
}