summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorYvonne Jiang <yvonnejiang@google.com>2020-01-22 01:43:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-01-22 01:43:38 +0000
commit1d1973ef97ee503df3497475c4e8edc6e6f8f5f4 (patch)
tree8195ee8b379c7a7a4bdeaecbc1981c301399653b /core/java
parentecc28832bafa3535c4599534f4ce7f759134da8f (diff)
parentb7024a251c33eab1d5a4bc89cc936a8dac443f39 (diff)
Merge "Adding API for displaying a DO/PO controlled secondary lock screen post initial system lock screen."
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/admin/DevicePolicyKeyguardService.java87
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java53
-rw-r--r--core/java/android/app/admin/IDevicePolicyManager.aidl3
-rw-r--r--core/java/android/app/admin/IKeyguardCallback.aidl27
-rw-r--r--core/java/android/app/admin/IKeyguardClient.aidl27
5 files changed, 197 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyKeyguardService.java b/core/java/android/app/admin/DevicePolicyKeyguardService.java
new file mode 100644
index 000000000000..c2a76c5014c0
--- /dev/null
+++ b/core/java/android/app/admin/DevicePolicyKeyguardService.java
@@ -0,0 +1,87 @@
+/*
+ * 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);
+ }
+ }
+}
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index a35a89948f25..d58c4eb1eb3d 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2384,6 +2384,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.
*
* @param admin The administrator component to check for.
@@ -8393,6 +8400,52 @@ public class DevicePolicyManager {
}
/**
+ * 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>
* Any packages that share uid with an allowed package will also be allowed to activate lock
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index a2c0856717f5..e7667c0a1b4a 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -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);
diff --git a/core/java/android/app/admin/IKeyguardCallback.aidl b/core/java/android/app/admin/IKeyguardCallback.aidl
new file mode 100644
index 000000000000..81e7d4dee902
--- /dev/null
+++ b/core/java/android/app/admin/IKeyguardCallback.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.view.SurfaceControl;
+
+/**
+ * Internal IPC interface for informing the keyguard of events on the secondary lockscreen.
+ * @hide
+ */
+interface IKeyguardCallback {
+ oneway void onSurfaceControlCreated(in SurfaceControl remoteSurfaceControl);
+ oneway void onDismiss();
+}
diff --git a/core/java/android/app/admin/IKeyguardClient.aidl b/core/java/android/app/admin/IKeyguardClient.aidl
new file mode 100644
index 000000000000..4bfd990cf717
--- /dev/null
+++ b/core/java/android/app/admin/IKeyguardClient.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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.app.admin.IKeyguardCallback;
+
+/**
+ * Internal IPC interface for a service to provide the SystemUI with secondary lockscreen
+ * information.
+ * @hide
+ */
+interface IKeyguardClient {
+ oneway void onSurfaceReady(in IBinder hostInputToken, in IKeyguardCallback keyguardCallback);
+}