Correct returns if PCC is enabled.

Before it was just using the general flags to see if the PCC enabled and
PCC service names are set to determine if PCC is enabled. This change
will get those values for the user instead.

Fixes: 283849162
Test: android.autofillservice.cts.dialog.LoginActivityTest
Change-Id: Id9baa2611ad9d1a8abf05896604609d2e35b7947
This commit is contained in:
Tim Yu
2023-05-25 20:31:44 +00:00
parent 63da86fe76
commit 53f537f85a
2 changed files with 13 additions and 4 deletions

View File

@@ -760,6 +760,18 @@ public final class AutofillManagerService
return false;
}
// Called by Shell command
boolean isFieldDetectionServiceEnabledForUser(@UserIdInt int userId) {
enforceCallingPermissionForManagement();
synchronized (mLock) {
final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
if (service != null) {
return service.isPccClassificationEnabled();
}
}
return false;
}
// Called by Shell command
String getFieldDetectionServiceName(@UserIdInt int userId) {
enforceCallingPermissionForManagement();

View File

@@ -26,7 +26,6 @@ import android.os.RemoteCallback;
import android.os.ShellCommand;
import android.os.UserHandle;
import android.service.autofill.AutofillFieldClassificationService.Scores;
import android.text.TextUtils;
import android.view.autofill.AutofillManager;
import com.android.internal.os.IResultReceiver;
@@ -348,9 +347,7 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
private int isFieldDetectionServiceEnabled(PrintWriter pw) {
final int userId = getNextIntArgRequired();
String name = mService.getFieldDetectionServiceName(userId);
boolean pccFlagEnabled = mService.isPccClassificationFlagEnabled();
boolean enabled = (!TextUtils.isEmpty(name)) && pccFlagEnabled;
boolean enabled = mService.isFieldDetectionServiceEnabledForUser(userId);
pw.println(enabled);
return 0;
}