Merge "Autofill: Shell command for saved password count" into sc-dev
This commit is contained in:
@@ -662,6 +662,26 @@ public final class AutofillManagerService
|
||||
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) {
|
||||
com.android.server.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.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.os.IResultReceiver;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.autofill.AutofillManagerService.AutofillCompatState;
|
||||
import com.android.server.autofill.AutofillManagerService.DisabledInfoCache;
|
||||
@@ -1180,6 +1181,15 @@ final class AutofillManagerServiceImpl
|
||||
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")
|
||||
@Nullable RemoteAugmentedAutofillService getRemoteAugmentedAutofillServiceLocked() {
|
||||
if (mRemoteAugmentedAutofillService == null) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.autofill;
|
||||
|
||||
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;
|
||||
|
||||
@@ -89,6 +90,9 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
pw.println(" get bind-instant-service-allowed");
|
||||
pw.println(" Gets whether binding to services provided by instant apps is allowed");
|
||||
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(" Sets the Autofill log level.");
|
||||
pw.println("");
|
||||
@@ -145,6 +149,8 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
return getBindInstantService(pw);
|
||||
case "default-augmented-service-enabled":
|
||||
return getDefaultAugmentedServiceEnabled(pw);
|
||||
case "saved-password-count":
|
||||
return getSavedPasswordCount(pw);
|
||||
default:
|
||||
pw.println("Invalid set: " + what);
|
||||
return -1;
|
||||
@@ -342,6 +348,25 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
|
||||
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) {
|
||||
if (!isNextArgSessions(pw)) {
|
||||
return -1;
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.util.Slog;
|
||||
|
||||
import com.android.internal.infra.AbstractRemoteService;
|
||||
import com.android.internal.infra.ServiceConnector;
|
||||
import com.android.internal.os.IResultReceiver;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
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() {
|
||||
unbind();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user