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

Commit 9c30e6bf authored by Jan Sebechlebsky's avatar Jan Sebechlebsky
Browse files

Override getDeviceId() of mock context

... to return DEVICE_ID_DEFAULT.

AudioManager uses device id of context to dispatch sound effects
asociated with virtual devices to virtual device manager and to
bypass audio focus request for playback on virtual devices with
custom audio policy.

DEVICE_ID_DEFAULT corresponds to default (non-virtual) device.

Bug: 267470284
Test: atest CreateConnectionProcessorTest
AOSP: Context#getDeviceId() is not yet merged in AOSP
Change-Id: I21d15d1077e8a7d45c0b48c673b8e668e263f9fc
parent 40286e50
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Executor;

import static android.companion.virtual.VirtualDeviceManager.DEVICE_ID_DEFAULT;

import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.matches;
import static org.mockito.ArgumentMatchers.nullable;
@@ -540,6 +542,11 @@ public class ComponentContextFixture implements TestFixture<Context> {
        public Resources getResources() {
            return mResources;
        }

        @Override
        public int getDeviceId() {
          return DEVICE_ID_DEFAULT;
        }
    };

    // The application context is the most important object this class provides to the system