Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70fe51f1 authored by Tim Yu's avatar Tim Yu Committed by Android (Google) Code Review
Browse files

Merge "Add Trunk Stable flags to Autofill" into main

parents d696063c 3cb5d8b2
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,4 +19,19 @@ java_library_static {
    defaults: ["platform_service_defaults"],
    srcs: [":services.autofill-sources"],
    libs: ["services.core"],
    static_libs: ["autofill_flags_java_lib"],
}

aconfig_declarations {
    name: "autofill_flags",
    package: "android.service.autofill",
    srcs: [
        "bugfixes.aconfig",
        "features.aconfig",
    ],
}

java_aconfig_library {
    name: "autofill_flags_java_lib",
    aconfig_declarations: "autofill_flags",
}
+8 −0
Original line number Diff line number Diff line
package: "android.service.autofill"

flag {
  name: "test"
  namespace: "autofill"
  description: "Test flag "
  bug: "297380045"
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
package: "android.service.autofill"
 No newline at end of file
+42 −7
Original line number Diff line number Diff line
@@ -26,11 +26,14 @@ import android.os.RemoteCallback;
import android.os.ShellCommand;
import android.os.UserHandle;
import android.service.autofill.AutofillFieldClassificationService.Scores;
import android.service.autofill.Flags;
import android.view.autofill.AutofillManager;

import com.android.internal.os.IResultReceiver;

import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -60,6 +63,8 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
                return requestGet(pw);
            case "set":
                return requestSet(pw);
            case "flags":
                return requestFlags(pw);
            default:
                return handleDefaultCommands(cmd);
        }
@@ -109,7 +114,8 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
            pw.println("    Sets whether binding to services provided by instant apps is allowed");
            pw.println("");
            pw.println("  set temporary-augmented-service USER_ID [COMPONENT_NAME DURATION]");
            pw.println("    Temporarily (for DURATION ms) changes the augmented autofill service "
            pw.println(
                    "    Temporarily (for DURATION ms) changes the augmented autofill service "
                            + "implementation.");
            pw.println("    To reset, call with just the USER_ID argument.");
            pw.println("");
@@ -117,12 +123,14 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
            pw.println("    Enable / disable the default augmented autofill service for the user.");
            pw.println("");
            pw.println("  set temporary-detection-service USER_ID [COMPONENT_NAME DURATION]");
            pw.println("    Temporarily (for DURATION ms) changes the autofill detection service "
            pw.println(
                    "    Temporarily (for DURATION ms) changes the autofill detection service "
                            + "implementation.");
            pw.println("    To reset, call with [COMPONENT_NAME 0].");
            pw.println("");
            pw.println("  get default-augmented-service-enabled USER_ID");
            pw.println("    Checks whether the default augmented autofill service is enabled for "
            pw.println(
                    "    Checks whether the default augmented autofill service is enabled for "
                            + "the user.");
            pw.println("");
            pw.println("  list sessions [--user USER_ID]");
@@ -134,8 +142,35 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
            pw.println("  reset");
            pw.println("    Resets all pending sessions and cached service connections.");
            pw.println("");
            pw.println("  flags");
            pw.println("    Prints out all autofill related flags.");
            pw.println("");
        }
    }

    private int requestFlags(PrintWriter pw) {

        if (Flags.test()) {
            pw.println("Hello Flag World!");
            pw.println("");
        }

        try {
            Method[] flagMethods = Flags.class.getMethods();
            // For some reason, unreferenced flags do not show up here
            // Maybe compiler optomized them out of bytecode?
            for (Method method : flagMethods) {
                if (Modifier.isPublic(method.getModifiers())) {
                    pw.println(method.getName() + ": " + method.invoke(null));
                }
            }
        } catch (Exception ex) {
            pw.println(ex);
            return -1;
        }

        return 0;
    }

    private int requestGet(PrintWriter pw) {
        final String what = getNextArgRequired();