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

Commit dd18a0b6 authored by Ruben Brunk's avatar Ruben Brunk
Browse files

Add a framework service tracking VR mode state.

- Implement a "VR mode" that may be enabled by a focused Activity.
- Add a system service that tracks the current VR mode state and notifies
  other core framework services of mode changes.
- Extend NotificationListenerService to allow the bind/unbind lifecycle
  of specified listeners to be triggered by system events.

Bug: 22855417
Bug: 25479708

Change-Id: I1ac8692bbb5521bb6c7cfb9d2b56b98b720f8568
parent bf0bbc87
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3538,6 +3538,7 @@ package android.app {
    method public deprecated void setTitleColor(int);
    method public void setVisible(boolean);
    method public final void setVolumeControlStream(int);
    method public void setVrMode(boolean);
    method public boolean shouldShowRequestPermissionRationale(java.lang.String);
    method public boolean shouldUpRecreateTask(android.content.Intent);
    method public boolean showAssist(android.os.Bundle);
@@ -8989,6 +8990,7 @@ package android.content.pm {
    field public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 8; // 0x8
    field public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 8192; // 0x2000
    field public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 4; // 0x4
    field public static final int FLAG_ENABLE_VR_MODE = 32768; // 0x8000
    field public static final int FLAG_EXCLUDE_FROM_RECENTS = 32; // 0x20
    field public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 256; // 0x100
    field public static final int FLAG_FINISH_ON_TASK_LAUNCH = 2; // 0x2
@@ -9552,6 +9554,7 @@ package android.content.pm {
    field public static final java.lang.String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
    field public static final java.lang.String FEATURE_USB_HOST = "android.hardware.usb.host";
    field public static final java.lang.String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
    field public static final java.lang.String FEATURE_VR_MODE = "android.software.vr.mode";
    field public static final java.lang.String FEATURE_WATCH = "android.hardware.type.watch";
    field public static final java.lang.String FEATURE_WEBVIEW = "android.software.webview";
    field public static final java.lang.String FEATURE_WIFI = "android.hardware.wifi";
@@ -33243,6 +33246,7 @@ package android.service.notification {
    method public final void requestInterruptionFilter(int);
    method public final void requestListenerHints(int);
    method public final void setNotificationsShown(java.lang.String[]);
    field public static final java.lang.String CATEGORY_VR_NOTIFICATIONS = "android.intent.category.vr.notifications";
    field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
    field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
    field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
+4 −0
Original line number Diff line number Diff line
@@ -3643,6 +3643,7 @@ package android.app {
    method public deprecated void setTitleColor(int);
    method public void setVisible(boolean);
    method public final void setVolumeControlStream(int);
    method public void setVrMode(boolean);
    method public boolean shouldShowRequestPermissionRationale(java.lang.String);
    method public boolean shouldUpRecreateTask(android.content.Intent);
    method public boolean showAssist(android.os.Bundle);
@@ -9257,6 +9258,7 @@ package android.content.pm {
    field public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 8; // 0x8
    field public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 8192; // 0x2000
    field public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 4; // 0x4
    field public static final int FLAG_ENABLE_VR_MODE = 32768; // 0x8000
    field public static final int FLAG_EXCLUDE_FROM_RECENTS = 32; // 0x20
    field public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 256; // 0x100
    field public static final int FLAG_FINISH_ON_TASK_LAUNCH = 2; // 0x2
@@ -9869,6 +9871,7 @@ package android.content.pm {
    field public static final java.lang.String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
    field public static final java.lang.String FEATURE_USB_HOST = "android.hardware.usb.host";
    field public static final java.lang.String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
    field public static final java.lang.String FEATURE_VR_MODE = "android.software.vr.mode";
    field public static final java.lang.String FEATURE_WATCH = "android.hardware.type.watch";
    field public static final java.lang.String FEATURE_WEBVIEW = "android.software.webview";
    field public static final java.lang.String FEATURE_WIFI = "android.hardware.wifi";
@@ -35389,6 +35392,7 @@ package android.service.notification {
    method public final void setNotificationsShown(java.lang.String[]);
    method public final void setOnNotificationPostedTrim(int);
    method public void unregisterAsSystemService() throws android.os.RemoteException;
    field public static final java.lang.String CATEGORY_VR_NOTIFICATIONS = "android.intent.category.vr.notifications";
    field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
    field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
    field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
+4 −0
Original line number Diff line number Diff line
@@ -3538,6 +3538,7 @@ package android.app {
    method public deprecated void setTitleColor(int);
    method public void setVisible(boolean);
    method public final void setVolumeControlStream(int);
    method public void setVrMode(boolean);
    method public boolean shouldShowRequestPermissionRationale(java.lang.String);
    method public boolean shouldUpRecreateTask(android.content.Intent);
    method public boolean showAssist(android.os.Bundle);
@@ -8989,6 +8990,7 @@ package android.content.pm {
    field public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 8; // 0x8
    field public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 8192; // 0x2000
    field public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 4; // 0x4
    field public static final int FLAG_ENABLE_VR_MODE = 32768; // 0x8000
    field public static final int FLAG_EXCLUDE_FROM_RECENTS = 32; // 0x20
    field public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 256; // 0x100
    field public static final int FLAG_FINISH_ON_TASK_LAUNCH = 2; // 0x2
@@ -9552,6 +9554,7 @@ package android.content.pm {
    field public static final java.lang.String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
    field public static final java.lang.String FEATURE_USB_HOST = "android.hardware.usb.host";
    field public static final java.lang.String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
    field public static final java.lang.String FEATURE_VR_MODE = "android.software.vr.mode";
    field public static final java.lang.String FEATURE_WATCH = "android.hardware.type.watch";
    field public static final java.lang.String FEATURE_WEBVIEW = "android.software.webview";
    field public static final java.lang.String FEATURE_WIFI = "android.hardware.wifi";
@@ -33245,6 +33248,7 @@ package android.service.notification {
    method public final void requestInterruptionFilter(int);
    method public final void requestListenerHints(int);
    method public final void setNotificationsShown(java.lang.String[]);
    field public static final java.lang.String CATEGORY_VR_NOTIFICATIONS = "android.intent.category.vr.notifications";
    field public static final int HINT_HOST_DISABLE_EFFECTS = 1; // 0x1
    field public static final int INTERRUPTION_FILTER_ALARMS = 4; // 0x4
    field public static final int INTERRUPTION_FILTER_ALL = 1; // 0x1
+16 −0
Original line number Diff line number Diff line
@@ -6021,6 +6021,22 @@ public class Activity extends ContextThemeWrapper
        }
    }

    /**
     * Enable or disable virtual reality (VR) mode.
     *
     * <p>VR mode is a hint to Android system services to switch to modes optimized for
     * high-performance stereoscopic rendering.</p>
     *
     * @param enabled {@code true} to enable this mode.
     */
    public void setVrMode(boolean enabled) {
        try {
            ActivityManagerNative.getDefault().setVrMode(mToken, enabled);
        } catch (RemoteException e) {
            // pass
        }
    }

    /**
     * Start an action mode of the default type {@link ActionMode#TYPE_PRIMARY}.
     *
+20 −0
Original line number Diff line number Diff line
@@ -2766,6 +2766,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeNoException();
            return true;
        }
        case SET_VR_MODE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final IBinder token = data.readStrongBinder();
            final boolean enable = data.readInt() == 1;
            setVrMode(token, enable);
            reply.writeNoException();
            return true;
        }
        }

        return super.onTransact(code, data, reply, flags);
@@ -5896,6 +5904,18 @@ class ActivityManagerProxy implements IActivityManager
        return res;
    }

    public void setVrMode(IBinder token, boolean enabled) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        data.writeInt(enabled ? 1 : 0);
        mRemote.transact(SET_VR_MODE_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public IActivityContainer createStackOnDisplay(int displayId) throws RemoteException {
        Parcel data = Parcel.obtain();
Loading