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

Commit 38d31c21 authored by Winson Chung's avatar Winson Chung
Browse files

Provide interface to temporarily fetch screenshot.

Bug: 68774229
Test: Build nexus launcher and verify we can call to get the screenshot
Change-Id: I6a5456efca94f45cda000fe9e097ec524540592b
parent a8d534bf
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -14,10 +14,12 @@
 * limitations under the License.
 */

package com.android.systemui.shared.recents.model;
package com.android.systemui.shared.recents;

import android.view.MotionEvent;
import com.android.systemui.shared.recents.ISystemUiProxy;

oneway interface IOverviewProxy {
    void onBind(in ISystemUiProxy sysUiProxy);
    void onMotionEvent(in MotionEvent event);
}
+33 −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.recents;

import android.graphics.Bitmap;
import android.graphics.Rect;

/**
 * Temporary callbacks into SystemUI.
 */
interface ISystemUiProxy {

    /**
     * Proxies SurfaceControl.screenshot().
     */
    Bitmap screenshot(in Rect sourceCrop, int width, int height,
                      int minLayer, int maxLayer, boolean useIdentityTransform,
                      int rotation);
}
+25 −1
Original line number Diff line number Diff line
@@ -20,12 +20,18 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import com.android.systemui.shared.recents.model.IOverviewProxy;
import android.view.SurfaceControl;

import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;

@@ -46,6 +52,19 @@ public class OverviewProxyService {
    private IOverviewProxy mOverviewProxy;
    private int mConnectionBackoffAttempts;

    private ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() {
        public Bitmap screenshot(Rect sourceCrop, int width, int height, int minLayer, int maxLayer,
                boolean useIdentityTransform, int rotation) {
            long token = Binder.clearCallingIdentity();
            try {
                return SurfaceControl.screenshot(sourceCrop, width, height, minLayer, maxLayer,
                        useIdentityTransform, rotation);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    };

    private final ServiceConnection mOverviewServiceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
@@ -58,6 +77,11 @@ public class OverviewProxyService {
                } catch (RemoteException e) {
                    Log.e(TAG, "Lost connection to launcher service", e);
                }
                try {
                    mOverviewProxy.onBind(mSysUiProxy);
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to call onBind()", e);
                }
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ import com.android.systemui.OverviewProxyService;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
import com.android.systemui.shared.recents.model.IOverviewProxy;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.tuner.TunerService;