apps are protected by PIN prompt. Test: manual test Bug: 279889563 Change-Id: Ife319469cee908f54618986107b40bcc82886b06
93 lines
3.6 KiB
Java
93 lines
3.6 KiB
Java
/*
|
|
* Copyright (C) 2018 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.settings.password;
|
|
|
|
import android.app.Activity;
|
|
import android.app.ActivityManager;
|
|
import android.app.ActivityOptions;
|
|
import android.app.IActivityManager;
|
|
import android.app.admin.DevicePolicyManager;
|
|
import android.content.Intent;
|
|
import android.content.IntentSender;
|
|
import android.os.RemoteException;
|
|
import android.os.UserManager;
|
|
import android.view.View;
|
|
import android.view.WindowInsets;
|
|
import android.view.WindowInsetsController;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import com.android.internal.widget.LockPatternUtils;
|
|
|
|
/** Class containing methods shared between CDCA and CDCBA */
|
|
public class ConfirmDeviceCredentialUtils {
|
|
|
|
public static void checkForPendingIntent(Activity activity) {
|
|
// See Change-Id I52c203735fa9b53fd2f7df971824747eeb930f36 for context
|
|
int taskId = activity.getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
|
|
if (taskId != -1) {
|
|
try {
|
|
IActivityManager activityManager = ActivityManager.getService();
|
|
final ActivityOptions options = ActivityOptions.makeBasic();
|
|
activityManager.startActivityFromRecents(taskId, options.toBundle());
|
|
return;
|
|
} catch (RemoteException e) {
|
|
// Do nothing.
|
|
}
|
|
}
|
|
IntentSender intentSender = activity.getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
|
|
if (intentSender != null) {
|
|
try {
|
|
ActivityOptions activityOptions =
|
|
ActivityOptions.makeBasic()
|
|
.setPendingIntentBackgroundActivityStartMode(
|
|
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
|
|
activity.startIntentSenderForResult(intentSender, -1, null, 0, 0, 0,
|
|
activityOptions.toBundle());
|
|
} catch (IntentSender.SendIntentException e) {
|
|
/* ignore */
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void reportSuccessfulAttempt(LockPatternUtils utils, UserManager userManager,
|
|
DevicePolicyManager dpm, int userId, boolean isStrongAuth) {
|
|
if (isStrongAuth) {
|
|
utils.reportSuccessfulPasswordAttempt(userId);
|
|
} else {
|
|
dpm.reportSuccessfulBiometricAttempt(userId);
|
|
}
|
|
if (userManager.isManagedProfile(userId)) {
|
|
// Keyguard is responsible to disable StrongAuth for primary user. Disable StrongAuth
|
|
// for work challenge only here.
|
|
utils.userPresent(userId);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Request hiding soft-keyboard before animating away credential UI, in case IME
|
|
* insets animation get delayed by dismissing animation.
|
|
* @param view used to get root {@link WindowInsets} and {@link WindowInsetsController}.
|
|
*/
|
|
public static void hideImeImmediately(@NonNull View view) {
|
|
if (view.isAttachedToWindow()
|
|
&& view.getRootWindowInsets().isVisible(WindowInsets.Type.ime())) {
|
|
view.getWindowInsetsController().hide(WindowInsets.Type.ime());
|
|
}
|
|
}
|
|
}
|