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

Commit 76d7e216 authored by Jan Sebechlebsky's avatar Jan Sebechlebsky
Browse files

Fix handling shell command when no argument is given.

```
adb shell cmd virtual_camera
```

Bug: 301023410
Test: atest virtual_camera_tests
Change-Id: Id7759525a2e1bbf1df7e53e4adbb287d60f73326
parent 3b6ad279
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -185,6 +185,8 @@ binder_status_t VirtualCameraService::handleShellCommand(int in, int out,
                                                         uint32_t numArgs) {
  if (numArgs <= 0) {
    dprintf(out, kShellCmdHelp);
    fsync(out);
    return STATUS_OK;
  }

  if (args == nullptr || args[0] == nullptr) {
+7 −0
Original line number Diff line number Diff line
@@ -267,6 +267,13 @@ TEST_F(VirtualCameraServiceTest, ShellCmdWithNullArgs) {
            STATUS_BAD_VALUE);
}

TEST_F(VirtualCameraServiceTest, ShellCmdWithNoArgs) {
  EXPECT_EQ(mCameraService->handleShellCommand(
                /*in=*/mDevNullFd, /*out=*/mDevNullFd, /*err=*/mDevNullFd,
                /*args=*/nullptr, /*numArgs=*/0),
            STATUS_OK);
}

TEST_F(VirtualCameraServiceTest, TestCameraShellCmd) {
  execute_shell_command("enable_test_camera");