summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSham Rathod <sham.rathod@ittiam.com>2023-07-18 09:24:54 +0530
committerSham Rathod <sham.rathod@ittiam.com>2023-07-18 09:40:10 +0530
commita371c105f687aea8a05c8e2f391ec0e2bcbe36b1 (patch)
tree666f5880a1cafeb02ff0004c8e6d0928a7ccb029
parent456192025498e5b4c1207b23acdac440ffcdc7b6 (diff)
downloadTvProvider-a371c105f687aea8a05c8e2f391ec0e2bcbe36b1.tar.gz
TvProvider: Reduce synchronized block
Remove synchronized from ensureOldTransientRowsDeleted method and make smaller critical section synchronized to reduce chances of ANR. Test: atest com.android.providers.tv.TransientRowHelperTests Bug: 259445912 Change-Id: Icd5029efa04e1239704cc2a81c43a1485f256f04
-rw-r--r--src/com/android/providers/tv/TransientRowHelper.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/com/android/providers/tv/TransientRowHelper.java b/src/com/android/providers/tv/TransientRowHelper.java
index 7054a0c..c289633 100644
--- a/src/com/android/providers/tv/TransientRowHelper.java
+++ b/src/com/android/providers/tv/TransientRowHelper.java
@@ -71,11 +71,13 @@ public class TransientRowHelper {
/**
* Ensures that transient rows, inserted previously before current boot, are deleted.
*/
- public synchronized void ensureOldTransientRowsDeleted() {
- if (mTransientRowsDeleted) {
- return;
+ public void ensureOldTransientRowsDeleted() {
+ synchronized (this) {
+ if (mTransientRowsDeleted) {
+ return;
+ }
+ mTransientRowsDeleted = true;
}
- mTransientRowsDeleted = true;
if (getLastDeletionBootCount() >= getBootCount()) {
// This can be the second execution of TvProvider after boot since system kills
// TvProvider in low memory conditions. If this is the case, we shouldn't delete