aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/receiver
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tv/receiver')
-rw-r--r--src/com/android/tv/receiver/AbstractGlobalKeyReceiver.java (renamed from src/com/android/tv/receiver/GlobalKeyReceiver.java)25
-rw-r--r--src/com/android/tv/receiver/AudioCapabilitiesReceiver.java35
-rw-r--r--src/com/android/tv/receiver/BootCompletedReceiver.java27
-rw-r--r--src/com/android/tv/receiver/PackageIntentsReceiver.java16
4 files changed, 51 insertions, 52 deletions
diff --git a/src/com/android/tv/receiver/GlobalKeyReceiver.java b/src/com/android/tv/receiver/AbstractGlobalKeyReceiver.java
index cc8e76c4..f88bd8a8 100644
--- a/src/com/android/tv/receiver/GlobalKeyReceiver.java
+++ b/src/com/android/tv/receiver/AbstractGlobalKeyReceiver.java
@@ -23,15 +23,14 @@ import android.os.AsyncTask;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
-
+import com.android.tv.Starter;
import com.android.tv.TvApplication;
+import com.android.tv.TvSingletons;
-/**
- * Handles global keys.
- */
-public class GlobalKeyReceiver extends BroadcastReceiver {
+/** Handles global keys. */
+public abstract class AbstractGlobalKeyReceiver extends BroadcastReceiver {
private static final boolean DEBUG = false;
- private static final String TAG = "GlobalKeyReceiver";
+ private static final String TAG = "AbstractGlobalKeyReceiver";
private static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
// Settings.Secure.USER_SETUP_COMPLETE is hidden.
@@ -42,11 +41,11 @@ public class GlobalKeyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- if (!TvApplication.getSingletons(context).getTvInputManagerHelper().hasTvInputManager()) {
+ if (!TvSingletons.getSingletons(context).getTvInputManagerHelper().hasTvInputManager()) {
Log.wtf(TAG, "Stopping because device does not have a TvInputManager");
return;
}
- TvApplication.setCurrentRunningProcess(context, true);
+ Starter.start(context);
Context appContext = context.getApplicationContext();
if (DEBUG) Log.d(TAG, "onReceive: " + intent);
if (sUserSetupComplete) {
@@ -55,8 +54,11 @@ public class GlobalKeyReceiver extends BroadcastReceiver {
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
- return Settings.Secure.getInt(appContext.getContentResolver(),
- SETTINGS_USER_SETUP_COMPLETE, 0) != 0;
+ return Settings.Secure.getInt(
+ appContext.getContentResolver(),
+ SETTINGS_USER_SETUP_COMPLETE,
+ 0)
+ != 0;
}
@Override
@@ -82,6 +84,9 @@ public class GlobalKeyReceiver extends BroadcastReceiver {
// Workaround for b/23947504, the same key event may be sent twice, filter it.
sLastEventTime = eventTime;
switch (keyCode) {
+ case KeyEvent.KEYCODE_DVR:
+ ((TvApplication) appContext).handleDvrKey();
+ break;
case KeyEvent.KEYCODE_GUIDE:
((TvApplication) appContext).handleGuideKey();
break;
diff --git a/src/com/android/tv/receiver/AudioCapabilitiesReceiver.java b/src/com/android/tv/receiver/AudioCapabilitiesReceiver.java
index 313b2dfa..3fb66245 100644
--- a/src/com/android/tv/receiver/AudioCapabilitiesReceiver.java
+++ b/src/com/android/tv/receiver/AudioCapabilitiesReceiver.java
@@ -24,17 +24,15 @@ import android.media.AudioFormat;
import android.media.AudioManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-
-import com.android.tv.ApplicationSingletons;
-import com.android.tv.TvApplication;
+import com.android.tv.TvSingletons;
import com.android.tv.analytics.Analytics;
import com.android.tv.analytics.Tracker;
-import com.android.tv.common.SharedPreferencesUtils;
+import com.android.tv.common.util.SharedPreferencesUtils;
/**
* Creates HDMI plug broadcast receiver, and reports AC3 passthrough capabilities to Google
- * Analytics and listeners. Call {@link #register} to start receiving notifications, and
- * {@link #unregister} to stop.
+ * Analytics and listeners. Call {@link #register} to start receiving notifications, and {@link
+ * #unregister} to stop.
*/
public final class AudioCapabilitiesReceiver {
private static final String SETTINGS_KEY_AC3_PASSTHRU_REPORTED = "ac3_passthrough_reported";
@@ -50,8 +48,7 @@ public final class AudioCapabilitiesReceiver {
private final Context mContext;
private final Analytics mAnalytics;
private final Tracker mTracker;
- @Nullable
- private final OnAc3PassthroughCapabilityChangeListener mListener;
+ @Nullable private final OnAc3PassthroughCapabilityChangeListener mListener;
private final BroadcastReceiver mReceiver = new HdmiAudioPlugBroadcastReceiver();
/**
@@ -60,12 +57,12 @@ public final class AudioCapabilitiesReceiver {
* @param context context for registering to receive broadcasts
* @param listener listener which receives AC3 passthrough capability change notification
*/
- public AudioCapabilitiesReceiver(@NonNull Context context,
- @Nullable OnAc3PassthroughCapabilityChangeListener listener) {
+ public AudioCapabilitiesReceiver(
+ @NonNull Context context, @Nullable OnAc3PassthroughCapabilityChangeListener listener) {
mContext = context;
- ApplicationSingletons appSingletons = TvApplication.getSingletons(context);
- mAnalytics = appSingletons.getAnalytics();
- mTracker = appSingletons.getTracker();
+ TvSingletons tvSingletons = TvSingletons.getSingletons(context);
+ mAnalytics = tvSingletons.getAnalytics();
+ mTracker = tvSingletons.getTracker();
mListener = listener;
}
@@ -121,8 +118,8 @@ public final class AudioCapabilitiesReceiver {
}
private SharedPreferences getSharedPreferences() {
- return mContext.getSharedPreferences(SharedPreferencesUtils.SHARED_PREF_AUDIO_CAPABILITIES,
- Context.MODE_PRIVATE);
+ return mContext.getSharedPreferences(
+ SharedPreferencesUtils.SHARED_PREF_AUDIO_CAPABILITIES, Context.MODE_PRIVATE);
}
private boolean getBoolean(String key, boolean def) {
@@ -141,13 +138,9 @@ public final class AudioCapabilitiesReceiver {
getSharedPreferences().edit().putInt(key, val).apply();
}
- /**
- * Listener notified when AC3 passthrough capability changes.
- */
+ /** Listener notified when AC3 passthrough capability changes. */
public interface OnAc3PassthroughCapabilityChangeListener {
- /**
- * Called when the AC3 passthrough capability changes.
- */
+ /** Called when the AC3 passthrough capability changes. */
void onAc3PassthroughCapabilityChange(boolean capability);
}
}
diff --git a/src/com/android/tv/receiver/BootCompletedReceiver.java b/src/com/android/tv/receiver/BootCompletedReceiver.java
index 369e7d54..d8528bb5 100644
--- a/src/com/android/tv/receiver/BootCompletedReceiver.java
+++ b/src/com/android/tv/receiver/BootCompletedReceiver.java
@@ -23,10 +23,10 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
-
-import com.android.tv.Features;
+import com.android.tv.Starter;
import com.android.tv.TvActivity;
-import com.android.tv.TvApplication;
+import com.android.tv.TvFeatures;
+import com.android.tv.TvSingletons;
import com.android.tv.dvr.recorder.DvrRecordingService;
import com.android.tv.dvr.recorder.RecordingScheduler;
import com.android.tv.recommendation.ChannelPreviewUpdater;
@@ -38,11 +38,12 @@ import com.android.tv.util.SetupUtils;
* Boot completed receiver for TV app.
*
* <p>It's used to
+ *
* <ul>
- * <li>start the {@link NotificationService} for recommendation</li>
- * <li>grant permission to the TIS's </li>
- * <li>enable {@link TvActivity} if necessary</li>
- * <li>start the {@link DvrRecordingService} </li>
+ * <li>start the {@link NotificationService} for recommendation
+ * <li>grant permission to the TIS's
+ * <li>enable {@link TvActivity} if necessary
+ * <li>start the {@link DvrRecordingService}
* </ul>
*/
public class BootCompletedReceiver extends BroadcastReceiver {
@@ -51,12 +52,12 @@ public class BootCompletedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- if (!TvApplication.getSingletons(context).getTvInputManagerHelper().hasTvInputManager()) {
+ if (!TvSingletons.getSingletons(context).getTvInputManagerHelper().hasTvInputManager()) {
Log.wtf(TAG, "Stopping because device does not have a TvInputManager");
return;
}
if (DEBUG) Log.d(TAG, "boot completed " + intent);
- TvApplication.setCurrentRunningProcess(context, true);
+ Starter.start(context);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ChannelPreviewUpdater.getInstance(context).updatePreviewDataForChannelsImmediately();
@@ -69,7 +70,7 @@ public class BootCompletedReceiver extends BroadcastReceiver {
// Grant permission to already set up packages after the system has finished booting.
SetupUtils.grantEpgPermissionToSetUpPackages(context);
- if (Features.UNHIDE.isEnabled(context)) {
+ if (TvFeatures.UNHIDE.isEnabled(context)) {
if (OnboardingUtils.isFirstBoot(context)) {
// Enable the application if this is the first "unhide" feature is enabled just in
// case when the app has been disabled before.
@@ -77,14 +78,14 @@ public class BootCompletedReceiver extends BroadcastReceiver {
ComponentName name = new ComponentName(context, TvActivity.class);
if (pm.getComponentEnabledSetting(name)
!= PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
- pm.setComponentEnabledSetting(name,
- PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
+ pm.setComponentEnabledSetting(
+ name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
}
OnboardingUtils.setFirstBootCompleted(context);
}
}
- RecordingScheduler scheduler = TvApplication.getSingletons(context).getRecordingScheduler();
+ RecordingScheduler scheduler = TvSingletons.getSingletons(context).getRecordingScheduler();
if (scheduler != null) {
scheduler.updateAndStartServiceIfNeeded();
}
diff --git a/src/com/android/tv/receiver/PackageIntentsReceiver.java b/src/com/android/tv/receiver/PackageIntentsReceiver.java
index 124172f0..07f5d6be 100644
--- a/src/com/android/tv/receiver/PackageIntentsReceiver.java
+++ b/src/com/android/tv/receiver/PackageIntentsReceiver.java
@@ -21,24 +21,24 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
-
-import com.android.tv.TvApplication;
+import com.android.tv.Starter;
+import com.android.tv.TvFeatures;
+import com.android.tv.TvSingletons;
import com.android.tv.util.Partner;
+import com.google.android.tv.partner.support.EpgContract;
-/**
- * A class for handling the broadcast intents from PackageManager.
- */
+/** A class for handling the broadcast intents from PackageManager. */
public class PackageIntentsReceiver extends BroadcastReceiver {
private static final String TAG = "PackageIntentsReceiver";
@Override
public void onReceive(Context context, Intent intent) {
- if (!TvApplication.getSingletons(context).getTvInputManagerHelper().hasTvInputManager()) {
+ if (!TvSingletons.getSingletons(context).getTvInputManagerHelper().hasTvInputManager()) {
Log.wtf(TAG, "Stopping because device does not have a TvInputManager");
return;
}
- TvApplication.setCurrentRunningProcess(context, true);
- ((TvApplication) context.getApplicationContext()).handleInputCountChanged();
+ Starter.start(context);
+ ((TvSingletons) context.getApplicationContext()).handleInputCountChanged();
Uri uri = intent.getData();
final String packageName = (uri != null ? uri.getSchemeSpecificPart() : null);