Merge "Autofill: Shell command for saved password count" into sc-dev am: 1344e18197
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15075578 Change-Id: Ibd6d329b7d09f9f430f58f8d6f0d9e049025906c
This commit is contained in:
@@ -662,6 +662,26 @@ public final class AutofillManagerService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests a count of saved passwords from the current service.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the request succeeded
|
||||||
|
*/
|
||||||
|
// Called by Shell command
|
||||||
|
boolean requestSavedPasswordCount(@UserIdInt int userId, @NonNull IResultReceiver receiver) {
|
||||||
|
enforceCallingPermissionForManagement();
|
||||||
|
synchronized (mLock) {
|
||||||
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
|
if (service != null) {
|
||||||
|
service.requestSavedPasswordCount(receiver);
|
||||||
|
return true;
|
||||||
|
} else if (sVerbose) {
|
||||||
|
Slog.v(TAG, "requestSavedPasswordCount(): no service for " + userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void setLoggingLevelsLocked(boolean debug, boolean verbose) {
|
private void setLoggingLevelsLocked(boolean debug, boolean verbose) {
|
||||||
com.android.server.autofill.Helper.sDebug = debug;
|
com.android.server.autofill.Helper.sDebug = debug;
|
||||||
android.view.autofill.Helper.sDebug = debug;
|
android.view.autofill.Helper.sDebug = debug;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
|
import com.android.internal.os.IResultReceiver;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.autofill.AutofillManagerService.AutofillCompatState;
|
import com.android.server.autofill.AutofillManagerService.AutofillCompatState;
|
||||||
import com.android.server.autofill.AutofillManagerService.DisabledInfoCache;
|
import com.android.server.autofill.AutofillManagerService.DisabledInfoCache;
|
||||||
@@ -1180,6 +1181,15 @@ final class AutofillManagerServiceImpl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
void requestSavedPasswordCount(IResultReceiver receiver) {
|
||||||
|
RemoteFillService remoteService =
|
||||||
|
new RemoteFillService(
|
||||||
|
getContext(), mInfo.getServiceInfo().getComponentName(), mUserId,
|
||||||
|
/* callbacks= */ null, mMaster.isInstantServiceAllowed());
|
||||||
|
remoteService.onSavedPasswordCountRequest(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@Nullable RemoteAugmentedAutofillService getRemoteAugmentedAutofillServiceLocked() {
|
@Nullable RemoteAugmentedAutofillService getRemoteAugmentedAutofillServiceLocked() {
|
||||||
if (mRemoteAugmentedAutofillService == null) {
|
if (mRemoteAugmentedAutofillService == null) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server.autofill;
|
package com.android.server.autofill;
|
||||||
|
|
||||||
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
|
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
|
||||||
|
import static android.service.autofill.AutofillService.EXTRA_RESULT;
|
||||||
|
|
||||||
import static com.android.server.autofill.AutofillManagerService.RECEIVER_BUNDLE_EXTRA_SESSIONS;
|
import static com.android.server.autofill.AutofillManagerService.RECEIVER_BUNDLE_EXTRA_SESSIONS;
|
||||||
|
|
||||||
@@ -89,6 +90,9 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
|||||||
pw.println(" get bind-instant-service-allowed");
|
pw.println(" get bind-instant-service-allowed");
|
||||||
pw.println(" Gets whether binding to services provided by instant apps is allowed");
|
pw.println(" Gets whether binding to services provided by instant apps is allowed");
|
||||||
pw.println("");
|
pw.println("");
|
||||||
|
pw.println(" get saved-password-count");
|
||||||
|
pw.println(" Gets the number of saved passwords in the current service.");
|
||||||
|
pw.println("");
|
||||||
pw.println(" set log_level [off | debug | verbose]");
|
pw.println(" set log_level [off | debug | verbose]");
|
||||||
pw.println(" Sets the Autofill log level.");
|
pw.println(" Sets the Autofill log level.");
|
||||||
pw.println("");
|
pw.println("");
|
||||||
@@ -145,6 +149,8 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
|||||||
return getBindInstantService(pw);
|
return getBindInstantService(pw);
|
||||||
case "default-augmented-service-enabled":
|
case "default-augmented-service-enabled":
|
||||||
return getDefaultAugmentedServiceEnabled(pw);
|
return getDefaultAugmentedServiceEnabled(pw);
|
||||||
|
case "saved-password-count":
|
||||||
|
return getSavedPasswordCount(pw);
|
||||||
default:
|
default:
|
||||||
pw.println("Invalid set: " + what);
|
pw.println("Invalid set: " + what);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -342,6 +348,25 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getSavedPasswordCount(PrintWriter pw) {
|
||||||
|
final int userId = getNextIntArgRequired();
|
||||||
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
IResultReceiver resultReceiver = new IResultReceiver.Stub() {
|
||||||
|
@Override
|
||||||
|
public void send(int resultCode, Bundle resultData) {
|
||||||
|
pw.println("resultCode=" + resultCode);
|
||||||
|
if (resultCode == 0 && resultData != null) {
|
||||||
|
pw.println("value=" + resultData.getInt(EXTRA_RESULT));
|
||||||
|
}
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (mService.requestSavedPasswordCount(userId, resultReceiver)) {
|
||||||
|
waitForLatch(pw, latch);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private int requestDestroy(PrintWriter pw) {
|
private int requestDestroy(PrintWriter pw) {
|
||||||
if (!isNextArgSessions(pw)) {
|
if (!isNextArgSessions(pw)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import android.util.Slog;
|
|||||||
|
|
||||||
import com.android.internal.infra.AbstractRemoteService;
|
import com.android.internal.infra.AbstractRemoteService;
|
||||||
import com.android.internal.infra.ServiceConnector;
|
import com.android.internal.infra.ServiceConnector;
|
||||||
|
import com.android.internal.os.IResultReceiver;
|
||||||
|
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -225,6 +226,10 @@ final class RemoteFillService extends ServiceConnector.Impl<IAutoFillService> {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSavedPasswordCountRequest(IResultReceiver receiver) {
|
||||||
|
run(service -> service.onSavedPasswordCountRequest(receiver));
|
||||||
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
unbind();
|
unbind();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user