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.content.Intent; 24 import android.content.IntentSender; 25 import android.os.RemoteException; 26 import android.os.UserManager; 27 28 import com.android.internal.widget.LockPatternUtils; 29 30 /** Class containing methods shared between CDCA and CDCBA */ 31 public class ConfirmDeviceCredentialUtils { 32 checkForPendingIntent(Activity activity)33 public static void checkForPendingIntent(Activity activity) { 34 // See Change-Id I52c203735fa9b53fd2f7df971824747eeb930f36 for context 35 int taskId = activity.getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1); 36 if (taskId != -1) { 37 try { 38 IActivityManager activityManager = ActivityManager.getService(); 39 final ActivityOptions options = ActivityOptions.makeBasic(); 40 activityManager.startActivityFromRecents(taskId, options.toBundle()); 41 return; 42 } catch (RemoteException e) { 43 // Do nothing. 44 } 45 } 46 IntentSender intentSender = activity.getIntent().getParcelableExtra(Intent.EXTRA_INTENT); 47 if (intentSender != null) { 48 try { 49 activity.startIntentSenderForResult(intentSender, -1, null, 0, 0, 0); 50 } catch (IntentSender.SendIntentException e) { 51 /* ignore */ 52 } 53 } 54 } 55 reportSuccessfulAttempt(LockPatternUtils utils, UserManager userManager, int userId)56 public static void reportSuccessfulAttempt(LockPatternUtils utils, UserManager userManager, 57 int userId) { 58 utils.reportSuccessfulPasswordAttempt(userId); 59 if (userManager.isManagedProfile(userId)) { 60 // Keyguard is responsible to disable StrongAuth for primary user. Disable StrongAuth 61 // for work challenge only here. 62 utils.userPresent(userId); 63 } 64 } 65 } 66