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

Commit 0c28244e authored by Nicholas Sauer's avatar Nicholas Sauer
Browse files

Use the current user rather than USER_SYSTEM as

default user for AccountManagerServiceShellCommand

This allows for testing of accountmanager with instant apps in secondary users.

bug: 138142372
Test:  cts-tradefed run cts  -m CtsAccountManagerTestCases -t android.accounts.cts.AccountManagerTest
$ adb shell am get-current-user
10
$ adb shell cmd account set-bind-instant-service-allowed true
$ adb shell cmd account get-bind-instant-service-allowed
true
$ adb shell cmd account get-bind-instant-service-allowed --user 0
false
$ adb shell cmd account get-bind-instant-service-allowed --user 10
true
$ adb shell cmd account set-bind-instant-service-allowed false
$ adb shell cmd account get-bind-instant-service-allowed --user 10
false

Change-Id: Ic4d4ce411f4471ea1b02e93f6a05857efc7287a8
parent ffd30331
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.accounts;

import android.annotation.NonNull;
import android.app.ActivityManager;
import android.os.ShellCommand;
import android.os.UserHandle;

@@ -83,7 +84,7 @@ final class AccountManagerServiceShellCommand extends ShellCommand {
                return null;
            }
        }
        return UserHandle.USER_SYSTEM;
        return ActivityManager.getCurrentUser();
    }

    @Override
@@ -92,9 +93,11 @@ final class AccountManagerServiceShellCommand extends ShellCommand {
        pw.println("Account manager service commands:");
        pw.println("  help");
        pw.println("    Print this help text.");
        pw.println("  set-bind-instant-service-allowed [--user <USER_ID>] true|false ");
        pw.println("  set-bind-instant-service-allowed "
                + "[--user <USER_ID> (current user if not specified)] true|false ");
        pw.println("    Set whether binding to services provided by instant apps is allowed.");
        pw.println("  get-bind-instant-service-allowed [--user <USER_ID>]");
        pw.println("  get-bind-instant-service-allowed "
                + "[--user <USER_ID> (current user if not specified)]");
        pw.println("    Get whether binding to services provided by instant apps is allowed.");
    }
}