summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author wei.jing <wei.jing@mediatek.com> 2023-09-28 22:56:09 +0000
committer David Zhao <qingxun@google.com> 2023-09-29 05:53:41 +0000
commit8afdc1c65aeeb47d78ad850b17799ade26f4933b (patch)
tree12ea84437bd6227d7ce9e42fdfac0e239a3ff23c
parent5fcf035c0b30a927b7735a712414bbe234307fc5 (diff)
Fix 'ConcurrentModificationException' issue
[Description] solution for adding read and write protection to ‘mPendingAppPrivateCommands’. [Test Report] AC on/off PASS can bootup to TvLauncher PASS LiveTV open PASS VTS/CTS cmd: NA (cherry picked from https://partner-android-review.googlesource.com/q/commit:bc3a33fd8317bc43997721e51c18ce85543d6441) Bug: 302245330 Merged-In: Ic80466518ca35c16dde74dbbaada92f28eaaf6ef Change-Id: Ic80466518ca35c16dde74dbbaada92f28eaaf6ef
-rw-r--r--media/java/android/media/tv/TvView.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index a4e5fb6a6165..196b5c3112c0 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -401,7 +401,9 @@ public class TvView extends ViewGroup {
private void resetInternal() {
mSessionCallback = null;
- mPendingAppPrivateCommands.clear();
+ synchronized (mPendingAppPrivateCommands) {
+ mPendingAppPrivateCommands.clear();
+ }
if (mSession != null) {
setSessionSurface(null);
removeSessionOverlayView();
@@ -691,7 +693,10 @@ public class TvView extends ViewGroup {
} else {
Log.w(TAG, "sendAppPrivateCommand - session not yet created (action \"" + action
+ "\" pending)");
- mPendingAppPrivateCommands.add(Pair.create(action, data));
+
+ synchronized (mPendingAppPrivateCommands) {
+ mPendingAppPrivateCommands.add(Pair.create(action, data));
+ }
}
}
@@ -1320,10 +1325,13 @@ public class TvView extends ViewGroup {
mSession = session;
if (session != null) {
// Sends the pending app private commands first.
- for (Pair<String, Bundle> command : mPendingAppPrivateCommands) {
- mSession.sendAppPrivateCommand(command.first, command.second);
+
+ synchronized (mPendingAppPrivateCommands) {
+ for (Pair<String, Bundle> command : mPendingAppPrivateCommands) {
+ mSession.sendAppPrivateCommand(command.first, command.second);
+ }
+ mPendingAppPrivateCommands.clear();
}
- mPendingAppPrivateCommands.clear();
synchronized (sMainTvViewLock) {
if (hasWindowFocus() && TvView.this == sMainTvView.get()