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

Commit 6689dc3b authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Support creation of self-managed associations in shell

So test VDM use cases may set it when creating a CDM association
via the CDM shell CMD. Otherwise some CDM APIs are impossible to
use because they throw if hte association is not self managed
(e.g. notifyDeviceAppeared)

Fix: 353764525
Flag: EXEMPT unfeasible
Test: n/a
Change-Id: Ifb69caf592d5a93ec01630ba86965058b4982764
parent 58dbc145
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -103,9 +103,10 @@ class CompanionDeviceShellCommand extends ShellCommand {
                    String packageName = getNextArgRequired();
                    String address = getNextArgRequired();
                    String deviceProfile = getNextArg();
                    boolean selfManaged = getNextBooleanArg();
                    final MacAddress macAddress = MacAddress.fromString(address);
                    mAssociationRequestsProcessor.createAssociation(userId, packageName, macAddress,
                            deviceProfile, deviceProfile, /* associatedDevice */ null, false,
                            deviceProfile, deviceProfile, /* associatedDevice */ null, selfManaged,
                            /* callback */ null, /* resultReceiver */ null);
                }
                break;
@@ -462,6 +463,17 @@ class CompanionDeviceShellCommand extends ShellCommand {
        }
    }

    private boolean getNextBooleanArg() {
        String arg = getNextArg();
        if (arg == null || "false".equalsIgnoreCase(arg)) {
            return false;
        } else if ("true".equalsIgnoreCase(arg)) {
            return Boolean.parseBoolean(arg);
        } else {
            throw new IllegalArgumentException("Expected a boolean argument but was: " + arg);
        }
    }

    @Override
    public void onHelp() {
        PrintWriter pw = getOutPrintWriter();
@@ -470,7 +482,7 @@ class CompanionDeviceShellCommand extends ShellCommand {
        pw.println("      Print this help text.");
        pw.println("  list USER_ID");
        pw.println("      List all Associations for a user.");
        pw.println("  associate USER_ID PACKAGE MAC_ADDRESS [DEVICE_PROFILE]");
        pw.println("  associate USER_ID PACKAGE MAC_ADDRESS [DEVICE_PROFILE] [SELF_MANAGED]");
        pw.println("      Create a new Association.");
        pw.println("  disassociate USER_ID PACKAGE MAC_ADDRESS");
        pw.println("      Remove an existing Association.");