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

Commit 7f97f732 authored by Yvonne Jiang's avatar Yvonne Jiang
Browse files

Update secondary lock screen implementation to use the newly updated SurfaceControlViewHost API.

Previously we passed back a SurfaceControl to the keyguard, updated to pass a SurfacePackage instead. The updated SurfaceControlViewHost logic addresses underlying accessibility bugs.

Bug: 136085151
Test: atest AdminSecondaryLockScreenControllerTest
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I4881d5766f118b99f497ee306cd71d3c5a65a2f3
parent fb961bf0
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -6795,7 +6795,7 @@ package android.app.admin {
    ctor public DevicePolicyKeyguardService();
    ctor public DevicePolicyKeyguardService();
    method @Nullable public void dismiss();
    method @Nullable public void dismiss();
    method @Nullable public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method @Nullable public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method @Nullable public android.view.SurfaceControl onSurfaceReady(@Nullable android.os.IBinder);
    method @Nullable public android.view.SurfaceControlViewHost.SurfacePackage onSurfaceReady(@Nullable android.os.IBinder);
  }
  }
  public class DevicePolicyManager {
  public class DevicePolicyManager {
+7 −7
Original line number Original line Diff line number Diff line
@@ -22,7 +22,7 @@ import android.content.Intent;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;
import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;


/**
/**
 * Client interface for providing the SystemUI with secondary lockscreen information.
 * Client interface for providing the SystemUI with secondary lockscreen information.
@@ -43,14 +43,14 @@ public class DevicePolicyKeyguardService extends Service {
        @Override
        @Override
        public void onSurfaceReady(@Nullable IBinder hostInputToken, IKeyguardCallback callback) {
        public void onSurfaceReady(@Nullable IBinder hostInputToken, IKeyguardCallback callback) {
            mCallback = callback;
            mCallback = callback;
            SurfaceControl surfaceControl =
            SurfaceControlViewHost.SurfacePackage surfacePackage =
                    DevicePolicyKeyguardService.this.onSurfaceReady(hostInputToken);
                    DevicePolicyKeyguardService.this.onSurfaceReady(hostInputToken);


            if (mCallback != null) {
            if (mCallback != null) {
                try {
                try {
                    mCallback.onSurfaceControlCreated(surfaceControl);
                    mCallback.onRemoteContentReady(surfacePackage);
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to return created SurfaceControl", e);
                    Log.e(TAG, "Failed to return created SurfacePackage", e);
                }
                }
            }
            }
        }
        }
@@ -65,11 +65,11 @@ public class DevicePolicyKeyguardService extends Service {
    /**
    /**
     * Called by keyguard once the host surface for the secondary lockscreen is ready to display
     * Called by keyguard once the host surface for the secondary lockscreen is ready to display
     * remote content.
     * remote content.
     * @return the {@link SurfaceControl} for the Surface the secondary lockscreen content is
     * @return the {@link SurfaceControlViewHost.SurfacePackage} for the Surface the
     *      attached to.
     *      secondary lockscreen content is attached to.
     */
     */
    @Nullable
    @Nullable
    public SurfaceControl onSurfaceReady(@Nullable IBinder hostInputToken) {
    public SurfaceControlViewHost.SurfacePackage onSurfaceReady(@Nullable IBinder hostInputToken) {
        return null;
        return null;
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -15,13 +15,13 @@
 */
 */
package android.app.admin;
package android.app.admin;


import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;


/**
/**
 * Internal IPC interface for informing the keyguard of events on the secondary lockscreen.
 * Internal IPC interface for informing the keyguard of events on the secondary lockscreen.
 * @hide
 * @hide
 */
 */
interface IKeyguardCallback {
interface IKeyguardCallback {
    oneway void onSurfaceControlCreated(in SurfaceControl remoteSurfaceControl);
    oneway void onRemoteContentReady(in SurfaceControlViewHost.SurfacePackage surfacePackage);
    oneway void onDismiss();
    oneway void onDismiss();
}
}
+19 −0
Original line number Original line Diff line number Diff line
/**
 * Copyright (c) 2020, 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 android.view;

parcelable SurfaceControlViewHost.SurfacePackage;
 No newline at end of file
+6 −8
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserHandle;
import android.util.Log;
import android.util.Log;
import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.SurfaceView;
import android.view.ViewGroup;
import android.view.ViewGroup;
@@ -47,7 +47,6 @@ public class AdminSecondaryLockScreenController {
    private Handler mHandler;
    private Handler mHandler;
    private IKeyguardClient mClient;
    private IKeyguardClient mClient;
    private KeyguardSecurityCallback mKeyguardCallback;
    private KeyguardSecurityCallback mKeyguardCallback;
    private SurfaceControl.Transaction mTransaction;


    private final ServiceConnection mConnection = new ServiceConnection() {
    private final ServiceConnection mConnection = new ServiceConnection() {
        @Override
        @Override
@@ -84,13 +83,13 @@ public class AdminSecondaryLockScreenController {
        }
        }


        @Override
        @Override
        public void onSurfaceControlCreated(@Nullable SurfaceControl remoteSurfaceControl) {
        public void onRemoteContentReady(
                @Nullable SurfaceControlViewHost.SurfacePackage surfacePackage) {
            if (mHandler != null) {
            if (mHandler != null) {
                mHandler.removeCallbacksAndMessages(null);
                mHandler.removeCallbacksAndMessages(null);
            }
            }
            if (remoteSurfaceControl != null) {
            if (surfacePackage != null) {
                mTransaction.reparent(remoteSurfaceControl, mView.getSurfaceControl())
                mView.setChildSurfacePackage(surfacePackage);
                    .apply();
            } else {
            } else {
                dismiss(KeyguardUpdateMonitor.getCurrentUser());
                dismiss(KeyguardUpdateMonitor.getCurrentUser());
            }
            }
@@ -138,11 +137,10 @@ public class AdminSecondaryLockScreenController {


    public AdminSecondaryLockScreenController(Context context, ViewGroup parent,
    public AdminSecondaryLockScreenController(Context context, ViewGroup parent,
            KeyguardUpdateMonitor updateMonitor, KeyguardSecurityCallback callback,
            KeyguardUpdateMonitor updateMonitor, KeyguardSecurityCallback callback,
            Handler handler, SurfaceControl.Transaction transaction) {
            Handler handler) {
        mContext = context;
        mContext = context;
        mHandler = handler;
        mHandler = handler;
        mParent = parent;
        mParent = parent;
        mTransaction = transaction;
        mUpdateMonitor = updateMonitor;
        mUpdateMonitor = updateMonitor;
        mKeyguardCallback = callback;
        mKeyguardCallback = callback;
        mView = new AdminSecurityView(mContext, mSurfaceHolderCallback);
        mView = new AdminSecurityView(mContext, mSurfaceHolderCallback);
Loading