* perform relevant animations before the window disappears.
*/
void onTaskRemovalStarted(int taskId);
+
+ /**
+ * Called when the task has been put in a locked state because one or more of the
+ * activities inside it belong to a managed profile user, and that user has just
+ * been locked.
+ */
+ void onTaskProfileLocked(int taskId, int userId);
}
public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation)
throws RemoteException {
}
+
+ @Override
+ public void onTaskProfileLocked(int taskId, int userId) {
+ }
}
*/
private boolean mPendingLock;
+ /**
+ * Controller for showing individual "work challenge" lock screen windows inside managed profile
+ * tasks when the current user has been unlocked but the profile is still locked.
+ */
+ private WorkLockActivityController mWorkLockController;
+
private boolean mLockLater;
private boolean mWakeAndUnlocking;
mHideAnimation = AnimationUtils.loadAnimation(mContext,
com.android.internal.R.anim.lock_screen_behind_enter);
+
+ mWorkLockController = new WorkLockActivityController(mContext);
}
@Override
--- /dev/null
+/*
+ * 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.keyguard;
+
+import android.app.Activity;
+import android.app.ActivityOptions;
+import android.app.KeyguardManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.UserHandle;
+
+import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
+
+public class WorkLockActivityController {
+ private final Context mContext;
+
+ public WorkLockActivityController(Context context) {
+ mContext = context;
+ EventBus.getDefault().register(this);
+ SystemServicesProxy.getInstance(context).registerTaskStackListener(mLockListener);
+ }
+
+ private void startWorkChallengeInTask(int taskId, int userId) {
+ Intent intent = new Intent(KeyguardManager.ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER)
+ .setComponent(new ComponentName(mContext, WorkLockActivity.class))
+ .putExtra(Intent.EXTRA_USER_ID, userId)
+ .addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
+ | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+ final ActivityOptions options = ActivityOptions.makeBasic();
+ options.setLaunchTaskId(taskId);
+ options.setTaskOverlay(true);
+ mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
+ }
+
+ private final TaskStackListener mLockListener = new TaskStackListener() {
+ @Override
+ public void onTaskProfileLocked(int taskId, int userId) {
+ startWorkChallengeInTask(taskId, userId);
+ }
+ };
+}
public void onPinnedStackAnimationEnded() { }
public void onActivityForcedResizable(String packageName, int taskId) { }
public void onActivityDismissingDockedStack() { }
+ public void onTaskProfileLocked(int taskId, int userId) { }
}
/**
public void onActivityDismissingDockedStack() throws RemoteException {
mHandler.sendEmptyMessage(H.ON_ACTIVITY_DISMISSING_DOCKED_STACK);
}
+
+ @Override
+ public void onTaskProfileLocked(int taskId, int userId) {
+ mHandler.obtainMessage(H.ON_TASK_PROFILE_LOCKED, taskId, userId).sendToTarget();
+ }
};
/**
private static final int ON_PINNED_STACK_ANIMATION_ENDED = 4;
private static final int ON_ACTIVITY_FORCED_RESIZABLE = 5;
private static final int ON_ACTIVITY_DISMISSING_DOCKED_STACK = 6;
+ private static final int ON_TASK_PROFILE_LOCKED = 7;
@Override
public void handleMessage(Message msg) {
}
break;
}
+ case ON_TASK_PROFILE_LOCKED: {
+ for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
+ mTaskStackListeners.get(i).onTaskProfileLocked(msg.arg1, msg.arg2);
+ }
+ break;
+ }
}
}
}
// to an activity belonging to userId. Example case: a document picker for
// personal files, opened by a work app, should still get locked.
if (taskTopActivityIsUser(task, userId)) {
- mService.mActivityStarter.startTaskLockedActivity(task);
+ mService.mTaskChangeNotificationController.notifyTaskProfileLocked(
+ task.taskId, userId);
}
}
}
UserHandle.CURRENT);
}
- void startTaskLockedActivity(final TaskRecord task) {
- final ActivityRecord activityRecord = task.topRunningActivityLocked();
- if (activityRecord == null) {
- Slog.w(TAG, "Unable to find activity record to start lock activity for task: " + task);
- return;
- }
-
- final KeyguardManager km = (KeyguardManager) mService.mContext
- .getSystemService(Context.KEYGUARD_SERVICE);
- Intent intent = new Intent(KeyguardManager.ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER);
- intent.setPackage("com.android.systemui");
- intent.putExtra(Intent.EXTRA_TASK_ID, task.lastTaskDescription);
- intent.putExtra(Intent.EXTRA_USER_ID, task.userId);
- intent.addFlags(FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | FLAG_ACTIVITY_REORDER_TO_FRONT
- | FLAG_ACTIVITY_SINGLE_TOP);
- final ActivityOptions options = ActivityOptions.makeBasic();
- options.setLaunchTaskId(task.taskId);
- options.setTaskOverlay(true);
- mService.mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
- }
-
final int startActivityMayWait(IApplicationThread caller, int callingUid,
String callingPackage, Intent intent, String resolvedType,
IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
static final int NOTIFY_TASK_DESCRIPTION_CHANGED_LISTENERS_MSG = 11;
static final int NOTIFY_ACTIVITY_REQUESTED_ORIENTATION_CHANGED_LISTENERS = 12;
static final int NOTIFY_TASK_REMOVAL_STARTED_LISTENERS = 13;
+ static final int NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG = 14;
// Delay in notifying task stack change listeners (in millis)
static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
case NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG:
forAllListeners((listener) -> listener.onActivityDismissingDockedStack());
break;
+ case NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG:
+ forAllListeners((listener) -> listener.onTaskProfileLocked(msg.arg1, msg.arg2));
+ break;
}
}
}
mHandler.obtainMessage(NOTIFY_TASK_REMOVAL_STARTED_LISTENERS, taskId, 0 /* unused */)
.sendToTarget();
}
+
+ /**
+ * Notify listeners that the task has been put in a locked state because one or more of the
+ * activities inside it belong to a managed profile user that has been locked.
+ */
+ void notifyTaskProfileLocked(int taskId, int userId) {
+ mHandler.obtainMessage(NOTIFY_TASK_PROFILE_LOCKED_LISTENERS_MSG, taskId, userId)
+ .sendToTarget();
+ }
}