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

Commit a46f1f70 authored by Ruben Brunk's avatar Ruben Brunk Committed by Android (Google) Code Review
Browse files

Merge "Notify VrListenerService when VR activity changes." into nyc-dev

parents 9bc6ba97 c7354fe2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -35022,6 +35022,7 @@ package android.service.vr {
    ctor public VrListenerService();
    method public static final boolean isVrModePackageEnabled(android.content.Context, android.content.ComponentName);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onCurrentVrActivityChanged(android.content.ComponentName);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.vr.VrListenerService";
  }
+1 −0
Original line number Diff line number Diff line
@@ -37565,6 +37565,7 @@ package android.service.vr {
    ctor public VrListenerService();
    method public static final boolean isVrModePackageEnabled(android.content.Context, android.content.ComponentName);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onCurrentVrActivityChanged(android.content.ComponentName);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.vr.VrListenerService";
  }
+1 −0
Original line number Diff line number Diff line
@@ -35093,6 +35093,7 @@ package android.service.vr {
    ctor public VrListenerService();
    method public static final boolean isVrModePackageEnabled(android.content.Context, android.content.ComponentName);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onCurrentVrActivityChanged(android.content.ComponentName);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.vr.VrListenerService";
  }
+4 −2
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package android.service.vr;

import android.content.ComponentName;

/** @hide */
oneway interface IVrListener {

    void focusedActivityChanged(in ComponentName component);
}
+43 −6
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@ import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;

/**
 * A service that is bound from the system while running in virtual reality (VR) mode.
@@ -55,19 +58,53 @@ public abstract class VrListenerService extends Service {
    @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
    public static final String SERVICE_INTERFACE = "android.service.vr.VrListenerService";

    /**
     * @hide
     */
    public static class VrListenerBinder extends IVrListener.Stub {
    private final Handler mHandler;

    private static final int MSG_ON_CURRENT_VR_ACTIVITY_CHANGED = 1;

    private final IVrListener.Stub mBinder = new IVrListener.Stub() {
        @Override
        public void focusedActivityChanged(ComponentName component) {
            mHandler.obtainMessage(MSG_ON_CURRENT_VR_ACTIVITY_CHANGED, component).sendToTarget();
        }
    };

    private final VrListenerBinder mBinder = new VrListenerBinder();
    private final class VrListenerHandler extends Handler {
        public VrListenerHandler(Looper looper) {
            super(looper);
        }

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_ON_CURRENT_VR_ACTIVITY_CHANGED: {
                    VrListenerService.this.onCurrentVrActivityChanged((ComponentName) msg.obj);
                } break;
            }
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    public VrListenerService() {
        mHandler = new VrListenerHandler(Looper.getMainLooper());
    }

    /**
     * Called when the current activity using VR mode is changed.
     * <p/>
     * This will be called immediately when this service is initially bound, but is
     * not guaranteed to be called before onUnbind.
     *
     * @param component the {@link ComponentName} of the new current VR activity.
     */
    public void onCurrentVrActivityChanged(ComponentName component) {
        // Override to implement
    }

    /**
     * Check if the given package is available to be enabled/disabled in VR mode settings.
     *
Loading