Rename Surface callback events to state

Surface Callback events were essentially communicating the state of the
surface. Rename the callback and the API to "state" instead of "event".

Bug: 217627954
Test: atest CtsPhotoPickerTest
Change-Id: Ic666f952248a9ca96b4160d38cb71f97240b3ac5
Merged-In: Ic666f952248a9ca96b4160d38cb71f97240b3ac5
diff --git a/apex/framework/java/android/provider/CloudMediaProvider.java b/apex/framework/java/android/provider/CloudMediaProvider.java
index 4feaa45..fa15563 100644
--- a/apex/framework/java/android/provider/CloudMediaProvider.java
+++ b/apex/framework/java/android/provider/CloudMediaProvider.java
@@ -22,7 +22,7 @@
 import static android.provider.CloudMediaProviderContract.EXTRA_LOOPING_PLAYBACK_ENABLED;
 import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_CONTROLLER;
 import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_CONTROLLER_AUDIO_MUTE_ENABLED;
-import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_EVENT_CALLBACK;
+import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_STATE_CALLBACK;
 import static android.provider.CloudMediaProviderContract.METHOD_CREATE_SURFACE_CONTROLLER;
 import static android.provider.CloudMediaProviderContract.METHOD_GET_ASYNC_CONTENT_PROVIDER;
 import static android.provider.CloudMediaProviderContract.METHOD_GET_MEDIA_COLLECTION_INFO;
@@ -342,12 +342,12 @@
      * <li> {@link CloudMediaProviderContract#EXTRA_LOOPING_PLAYBACK_ENABLED}
      * <li> {@link CloudMediaProviderContract#EXTRA_SURFACE_CONTROLLER_AUDIO_MUTE_ENABLED}
      * </ul>
-     * @param callback {@link CloudMediaSurfaceEventCallback} to send event updates for
+     * @param callback {@link CloudMediaSurfaceStateChangedCallback} to send state updates for
      *                 {@link Surface} to picker launched via {@link MediaStore#ACTION_PICK_IMAGES}
      */
     @Nullable
     public CloudMediaSurfaceController onCreateCloudMediaSurfaceController(@NonNull Bundle config,
-            @NonNull CloudMediaSurfaceEventCallback callback) {
+            @NonNull CloudMediaSurfaceStateChangedCallback callback) {
         return null;
     }
 
@@ -386,14 +386,14 @@
     private Bundle onCreateCloudMediaSurfaceController(@NonNull Bundle extras) {
         Objects.requireNonNull(extras);
 
-        final IBinder binder = extras.getBinder(EXTRA_SURFACE_EVENT_CALLBACK);
+        final IBinder binder = extras.getBinder(EXTRA_SURFACE_STATE_CALLBACK);
         if (binder == null) {
-            throw new IllegalArgumentException("Missing surface event callback");
+            throw new IllegalArgumentException("Missing surface state callback");
         }
 
-        final CloudMediaSurfaceEventCallback callback =
-                new CloudMediaSurfaceEventCallback(
-                        ICloudSurfaceEventCallback.Stub.asInterface(binder));
+        final CloudMediaSurfaceStateChangedCallback callback =
+                new CloudMediaSurfaceStateChangedCallback(
+                        ICloudMediaSurfaceStateChangedCallback.Stub.asInterface(binder));
         final Bundle config = new Bundle();
         config.putBoolean(EXTRA_LOOPING_PLAYBACK_ENABLED, DEFAULT_LOOPING_PLAYBACK_ENABLED);
         config.putBoolean(EXTRA_SURFACE_CONTROLLER_AUDIO_MUTE_ENABLED,
@@ -693,61 +693,61 @@
     }
 
     /**
-     * This class is used by {@link CloudMediaProvider} to send {@link Surface} event updates to
+     * This class is used by {@link CloudMediaProvider} to send {@link Surface} state updates to
      * picker launched via {@link MediaStore#ACTION_PICK_IMAGES}.
      *
      * @see MediaStore#ACTION_PICK_IMAGES
      */
-    public static final class CloudMediaSurfaceEventCallback {
+    public static final class CloudMediaSurfaceStateChangedCallback {
 
         /** {@hide} */
-        @IntDef(flag = true, prefix = { "PLAYBACK_EVENT_" }, value = {
-                PLAYBACK_EVENT_BUFFERING,
-                PLAYBACK_EVENT_READY,
-                PLAYBACK_EVENT_STARTED,
-                PLAYBACK_EVENT_PAUSED,
-                PLAYBACK_EVENT_COMPLETED,
-                PLAYBACK_EVENT_ERROR_RETRIABLE_FAILURE,
-                PLAYBACK_EVENT_ERROR_PERMANENT_FAILURE,
-                PLAYBACK_EVENT_MEDIA_SIZE_CHANGED
+        @IntDef(flag = true, prefix = { "PLAYBACK_STATE_" }, value = {
+                PLAYBACK_STATE_BUFFERING,
+                PLAYBACK_STATE_READY,
+                PLAYBACK_STATE_STARTED,
+                PLAYBACK_STATE_PAUSED,
+                PLAYBACK_STATE_COMPLETED,
+                PLAYBACK_STATE_ERROR_RETRIABLE_FAILURE,
+                PLAYBACK_STATE_ERROR_PERMANENT_FAILURE,
+                PLAYBACK_STATE_MEDIA_SIZE_CHANGED
         })
         @Retention(RetentionPolicy.SOURCE)
-        public @interface PlaybackEvent {}
+        public @interface PlaybackState {}
 
         /**
          * Constant to notify that the playback is buffering
          */
-        public static final int PLAYBACK_EVENT_BUFFERING = 1;
+        public static final int PLAYBACK_STATE_BUFFERING = 1;
 
         /**
          * Constant to notify that the playback is ready to be played
          */
-        public static final int PLAYBACK_EVENT_READY = 2;
+        public static final int PLAYBACK_STATE_READY = 2;
 
         /**
          * Constant to notify that the playback has started
          */
-        public static final int PLAYBACK_EVENT_STARTED = 3;
+        public static final int PLAYBACK_STATE_STARTED = 3;
 
         /**
          * Constant to notify that the playback is paused.
          */
-        public static final int PLAYBACK_EVENT_PAUSED = 4;
+        public static final int PLAYBACK_STATE_PAUSED = 4;
 
         /**
-         * Constant to notify that the playback event has completed
+         * Constant to notify that the playback has completed
          */
-        public static final int PLAYBACK_EVENT_COMPLETED = 5;
+        public static final int PLAYBACK_STATE_COMPLETED = 5;
 
         /**
          * Constant to notify that the playback has failed with a retriable error.
          */
-        public static final int PLAYBACK_EVENT_ERROR_RETRIABLE_FAILURE = 6;
+        public static final int PLAYBACK_STATE_ERROR_RETRIABLE_FAILURE = 6;
 
         /**
          * Constant to notify that the playback has failed with a permanent error.
          */
-        public static final int PLAYBACK_EVENT_ERROR_PERMANENT_FAILURE = 7;
+        public static final int PLAYBACK_STATE_ERROR_PERMANENT_FAILURE = 7;
 
         /**
          * Constant to notify that the media size is first known or has changed.
@@ -755,34 +755,34 @@
          * Pass the width and height of the media as a {@link Point} inside the {@link Bundle} with
          * {@link ContentResolver#EXTRA_SIZE} as the key.
          *
-         * @see CloudMediaSurfaceEventCallback#onPlaybackEvent(int, int, Bundle)
+         * @see CloudMediaSurfaceStateChangedCallback#setPlaybackState(int, int, Bundle)
          * @see MediaPlayer.OnVideoSizeChangedListener#onVideoSizeChanged(MediaPlayer, int, int)
          */
-        public static final int PLAYBACK_EVENT_MEDIA_SIZE_CHANGED = 8;
+        public static final int PLAYBACK_STATE_MEDIA_SIZE_CHANGED = 8;
 
-        private final ICloudSurfaceEventCallback mCallback;
+        private final ICloudMediaSurfaceStateChangedCallback mCallback;
 
-        CloudMediaSurfaceEventCallback (ICloudSurfaceEventCallback callback) {
+        CloudMediaSurfaceStateChangedCallback(ICloudMediaSurfaceStateChangedCallback callback) {
             mCallback = callback;
         }
 
         /**
-         * This is called to notify playback event update for a {@link Surface}
+         * This is called to notify playback state update for a {@link Surface}
          * on the picker launched via {@link MediaStore#ACTION_PICK_IMAGES}.
          *
          * @param surfaceId id which uniquely identifies a {@link Surface}
-         * @param playbackEventType playback event type to notify picker about
-         * @param playbackEventInfo {@link Bundle} which may contain extra information about the
-         *                          playback event, such as media size, progress/seek info or
+         * @param playbackState playback state to notify picker about
+         * @param playbackStateInfo {@link Bundle} which may contain extra information about the
+         *                          playback state, such as media size, progress/seek info or
          *                          details about errors.
          */
-        public void onPlaybackEvent(int surfaceId, @PlaybackEvent int playbackEventType,
-                @Nullable Bundle playbackEventInfo) {
+        public void setPlaybackState(int surfaceId, @PlaybackState int playbackState,
+                @Nullable Bundle playbackStateInfo) {
             try {
-                mCallback.onPlaybackEvent(surfaceId, playbackEventType, playbackEventInfo);
+                mCallback.setPlaybackState(surfaceId, playbackState, playbackStateInfo);
             } catch (Exception e) {
-                Log.w(TAG, "Failed to notify playback event (" + playbackEventType + ") for "
-                        + "surfaceId: " + surfaceId + " ; playbackEventInfo: " + playbackEventInfo,
+                Log.w(TAG, "Failed to notify playback state (" + playbackState + ") for "
+                        + "surfaceId: " + surfaceId + " ; playbackStateInfo: " + playbackStateInfo,
                         e);
             }
         }
diff --git a/apex/framework/java/android/provider/CloudMediaProviderContract.java b/apex/framework/java/android/provider/CloudMediaProviderContract.java
index bc19561..d30bbb5 100644
--- a/apex/framework/java/android/provider/CloudMediaProviderContract.java
+++ b/apex/framework/java/android/provider/CloudMediaProviderContract.java
@@ -607,15 +607,15 @@
             "android.provider.extra.SURFACE_CONTROLLER_AUDIO_MUTE_ENABLED";
 
     /**
-     * Gets surface event callback from picker launched via
+     * Gets surface state callback from picker launched via
      * {@link MediaStore#ACTION_PICK_IMAGES}).
      *
      * @see MediaStore#ACTION_PICK_IMAGES
      *
      * {@hide}
      */
-    public static final String EXTRA_SURFACE_EVENT_CALLBACK =
-            "android.provider.extra.SURFACE_EVENT_CALLBACK";
+    public static final String EXTRA_SURFACE_STATE_CALLBACK =
+            "android.provider.extra.SURFACE_STATE_CALLBACK";
 
     /**
      * Constant used to execute {@link CloudMediaProvider#onGetAsyncContentProvider()} via
diff --git a/apex/framework/java/android/provider/ICloudSurfaceEventCallback.aidl b/apex/framework/java/android/provider/ICloudMediaSurfaceStateChangedCallback.aidl
similarity index 74%
rename from apex/framework/java/android/provider/ICloudSurfaceEventCallback.aidl
rename to apex/framework/java/android/provider/ICloudMediaSurfaceStateChangedCallback.aidl
index 369da77..d557dd0 100644
--- a/apex/framework/java/android/provider/ICloudSurfaceEventCallback.aidl
+++ b/apex/framework/java/android/provider/ICloudMediaSurfaceStateChangedCallback.aidl
@@ -19,9 +19,9 @@
 import android.os.Bundle;
 
 /**
- * Interface through which Photo Picker receives playback events from the CloudMediaProviders
+ * Interface through which Photo Picker receives playback state updates from the CloudMediaProviders
  * @hide
  */
-interface ICloudSurfaceEventCallback {
-    void onPlaybackEvent(int surfaceId, int eventType, in Bundle eventInfo);
+interface ICloudMediaSurfaceStateChangedCallback {
+    void setPlaybackState(int surfaceId, int playbackState, in Bundle playbackStateInfo);
 }
diff --git a/src/com/android/providers/media/photopicker/PhotoPickerProvider.java b/src/com/android/providers/media/photopicker/PhotoPickerProvider.java
index 715a100..96b698c 100644
--- a/src/com/android/providers/media/photopicker/PhotoPickerProvider.java
+++ b/src/com/android/providers/media/photopicker/PhotoPickerProvider.java
@@ -17,10 +17,10 @@
 package com.android.providers.media.photopicker;
 
 import static android.provider.CloudMediaProviderContract.EXTRA_LOOPING_PLAYBACK_ENABLED;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_BUFFERING;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_COMPLETED;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_MEDIA_SIZE_CHANGED;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_READY;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_BUFFERING;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_COMPLETED;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_MEDIA_SIZE_CHANGED;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_READY;
 import static android.provider.CloudMediaProviderContract.MediaCollectionInfo;
 
 import android.annotation.DurationMillisLong;
@@ -169,7 +169,7 @@
     @Override
     @Nullable
     public CloudMediaSurfaceController onCreateCloudMediaSurfaceController(@Nullable Bundle config,
-            CloudMediaSurfaceEventCallback callback) {
+            CloudMediaSurfaceStateChangedCallback callback) {
         if (RemotePreviewHandler.isRemotePreviewEnabled()) {
             boolean enableLoop = config != null && config.getBoolean(EXTRA_LOOPING_PLAYBACK_ENABLED,
                     false);
@@ -213,7 +213,7 @@
                         BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS).build();
 
         private final Context mContext;
-        private final CloudMediaSurfaceEventCallback mCallback;
+        private final CloudMediaSurfaceStateChangedCallback mCallback;
         private final Handler mHandler = new Handler(Looper.getMainLooper());
         private final boolean mEnableLoop;
         private final Player.Listener mEventListener = new Player.Listener() {
@@ -223,15 +223,15 @@
 
                 switch (state) {
                     case Player.STATE_READY:
-                        mCallback.onPlaybackEvent(mCurrentSurfaceId, PLAYBACK_EVENT_READY,
+                        mCallback.setPlaybackState(mCurrentSurfaceId, PLAYBACK_STATE_READY,
                                 null);
                         return;
                     case Player.STATE_BUFFERING:
-                        mCallback.onPlaybackEvent(mCurrentSurfaceId, PLAYBACK_EVENT_BUFFERING,
+                        mCallback.setPlaybackState(mCurrentSurfaceId, PLAYBACK_STATE_BUFFERING,
                                 null);
                         return;
                     case Player.STATE_ENDED:
-                        mCallback.onPlaybackEvent(mCurrentSurfaceId, PLAYBACK_EVENT_COMPLETED,
+                        mCallback.setPlaybackState(mCurrentSurfaceId, PLAYBACK_STATE_COMPLETED,
                                 null);
                         return;
                     default:
@@ -243,7 +243,7 @@
                 Point size = new Point(videoSize.width, videoSize.height);
                 Bundle bundle = new Bundle();
                 bundle.putParcelable(ContentResolver.EXTRA_SIZE, size);
-                mCallback.onPlaybackEvent(mCurrentSurfaceId, PLAYBACK_EVENT_MEDIA_SIZE_CHANGED,
+                mCallback.setPlaybackState(mCurrentSurfaceId, PLAYBACK_STATE_MEDIA_SIZE_CHANGED,
                         bundle);
             }
         };
@@ -252,7 +252,7 @@
         private int mCurrentSurfaceId = -1;
 
         CloudMediaSurfaceControllerImpl(Context context, boolean enableLoop,
-                CloudMediaSurfaceEventCallback callback) {
+                CloudMediaSurfaceStateChangedCallback callback) {
             mCallback = callback;
             mContext = context;
             mEnableLoop = enableLoop;
diff --git a/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewHandler.java b/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewHandler.java
index 97bd8f3..17571f5 100644
--- a/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewHandler.java
+++ b/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewHandler.java
@@ -18,7 +18,7 @@
 
 import static android.provider.CloudMediaProviderContract.EXTRA_LOOPING_PLAYBACK_ENABLED;
 import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_CONTROLLER;
-import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_EVENT_CALLBACK;
+import static android.provider.CloudMediaProviderContract.EXTRA_SURFACE_STATE_CALLBACK;
 import static android.provider.CloudMediaProviderContract.METHOD_CREATE_SURFACE_CONTROLLER;
 
 import static com.android.providers.media.PickerUriResolver.createSurfaceControllerUri;
@@ -31,9 +31,9 @@
 import android.os.Looper;
 import android.os.RemoteException;
 import android.os.SystemProperties;
-import android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PlaybackEvent;
+import android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PlaybackState;
 import android.provider.ICloudMediaSurfaceController;
-import android.provider.ICloudSurfaceEventCallback;
+import android.provider.ICloudMediaSurfaceStateChangedCallback;
 import android.util.ArrayMap;
 import android.util.Log;
 import android.view.Surface;
@@ -63,8 +63,8 @@
     private final Map<String, SurfaceControllerProxy> mControllers =
             new ArrayMap<>();
     private final SurfaceHolder.Callback mSurfaceHolderCallback = new PreviewSurfaceCallback();
-    private final SurfaceEventCallbackWrapper mSurfaceEventCallbackWrapper =
-            new SurfaceEventCallbackWrapper();
+    private final SurfaceStateChangedCallbackWrapper mSurfaceStateChangedCallbackWrapper =
+            new SurfaceStateChangedCallbackWrapper();
     private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
     private final ItemPreviewState mCurrentPreviewState = new ItemPreviewState();
 
@@ -221,7 +221,7 @@
         Log.i(TAG, "Creating new SurfaceController for authority: " + authority);
         Bundle extras = new Bundle();
         extras.putBoolean(EXTRA_LOOPING_PLAYBACK_ENABLED, true);
-        extras.putBinder(EXTRA_SURFACE_EVENT_CALLBACK, mSurfaceEventCallbackWrapper);
+        extras.putBinder(EXTRA_SURFACE_STATE_CALLBACK, mSurfaceStateChangedCallbackWrapper);
         final Bundle surfaceControllerBundle = mContext.getContentResolver().call(
                 createSurfaceControllerUri(authority),
                 METHOD_CREATE_SURFACE_CONTROLLER, /* arg */ null, extras);
@@ -232,15 +232,18 @@
     }
 
     /**
-     * Wrapper class for {@link ICloudSurfaceEventCallback} interface implementation.
+     * Wrapper class for {@link android.provider.ICloudMediaSurfaceStateChangedCallback} interface
+     * implementation.
      */
-    private final class SurfaceEventCallbackWrapper extends ICloudSurfaceEventCallback.Stub {
+    private final class SurfaceStateChangedCallbackWrapper extends
+            ICloudMediaSurfaceStateChangedCallback.Stub {
 
         @Override
-        public void onPlaybackEvent(int surfaceId, @PlaybackEvent int eventType,
-                @Nullable Bundle eventInfo) {
+        public void setPlaybackState(int surfaceId, @PlaybackState int playbackState,
+                @Nullable Bundle playbackStateInfo) {
             Log.d(TAG, "Received onPlaybackEvent for surfaceId: " + surfaceId +
-                    " ; eventType: " + eventType + " ; eventInfo: " + eventInfo);
+                    " ; playbackState: " + playbackState + " ; playbackStateInfo: " +
+                    playbackStateInfo);
 
             mMainThreadHandler.post(() -> {
                 final RemotePreviewSession session = getSessionForSurfaceId(surfaceId);
@@ -248,7 +251,7 @@
                     Log.w(TAG, "No RemotePreviewSession found.");
                     return;
                 }
-                session.onPlaybackEvent(eventType, eventInfo);
+                session.setPlaybackState(playbackState, playbackStateInfo);
             });
         }
     }
diff --git a/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewSession.java b/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewSession.java
index 4d59708..92c11ce 100644
--- a/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewSession.java
+++ b/src/com/android/providers/media/photopicker/ui/remotepreview/RemotePreviewSession.java
@@ -16,11 +16,11 @@
 
 package com.android.providers.media.photopicker.ui.remotepreview;
 
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_ERROR_PERMANENT_FAILURE;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_ERROR_RETRIABLE_FAILURE;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_MEDIA_SIZE_CHANGED;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_PAUSED;
-import static android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PLAYBACK_EVENT_READY;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_ERROR_PERMANENT_FAILURE;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_ERROR_RETRIABLE_FAILURE;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_MEDIA_SIZE_CHANGED;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_PAUSED;
+import static android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PLAYBACK_STATE_READY;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -28,7 +28,7 @@
 import android.graphics.Point;
 import android.os.Bundle;
 import android.os.RemoteException;
-import android.provider.CloudMediaProvider.CloudMediaSurfaceEventCallback.PlaybackEvent;
+import android.provider.CloudMediaProvider.CloudMediaSurfaceStateChangedCallback.PlaybackState;
 import android.util.Log;
 import android.view.Surface;
 import android.view.View;
@@ -139,9 +139,9 @@
         mIsPlaybackRequested = true;
     }
 
-    void onPlaybackEvent(@PlaybackEvent int eventType, @Nullable Bundle eventInfo) {
-        switch (eventType) {
-            case PLAYBACK_EVENT_READY:
+    void setPlaybackState(@PlaybackState int playbackState, @Nullable Bundle playbackStateInfo) {
+        switch (playbackState) {
+            case PLAYBACK_STATE_READY:
                 mIsPlayerReady = true;
 
                 if (mIsPlaybackRequested) {
@@ -149,15 +149,15 @@
                     mIsPlaybackRequested = false;
                 }
                 return;
-            case PLAYBACK_EVENT_ERROR_PERMANENT_FAILURE:
-            case PLAYBACK_EVENT_ERROR_RETRIABLE_FAILURE:
+            case PLAYBACK_STATE_ERROR_PERMANENT_FAILURE:
+            case PLAYBACK_STATE_ERROR_RETRIABLE_FAILURE:
                 mIsPlayerReady = false;
                 return;
-            case PLAYBACK_EVENT_PAUSED:
+            case PLAYBACK_STATE_PAUSED:
                 mIsPlaying = false;
                 return;
-            case PLAYBACK_EVENT_MEDIA_SIZE_CHANGED:
-                Point size = eventInfo.getParcelable(ContentResolver.EXTRA_SIZE);
+            case PLAYBACK_STATE_MEDIA_SIZE_CHANGED:
+                Point size = playbackStateInfo.getParcelable(ContentResolver.EXTRA_SIZE);
                 updateAspectRatio(size.x, size.y);
                 return;
             default: