2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.app.Fragment;
20 import android.content.Intent;
21 import android.os.Bundle;
24 * An invisible retained fragment to track lock check result.
26 public class CredentialCheckResultTracker extends Fragment {
28 private Listener mListener;
29 private boolean mHasResult = false;
31 private boolean mResultMatched;
32 private Intent mResultData;
33 private int mResultTimeoutMs;
34 private int mResultEffectiveUserId;
37 public void onCreate(Bundle savedInstanceState) {
38 super.onCreate(savedInstanceState);
39 setRetainInstance(true);
42 public void setListener(Listener listener) {
43 if (mListener == listener) {
48 if (mListener != null && mHasResult) {
49 mListener.onCredentialChecked(mResultMatched, mResultData, mResultTimeoutMs,
50 mResultEffectiveUserId, false /* newResult */);
54 public void setResult(boolean matched, Intent intent, int timeoutMs, int effectiveUserId) {
55 mResultMatched = matched;
57 mResultTimeoutMs = timeoutMs;
58 mResultEffectiveUserId = effectiveUserId;
61 if (mListener != null) {
62 mListener.onCredentialChecked(mResultMatched, mResultData, mResultTimeoutMs,
63 mResultEffectiveUserId, true /* newResult */);
68 public void clearResult() {
70 mResultMatched = false;
73 mResultEffectiveUserId = 0;
77 public void onCredentialChecked(boolean matched, Intent intent, int timeoutMs,
78 int effectiveUserId, boolean newResult);