Merge "TIF: Minor code improvement" into mnc-dev

This commit is contained in:
Jae Seo
2015-06-22 01:18:04 +00:00
committed by Android (Google) Code Review
9 changed files with 81 additions and 91 deletions

View File

@@ -282,12 +282,12 @@ public final class TvContract {
return ContentUris.withAppendedId(WatchedPrograms.CONTENT_URI, watchedProgramId); return ContentUris.withAppendedId(WatchedPrograms.CONTENT_URI, watchedProgramId);
} }
private static final boolean isTvUri(Uri uri) { private static boolean isTvUri(Uri uri) {
return uri != null && ContentResolver.SCHEME_CONTENT.equals(uri.getScheme()) return uri != null && ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())
&& AUTHORITY.equals(uri.getAuthority()); && AUTHORITY.equals(uri.getAuthority());
} }
private static final boolean isTwoSegmentUriStartingWith(Uri uri, String pathSegment) { private static boolean isTwoSegmentUriStartingWith(Uri uri, String pathSegment) {
List<String> pathSegments = uri.getPathSegments(); List<String> pathSegments = uri.getPathSegments();
return pathSegments.size() == 2 && pathSegment.equals(pathSegments.get(0)); return pathSegments.size() == 2 && pathSegment.equals(pathSegments.get(0));
} }
@@ -565,7 +565,7 @@ public final class TvContract {
* defined there (e.g. ETSI EN 300 468/TR 101 211 and ARIB STD-B10). If channels cannot be * defined there (e.g. ETSI EN 300 468/TR 101 211 and ARIB STD-B10). If channels cannot be
* globally identified by 2-tuple {{@link #COLUMN_TRANSPORT_STREAM_ID}, * globally identified by 2-tuple {{@link #COLUMN_TRANSPORT_STREAM_ID},
* {@link #COLUMN_SERVICE_ID}}, one must carefully assign a value to this field to form a * {@link #COLUMN_SERVICE_ID}}, one must carefully assign a value to this field to form a
* unique 3-tuple identification {{@link #COLUMN_ORIGINAL_NETWORK_ID}, * unique 3-tuple identification {{@code COLUMN_ORIGINAL_NETWORK_ID},
* {@link #COLUMN_TRANSPORT_STREAM_ID}, {@link #COLUMN_SERVICE_ID}} for its channels. * {@link #COLUMN_TRANSPORT_STREAM_ID}, {@link #COLUMN_SERVICE_ID}} for its channels.
* *
* <p>This is a required field if the channel cannot be uniquely identified by a 2-tuple * <p>This is a required field if the channel cannot be uniquely identified by a 2-tuple

View File

@@ -106,7 +106,7 @@ public final class TvInputInfo implements Parcelable {
*/ */
public static final String EXTRA_INPUT_ID = "android.media.tv.extra.INPUT_ID"; public static final String EXTRA_INPUT_ID = "android.media.tv.extra.INPUT_ID";
private static SparseIntArray sHardwareTypeToTvInputType = new SparseIntArray(); private static final SparseIntArray sHardwareTypeToTvInputType = new SparseIntArray();
private static final String XML_START_TAG_NAME = "tv-input"; private static final String XML_START_TAG_NAME = "tv-input";
private static final String DELIMITER_INFO_IN_ID = "/"; private static final String DELIMITER_INFO_IN_ID = "/";
@@ -594,7 +594,7 @@ public final class TvInputInfo implements Parcelable {
* @param name the component name for generating an input id. * @param name the component name for generating an input id.
* @return the generated input id for the given {@code name}. * @return the generated input id for the given {@code name}.
*/ */
private static final String generateInputIdForComponentName(ComponentName name) { private static String generateInputIdForComponentName(ComponentName name) {
return name.flattenToShortString(); return name.flattenToShortString();
} }
@@ -605,7 +605,7 @@ public final class TvInputInfo implements Parcelable {
* @param deviceInfo HdmiDeviceInfo describing this TV input. * @param deviceInfo HdmiDeviceInfo describing this TV input.
* @return the generated input id for the given {@code name} and {@code deviceInfo}. * @return the generated input id for the given {@code name} and {@code deviceInfo}.
*/ */
private static final String generateInputIdForHdmiDevice( private static String generateInputIdForHdmiDevice(
ComponentName name, HdmiDeviceInfo deviceInfo) { ComponentName name, HdmiDeviceInfo deviceInfo) {
// Example of the format : "/HDMI%04X%02X" // Example of the format : "/HDMI%04X%02X"
String format = DELIMITER_INFO_IN_ID + PREFIX_HDMI_DEVICE String format = DELIMITER_INFO_IN_ID + PREFIX_HDMI_DEVICE
@@ -622,7 +622,7 @@ public final class TvInputInfo implements Parcelable {
* @param hardwareInfo TvInputHardwareInfo describing this TV input. * @param hardwareInfo TvInputHardwareInfo describing this TV input.
* @return the generated input id for the given {@code name} and {@code hardwareInfo}. * @return the generated input id for the given {@code name} and {@code hardwareInfo}.
*/ */
private static final String generateInputIdForHardware( private static String generateInputIdForHardware(
ComponentName name, TvInputHardwareInfo hardwareInfo) { ComponentName name, TvInputHardwareInfo hardwareInfo) {
return name.flattenToShortString() + DELIMITER_INFO_IN_ID + PREFIX_HARDWARE_DEVICE return name.flattenToShortString() + DELIMITER_INFO_IN_ID + PREFIX_HARDWARE_DEVICE
+ hardwareInfo.getDeviceId(); + hardwareInfo.getDeviceId();
@@ -648,13 +648,13 @@ public final class TvInputInfo implements Parcelable {
mSetupActivity = in.readString(); mSetupActivity = in.readString();
mSettingsActivity = in.readString(); mSettingsActivity = in.readString();
mType = in.readInt(); mType = in.readInt();
mIsHardwareInput = in.readByte() == 1 ? true : false; mIsHardwareInput = in.readByte() == 1;
mHdmiDeviceInfo = in.readParcelable(null); mHdmiDeviceInfo = in.readParcelable(null);
mIcon = in.readParcelable(null); mIcon = in.readParcelable(null);
mIconUri = in.readParcelable(null); mIconUri = in.readParcelable(null);
mLabelRes = in.readInt(); mLabelRes = in.readInt();
mLabel = in.readString(); mLabel = in.readString();
mIsConnectedToHdmiSwitch = in.readByte() == 1 ? true : false; mIsConnectedToHdmiSwitch = in.readByte() == 1;
} }
/** /**

View File

@@ -1932,7 +1932,7 @@ public final class TvInputManager {
* @param handled {@code true} if the dispatched input event was handled properly. * @param handled {@code true} if the dispatched input event was handled properly.
* {@code false} otherwise. * {@code false} otherwise.
*/ */
public void onFinishedInputEvent(Object token, boolean handled); void onFinishedInputEvent(Object token, boolean handled);
} }
// Must be called on the main looper // Must be called on the main looper

View File

@@ -233,10 +233,7 @@ public abstract class TvInputService extends Service {
mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE); mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
} }
TvInputInfo info = mTvInputManager.getTvInputInfo(inputId); TvInputInfo info = mTvInputManager.getTvInputInfo(inputId);
if (info != null && info.isPassthroughInput()) { return info != null && info.isPassthroughInput();
return true;
}
return false;
} }
/** /**
@@ -1383,7 +1380,7 @@ public abstract class TvInputService extends Service {
} }
} }
private final void executeOrPostRunnable(Runnable action) { private void executeOrPostRunnable(Runnable action) {
synchronized(mLock) { synchronized(mLock) {
if (mSessionCallback == null) { if (mSessionCallback == null) {
// The session is not initialized yet. // The session is not initialized yet.
@@ -1651,13 +1648,13 @@ public abstract class TvInputService extends Service {
if (sessionImpl instanceof HardwareSession) { if (sessionImpl instanceof HardwareSession) {
HardwareSession proxySession = HardwareSession proxySession =
((HardwareSession) sessionImpl); ((HardwareSession) sessionImpl);
String harewareInputId = proxySession.getHardwareInputId(); String hardwareInputId = proxySession.getHardwareInputId();
if (TextUtils.isEmpty(harewareInputId) || if (TextUtils.isEmpty(hardwareInputId) ||
!isPassthroughInput(harewareInputId)) { !isPassthroughInput(hardwareInputId)) {
if (TextUtils.isEmpty(harewareInputId)) { if (TextUtils.isEmpty(hardwareInputId)) {
Log.w(TAG, "Hardware input id is not setup yet."); Log.w(TAG, "Hardware input id is not setup yet.");
} else { } else {
Log.w(TAG, "Invalid hardware input id : " + harewareInputId); Log.w(TAG, "Invalid hardware input id : " + hardwareInputId);
} }
sessionImpl.onRelease(); sessionImpl.onRelease();
try { try {
@@ -1672,7 +1669,7 @@ public abstract class TvInputService extends Service {
proxySession.mServiceHandler = mServiceHandler; proxySession.mServiceHandler = mServiceHandler;
TvInputManager manager = (TvInputManager) getSystemService( TvInputManager manager = (TvInputManager) getSystemService(
Context.TV_INPUT_SERVICE); Context.TV_INPUT_SERVICE);
manager.createSession(harewareInputId, manager.createSession(hardwareInputId,
proxySession.mHardwareSessionCallback, mServiceHandler); proxySession.mHardwareSessionCallback, mServiceHandler);
} else { } else {
SomeArgs someArgs = SomeArgs.obtain(); SomeArgs someArgs = SomeArgs.obtain();

View File

@@ -191,7 +191,7 @@ public class TvView extends ViewGroup {
* the active source. * the active source.
* *
* <p>First tuned {@link TvView} becomes main automatically, and keeps to be main until either * <p>First tuned {@link TvView} becomes main automatically, and keeps to be main until either
* {@link #reset} is called for the main {@link TvView} or {@link #setMain} is called for other * {@link #reset} is called for the main {@link TvView} or {@code setMain()} is called for other
* {@link TvView}. * {@link TvView}.
* @hide * @hide
*/ */

View File

@@ -111,8 +111,8 @@ final class PersistentDataStore {
public boolean isRatingBlocked(TvContentRating rating) { public boolean isRatingBlocked(TvContentRating rating) {
loadIfNeeded(); loadIfNeeded();
synchronized (mBlockedRatings) { synchronized (mBlockedRatings) {
for (TvContentRating blcokedRating : mBlockedRatings) { for (TvContentRating blockedRating : mBlockedRatings) {
if (rating.contains(blcokedRating)) { if (rating.contains(blockedRating)) {
return true; return true;
} }
} }

View File

@@ -47,11 +47,10 @@ final class TvInputHal implements Handler.Callback {
public static final int EVENT_FIRST_FRAME_CAPTURED = 4; public static final int EVENT_FIRST_FRAME_CAPTURED = 4;
public interface Callback { public interface Callback {
public void onDeviceAvailable( void onDeviceAvailable(TvInputHardwareInfo info, TvStreamConfig[] configs);
TvInputHardwareInfo info, TvStreamConfig[] configs); void onDeviceUnavailable(int deviceId);
public void onDeviceUnavailable(int deviceId); void onStreamConfigurationChanged(int deviceId, TvStreamConfig[] configs);
public void onStreamConfigurationChanged(int deviceId, TvStreamConfig[] configs); void onFirstFrameCaptured(int deviceId, int streamId);
public void onFirstFrameCaptured(int deviceId, int streamId);
} }
private native long nativeOpen(MessageQueue queue); private native long nativeOpen(MessageQueue queue);
@@ -152,7 +151,7 @@ final class TvInputHal implements Handler.Callback {
// Handler.Callback implementation // Handler.Callback implementation
private final Queue<Message> mPendingMessageQueue = new LinkedList<Message>(); private final Queue<Message> mPendingMessageQueue = new LinkedList<>();
@Override @Override
public boolean handleMessage(Message msg) { public boolean handleMessage(Message msg) {

View File

@@ -252,13 +252,8 @@ class TvInputHardwareManager implements TvInputHal.Callback {
Connection connection, int callingUid, int resolvedUserId) { Connection connection, int callingUid, int resolvedUserId) {
Integer connectionCallingUid = connection.getCallingUidLocked(); Integer connectionCallingUid = connection.getCallingUidLocked();
Integer connectionResolvedUserId = connection.getResolvedUserIdLocked(); Integer connectionResolvedUserId = connection.getResolvedUserIdLocked();
if (connectionCallingUid == null || connectionResolvedUserId == null) { return connectionCallingUid == null || connectionResolvedUserId == null
return true; || connectionCallingUid != callingUid || connectionResolvedUserId != resolvedUserId;
}
if (connectionCallingUid != callingUid || connectionResolvedUserId != resolvedUserId) {
return true;
}
return false;
} }
private int convertConnectedToState(boolean connected) { private int convertConnectedToState(boolean connected) {
@@ -303,7 +298,6 @@ class TvInputHardwareManager implements TvInputHal.Callback {
mHandler.obtainMessage(ListenerHandler.STATE_CHANGED, mHandler.obtainMessage(ListenerHandler.STATE_CHANGED,
convertConnectedToState(connection.getConfigsLocked().length > 0), 0, convertConnectedToState(connection.getConfigsLocked().length > 0), 0,
info.getId()).sendToTarget(); info.getId()).sendToTarget();
return;
} }
} }
} }
@@ -435,7 +429,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
*/ */
public List<TvStreamConfig> getAvailableTvStreamConfigList(String inputId, int callingUid, public List<TvStreamConfig> getAvailableTvStreamConfigList(String inputId, int callingUid,
int resolvedUserId) { int resolvedUserId) {
List<TvStreamConfig> configsList = new ArrayList<TvStreamConfig>(); List<TvStreamConfig> configsList = new ArrayList<>();
synchronized (mLock) { synchronized (mLock) {
int deviceId = findDeviceIdForInputIdLocked(inputId); int deviceId = findDeviceIdForInputIdLocked(inputId);
if (deviceId < 0) { if (deviceId < 0) {
@@ -508,7 +502,8 @@ class TvInputHardwareManager implements TvInputHal.Callback {
private void handleVolumeChange(Context context, Intent intent) { private void handleVolumeChange(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
if (action.equals(AudioManager.VOLUME_CHANGED_ACTION)) { switch (action) {
case AudioManager.VOLUME_CHANGED_ACTION: {
int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
if (streamType != AudioManager.STREAM_MUSIC) { if (streamType != AudioManager.STREAM_MUSIC) {
return; return;
@@ -518,13 +513,18 @@ class TvInputHardwareManager implements TvInputHal.Callback {
return; return;
} }
mCurrentIndex = index; mCurrentIndex = index;
} else if (action.equals(AudioManager.STREAM_MUTE_CHANGED_ACTION)) { break;
}
case AudioManager.STREAM_MUTE_CHANGED_ACTION: {
int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
if (streamType != AudioManager.STREAM_MUSIC) { if (streamType != AudioManager.STREAM_MUSIC) {
return; return;
} }
// volume index will be updated at onMediaStreamVolumeChanged() through updateVolume(). // volume index will be updated at onMediaStreamVolumeChanged() through
} else { // updateVolume().
break;
}
default:
Slog.w(TAG, "Unrecognized intent: " + intent); Slog.w(TAG, "Unrecognized intent: " + intent);
return; return;
} }
@@ -691,7 +691,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
private void findAudioSinkFromAudioPolicy(List<AudioDevicePort> sinks) { private void findAudioSinkFromAudioPolicy(List<AudioDevicePort> sinks) {
sinks.clear(); sinks.clear();
ArrayList<AudioDevicePort> devicePorts = new ArrayList<AudioDevicePort>(); ArrayList<AudioDevicePort> devicePorts = new ArrayList<>();
if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) { if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) {
return; return;
} }
@@ -707,7 +707,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
if (type == AudioManager.DEVICE_NONE) { if (type == AudioManager.DEVICE_NONE) {
return null; return null;
} }
ArrayList<AudioDevicePort> devicePorts = new ArrayList<AudioDevicePort>(); ArrayList<AudioDevicePort> devicePorts = new ArrayList<>();
if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) { if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) {
return null; return null;
} }
@@ -1027,12 +1027,12 @@ class TvInputHardwareManager implements TvInputHal.Callback {
} }
interface Listener { interface Listener {
public void onStateChanged(String inputId, int state); void onStateChanged(String inputId, int state);
public void onHardwareDeviceAdded(TvInputHardwareInfo info); void onHardwareDeviceAdded(TvInputHardwareInfo info);
public void onHardwareDeviceRemoved(TvInputHardwareInfo info); void onHardwareDeviceRemoved(TvInputHardwareInfo info);
public void onHdmiDeviceAdded(HdmiDeviceInfo device); void onHdmiDeviceAdded(HdmiDeviceInfo device);
public void onHdmiDeviceRemoved(HdmiDeviceInfo device); void onHdmiDeviceRemoved(HdmiDeviceInfo device);
public void onHdmiDeviceUpdated(String inputId, HdmiDeviceInfo device); void onHdmiDeviceUpdated(String inputId, HdmiDeviceInfo device);
} }
private class ListenerHandler extends Handler { private class ListenerHandler extends Handler {
@@ -1074,7 +1074,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
} }
case HDMI_DEVICE_UPDATED: { case HDMI_DEVICE_UPDATED: {
HdmiDeviceInfo info = (HdmiDeviceInfo) msg.obj; HdmiDeviceInfo info = (HdmiDeviceInfo) msg.obj;
String inputId = null; String inputId;
synchronized (mLock) { synchronized (mLock) {
inputId = mHdmiInputIdMap.get(info.getId()); inputId = mHdmiInputIdMap.get(info.getId());
} }

View File

@@ -121,7 +121,7 @@ public final class TvInputManagerService extends SystemService {
private int mCurrentUserId = UserHandle.USER_OWNER; private int mCurrentUserId = UserHandle.USER_OWNER;
// A map from user id to UserState. // A map from user id to UserState.
private final SparseArray<UserState> mUserStates = new SparseArray<UserState>(); private final SparseArray<UserState> mUserStates = new SparseArray<>();
private final WatchLogHandler mWatchLogHandler; private final WatchLogHandler mWatchLogHandler;
@@ -231,8 +231,7 @@ public final class TvInputManagerService extends SystemService {
} }
} }
ArrayList<ContentProviderOperation> operations = ArrayList<ContentProviderOperation> operations = new ArrayList<>();
new ArrayList<ContentProviderOperation>();
String selection = TvContract.BaseTvColumns.COLUMN_PACKAGE_NAME + "=?"; String selection = TvContract.BaseTvColumns.COLUMN_PACKAGE_NAME + "=?";
String[] selectionArgs = { packageName }; String[] selectionArgs = { packageName };
@@ -292,7 +291,7 @@ public final class TvInputManagerService extends SystemService {
new Intent(TvInputService.SERVICE_INTERFACE), new Intent(TvInputService.SERVICE_INTERFACE),
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
userId); userId);
List<TvInputInfo> inputList = new ArrayList<TvInputInfo>(); List<TvInputInfo> inputList = new ArrayList<>();
for (ResolveInfo ri : services) { for (ResolveInfo ri : services) {
ServiceInfo si = ri.serviceInfo; ServiceInfo si = ri.serviceInfo;
if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) { if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) {
@@ -325,7 +324,7 @@ public final class TvInputManagerService extends SystemService {
userState.packageSet.add(si.packageName); userState.packageSet.add(si.packageName);
} }
Map<String, TvInputState> inputMap = new HashMap<String, TvInputState>(); Map<String, TvInputState> inputMap = new HashMap<>();
for (TvInputInfo info : inputList) { for (TvInputInfo info : inputList) {
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "add " + info.getId()); Slog.d(TAG, "add " + info.getId());
@@ -777,7 +776,7 @@ public final class TvInputManagerService extends SystemService {
try { try {
synchronized (mLock) { synchronized (mLock) {
UserState userState = getUserStateLocked(resolvedUserId); UserState userState = getUserStateLocked(resolvedUserId);
List<TvInputInfo> inputList = new ArrayList<TvInputInfo>(); List<TvInputInfo> inputList = new ArrayList<>();
for (TvInputState state : userState.inputMap.values()) { for (TvInputState state : userState.inputMap.values()) {
inputList.add(state.info); inputList.add(state.info);
} }
@@ -934,7 +933,7 @@ public final class TvInputManagerService extends SystemService {
try { try {
synchronized (mLock) { synchronized (mLock) {
UserState userState = getUserStateLocked(resolvedUserId); UserState userState = getUserStateLocked(resolvedUserId);
List<String> ratings = new ArrayList<String>(); List<String> ratings = new ArrayList<>();
for (TvContentRating rating for (TvContentRating rating
: userState.persistentDataStore.getBlockedRatings()) { : userState.persistentDataStore.getBlockedRatings()) {
ratings.add(rating.flattenToString()); ratings.add(rating.flattenToString());
@@ -1012,7 +1011,7 @@ public final class TvInputManagerService extends SystemService {
userState.serviceStateMap.put(info.getComponent(), serviceState); userState.serviceStateMap.put(info.getComponent(), serviceState);
} }
// Send a null token immediately while reconnecting. // Send a null token immediately while reconnecting.
if (serviceState.reconnecting == true) { if (serviceState.reconnecting) {
sendSessionTokenToClientLocked(client, inputId, null, null, seq); sendSessionTokenToClientLocked(client, inputId, null, null, seq);
return; return;
} }
@@ -1210,7 +1209,6 @@ public final class TvInputManagerService extends SystemService {
.sendToTarget(); .sendToTarget();
} catch (RemoteException | SessionNotFoundException e) { } catch (RemoteException | SessionNotFoundException e) {
Slog.e(TAG, "error in tune", e); Slog.e(TAG, "error in tune", e);
return;
} }
} }
} finally { } finally {
@@ -1799,30 +1797,26 @@ public final class TvInputManagerService extends SystemService {
private static final class UserState { private static final class UserState {
// A mapping from the TV input id to its TvInputState. // A mapping from the TV input id to its TvInputState.
private Map<String, TvInputState> inputMap = new HashMap<String, TvInputState>(); private Map<String, TvInputState> inputMap = new HashMap<>();
// A set of all TV input packages. // A set of all TV input packages.
private final Set<String> packageSet = new HashSet<String>(); private final Set<String> packageSet = new HashSet<>();
// A list of all TV content rating systems defined. // A list of all TV content rating systems defined.
private final List<TvContentRatingSystemInfo> private final List<TvContentRatingSystemInfo>
contentRatingSystemList = new ArrayList<TvContentRatingSystemInfo>(); contentRatingSystemList = new ArrayList<>();
// A mapping from the token of a client to its state. // A mapping from the token of a client to its state.
private final Map<IBinder, ClientState> clientStateMap = private final Map<IBinder, ClientState> clientStateMap = new HashMap<>();
new HashMap<IBinder, ClientState>();
// A mapping from the name of a TV input service to its state. // A mapping from the name of a TV input service to its state.
private final Map<ComponentName, ServiceState> serviceStateMap = private final Map<ComponentName, ServiceState> serviceStateMap = new HashMap<>();
new HashMap<ComponentName, ServiceState>();
// A mapping from the token of a TV input session to its state. // A mapping from the token of a TV input session to its state.
private final Map<IBinder, SessionState> sessionStateMap = private final Map<IBinder, SessionState> sessionStateMap = new HashMap<>();
new HashMap<IBinder, SessionState>();
// A set of callbacks. // A set of callbacks.
private final Set<ITvInputManagerCallback> callbackSet = private final Set<ITvInputManagerCallback> callbackSet = new HashSet<>();
new HashSet<ITvInputManagerCallback>();
// The token of a "main" TV input session. // The token of a "main" TV input session.
private IBinder mainSessionToken = null; private IBinder mainSessionToken = null;
@@ -1837,7 +1831,7 @@ public final class TvInputManagerService extends SystemService {
} }
private final class ClientState implements IBinder.DeathRecipient { private final class ClientState implements IBinder.DeathRecipient {
private final List<IBinder> sessionTokens = new ArrayList<IBinder>(); private final List<IBinder> sessionTokens = new ArrayList<>();
private IBinder clientToken; private IBinder clientToken;
private final int userId; private final int userId;
@@ -1870,11 +1864,11 @@ public final class TvInputManagerService extends SystemService {
} }
private final class ServiceState { private final class ServiceState {
private final List<IBinder> sessionTokens = new ArrayList<IBinder>(); private final List<IBinder> sessionTokens = new ArrayList<>();
private final ServiceConnection connection; private final ServiceConnection connection;
private final ComponentName component; private final ComponentName component;
private final boolean isHardware; private final boolean isHardware;
private final List<TvInputInfo> inputList = new ArrayList<TvInputInfo>(); private final List<TvInputInfo> inputList = new ArrayList<>();
private ITvInputService service; private ITvInputService service;
private ServiceCallback callback; private ServiceCallback callback;
@@ -2124,13 +2118,13 @@ public final class TvInputManagerService extends SystemService {
} }
@Override @Override
public void onSessionCreated(ITvInputSession session, IBinder harewareSessionToken) { public void onSessionCreated(ITvInputSession session, IBinder hardwareSessionToken) {
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "onSessionCreated(inputId=" + mSessionState.info.getId() + ")"); Slog.d(TAG, "onSessionCreated(inputId=" + mSessionState.info.getId() + ")");
} }
synchronized (mLock) { synchronized (mLock) {
mSessionState.session = session; mSessionState.session = session;
mSessionState.hardwareSessionToken = harewareSessionToken; mSessionState.hardwareSessionToken = hardwareSessionToken;
if (session != null && addSessionTokenToClientStateLocked(session)) { if (session != null && addSessionTokenToClientStateLocked(session)) {
sendSessionTokenToClientLocked(mSessionState.client, sendSessionTokenToClientLocked(mSessionState.client,
mSessionState.info.getId(), mSessionState.sessionToken, mChannels[0], mSessionState.info.getId(), mSessionState.sessionToken, mChannels[0],
@@ -2558,7 +2552,7 @@ public final class TvInputManagerService extends SystemService {
@Override @Override
public void onHdmiDeviceUpdated(String inputId, HdmiDeviceInfo deviceInfo) { public void onHdmiDeviceUpdated(String inputId, HdmiDeviceInfo deviceInfo) {
synchronized (mLock) { synchronized (mLock) {
Integer state = null; Integer state;
switch (deviceInfo.getDevicePowerStatus()) { switch (deviceInfo.getDevicePowerStatus()) {
case HdmiControlManager.POWER_STATUS_ON: case HdmiControlManager.POWER_STATUS_ON:
state = INPUT_STATE_CONNECTED; state = INPUT_STATE_CONNECTED;
@@ -2574,7 +2568,7 @@ public final class TvInputManagerService extends SystemService {
break; break;
} }
if (state != null) { if (state != null) {
setStateLocked(inputId, state.intValue(), mCurrentUserId); setStateLocked(inputId, state, mCurrentUserId);
} }
} }
} }