summaryrefslogtreecommitdiff
path: root/telecomm/java
diff options
context:
space:
mode:
author Priyanka Advani (xWF) <padvani@google.com> 2024-11-06 22:13:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-11-06 22:13:39 +0000
commit5d8accdd3da449b0d99147c77acaa525870527e8 (patch)
tree4b3cf1dbae8e6770508451b99ed36e92cef8eeb5 /telecomm/java
parentd4a941eb7bf04ad9298f5f598dd64dcb01783110 (diff)
Revert "Speculative fix for concurrency SessionManager issue"
Revert submission 30239784-spec_session_fix Reason for revert: Droidmonitor created revert due to b/377750579. Will be verifying through ABTD before submission. Reverted changes: /q/submissionid:30239784-spec_session_fix Change-Id: I3642b453f10095354bf4f82d14cfd275e7d143cc
Diffstat (limited to 'telecomm/java')
-rw-r--r--telecomm/java/android/telecom/Log.java19
-rw-r--r--telecomm/java/android/telecom/Logging/SessionManager.java34
2 files changed, 14 insertions, 39 deletions
diff --git a/telecomm/java/android/telecom/Log.java b/telecomm/java/android/telecom/Log.java
index 98949d0c45cf..a34094ce6452 100644
--- a/telecomm/java/android/telecom/Log.java
+++ b/telecomm/java/android/telecom/Log.java
@@ -68,7 +68,7 @@ public class Log {
// Used to synchronize singleton logging lazy initialization
private static final Object sSingletonSync = new Object();
private static EventManager sEventManager;
- private static volatile SessionManager sSessionManager;
+ private static SessionManager sSessionManager;
private static Object sLock = null;
/**
@@ -379,23 +379,6 @@ public class Log {
return sSessionManager;
}
- @VisibleForTesting
- public static SessionManager setSessionManager(Context context,
- java.lang.Runnable cleanSessionRunnable) {
- // Checking for null again outside of synchronization because we only need to synchronize
- // during the lazy loading of the session logger. We don't need to synchronize elsewhere.
- if (sSessionManager == null) {
- synchronized (sSingletonSync) {
- if (sSessionManager == null) {
- sSessionManager = new SessionManager(cleanSessionRunnable);
- sSessionManager.setContext(context);
- return sSessionManager;
- }
- }
- }
- return sSessionManager;
- }
-
public static void setTag(String tag) {
TAG = tag;
DEBUG = isLoggable(android.util.Log.DEBUG);
diff --git a/telecomm/java/android/telecom/Logging/SessionManager.java b/telecomm/java/android/telecom/Logging/SessionManager.java
index ac1e69e92ec0..00e344c67cc5 100644
--- a/telecomm/java/android/telecom/Logging/SessionManager.java
+++ b/telecomm/java/android/telecom/Logging/SessionManager.java
@@ -62,7 +62,9 @@ public class SessionManager {
@VisibleForTesting
public final ConcurrentHashMap<Integer, Session> mSessionMapper = new ConcurrentHashMap<>(64);
- private final java.lang.Runnable mCleanStaleSessions;
+ @VisibleForTesting
+ public java.lang.Runnable mCleanStaleSessions = () ->
+ cleanupStaleSessions(getSessionCleanupTimeoutMs());
private final Handler mSessionCleanupHandler = new Handler(Looper.getMainLooper());
// Overridden in LogTest to skip query to ContentProvider
@@ -108,39 +110,29 @@ public class SessionManager {
}
public SessionManager() {
- mCleanStaleSessions = () -> cleanupStaleSessions(getSessionCleanupTimeoutMs());
- }
-
- @VisibleForTesting
- public SessionManager(java.lang.Runnable cleanStaleSessionsRunnable) {
- mCleanStaleSessions = cleanStaleSessionsRunnable;
}
private long getSessionCleanupTimeoutMs() {
return mSessionCleanupTimeoutMs.get();
}
- private void resetStaleSessionTimer() {
+ private synchronized void resetStaleSessionTimer() {
if (!Flags.endSessionImprovements()) {
- resetStaleSessionTimerOld();
- return;
- }
- // Will be null in Log Testing
- if (mCleanStaleSessions == null) return;
- synchronized (mSessionCleanupHandler) {
- if (!mSessionCleanupHandler.hasCallbacks(mCleanStaleSessions)) {
+ mSessionCleanupHandler.removeCallbacksAndMessages(null);
+ // Will be null in Log Testing
+ if (mCleanStaleSessions != null) {
+ mSessionCleanupHandler.postDelayed(mCleanStaleSessions,
+ getSessionCleanupTimeoutMs());
+ }
+ } else {
+ if (mCleanStaleSessions != null
+ && !mSessionCleanupHandler.hasCallbacks(mCleanStaleSessions)) {
mSessionCleanupHandler.postDelayed(mCleanStaleSessions,
getSessionCleanupTimeoutMs());
}
}
}
- private synchronized void resetStaleSessionTimerOld() {
- if (mCleanStaleSessions == null) return;
- mSessionCleanupHandler.removeCallbacksAndMessages(null);
- mSessionCleanupHandler.postDelayed(mCleanStaleSessions, getSessionCleanupTimeoutMs());
- }
-
/**
* Determines whether or not to start a new session or continue an existing session based on
* the {@link Session.Info} info passed into startSession. If info is null, a new Session is