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

Commit b8f41d02 authored by Tim Yu's avatar Tim Yu
Browse files

Better error handling for printing out Autofill flags

Test: na
Bug: na
Change-Id: Ie2a026277703e130d5ea7415c3b8b6b895a058ac
parent b920b8c4
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;