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

Commit 40a1db72 authored by Felipe Leme's avatar Felipe Leme
Browse files

Disable autofill service when new service from Settings is invalid.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -t android.autofillservice.cts.LoginActivityTest#testServiceIsDisabledWhenNewServiceInfoIsInvalid
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -t android.autofillservice.cts.LoginActivityTest#testServiceIsDisabledWhenNewServiceNameIsInvalid
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases

Bug: 67496182

Change-Id: I2ee2b0ff125434feb18e539a07b64b83d390291f
parent 9eb15556
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -216,9 +216,12 @@ final class AutofillManagerServiceImpl {
                serviceComponent = ComponentName.unflattenFromString(componentName);
                serviceInfo = AppGlobals.getPackageManager().getServiceInfo(serviceComponent,
                        0, mUserId);
                if (serviceInfo == null) {
                    Slog.e(TAG, "Bad AutofillService name: " + componentName);
                }
            } catch (RuntimeException | RemoteException e) {
                Slog.e(TAG, "Bad autofill service name " + componentName + ": " + e);
                return;
                Slog.e(TAG, "Error getting service info for '" + componentName + "': " + e);
                serviceInfo = null;
            }
        }
        try {
@@ -228,7 +231,13 @@ final class AutofillManagerServiceImpl {
                if (sDebug) Slog.d(TAG, "Set component for user " + mUserId + " as " + mInfo);
            } else {
                mInfo = null;
                if (sDebug) Slog.d(TAG, "Reset component for user " + mUserId);
                if (sDebug) {
                    Slog.d(TAG, "Reset component for user " + mUserId + " (" + componentName + ")");
                }
            }
        } catch (Exception e) {
            Slog.e(TAG, "Bad AutofillServiceInfo for '" + componentName + "': " + e);
            mInfo = null;
        }
        final boolean isEnabled = isEnabled();
        if (wasEnabled != isEnabled) {
@@ -241,9 +250,6 @@ final class AutofillManagerServiceImpl {
            }
            sendStateToClients(false);
        }
        } catch (Exception e) {
            Slog.e(TAG, "Bad AutofillService '" + componentName + "': " + e);
        }
    }

    boolean addClientLocked(IAutoFillManagerClient client) {