author | wei wang <wei.wang@amlogic.com> | 2018-01-12 09:57:20 (GMT) |
---|---|---|
committer | Wei Wang <wei.wang@amlogic.com> | 2018-01-19 07:59:36 (GMT) |
commit | 75d9f937d188606485803f7e2d43e97dfddaa70f (patch) | |
tree | f80815290e756978af7fc40d11ac50df43d15d45 | |
parent | d80914e2af6c86883c50140cd29122dabe2d26ee (diff) | |
download | tv-75d9f937d188606485803f7e2d43e97dfddaa70f.zip tv-75d9f937d188606485803f7e2d43e97dfddaa70f.tar.gz tv-75d9f937d188606485803f7e2d43e97dfddaa70f.tar.bz2 |
TIF:reset session-status when it's released [3/3]
PD# 158650
Change-Id: I0d23b6b961ad186b55c66c41e46135b93972a966
-rw-r--r-- | core/java/com/droidlogic/app/tv/DroidLogicTvInputService.java | 43 | ||||
-rw-r--r-- | core/java/com/droidlogic/app/tv/TvInputBaseSession.java | 9 |
2 files changed, 37 insertions, 15 deletions
diff --git a/core/java/com/droidlogic/app/tv/DroidLogicTvInputService.java b/core/java/com/droidlogic/app/tv/DroidLogicTvInputService.java index d867874..57db083 100644 --- a/core/java/com/droidlogic/app/tv/DroidLogicTvInputService.java +++ b/core/java/com/droidlogic/app/tv/DroidLogicTvInputService.java @@ -70,6 +70,7 @@ public class DroidLogicTvInputService extends TvInputService implements private String mChildClassName; private SurfaceHandler mSessionHandler; private static final int MSG_DO_TUNE = 0; + private static final int MSG_DO_RELEASE = 1; private static final int MSG_DO_SET_SURFACE = 3; private static final int RETUNE_TIMEOUT = 20; // 1 second private static int mSelectPort = -1; @@ -165,8 +166,10 @@ public class DroidLogicTvInputService extends TvInputService implements * @param session {@link HdmiInputSession} or {@link AVInputSession} */ protected void registerInputSession(TvInputBaseSession session) { - Log.d(TAG, "registerInputSession"); + Log.d(TAG, "registerInputSession:"+session); mSession = session; + if (session == null) + return; mCurrentSessionId = session.mId; Log.d(TAG, "inputId["+mCurrentInputId+"]"); Log.d(TAG, "xsession["+session+"]"); @@ -309,7 +312,10 @@ public class DroidLogicTvInputService extends TvInputService implements if (DEBUG) Log.d(TAG, "onSigChange" + status.ordinal() + status.toString()); - + if (mSession == null) { + Log.w(TAG, "mSession is null ,discard this signal!"); + return; + } onSigChanged(signal_info); if (status == TVInSignalInfo.SignalStatus.TVIN_SIG_STATUS_NOSIG @@ -411,13 +417,14 @@ public class DroidLogicTvInputService extends TvInputService implements Log.d(TAG, "scanning frame stable!"); Bundle bundle = new Bundle(); bundle.putInt(DroidLogicTvUtils.SIG_INFO_C_FREQ, event.CurScanningFrq); - mSession.notifySessionEvent(DroidLogicTvUtils.SIG_INFO_C_SCANNING_FRAME_STABLE_EVENT, bundle); + if (mSession != null) + mSession.notifySessionEvent(DroidLogicTvUtils.SIG_INFO_C_SCANNING_FRAME_STABLE_EVENT, bundle); } public void onUpdateCurrentChannel(ChannelInfo channel, boolean store) {} protected boolean setSurfaceInService(Surface surface, TvInputBaseSession session ) { - Log.d(TAG, "SetSurface"); + Log.d(TAG, "setSurfaceInService,session:"+session); Message message = mSessionHandler.obtainMessage(); message.what = MSG_DO_SET_SURFACE; @@ -431,7 +438,7 @@ public class DroidLogicTvInputService extends TvInputService implements } protected boolean doTuneInService(Uri channelUri, int sessionId) { - Log.d(TAG, "[source_switch_time]:" +getUptimeSeconds() + "s, onTune channelUri=" + channelUri); + Log.d(TAG, "doTuneInService,[source_switch_time]:" +getUptimeSeconds() + "s, onTune channelUri=" + channelUri); if (mSession != null) mSession.hideUI(); @@ -439,6 +446,11 @@ public class DroidLogicTvInputService extends TvInputService implements return false; } + protected void doReleaseInService (int sessionId) { + Log.d(TAG, "doReleaseInService,[source_switch_time]:" +getUptimeSeconds() + "s,sessionid:"+sessionId); + mSessionHandler.obtainMessage(MSG_DO_RELEASE, sessionId, 0).sendToTarget(); + } + private final class SurfaceHandler extends Handler { @Override public void handleMessage(Message message) { @@ -453,6 +465,9 @@ public class DroidLogicTvInputService extends TvInputService implements SomeArgs args = (SomeArgs) message.obj; doSetSurface((Surface)args.arg1, (TvInputBaseSession)args.arg2); break; + case MSG_DO_RELEASE: + doSessionRelease(message.arg1); + break; } } } @@ -465,10 +480,15 @@ public class DroidLogicTvInputService extends TvInputService implements Log.d(TAG, "onSetSurface get invalid surface"); return; } else if (surface != null) { + if (mSession == null) { + Log.w(TAG, "session should not be null when surface is not null!!!!!"); + int test_ww = mSession.getDeviceId(); + return; + } if (mHardware != null && mSurface != null && (mSourceType >= DroidLogicTvUtils.DEVICE_ID_HDMI1) && (mSourceType <= DroidLogicTvUtils.DEVICE_ID_HDMI4)) { - stopTvPlay(mSession.mId); + stopTvPlay(mSession.mId); } registerInputSession(session); setCurrentSessionById(mSession.mId); @@ -496,14 +516,20 @@ public class DroidLogicTvInputService extends TvInputService implements Message msg = mSessionHandler.obtainMessage(MSG_DO_TUNE, sessionId, 0, uri); mSessionHandler.sendMessageDelayed(msg, 50); timeout--; - return ACTION_FAILED; - } + } else + doTuneFinish(ACTION_FAILED, uri, sessionId); + return ACTION_FAILED; } mSystemControlManager.writeSysFs("/sys/class/deinterlace/di0/config", "hold_video 0"); doTuneFinish(ACTION_SUCCESS, uri, sessionId); return ACTION_SUCCESS; } + private void doSessionRelease(int sessionId) { + Log.d(TAG, "doRelese, sessionId = " + sessionId); + doReleaseFinish(sessionId); + } + private int startTvPlay() { Log.d(TAG, "startTvPlay inputId=" + mCurrentInputId + " surface=" + mSurface); if (mHardware != null && mSurface != null && mSurface.isValid()) { @@ -525,6 +551,7 @@ public class DroidLogicTvInputService extends TvInputService implements } public void setCurrentSessionById(int sessionId){} public void doTuneFinish(int result, Uri uri, int sessionId){}; + public void doReleaseFinish(int sessionId){}; public void tvPlayStopped(int sessionId){}; protected int getCurrentSessionId() { diff --git a/core/java/com/droidlogic/app/tv/TvInputBaseSession.java b/core/java/com/droidlogic/app/tv/TvInputBaseSession.java index 47c6eed..03d8da3 100644 --- a/core/java/com/droidlogic/app/tv/TvInputBaseSession.java +++ b/core/java/com/droidlogic/app/tv/TvInputBaseSession.java @@ -97,8 +97,8 @@ public abstract class TvInputBaseSession extends TvInputService.Session implemen return mDeviceId; } - public void doRelease() { - Log.d(TAG, "doRelease"); + public void performDoReleaseSession() { + Log.d(TAG, "performDoReleaseSession,session:"+this); //setAudiodMute(false); mContext.unregisterReceiver(mBroadcastReceiver); setOverlayViewEnabled(false); @@ -112,11 +112,6 @@ public abstract class TvInputBaseSession extends TvInputService.Session implemen public void doUnblockContent(TvContentRating rating) {} @Override - public void onRelease() { - doRelease(); - } - - @Override public void onSurfaceChanged(int format, int width, int height) { } |