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

Commit 1d1973ef authored by Yvonne Jiang's avatar Yvonne Jiang Committed by Android (Google) Code Review
Browse files

Merge "Adding API for displaying a DO/PO controlled secondary lock screen post...

Merge "Adding API for displaying a DO/PO controlled secondary lock screen post initial system lock screen."
parents ecc28832 b7024a25
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -6767,6 +6767,13 @@ package android.app.admin {
    method public final android.os.IBinder onBind(android.content.Intent);
  }
  public class DevicePolicyKeyguardService extends android.app.Service {
    ctor public DevicePolicyKeyguardService();
    method @Nullable public void dismiss();
    method @Nullable public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method @Nullable public android.view.SurfaceControl onSurfaceReady(@Nullable android.os.IBinder);
  }
  public class DevicePolicyManager {
    method public void addCrossProfileIntentFilter(@NonNull android.content.ComponentName, android.content.IntentFilter, int);
    method public boolean addCrossProfileWidgetProvider(@NonNull android.content.ComponentName, String);
@@ -6979,6 +6986,7 @@ package android.app.admin {
    method public boolean setResetPasswordToken(android.content.ComponentName, byte[]);
    method public void setRestrictionsProvider(@NonNull android.content.ComponentName, @Nullable android.content.ComponentName);
    method public void setScreenCaptureDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setSecondaryLockscreenEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setSecureSetting(@NonNull android.content.ComponentName, String, String);
    method public void setSecurityLoggingEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setShortSupportMessage(@NonNull android.content.ComponentName, @Nullable CharSequence);
@@ -7004,6 +7012,7 @@ package android.app.admin {
    field public static final String ACTION_ADD_DEVICE_ADMIN = "android.app.action.ADD_DEVICE_ADMIN";
    field public static final String ACTION_ADMIN_POLICY_COMPLIANCE = "android.app.action.ADMIN_POLICY_COMPLIANCE";
    field public static final String ACTION_APPLICATION_DELEGATION_SCOPES_CHANGED = "android.app.action.APPLICATION_DELEGATION_SCOPES_CHANGED";
    field public static final String ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE = "android.app.action.BIND_SECONDARY_LOCKSCREEN_SERVICE";
    field public static final String ACTION_DEVICE_ADMIN_SERVICE = "android.app.action.DEVICE_ADMIN_SERVICE";
    field public static final String ACTION_DEVICE_OWNER_CHANGED = "android.app.action.DEVICE_OWNER_CHANGED";
    field public static final String ACTION_GET_PROVISIONING_MODE = "android.app.action.GET_PROVISIONING_MODE";
+1 −0
Original line number Diff line number Diff line
@@ -845,6 +845,7 @@ package android.app.admin {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioningConfigApplied();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isManagedKiosk();
    method public boolean isSecondaryLockscreenEnabled(int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isUnattendedManagedKiosk();
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long);
    method @RequiresPermission("android.permission.NOTIFY_PENDING_SYSTEM_UPDATE") public void notifyPendingSystemUpdate(long, boolean);
+87 −0
Original line number 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.app.admin;

import android.annotation.Nullable;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.SurfaceControl;

/**
 * Client interface for providing the SystemUI with secondary lockscreen information.
 *
 * <p>An implementation must be provided by the device admin app when
 * {@link DevicePolicyManager#setSecondaryLockscreenEnabled} is set to true and the service must be
 * declared in the manifest as handling the action
 * {@link DevicePolicyManager#ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE}, otherwise the keyguard
 * will fail to bind to the service and continue to unlock.
 *
 * @see DevicePolicyManager#setSecondaryLockscreenEnabled
 */
public class DevicePolicyKeyguardService extends Service {
    private static final String TAG = "DevicePolicyKeyguardService";
    private IKeyguardCallback mCallback;

    private final IKeyguardClient mClient = new IKeyguardClient.Stub() {
        @Override
        public void onSurfaceReady(@Nullable IBinder hostInputToken, IKeyguardCallback callback) {
            mCallback = callback;
            SurfaceControl surfaceControl =
                    DevicePolicyKeyguardService.this.onSurfaceReady(hostInputToken);

            if (mCallback != null) {
                try {
                    mCallback.onSurfaceControlCreated(surfaceControl);
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to return created SurfaceControl", e);
                }
            }
        }
    };

    @Override
    @Nullable
    public final IBinder onBind(@Nullable Intent intent) {
        return mClient.asBinder();
    }

    /**
     * Called by keyguard once the host surface for the secondary lockscreen is ready to display
     * remote content.
     * @return the {@link SurfaceControl} for the Surface the secondary lockscreen content is
     *      attached to.
     */
    @Nullable
    public SurfaceControl onSurfaceReady(@Nullable IBinder hostInputToken) {
        return null;
    }

    /**
     * Signals to keyguard that the secondary lock screen is ready to be dismissed.
     */
    @Nullable
    public void dismiss() {
        try {
            mCallback.onDismiss();
        } catch (RemoteException e) {
            Log.e(TAG, "onDismiss failed", e);
        }
    }
}
+53 −0
Original line number Diff line number Diff line
@@ -2383,6 +2383,13 @@ public class DevicePolicyManager {
     */
    public static final int MAX_PASSWORD_LENGTH = 16;
    /**
     * Service Action: Service implemented by a device owner or profile owner to provide a
     * secondary lockscreen.
     */
    public static final String ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE =
            "android.app.action.BIND_SECONDARY_LOCKSCREEN_SERVICE";
    /**
     * Return true if the given administrator component is currently active (enabled) in the system.
     *
@@ -8392,6 +8399,52 @@ public class DevicePolicyManager {
        return null;
    }
    /**
     * Called by device owner or profile owner to set whether a secondary lockscreen needs to be
     * shown.
     *
     * <p>The secondary lockscreen will by displayed after the primary keyguard security screen
     * requirements are met. To provide the lockscreen content the DO/PO will need to provide a
     * service handling the {@link #ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE} intent action,
     * extending the {@link DevicePolicyKeyguardService} class.
     *
     * <p>Relevant interactions on the secondary lockscreen should be communicated back to the
     * keyguard via {@link IKeyguardCallback}, such as when the screen is ready to be dismissed.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param enabled Whether or not the lockscreen needs to be shown.
     * @throws SecurityException if {@code admin} is not a device or profile owner.
     * @see #isSecondaryLockscreenEnabled
     **/
    public void setSecondaryLockscreenEnabled(@NonNull ComponentName admin, boolean enabled) {
        throwIfParentInstance("setSecondaryLockscreenEnabled");
        if (mService != null) {
            try {
                mService.setSecondaryLockscreenEnabled(admin, enabled);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
    /**
     * Returns whether the secondary lock screen needs to be shown.
     * @see #setSecondaryLockscreenEnabled
     * @hide
     */
    @SystemApi
    public boolean isSecondaryLockscreenEnabled(int userId) {
        throwIfParentInstance("isSecondaryLockscreenEnabled");
        if (mService != null) {
            try {
                return mService.isSecondaryLockscreenEnabled(userId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return false;
    }
    /**
     * Sets which packages may enter lock task mode.
     * <p>
+3 −0
Original line number Diff line number Diff line
@@ -252,6 +252,9 @@ interface IDevicePolicyManager {
    String[] getAccountTypesWithManagementDisabled();
    String[] getAccountTypesWithManagementDisabledAsUser(int userId);

    void setSecondaryLockscreenEnabled(in ComponentName who, boolean enabled);
    boolean isSecondaryLockscreenEnabled(int userId);

    void setLockTaskPackages(in ComponentName who, in String[] packages);
    String[] getLockTaskPackages(in ComponentName who);
    boolean isLockTaskPermitted(in String pkg);
Loading