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

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

Merge "Better error handling for printing out Autofill flags" into main

parents 492d02ff b8f41d02
Loading
Loading
Loading
Loading
+21 −11
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ 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;

import android.os.Bundle;
@@ -155,18 +154,29 @@ public final class AutofillManagerServiceShellCommand extends ShellCommand {
            pw.println("");
        }

        Method[] flagMethods = {};

        try {
            Method[] flagMethods = Flags.class.getMethods();
            flagMethods = Flags.class.getDeclaredMethods();
        } catch (SecurityException ex) {
            ex.printStackTrace(pw);
            return -1;
        }

        // 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));
                }
            if (!Modifier.isPublic(method.getModifiers())) {
                continue;
            }
            try {
                pw.print(method.getName() + ": ");
                pw.print(method.invoke(null));
            } catch (Exception ex) {
            pw.println(ex);
            return -1;
                ex.printStackTrace(pw);
            } finally {
                pw.println("");
            }
        }

        return 0;