Fullscreen support in VDM Client
Replacing the host's immersive mode. Volume down goes back
to the main activity. Supports rotation.
Adding pause/resume for all displays so we don't send frames
when the client activity is not in foreground.
Fixing the key event dispatch, so the top focused display has
first dibs but if not tracking focus, the event reaches the client
app.
Fixing the IFTTT paths because they don't seem to work like in g3.
Fix: 314729842
Test: manual
Change-Id: I153c595e688b79339b3b9db9936e4cc33ccef487
diff --git a/samples/VirtualDeviceManager/README.md b/samples/VirtualDeviceManager/README.md
index 35133d1..645991d 100644
--- a/samples/VirtualDeviceManager/README.md
+++ b/samples/VirtualDeviceManager/README.md
@@ -131,6 +131,12 @@
the display of the streamed activity. The "Resize" button can be used to
change the display dimensions.
+1. Each display on the Client app has a "Fullscreen" button which will move
+ the contents of that display to an immersive fullscreen activity. The
+ client's back button/gestures are sent back to the streamed app. Use
+ Volume Down on the client device to exit fullscreen. Volume Up acts as a
+ home key, if the streamed display is a home display.
+
1. The Host app has a "CREATE HOME DISPLAY" button, clicking it will create a
new virtual display, launch the secondary home activity there and start
streaming the display contents to the client. The display on the Client app
@@ -211,12 +217,6 @@
input pointer devices. \
*This can be changed dynamically.*
-- **Immersive mode**: Makes the streamed activities fullscreen on the client
- device. The client's back button/gesture results in sending back to the
- streamed app and Volume Up acts as a home key, if the streamed display is a
- home display. Use Volume Down on the client device to exit the activity. \
- *Changing this will recreate the virtual device.*
-
- **Custom home**: Whether to use a custom activity as home on home displays,
or use the device-default secondary home activity. Run the command below to
enable this functionality. \
@@ -226,7 +226,7 @@
adb shell device_config put virtual_devices android.companion.virtual.flags.vdm_custom_home true
```
-<!-- LINT.ThenChange() -->
+<!-- LINT.ThenChange(/samples/VirtualDeviceManager/host/res/menu/settings.xml) -->
<!-- LINT.IfChange(client_settings) -->
## Client Settings
@@ -246,7 +246,7 @@
from a keyboard or mouse, which is externally connected to the client device
to the activity on the focused display.
-<!-- LINT.ThenChange() -->
+<!-- LINT.ThenChange(/samples/VirtualDeviceManager/client/res/menu/settings.xml) -->
<!-- LINT.IfChange(demos) -->
## Demos
@@ -279,4 +279,4 @@
is no vibration support on virtual devices, so vibration requests from
streamed activities are ignored.
-<!-- LINT.ThenChange() -->
+<!-- LINT.ThenChange(/samples/VirtualDeviceManager/demos/AndroidManifest.xml) -->
diff --git a/samples/VirtualDeviceManager/client/AndroidManifest.xml b/samples/VirtualDeviceManager/client/AndroidManifest.xml
index f3624c7..4fb9a33 100644
--- a/samples/VirtualDeviceManager/client/AndroidManifest.xml
+++ b/samples/VirtualDeviceManager/client/AndroidManifest.xml
@@ -27,6 +27,7 @@
</activity>
<activity
android:name=".ImmersiveActivity"
+ android:configChanges="orientation|screenSize"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" />
</application>
</manifest>
diff --git a/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml b/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml
index 1907398..157b3a9 100644
--- a/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml
+++ b/samples/VirtualDeviceManager/client/res/layout/display_fragment.xml
@@ -61,6 +61,13 @@
android:src="@drawable/resize" />
<ImageButton
+ android:id="@+id/display_fullscreen"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@string/display_fullscreen"
+ android:src="@drawable/fullscreen" />
+
+ <ImageButton
android:id="@+id/display_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/samples/VirtualDeviceManager/client/res/menu/settings.xml b/samples/VirtualDeviceManager/client/res/menu/settings.xml
index e4b997f..36ba8e1 100644
--- a/samples/VirtualDeviceManager/client/res/menu/settings.xml
+++ b/samples/VirtualDeviceManager/client/res/menu/settings.xml
@@ -16,4 +16,4 @@
android:title="@string/enable_external_mouse" />
</group>
</menu>
-<!-- LINT.ThenChange(development/samples/VirtualDeviceManager/README.md:client_settings) -->
+<!-- LINT.ThenChange(/samples/VirtualDeviceManager/README.md:client_settings) -->
diff --git a/samples/VirtualDeviceManager/client/res/values/strings.xml b/samples/VirtualDeviceManager/client/res/values/strings.xml
index a14cd5e..b9f5f41 100644
--- a/samples/VirtualDeviceManager/client/res/values/strings.xml
+++ b/samples/VirtualDeviceManager/client/res/values/strings.xml
@@ -5,6 +5,7 @@
<string name="display_home" translatable="false">Home</string>
<string name="display_rotate" translatable="false">Rotate</string>
<string name="display_resize" translatable="false">Resize</string>
+ <string name="display_fullscreen" translatable="false">Fullscreen</string>
<string name="display_close" translatable="false">Close</string>
<string name="enable_dpad" translatable="false">Show dpad</string>
diff --git a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java
index 730e73d..d7268b9 100644
--- a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java
+++ b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/DisplayAdapter.java
@@ -17,9 +17,11 @@
package com.example.android.vdmdemo.client;
import android.annotation.SuppressLint;
+import android.content.Intent;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.util.Log;
+import android.view.Display;
import android.view.InputDevice;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -29,6 +31,8 @@
import android.view.ViewGroup;
import android.widget.TextView;
+import androidx.activity.result.ActivityResult;
+import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
@@ -43,6 +47,7 @@
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
final class DisplayAdapter extends RecyclerView.Adapter<DisplayHolder> {
private static final String TAG = "VdmClient";
@@ -56,6 +61,7 @@
private final RemoteIo mRemoteIo;
private final ClientView mRecyclerView;
private final InputManager mInputManager;
+ private ActivityResultLauncher<Intent> mFullscreenLauncher;
DisplayAdapter(ClientView recyclerView, RemoteIo remoteIo, InputManager inputManager) {
mRecyclerView = recyclerView;
@@ -64,6 +70,26 @@
setHasStableIds(true);
}
+ void setFullscreenLauncher(ActivityResultLauncher<Intent> launcher) {
+ mFullscreenLauncher = launcher;
+ }
+
+ void onFullscreenActivityResult(ActivityResult result) {
+ Intent data = result.getData();
+ if (data == null) {
+ return;
+ }
+ int displayId =
+ data.getIntExtra(ImmersiveActivity.EXTRA_DISPLAY_ID, Display.INVALID_DISPLAY);
+ if (result.getResultCode() == ImmersiveActivity.RESULT_CLOSE) {
+ removeDisplay(displayId);
+ } else if (result.getResultCode() == ImmersiveActivity.RESULT_MINIMIZE) {
+ int requestedRotation =
+ data.getIntExtra(ImmersiveActivity.EXTRA_REQUESTED_ROTATION, 0);
+ rotateDisplay(displayId, requestedRotation);
+ }
+ }
+
void addDisplay(boolean homeSupported) {
Log.i(TAG, "Adding display " + sNextDisplayIndex);
mDisplayRepository.add(
@@ -82,11 +108,10 @@
}
}
- void rotateDisplay(RemoteEvent event) {
- DisplayHolder holder = getDisplayHolder(event.getDisplayId());
+ void rotateDisplay(int displayId, int rotationDegrees) {
+ DisplayHolder holder = getDisplayHolder(displayId);
if (holder != null) {
- holder.rotateDisplay(
- event.getDisplayRotation().getRotationDegrees(), /* resize= */ false);
+ holder.rotateDisplay(rotationDegrees, /* resize= */ false);
}
}
@@ -104,6 +129,26 @@
notifyItemRangeRemoved(0, size);
}
+ void pauseAllDisplays() {
+ Log.i(TAG, "Pausing all displays");
+ forAllDisplays(DisplayHolder::pause);
+ }
+
+ void resumeAllDisplays() {
+ Log.i(TAG, "Resuming all displays");
+ forAllDisplays(DisplayHolder::resume);
+ }
+
+ private void forAllDisplays(Consumer<DisplayHolder> consumer) {
+ for (int i = 0; i < mDisplayRepository.size(); ++i) {
+ DisplayHolder holder =
+ (DisplayHolder) mRecyclerView.findViewHolderForAdapterPosition(i);
+ if (holder != null) {
+ consumer.accept(holder);
+ }
+ }
+ }
+
private DisplayHolder getDisplayHolder(int displayId) {
for (int i = 0; i < mDisplayRepository.size(); ++i) {
if (displayId == mDisplayRepository.get(i).getDisplayId()) {
@@ -158,6 +203,9 @@
}
void rotateDisplay(int rotationDegrees, boolean resize) {
+ if (mTextureView.getRotation() == rotationDegrees) {
+ return;
+ }
Log.i(TAG, "Rotating display " + mDisplayId + " to " + rotationDegrees);
mRotateButton.setEnabled(rotationDegrees == 0 || resize);
@@ -214,6 +262,15 @@
}
}
+ void pause() {
+ mDisplayController.pause();
+ }
+
+ void resume() {
+ mDisplayController.setSurface(
+ mSurface, mTextureView.getWidth(), mTextureView.getHeight());
+ }
+
@SuppressLint("ClickableViewAccessibility")
void onBind(int position) {
RemoteDisplay remoteDisplay = mDisplayRepository.get(position);
@@ -278,6 +335,13 @@
return true;
});
+ View fullscreenButton = itemView.requireViewById(R.id.display_fullscreen);
+ fullscreenButton.setOnClickListener(v -> {
+ Intent intent = new Intent(v.getContext(), ImmersiveActivity.class);
+ intent.putExtra(ImmersiveActivity.EXTRA_DISPLAY_ID, mDisplayId);
+ mFullscreenLauncher.launch(intent);
+ });
+
mTextureView.setOnTouchListener(
(v, event) -> {
if (event.getDevice().supportsSource(InputDevice.SOURCE_TOUCHSCREEN)) {
diff --git a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/ImmersiveActivity.java b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/ImmersiveActivity.java
index 6da311e..af13791 100644
--- a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/ImmersiveActivity.java
+++ b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/ImmersiveActivity.java
@@ -16,11 +16,13 @@
package com.example.android.vdmdemo.client;
-import static android.view.Display.DEFAULT_DISPLAY;
-
import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.content.res.Configuration;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
+import android.util.Log;
+import android.view.Display;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.Surface;
@@ -50,6 +52,14 @@
@AndroidEntryPoint(AppCompatActivity.class)
public class ImmersiveActivity extends Hilt_ImmersiveActivity {
+ private static final String TAG = "VdmClientImmersiveActivity";
+
+ static final String EXTRA_DISPLAY_ID = "displayId";
+ static final String EXTRA_REQUESTED_ROTATION = "requestedRotation";
+
+ static final int RESULT_MINIMIZE = 1;
+ static final int RESULT_CLOSE = 2;
+
// Approximately, see
// https://developer.android.com/reference/android/util/DisplayMetrics#density
private static final float DIP_TO_DPI = 160f;
@@ -60,7 +70,14 @@
@Inject AudioPlayer mAudioPlayer;
@Inject InputManager mInputManager;
+ private int mDisplayId = Display.INVALID_DISPLAY;
private DisplayController mDisplayController;
+ private Surface mSurface;
+
+ private int mPortraitWidth;
+ private int mPortraitHeight;
+ private int mRequestedRotation = 0;
+
private final Consumer<RemoteEvent> mRemoteEventConsumer = this::processRemoteEvent;
private final ConnectionManager.ConnectionCallback mConnectionCallback =
@@ -68,7 +85,7 @@
@Override
public void onDisconnected() {
- finish();
+ finish(/* minimize= */ false);
}
};
@@ -85,16 +102,18 @@
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
+ mDisplayId = getIntent().getIntExtra(EXTRA_DISPLAY_ID, Display.INVALID_DISPLAY);
+
OnBackPressedCallback callback =
new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
- mInputManager.sendBack(DEFAULT_DISPLAY);
+ mInputManager.sendBack(mDisplayId);
}
};
getOnBackPressedDispatcher().addCallback(this, callback);
- mDisplayController = new DisplayController(DEFAULT_DISPLAY, mRemoteIo);
+ mDisplayController = new DisplayController(mDisplayId, mRemoteIo);
mDisplayController.setDpi((int) (getResources().getDisplayMetrics().density * DIP_TO_DPI));
TextureView textureView = requireViewById(R.id.immersive_surface_view);
@@ -103,7 +122,7 @@
if (event.getDevice().supportsSource(InputDevice.SOURCE_TOUCHSCREEN)) {
textureView.getParent().requestDisallowInterceptTouchEvent(true);
mInputManager.sendInputEvent(
- InputDeviceType.DEVICE_TYPE_TOUCHSCREEN, event, DEFAULT_DISPLAY);
+ InputDeviceType.DEVICE_TYPE_TOUCHSCREEN, event, mDisplayId);
}
return true;
});
@@ -115,11 +134,16 @@
@Override
public void onSurfaceTextureAvailable(
@NonNull SurfaceTexture texture, int width, int height) {
- mDisplayController.setSurface(new Surface(texture), width, height);
+ Log.v(TAG, "Setting surface for immersive display " + mDisplayId);
+ mSurface = new Surface(texture);
+ mPortraitWidth = Math.min(width, height);
+ mPortraitHeight = Math.max(width, height);
+ mDisplayController.setSurface(mSurface, width, height);
}
@Override
public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture texture) {
+ Log.v(TAG, "onSurfaceTextureDestroyed for immersive display " + mDisplayId);
return true;
}
@@ -127,6 +151,16 @@
public void onSurfaceTextureSizeChanged(
@NonNull SurfaceTexture texture, int width, int height) {}
});
+ textureView.setOnGenericMotionListener(
+ (v, event) -> {
+ if (event.getDevice() == null
+ || !event.getDevice().supportsSource(InputDevice.SOURCE_MOUSE)) {
+ return false;
+ }
+ mInputManager.sendInputEvent(
+ InputDeviceType.DEVICE_TYPE_MOUSE, event, mDisplayId);
+ return true;
+ });
}
@Override
@@ -148,33 +182,54 @@
@Override
protected void onDestroy() {
super.onDestroy();
- mDisplayController.close();
mSensorController.close();
}
private void processRemoteEvent(RemoteEvent event) {
- if (event.hasStopStreaming() && !event.getStopStreaming().getPause()) {
- finish();
- } else if (event.hasStartStreaming()) {
- mDisplayController.sendDisplayCapabilities();
+ if (event.hasStopStreaming()) {
+ finish(/* minimize= */ false);
+ } else if (event.hasDisplayRotation()) {
+ mRequestedRotation = event.getDisplayRotation().getRotationDegrees();
}
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- int keyCode = event.getKeyCode();
- switch (keyCode) {
- case KeyEvent.KEYCODE_VOLUME_UP -> {
- mInputManager.sendHome(DEFAULT_DISPLAY);
- return true;
- }
- case KeyEvent.KEYCODE_VOLUME_DOWN -> {
- finish();
- return true;
- }
- default -> {
+ switch (event.getKeyCode()) {
+ case KeyEvent.KEYCODE_VOLUME_UP -> mInputManager.sendHome(mDisplayId);
+ case KeyEvent.KEYCODE_VOLUME_DOWN -> finish(/* minimize= */ true);
+ case KeyEvent.KEYCODE_BACK -> {
return super.dispatchKeyEvent(event);
}
+ default -> mInputManager.sendInputEvent(
+ InputDeviceType.DEVICE_TYPE_KEYBOARD, event, mDisplayId);
}
+ return true;
+ }
+
+ @Override
+ public void onConfigurationChanged(@NonNull Configuration config) {
+ super.onConfigurationChanged(config);
+ if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ Log.d(TAG, "Switching landscape");
+ mDisplayController.setSurface(
+ mSurface, /* width= */ mPortraitHeight, /* height= */ mPortraitWidth);
+ } else if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
+ Log.d(TAG, "Switching to portrait");
+ mDisplayController.setSurface(mSurface, mPortraitWidth, mPortraitHeight);
+ }
+ }
+
+ private void finish(boolean minimize) {
+ if (minimize) {
+ mDisplayController.close();
+ } else {
+ mDisplayController.pause();
+ }
+ Intent result = new Intent();
+ result.putExtra(EXTRA_DISPLAY_ID, mDisplayId);
+ result.putExtra(EXTRA_REQUESTED_ROTATION, mRequestedRotation);
+ setResult(minimize ? RESULT_MINIMIZE : RESULT_CLOSE, result);
+ finish();
}
}
diff --git a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/InputManager.java b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/InputManager.java
index e9ab864..b752f7a 100644
--- a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/InputManager.java
+++ b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/InputManager.java
@@ -148,39 +148,41 @@
/**
* Injects {@link InputEvent} for the given {@link InputDeviceType} into the focused display.
+ *
+ * @return whether the event was sent.
*/
- public void sendInputEventToFocusedDisplay(InputDeviceType deviceType, InputEvent inputEvent) {
- int targetDisplay;
+ public boolean sendInputEventToFocusedDisplay(
+ InputDeviceType deviceType, InputEvent inputEvent) {
+ int targetDisplayId;
synchronized (mLock) {
if (!mIsTrackingFocus || mFocusedDisplayId == Display.INVALID_DISPLAY) {
- return;
+ return false;
}
- targetDisplay = mFocusedDisplayId;
+ targetDisplayId = mFocusedDisplayId;
}
switch (deviceType) {
case DEVICE_TYPE_NAVIGATION_TOUCHPAD:
if (!mSettings.navTouchpadEnabled) {
- return;
+ return false;
}
break;
case DEVICE_TYPE_DPAD:
if (!mSettings.dpadEnabled) {
- return;
+ return false;
}
break;
case DEVICE_TYPE_KEYBOARD:
if (!mSettings.externalKeyboardEnabled) {
- return;
+ return false;
}
break;
default:
- Log.e(
- TAG,
- "sendInputEventToFocusedDisplay got invalid device type "
- + deviceType.getNumber());
- return;
+ Log.e(TAG, "sendInputEventToFocusedDisplay got invalid device type "
+ + deviceType.getNumber());
+ return false;
}
- sendInputEvent(deviceType, inputEvent, targetDisplay);
+ sendInputEvent(deviceType, inputEvent, targetDisplayId);
+ return true;
}
void sendBack(int displayId) {
diff --git a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/MainActivity.java b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/MainActivity.java
index 6354ef9..7c570a6 100644
--- a/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/MainActivity.java
+++ b/samples/VirtualDeviceManager/client/src/com/example/android/vdmdemo/client/MainActivity.java
@@ -20,13 +20,14 @@
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
-import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -96,6 +97,11 @@
displaysView.setItemAnimator(null);
mDisplayAdapter = new DisplayAdapter(displaysView, mRemoteIo, mInputManager);
displaysView.setAdapter(mDisplayAdapter);
+
+ ActivityResultLauncher<Intent> fullscreenLauncher = registerForActivityResult(
+ new ActivityResultContracts.StartActivityForResult(),
+ mDisplayAdapter::onFullscreenActivityResult);
+ mDisplayAdapter.setFullscreenLauncher(fullscreenLauncher);
}
@Override
@@ -109,6 +115,18 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ mDisplayAdapter.resumeAllDisplays();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mDisplayAdapter.pauseAllDisplays();
+ }
+
+ @Override
public void onStop() {
super.onStop();
mInputManager.removeFocusListener(mFocusListener);
@@ -127,12 +145,9 @@
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- if (event.getDevice() == null
- || !event.getDevice().supportsSource(InputDevice.SOURCE_KEYBOARD)) {
- return false;
- }
- mInputManager.sendInputEventToFocusedDisplay(InputDeviceType.DEVICE_TYPE_KEYBOARD, event);
- return true;
+ return mInputManager.sendInputEventToFocusedDisplay(
+ InputDeviceType.DEVICE_TYPE_KEYBOARD, event)
+ || super.dispatchKeyEvent(event);
}
@Override
@@ -176,18 +191,13 @@
private void processRemoteEvent(RemoteEvent event) {
if (event.hasStartStreaming()) {
- if (event.getStartStreaming().getImmersive()) {
- startActivity(new Intent(this, ImmersiveActivity.class));
- } else {
- runOnUiThread(
- () ->
- mDisplayAdapter.addDisplay(
- event.getStartStreaming().getHomeEnabled()));
- }
+ runOnUiThread(
+ () -> mDisplayAdapter.addDisplay(event.getStartStreaming().getHomeEnabled()));
} else if (event.hasStopStreaming()) {
runOnUiThread(() -> mDisplayAdapter.removeDisplay(event.getDisplayId()));
} else if (event.hasDisplayRotation()) {
- runOnUiThread(() -> mDisplayAdapter.rotateDisplay(event));
+ runOnUiThread(() -> mDisplayAdapter.rotateDisplay(
+ event.getDisplayId(), event.getDisplayRotation().getRotationDegrees()));
} else if (event.hasDisplayChangeEvent()) {
runOnUiThread(() -> mDisplayAdapter.processDisplayChange(event));
}
diff --git a/samples/VirtualDeviceManager/common/proto/remote_event.proto b/samples/VirtualDeviceManager/common/proto/remote_event.proto
index 37cc789..12750f6 100644
--- a/samples/VirtualDeviceManager/common/proto/remote_event.proto
+++ b/samples/VirtualDeviceManager/common/proto/remote_event.proto
@@ -66,7 +66,6 @@
message StartStreaming {
bool home_enabled = 1;
- bool immersive = 2;
}
message StopStreaming {
diff --git a/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java b/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java
index f0660c5..15343bb 100644
--- a/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java
+++ b/samples/VirtualDeviceManager/common/src/com/example/android/vdmdemo/common/ConnectivityFragment.java
@@ -28,8 +28,6 @@
import dagger.hilt.android.AndroidEntryPoint;
-import java.util.Objects;
-
import javax.inject.Inject;
/** Fragment that holds the connectivity status UI. */
@@ -72,7 +70,7 @@
public void onViewCreated(@NonNull View view, Bundle bundle) {
super.onViewCreated(view, bundle);
- mStatus = Objects.requireNonNull(getActivity()).requireViewById(R.id.connection_status);
+ mStatus = requireActivity().requireViewById(R.id.connection_status);
TypedValue background = new TypedValue();
getActivity()
@@ -105,7 +103,7 @@
}
private void updateStatus(int backgroundColor, int resId, Object... formatArgs) {
- Activity activity = Objects.requireNonNull(getActivity());
+ Activity activity = requireActivity();
activity.runOnUiThread(() -> {
mStatus.setText(activity.getString(resId, formatArgs));
mStatus.setBackgroundColor(backgroundColor);
diff --git a/samples/VirtualDeviceManager/demos/AndroidManifest.xml b/samples/VirtualDeviceManager/demos/AndroidManifest.xml
index ba65424..f13f887 100644
--- a/samples/VirtualDeviceManager/demos/AndroidManifest.xml
+++ b/samples/VirtualDeviceManager/demos/AndroidManifest.xml
@@ -72,5 +72,5 @@
android:label="@string/vibration_demo" />
</application>
- <!-- LINT.ThenChange(development/samples/VirtualDeviceManager/README.md:demos) -->
+ <!-- LINT.ThenChange(/samples/VirtualDeviceManager/README.md:demos) -->
</manifest>
\ No newline at end of file
diff --git a/samples/VirtualDeviceManager/host/res/menu/settings.xml b/samples/VirtualDeviceManager/host/res/menu/settings.xml
index 3e2b704..698376f 100644
--- a/samples/VirtualDeviceManager/host/res/menu/settings.xml
+++ b/samples/VirtualDeviceManager/host/res/menu/settings.xml
@@ -30,11 +30,8 @@
android:id="@+id/show_pointer_icon"
android:title="@string/show_pointer_icon" />
<item
- android:id="@+id/immersive_mode"
- android:title="@string/immersive_mode" />
- <item
android:id="@+id/custom_home"
android:title="@string/custom_home" />
</group>
</menu>
-<!-- LINT.ThenChange(development/samples/VirtualDeviceManager/README.md:host_settings) -->
+<!-- LINT.ThenChange(/samples/VirtualDeviceManager/README.md:host_settings) -->
diff --git a/samples/VirtualDeviceManager/host/res/values/strings.xml b/samples/VirtualDeviceManager/host/res/values/strings.xml
index f1433f1..d8966ff 100644
--- a/samples/VirtualDeviceManager/host/res/values/strings.xml
+++ b/samples/VirtualDeviceManager/host/res/values/strings.xml
@@ -14,6 +14,5 @@
<string name="use_device_streaming" translatable="false">Device streaming profile</string>
<string name="record_encoder_output" translatable="false">Record encoder output</string>
<string name="show_pointer_icon" translatable="false">Show pointer icon</string>
- <string name="immersive_mode" translatable="false">Immersive mode</string>
<string name="custom_home" translatable="false">Custom home</string>
</resources>
\ No newline at end of file
diff --git a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/MainActivity.java b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/MainActivity.java
index 01247ce..f594e74 100644
--- a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/MainActivity.java
+++ b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/MainActivity.java
@@ -107,12 +107,7 @@
if (intent == null || mVdmService == null) {
return;
}
- int[] remoteDisplayIds = mVdmService.getRemoteDisplayIds();
- if (mSettings.immersiveMode && remoteDisplayIds.length > 0) {
- mVdmService.startIntentOnDisplayIndex(intent, 0);
- } else {
- mVdmService.startStreaming(intent);
- }
+ mVdmService.startStreaming(intent);
});
mLauncher.setOnItemLongClickListener(
(parent, v, position, id) -> {
@@ -123,8 +118,6 @@
int[] remoteDisplayIds = mVdmService.getRemoteDisplayIds();
if (remoteDisplayIds.length == 0) {
mVdmService.startStreaming(intent);
- } else if (mSettings.immersiveMode) {
- mVdmService.startIntentOnDisplayIndex(intent, 0);
} else {
String[] displays = new String[remoteDisplayIds.length + 1];
for (int i = 0; i < remoteDisplayIds.length; ++i) {
@@ -224,9 +217,6 @@
case R.id.show_pointer_icon:
item.setChecked(mSettings.showPointerIcon);
break;
- case R.id.immersive_mode:
- item.setChecked(mSettings.immersiveMode);
- break;
case R.id.record_encoder_output:
item.setChecked(mSettings.recordEncoderOutput);
break;
@@ -270,9 +260,6 @@
case R.id.show_pointer_icon:
mVdmService.setShowPointerIcon(item.isChecked());
return true;
- case R.id.immersive_mode:
- mVdmService.setImmersiveMode(item.isChecked());
- return true;
case R.id.custom_home:
mVdmService.setCustomHome(item.isChecked());
return true;
diff --git a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/Settings.java b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/Settings.java
index 7628e18..0eaebc5 100644
--- a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/Settings.java
+++ b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/Settings.java
@@ -30,7 +30,6 @@
public boolean alwaysUnlocked = true;
public boolean deviceStreaming = false;
public boolean showPointerIcon = true;
- public boolean immersiveMode = false;
public boolean customHome = false;
/**
diff --git a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/VdmService.java b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/VdmService.java
index deea509..114dd0f 100644
--- a/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/VdmService.java
+++ b/samples/VirtualDeviceManager/host/src/com/example/android/vdmdemo/host/VdmService.java
@@ -423,16 +423,8 @@
void startStreamingHome() {
mPendingRemoteIntent = null;
mPendingHome = true;
- if (mSettings.immersiveMode) {
- mDisplayRepository.clear();
- }
- mRemoteIo.sendMessage(
- RemoteEvent.newBuilder()
- .setStartStreaming(
- StartStreaming.newBuilder()
- .setHomeEnabled(true)
- .setImmersive(mSettings.immersiveMode))
- .build());
+ mRemoteIo.sendMessage(RemoteEvent.newBuilder()
+ .setStartStreaming(StartStreaming.newBuilder().setHomeEnabled(true)).build());
}
void startMirroring() {
@@ -445,10 +437,7 @@
void startStreaming(Intent intent) {
mPendingRemoteIntent = intent;
mRemoteIo.sendMessage(
- RemoteEvent.newBuilder()
- .setStartStreaming(
- StartStreaming.newBuilder().setImmersive(mSettings.immersiveMode))
- .build());
+ RemoteEvent.newBuilder().setStartStreaming(StartStreaming.newBuilder()).build());
}
void startIntentOnDisplayIndex(Intent intent, int displayIndex) {
@@ -511,10 +500,6 @@
}
}
- void setImmersiveMode(boolean enabled) {
- recreateVirtualDevice(() -> mSettings.immersiveMode = enabled);
- }
-
void setCustomHome(boolean enabled) {
recreateVirtualDevice(() -> mSettings.customHome = enabled);
}
diff --git a/samples/VirtualDeviceManager/setup.sh b/samples/VirtualDeviceManager/setup.sh
index 390e09c..4de6389 100755
--- a/samples/VirtualDeviceManager/setup.sh
+++ b/samples/VirtualDeviceManager/setup.sh
@@ -96,7 +96,7 @@
if [[ -n "${HOST_SERIAL}" ]]; then
echo
echo "Installing VdmDemos.apk to ${HOST_NAME}..."
- install_app "${CLIENT_SERIAL}" "${OUT}/system/app/VdmDemos/VdmDemos.apk" demos
+ install_app "${HOST_SERIAL}" "${OUT}/system/app/VdmDemos/VdmDemos.apk" demos
echo
readonly PERM_BASENAME=com.example.android.vdmdemo.host.xml