From bebfebaaf4d82a2907c2bc87c55b2fbd6cdf449d Mon Sep 17 00:00:00 2001 From: Live Channels Team Date: Mon, 29 Apr 2019 16:08:15 -0700 Subject: Changes imported from Live Channels - 245843574 CLEANUP: Remove unused fields and methods from TestSingle... by nchalko PiperOrigin-RevId: 245843574 Change-Id: I536e4a683efd642e1ff2f9594f6c08b3abc20b1e Test: m LiveTv --- src/com/android/tv/SetupPassthroughActivity.java | 65 +++++++++++++++--------- 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'src/com/android/tv/SetupPassthroughActivity.java') diff --git a/src/com/android/tv/SetupPassthroughActivity.java b/src/com/android/tv/SetupPassthroughActivity.java index 5185b122..95fd93d5 100644 --- a/src/com/android/tv/SetupPassthroughActivity.java +++ b/src/com/android/tv/SetupPassthroughActivity.java @@ -37,7 +37,10 @@ import com.android.tv.util.SetupUtils; import com.android.tv.util.TvInputManagerHelper; import com.android.tv.util.Utils; import com.google.android.tv.partner.support.EpgContract; +import dagger.android.AndroidInjection; +import dagger.android.ContributesAndroidInjector; import java.util.concurrent.TimeUnit; +import javax.inject.Inject; /** * An activity to launch a TV input setup activity. @@ -55,18 +58,19 @@ public class SetupPassthroughActivity extends Activity { private TvInputInfo mTvInputInfo; private Intent mActivityAfterCompletion; private boolean mEpgFetcherDuringScan; - private EpgInputWhiteList mEpgInputWhiteList; + @Inject EpgInputWhiteList mEpgInputWhiteList; + @Inject TvInputManagerHelper mInputManager; + @Inject SetupUtils mSetupUtils; + @Inject ChannelDataManager mChannelDataManager; @Override public void onCreate(Bundle savedInstanceState) { if (DEBUG) Log.d(TAG, "onCreate"); + AndroidInjection.inject(this); super.onCreate(savedInstanceState); - TvSingletons tvSingletons = TvSingletons.getSingletons(this); - TvInputManagerHelper inputManager = tvSingletons.getTvInputManagerHelper(); Intent intent = getIntent(); String inputId = intent.getStringExtra(InputSetupActionUtils.EXTRA_INPUT_ID); - mTvInputInfo = inputManager.getTvInputInfo(inputId); - mEpgInputWhiteList = new EpgInputWhiteList(tvSingletons.getCloudEpgFlags()); + mTvInputInfo = mInputManager.getTvInputInfo(inputId); mActivityAfterCompletion = InputSetupActionUtils.getExtraActivityAfter(intent); boolean needToFetchEpg = mTvInputInfo != null && Utils.isInternalTvInput(this, mTvInputInfo.getId()); @@ -114,7 +118,7 @@ public class SetupPassthroughActivity extends Activity { } if (needToFetchEpg) { if (sScanTimeoutMonitor == null) { - sScanTimeoutMonitor = new ScanTimeoutMonitor(this); + sScanTimeoutMonitor = new ScanTimeoutMonitor(this, mChannelDataManager); } sScanTimeoutMonitor.startMonitoring(); TvSingletons.getSingletons(this).getEpgFetcher().onChannelScanStarted(); @@ -142,6 +146,16 @@ public class SetupPassthroughActivity extends Activity { finish(); return; } + if (TvFeatures.CLOUD_EPG_FOR_3RD_PARTY.isEnabled(this) + && data != null + && data.getBooleanExtra(EpgContract.EXTRA_USE_CLOUD_EPG, false)) { + if (DEBUG) Log.d(TAG, "extra " + data.getExtras()); + String inputId = data.getStringExtra(TvInputInfo.EXTRA_INPUT_ID); + if (mEpgInputWhiteList.isInputWhiteListed(inputId)) { + epgFetcher.fetchImmediately(); + } + } + if (mTvInputInfo == null) { Log.w( TAG, @@ -152,21 +166,19 @@ public class SetupPassthroughActivity extends Activity { finish(); return; } - TvSingletons.getSingletons(this) - .getSetupUtils() - .onTvInputSetupFinished( - mTvInputInfo.getId(), - () -> { - if (mActivityAfterCompletion != null) { - try { - startActivity(mActivityAfterCompletion); - } catch (ActivityNotFoundException e) { - Log.w(TAG, "Activity launch failed", e); - } - } - setResult(resultCode, data); - finish(); - }); + mSetupUtils.onTvInputSetupFinished( + mTvInputInfo.getId(), + () -> { + if (mActivityAfterCompletion != null) { + try { + startActivity(mActivityAfterCompletion); + } catch (ActivityNotFoundException e) { + Log.w(TAG, "Activity launch failed", e); + } + } + setResult(resultCode, data); + finish(); + }); } /** @@ -207,9 +219,9 @@ public class SetupPassthroughActivity extends Activity { }; private boolean mStarted; - private ScanTimeoutMonitor(Context context) { + private ScanTimeoutMonitor(Context context, ChannelDataManager mChannelDataManager) { mContext = context.getApplicationContext(); - mChannelDataManager = TvSingletons.getSingletons(context).getChannelDataManager(); + this.mChannelDataManager = mChannelDataManager; } private void startMonitoring() { @@ -240,4 +252,11 @@ public class SetupPassthroughActivity extends Activity { TvSingletons.getSingletons(mContext).getEpgFetcher().onChannelScanFinished(); } } + + /** Exports {@link MainActivity} for Dagger codegen to create the appropriate injector. */ + @dagger.Module + public abstract static class Module { + @ContributesAndroidInjector + abstract SetupPassthroughActivity contributesSetupPassthroughActivity(); + } } -- cgit v1.2.3