Add help/error msg for ProgressViewModel
Pass Help and Error message from FingerprintManager callback to LiveData in FingerprintEnrollProgressViewModel. Bug: 259664912 Test: Manually test FindSensor page Change-Id: I3a992a51d97368fc82f6a1064d0c0d1e445e276b
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
@@ -38,6 +38,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.biometrics.fingerprint.FingerprintUpdater;
|
import com.android.settings.biometrics.fingerprint.FingerprintUpdater;
|
||||||
import com.android.settings.biometrics.fingerprint.MessageDisplayController;
|
import com.android.settings.biometrics.fingerprint.MessageDisplayController;
|
||||||
import com.android.settings.biometrics2.ui.model.EnrollmentProgress;
|
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
|
* 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<EnrollmentProgress> mProgressLiveData = new MutableLiveData<>(
|
private final MutableLiveData<EnrollmentProgress> mProgressLiveData = new MutableLiveData<>(
|
||||||
new EnrollmentProgress(INITIAL_STEPS, INITIAL_REMAINING));
|
new EnrollmentProgress(INITIAL_STEPS, INITIAL_REMAINING));
|
||||||
|
private final MutableLiveData<EnrollmentStatusMessage> mHelpMessageLiveData =
|
||||||
|
new MutableLiveData<>();
|
||||||
|
private final MutableLiveData<EnrollmentStatusMessage> mErrorMessageLiveData =
|
||||||
|
new MutableLiveData<>();
|
||||||
|
|
||||||
private byte[] mToken = null;
|
private byte[] mToken = null;
|
||||||
private int mUserId = UserHandle.myUserId();
|
private int mUserId = UserHandle.myUserId();
|
||||||
@@ -75,12 +80,12 @@ public class FingerprintEnrollProgressViewModel extends AndroidViewModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
|
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
|
||||||
// TODO add LiveData for help message during implementing b/260957933
|
mHelpMessageLiveData.postValue(new EnrollmentStatusMessage(helpMsgId, helpString));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentError(int errMsgId, CharSequence errString) {
|
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();
|
final Resources res = application.getResources();
|
||||||
mMessageDisplayController =
|
mMessageDisplayController =
|
||||||
res.getBoolean(R.bool.enrollment_message_display_controller_flag)
|
res.getBoolean(R.bool.enrollment_message_display_controller_flag)
|
||||||
? new MessageDisplayController(
|
? new MessageDisplayController(
|
||||||
application.getMainThreadHandler(),
|
application.getMainThreadHandler(),
|
||||||
mEnrollmentCallback,
|
mEnrollmentCallback,
|
||||||
SystemClock.elapsedRealtimeClock(),
|
SystemClock.elapsedRealtimeClock(),
|
||||||
res.getInteger(R.integer.enrollment_help_minimum_time_display),
|
res.getInteger(R.integer.enrollment_help_minimum_time_display),
|
||||||
res.getInteger(R.integer.enrollment_progress_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_progress_priority_over_help),
|
||||||
res.getBoolean(R.bool.enrollment_prioritize_acquire_messages),
|
res.getBoolean(R.bool.enrollment_prioritize_acquire_messages),
|
||||||
res.getInteger(R.integer.enrollment_collect_time)) : null;
|
res.getInteger(R.integer.enrollment_collect_time))
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToken(byte[] token) {
|
public void setToken(byte[] token) {
|
||||||
@@ -121,6 +127,14 @@ public class FingerprintEnrollProgressViewModel extends AndroidViewModel {
|
|||||||
return mProgressLiveData;
|
return mProgressLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<EnrollmentStatusMessage> getHelpMessageLiveData() {
|
||||||
|
return mHelpMessageLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<EnrollmentStatusMessage> getErrorMessageLiveData() {
|
||||||
|
return mErrorMessageLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts enrollment and return latest isEnrolling() result
|
* Starts enrollment and return latest isEnrolling() result
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user