summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amy <amyjojo@google.com> 2019-01-18 14:17:55 -0800
committer Amy <amyjojo@google.com> 2019-02-01 11:55:48 -0800
commit4aef3b40e01e69c3b08ded9c9cd7492c5764fb26 (patch)
treeb2fb4e89d2a8c85db69163ce2fa97454b1c67e81
parent4d1a60d70f1364249a61b226d681c5b0d5ecf9ac (diff)
Catch Activity Not Found Exception when switching to specific TV input.
Test: manual Bug: 122239611 Change-Id: I7f80fe864282fe5ca0639baa7d2adc797b14d9dc
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
index cac1a95454fa..93eba4dcd80e 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
@@ -20,6 +20,7 @@ import static com.android.server.hdmi.Constants.PROPERTY_SYSTEM_AUDIO_CONTROL_ON
import static com.android.server.hdmi.Constants.USE_LAST_STATE_SYSTEM_AUDIO_CONTROL_ON_POWER_ON;
import android.annotation.Nullable;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
@@ -1075,20 +1076,28 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
// For device to switch to specific TvInput with corresponding URI.
private void switchToTvInput(String uri) {
- mService.getContext().startActivity(new Intent(Intent.ACTION_VIEW,
- TvContract.buildChannelUriForPassthroughInput(uri))
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ try {
+ mService.getContext().startActivity(new Intent(Intent.ACTION_VIEW,
+ TvContract.buildChannelUriForPassthroughInput(uri))
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ } catch (ActivityNotFoundException e) {
+ Slog.e(TAG, "Can't find activity to switch to " + uri, e);
+ }
}
// For device using TvInput to switch to Home.
private void switchToHomeTvInput() {
- Intent activityIntent = new Intent(Intent.ACTION_MAIN)
- .addCategory(Intent.CATEGORY_HOME)
- .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
- | Intent.FLAG_ACTIVITY_SINGLE_TOP
- | Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_NO_ANIMATION);
- mService.getContext().startActivity(activityIntent);
+ try {
+ Intent activityIntent = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_HOME)
+ .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP
+ | Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ mService.getContext().startActivity(activityIntent);
+ } catch (ActivityNotFoundException e) {
+ Slog.e(TAG, "Can't find activity to switch to HOME", e);
+ }
}
@Override
@@ -1131,7 +1140,8 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
if (routingInformationPath == mService.getPhysicalAddress()) {
HdmiLogger.debug("Current device can't assign valid physical address"
+ "to devices under it any more. "
- + "It's physical address is " + routingInformationPath);
+ + "It's physical address is "
+ + routingInformationPath);
return;
}
// Otherwise will switch to the current active port and broadcast routing information.
@@ -1208,5 +1218,4 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
pw.decreaseIndent();
super.dump(pw);
}
-
}