diff --git a/src/com/android/settings/biometrics2/ui/model/EnrollmentStatusMessage.java b/src/com/android/settings/biometrics2/ui/model/EnrollmentStatusMessage.java new file mode 100644 index 00000000000..184e1d1c839 --- /dev/null +++ b/src/com/android/settings/biometrics2/ui/model/EnrollmentStatusMessage.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 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.biometrics2.ui.model; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +/** + * Enrolling status message (help or error) + */ +public final class EnrollmentStatusMessage { + + private final int mMsgId; + @NonNull private final CharSequence mStr; + + public EnrollmentStatusMessage(int msgId, @Nullable CharSequence str) { + mMsgId = msgId; + mStr = str != null ? str : ""; + } + + public int getMsgId() { + return mMsgId; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) + + "{id:" + mMsgId + ", str:" + mStr + "}"; + } + + /** + * Gets status string + */ + @NonNull + public CharSequence getStr() { + return mStr; + } +} diff --git a/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollProgressViewModel.java b/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollProgressViewModel.java index cec94751f73..0483c6fd38d 100644 --- a/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollProgressViewModel.java +++ b/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollProgressViewModel.java @@ -38,6 +38,7 @@ import com.android.settings.R; import com.android.settings.biometrics.fingerprint.FingerprintUpdater; import com.android.settings.biometrics.fingerprint.MessageDisplayController; import com.android.settings.biometrics2.ui.model.EnrollmentProgress; +import com.android.settings.biometrics2.ui.model.EnrollmentStatusMessage; /** * Progress ViewModel handles the state around biometric enrollment. It manages the state of @@ -51,6 +52,10 @@ public class FingerprintEnrollProgressViewModel extends AndroidViewModel { private final MutableLiveData mProgressLiveData = new MutableLiveData<>( new EnrollmentProgress(INITIAL_STEPS, INITIAL_REMAINING)); + private final MutableLiveData mHelpMessageLiveData = + new MutableLiveData<>(); + private final MutableLiveData mErrorMessageLiveData = + new MutableLiveData<>(); private byte[] mToken = null; private int mUserId = UserHandle.myUserId(); @@ -75,12 +80,12 @@ public class FingerprintEnrollProgressViewModel extends AndroidViewModel { @Override public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { - // TODO add LiveData for help message during implementing b/260957933 + mHelpMessageLiveData.postValue(new EnrollmentStatusMessage(helpMsgId, helpString)); } @Override public void onEnrollmentError(int errMsgId, CharSequence errString) { - // TODO add LiveData for error message during implementing b/260957933 + mErrorMessageLiveData.postValue(new EnrollmentStatusMessage(errMsgId, errString)); } }; @@ -91,15 +96,16 @@ public class FingerprintEnrollProgressViewModel extends AndroidViewModel { final Resources res = application.getResources(); mMessageDisplayController = res.getBoolean(R.bool.enrollment_message_display_controller_flag) - ? new MessageDisplayController( - application.getMainThreadHandler(), - mEnrollmentCallback, - SystemClock.elapsedRealtimeClock(), - res.getInteger(R.integer.enrollment_help_minimum_time_display), - res.getInteger(R.integer.enrollment_progress_minimum_time_display), - res.getBoolean(R.bool.enrollment_progress_priority_over_help), - res.getBoolean(R.bool.enrollment_prioritize_acquire_messages), - res.getInteger(R.integer.enrollment_collect_time)) : null; + ? new MessageDisplayController( + application.getMainThreadHandler(), + mEnrollmentCallback, + SystemClock.elapsedRealtimeClock(), + res.getInteger(R.integer.enrollment_help_minimum_time_display), + res.getInteger(R.integer.enrollment_progress_minimum_time_display), + res.getBoolean(R.bool.enrollment_progress_priority_over_help), + res.getBoolean(R.bool.enrollment_prioritize_acquire_messages), + res.getInteger(R.integer.enrollment_collect_time)) + : null; } public void setToken(byte[] token) { @@ -121,6 +127,14 @@ public class FingerprintEnrollProgressViewModel extends AndroidViewModel { return mProgressLiveData; } + public LiveData getHelpMessageLiveData() { + return mHelpMessageLiveData; + } + + public LiveData getErrorMessageLiveData() { + return mErrorMessageLiveData; + } + /** * Starts enrollment and return latest isEnrolling() result */