• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.settings.password;
18 
19 import android.app.Activity;
20 import android.app.ActivityManager;
21 import android.app.ActivityOptions;
22 import android.app.IActivityManager;
23 import android.app.admin.DevicePolicyManager;
24 import android.content.Intent;
25 import android.content.IntentSender;
26 import android.os.RemoteException;
27 import android.os.UserManager;
28 
29 import com.android.internal.widget.LockPatternUtils;
30 
31 /** Class containing methods shared between CDCA and CDCBA */
32 public class ConfirmDeviceCredentialUtils {
33 
checkForPendingIntent(Activity activity)34     public static void checkForPendingIntent(Activity activity) {
35         // See Change-Id I52c203735fa9b53fd2f7df971824747eeb930f36 for context
36         int taskId = activity.getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
37         if (taskId != -1) {
38             try {
39                 IActivityManager activityManager = ActivityManager.getService();
40                 final ActivityOptions options = ActivityOptions.makeBasic();
41                 activityManager.startActivityFromRecents(taskId, options.toBundle());
42                 return;
43             } catch (RemoteException e) {
44                 // Do nothing.
45             }
46         }
47         IntentSender intentSender = activity.getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
48         if (intentSender != null) {
49             try {
50                 activity.startIntentSenderForResult(intentSender, -1, null, 0, 0, 0);
51             } catch (IntentSender.SendIntentException e) {
52                 /* ignore */
53             }
54         }
55     }
56 
reportSuccessfulAttempt(LockPatternUtils utils, UserManager userManager, DevicePolicyManager dpm, int userId, boolean isStrongAuth)57     public static void reportSuccessfulAttempt(LockPatternUtils utils, UserManager userManager,
58             DevicePolicyManager dpm, int userId, boolean isStrongAuth) {
59         if (isStrongAuth) {
60             utils.reportSuccessfulPasswordAttempt(userId);
61         } else {
62             dpm.reportSuccessfulBiometricAttempt(userId);
63         }
64         if (userManager.isManagedProfile(userId)) {
65             // Keyguard is responsible to disable StrongAuth for primary user. Disable StrongAuth
66             // for work challenge only here.
67             utils.userPresent(userId);
68         }
69     }
70 }
71