* commit '1d96b28d1d8d6882c30604721b81ac5dab1323d6': TIF: fix NPE for TvInputHardwareManager
This commit is contained in:
@@ -673,28 +673,35 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
|||||||
if (mReleased) {
|
if (mReleased) {
|
||||||
throw new IllegalStateException("Device already released.");
|
throw new IllegalStateException("Device already released.");
|
||||||
}
|
}
|
||||||
if (surface != null && config == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (surface == null && mActiveConfig == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int result = TvInputHal.ERROR_UNKNOWN;
|
int result = TvInputHal.ERROR_UNKNOWN;
|
||||||
if (surface == null) {
|
if (surface == null) {
|
||||||
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
// The value of config is ignored when surface == null.
|
||||||
mActiveConfig = null;
|
if (mActiveConfig != null) {
|
||||||
|
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
||||||
|
mActiveConfig = null;
|
||||||
|
} else {
|
||||||
|
// We already have no active stream.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!config.equals(mActiveConfig)) {
|
// It's impossible to set a non-null surface with a null config.
|
||||||
|
if (config == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Remove stream only if we have an existing active configuration.
|
||||||
|
if (mActiveConfig != null && !config.equals(mActiveConfig)) {
|
||||||
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
||||||
if (result != TvInputHal.SUCCESS) {
|
if (result != TvInputHal.SUCCESS) {
|
||||||
mActiveConfig = null;
|
mActiveConfig = null;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = mHal.addOrUpdateStream(mInfo.getDeviceId(), surface, config);
|
// Proceed only if all previous operations succeeded.
|
||||||
if (result == TvInputHal.SUCCESS) {
|
if (result == TvInputHal.SUCCESS) {
|
||||||
mActiveConfig = config;
|
result = mHal.addOrUpdateStream(mInfo.getDeviceId(), surface, config);
|
||||||
|
if (result == TvInputHal.SUCCESS) {
|
||||||
|
mActiveConfig = config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateAudioConfigLocked();
|
updateAudioConfigLocked();
|
||||||
|
|||||||
Reference in New Issue
Block a user