diff --git a/media/java/android/media/tv/TvInputInfo.java b/media/java/android/media/tv/TvInputInfo.java index 6a7433dbe035a..3f5697f6c701e 100644 --- a/media/java/android/media/tv/TvInputInfo.java +++ b/media/java/android/media/tv/TvInputInfo.java @@ -158,17 +158,17 @@ public final class TvInputInfo implements Parcelable { } /** - * Create a new instance of the TvInputInfo class, - * instantiating it from the given Context, ResolveInfo, and HdmiDeviceInfo. + * Create a new instance of the TvInputInfo class, instantiating it from the given Context, + * ResolveInfo, and HdmiDeviceInfo. * * @param service The ResolveInfo returned from the package manager about this TV input service. * @param deviceInfo The HdmiDeviceInfo for a HDMI CEC logical device. * @param parentId The ID of this TV input's parent input. {@code null} if none exists. - * @param iconUri The {@link android.net.Uri} to load the icon image. - * {@see android.content.ContentResolver#openInputStream}. If it is null, the application - * icon of {@code service} will be loaded. - * @param label The label of this TvInputInfo. If it is null or empty, {@code service} label - * will be loaded. + * @param iconUri The {@link android.net.Uri} to load the icon image. See + * {@link android.content.ContentResolver#openInputStream}. If it is {@code null}, + * the application icon of {@code service} will be loaded. + * @param label The label of this TvInputInfo. If it is {@code null} or empty, {@code service} + * label will be loaded. * @hide */ @SystemApi @@ -182,16 +182,16 @@ public final class TvInputInfo implements Parcelable { } /** - * Create a new instance of the TvInputInfo class, - * instantiating it from the given Context, ResolveInfo, and TvInputHardwareInfo. + * Create a new instance of the TvInputInfo class, instantiating it from the given Context, + * ResolveInfo, and TvInputHardwareInfo. * * @param service The ResolveInfo returned from the package manager about this TV input service. * @param hardwareInfo The TvInputHardwareInfo for a TV input hardware device. - * @param iconUri The {@link android.net.Uri} to load the icon image. - * {@see android.content.ContentResolver#openInputStream}. If it is null, the application - * icon of {@code service} will be loaded. - * @param label The label of this TvInputInfo. If it is null or empty, {@code service} label - * will be loaded. + * @param iconUri The {@link android.net.Uri} to load the icon image. See + * {@link android.content.ContentResolver#openInputStream}. If it is {@code null}, + * the application icon of {@code service} will be loaded. + * @param label The label of this TvInputInfo. If it is {@code null} or empty, {@code service} + * label will be loaded. * @hide */ @SystemApi @@ -620,7 +620,7 @@ public final class TvInputInfo implements Parcelable { return new HashSet(); } String[] ids = hiddenIdsString.split(TV_INPUT_SEPARATOR); - return new HashSet(Arrays.asList(ids)); + return new HashSet<>(Arrays.asList(ids)); } /** diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index 6e075b204b8f8..f76c78b66044a 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -235,14 +235,14 @@ public final class TvInputManager { } /** - * This is called when {@link TvInputService.Session#layoutSurface} is called to - * change the layout of surface. + * This is called when {@link TvInputService.Session#layoutSurface} is called to change the + * layout of surface. * * @param session A {@link TvInputManager.Session} associated with this callback - * @param l Left position. - * @param t Top position. - * @param r Right position. - * @param b Bottom position. + * @param left Left position. + * @param top Top position. + * @param right Right position. + * @param bottom Bottom position. * @hide */ @SystemApi @@ -1164,7 +1164,7 @@ public final class TvInputManager { * {@link TvTrackInfo#TYPE_SUBTITLE}. * @param trackId The ID of the track to select. When {@code null}, the currently selected * track of the given type will be unselected. - * @see #getTracks() + * @see #getTracks */ public void selectTrack(int type, String trackId) { if (type == TvTrackInfo.TYPE_AUDIO) { @@ -1462,14 +1462,14 @@ public final class TvInputManager { // Assumes the event has already been removed from the queue. void invokeFinishedInputEventCallback(PendingEvent p, boolean handled) { p.mHandled = handled; - if (p.mHandler.getLooper().isCurrentThread()) { + if (p.mEventHandler.getLooper().isCurrentThread()) { // Already running on the callback handler thread so we can send the callback // immediately. p.run(); } else { // Post the event to the callback handler thread. // In this case, the callback will be responsible for recycling the event. - Message msg = Message.obtain(p.mHandler, p); + Message msg = Message.obtain(p.mEventHandler, p); msg.setAsynchronous(true); msg.sendToTarget(); } @@ -1494,9 +1494,9 @@ public final class TvInputManager { p = new PendingEvent(); } p.mEvent = event; - p.mToken = token; + p.mEventToken = token; p.mCallback = callback; - p.mHandler = handler; + p.mEventHandler = handler; return p; } @@ -1568,24 +1568,24 @@ public final class TvInputManager { private final class PendingEvent implements Runnable { public InputEvent mEvent; - public Object mToken; + public Object mEventToken; public FinishedInputEventCallback mCallback; - public Handler mHandler; + public Handler mEventHandler; public boolean mHandled; public void recycle() { mEvent = null; - mToken = null; + mEventToken = null; mCallback = null; - mHandler = null; + mEventHandler = null; mHandled = false; } @Override public void run() { - mCallback.onFinishedInputEvent(mToken, mHandled); + mCallback.onFinishedInputEvent(mEventToken, mHandled); - synchronized (mHandler) { + synchronized (mEventHandler) { recyclePendingEventLocked(this); } } diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index 8ffe6cc8405af..c93b2616b5db6 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -504,12 +504,13 @@ public abstract class TvInputService extends Service { /** * Assigns a position of the {@link Surface} passed by {@link #onSetSurface}. The position - * is relative to an overlay view. {@see #onOverlayViewSizeChanged}. + * is relative to an overlay view. * * @param left Left position in pixels, relative to the overlay view. * @param top Top position in pixels, relative to the overlay view. * @param right Right position in pixels, relative to the overlay view. * @param bottm Bottom position in pixels, relative to the overlay view. + * @see #onOverlayViewSizeChanged * @hide */ @SystemApi diff --git a/services/core/java/com/android/server/tv/TvInputHal.java b/services/core/java/com/android/server/tv/TvInputHal.java index e7dd82d9d9bf5..c7d95aa41f028 100644 --- a/services/core/java/com/android/server/tv/TvInputHal.java +++ b/services/core/java/com/android/server/tv/TvInputHal.java @@ -19,12 +19,11 @@ package com.android.server.tv; import android.media.tv.TvInputHardwareInfo; import android.media.tv.TvStreamConfig; import android.os.Handler; -import android.os.HandlerThread; import android.os.Message; -import android.view.Surface; import android.util.Slog; import android.util.SparseArray; import android.util.SparseIntArray; +import android.view.Surface; import java.util.LinkedList; import java.util.Queue; @@ -64,12 +63,12 @@ final class TvInputHal implements Handler.Callback { int generation); private static native void nativeClose(long ptr); - private Object mLock = new Object(); + private final Object mLock = new Object(); private long mPtr = 0; private final Callback mCallback; private final Handler mHandler; - private SparseIntArray mStreamConfigGenerations = new SparseIntArray(); - private SparseArray mStreamConfigs = new SparseArray<>();; + private final SparseIntArray mStreamConfigGenerations = new SparseIntArray(); + private final SparseArray mStreamConfigs = new SparseArray<>(); public TvInputHal(Callback callback) { mCallback = callback; @@ -153,7 +152,7 @@ final class TvInputHal implements Handler.Callback { // Handler.Callback implementation - private Queue mPendingMessageQueue = new LinkedList(); + private final Queue mPendingMessageQueue = new LinkedList(); @Override public boolean handleMessage(Message msg) { diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java index ae9ae130a26f7..425eff302c543 100644 --- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java +++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java @@ -20,14 +20,12 @@ import static android.media.tv.TvInputManager.INPUT_STATE_CONNECTED; import static android.media.tv.TvInputManager.INPUT_STATE_DISCONNECTED; import android.content.Context; -import android.content.Intent; import android.hardware.hdmi.HdmiControlManager; import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.HdmiHotplugEvent; import android.hardware.hdmi.IHdmiControlService; import android.hardware.hdmi.IHdmiDeviceEventListener; import android.hardware.hdmi.IHdmiHotplugEventListener; -import android.hardware.hdmi.IHdmiInputChangeListener; import android.hardware.hdmi.IHdmiSystemAudioModeChangeListener; import android.media.AudioDevicePort; import android.media.AudioFormat; @@ -39,7 +37,6 @@ import android.media.AudioPort; import android.media.AudioPortConfig; import android.media.tv.ITvInputHardware; import android.media.tv.ITvInputHardwareCallback; -import android.media.tv.TvContract; import android.media.tv.TvInputHardwareInfo; import android.media.tv.TvInputInfo; import android.media.tv.TvStreamConfig; @@ -77,7 +74,6 @@ import java.util.Map; class TvInputHardwareManager implements TvInputHal.Callback { private static final String TAG = TvInputHardwareManager.class.getSimpleName(); - private final Context mContext; private final Listener mListener; private final TvInputHal mHal = new TvInputHal(this); private final SparseArray mConnections = new SparseArray<>(); @@ -107,7 +103,6 @@ class TvInputHardwareManager implements TvInputHal.Callback { private final Object mLock = new Object(); public TvInputHardwareManager(Context context, Listener listener) { - mContext = context; mListener = listener; mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mHal.init();