aboutsummaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2023-01-10 04:37:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-01-10 04:37:19 +0000
commitf2f975669134dafd8a7ca3ecea993f7d35852349 (patch)
tree8abdac95df9c079da43f9494e92309a1bc0b532d /src/com
parent89c8afb1214dbfad47462444a7920ed6b89cd68a (diff)
parent61fe46ffa4912b7d18e1d59e67bb95f13fb33d59 (diff)
downloadTV-f2f975669134dafd8a7ca3ecea993f7d35852349.tar.gz
Merge "enable device to customize setup activity via RRO"
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/tv/MainActivity.java2
-rw-r--r--src/com/android/tv/onboarding/OnboardingActivity.java2
-rw-r--r--src/com/android/tv/setup/SystemSetupActivity.java3
-rw-r--r--src/com/android/tv/util/SetupUtils.java50
4 files changed, 54 insertions, 3 deletions
diff --git a/src/com/android/tv/MainActivity.java b/src/com/android/tv/MainActivity.java
index 432f2e00..1f2fd027 100644
--- a/src/com/android/tv/MainActivity.java
+++ b/src/com/android/tv/MainActivity.java
@@ -1162,7 +1162,7 @@ public class MainActivity extends Activity
* @param calledByPopup If true, startSetupActivity is invoked from the setup fragment.
*/
public void startSetupActivity(TvInputInfo input, boolean calledByPopup) {
- Intent intent = CommonUtils.createSetupIntent(input);
+ Intent intent = mSetupUtils.createSetupIntent(this, input);
if (intent == null) {
Toast.makeText(this, R.string.msg_no_setup_activity, Toast.LENGTH_SHORT).show();
return;
diff --git a/src/com/android/tv/onboarding/OnboardingActivity.java b/src/com/android/tv/onboarding/OnboardingActivity.java
index dd386d81..0ce5d931 100644
--- a/src/com/android/tv/onboarding/OnboardingActivity.java
+++ b/src/com/android/tv/onboarding/OnboardingActivity.java
@@ -193,7 +193,7 @@ public class OnboardingActivity extends SetupActivity {
params.getString(
SetupSourcesFragment.ACTION_PARAM_KEY_INPUT_ID);
TvInputInfo input = mInputManager.getTvInputInfo(inputId);
- Intent intent = CommonUtils.createSetupIntent(input);
+ Intent intent = mSetupUtils.createSetupIntent(this, input);
if (intent == null) {
Toast.makeText(
this,
diff --git a/src/com/android/tv/setup/SystemSetupActivity.java b/src/com/android/tv/setup/SystemSetupActivity.java
index 7bf04692..b39ac4ea 100644
--- a/src/com/android/tv/setup/SystemSetupActivity.java
+++ b/src/com/android/tv/setup/SystemSetupActivity.java
@@ -53,6 +53,7 @@ public class SystemSetupActivity extends SetupActivity {
private static final int REQUEST_CODE_START_SETUP_ACTIVITY = 1;
@Inject TvInputManagerHelper mInputManager;
+ @Inject SetupUtils mSetupUtils;
@Inject UiFlags mUiFlags;
@Override
@@ -97,7 +98,7 @@ public class SystemSetupActivity extends SetupActivity {
params.getString(
SetupSourcesFragment.ACTION_PARAM_KEY_INPUT_ID);
TvInputInfo input = mInputManager.getTvInputInfo(inputId);
- Intent intent = CommonUtils.createSetupIntent(input);
+ Intent intent = mSetupUtils.createSetupIntent(this, input);
if (intent == null) {
Toast.makeText(
this,
diff --git a/src/com/android/tv/util/SetupUtils.java b/src/com/android/tv/util/SetupUtils.java
index 52b3e3e8..aaee1047 100644
--- a/src/com/android/tv/util/SetupUtils.java
+++ b/src/com/android/tv/util/SetupUtils.java
@@ -31,14 +31,18 @@ import android.support.annotation.UiThread;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
+import com.android.tv.R;
import com.android.tv.TvSingletons;
import com.android.tv.common.SoftPreconditions;
import com.android.tv.common.dagger.annotations.ApplicationContext;
import com.android.tv.common.singletons.HasTvInputId;
+import com.android.tv.common.util.CommonUtils;
import com.android.tv.data.ChannelDataManager;
import com.android.tv.data.api.Channel;
import com.android.tv.tunerinputcontroller.BuiltInTunerManager;
import com.google.common.base.Optional;
+
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -362,6 +366,52 @@ public class SetupUtils {
}
/**
+ * Create a Intent to launch setup activity for {@code inputId}. The setup activity defined
+ * in the overlayable resources precedes the one defined in the corresponding TV input service.
+ */
+ @Nullable
+ public Intent createSetupIntent(Context context, TvInputInfo input) {
+ String[] componentStrings = context.getResources()
+ .getStringArray(R.array.setup_ComponentNames);
+
+ if (componentStrings != null) {
+ for (String component : componentStrings) {
+ String[] split = component.split("#");
+ if (split.length != 2) {
+ Log.w(TAG, "Invalid component item: " + Arrays.toString(split));
+ continue;
+ }
+
+ final String inputId = split[0].trim();
+ if (inputId.equals(input.getId())) {
+ final String flattenedComponentName = split[1].trim();
+ final ComponentName componentName = ComponentName
+ .unflattenFromString(flattenedComponentName);
+ if (componentName == null) {
+ Log.w(TAG, "Failed to unflatten component: " + flattenedComponentName);
+ continue;
+ }
+
+ final Intent overlaySetupIntent = new Intent(Intent.ACTION_MAIN);
+ overlaySetupIntent.setComponent(componentName);
+ overlaySetupIntent.putExtra(TvInputInfo.EXTRA_INPUT_ID, inputId);
+
+ PackageManager pm = context.getPackageManager();
+ if (overlaySetupIntent.resolveActivityInfo(pm, 0) == null) {
+ Log.w(TAG, "unable to find component" + flattenedComponentName);
+ continue;
+ }
+
+ Log.i(TAG, "overlay input id: " + inputId
+ + " to setup activity: " + flattenedComponentName);
+ return CommonUtils.createSetupIntent(overlaySetupIntent, inputId);
+ }
+ }
+ }
+ return CommonUtils.createSetupIntent(input);
+ }
+
+ /**
* Called when an setup is done. Once it is called, {@link #isSetupDone} returns {@code true}
* for {@code inputId}.
*/