summaryrefslogtreecommitdiff
path: root/telecomm/java/android/telecom/Logging/Session.java
diff options
context:
space:
mode:
authorBrad Ebinger <breadley@google.com>2016-10-13 15:26:58 -0700
committerBrad Ebinger <breadley@google.com>2016-10-13 15:26:58 -0700
commit096d2829edd2cda66a004ea7216975730981814e (patch)
tree4e34b687722cac96dd091837b045165f34239bfc /telecomm/java/android/telecom/Logging/Session.java
parentcbb03d1ad375fb5252a5da47f5438667134ab848 (diff)
Add support for new SessionManager and EventManager tests
Test: Ran new unit tests Bug: 26571395 Change-Id: I6d14d7c05b8fdc8dc1319a81f0e41f7bcd989b85
Diffstat (limited to 'telecomm/java/android/telecom/Logging/Session.java')
-rw-r--r--telecomm/java/android/telecom/Logging/Session.java69
1 files changed, 48 insertions, 21 deletions
diff --git a/telecomm/java/android/telecom/Logging/Session.java b/telecomm/java/android/telecom/Logging/Session.java
index 14f4a0f82f89..510abddb4f93 100644
--- a/telecomm/java/android/telecom/Logging/Session.java
+++ b/telecomm/java/android/telecom/Logging/Session.java
@@ -33,6 +33,10 @@ public class Session {
public static final String END_SUBSESSION = "END_SUBSESSION";
public static final String END_SESSION = "END_SESSION";
+ /**
+ * Initial value of mExecutionEndTimeMs and the final value of {@link #getLocalExecutionTime()}
+ * if the Session is canceled.
+ */
public static final int UNDEFINED = -1;
private String mSessionId;
@@ -140,27 +144,6 @@ public class Session {
return String.valueOf(mChildCounter++);
}
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Session)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- Session otherSession = (Session) obj;
- return (mSessionId.equals(otherSession.mSessionId)) &&
- (mShortMethodName.equals(otherSession.mShortMethodName)) &&
- mExecutionStartTimeMs == otherSession.mExecutionStartTimeMs &&
- mParentSession == otherSession.mParentSession &&
- mChildSessions.equals(otherSession.mChildSessions) &&
- mIsCompleted == otherSession.mIsCompleted &&
- mExecutionEndTimeMs == otherSession.mExecutionEndTimeMs &&
- mChildCounter == otherSession.mChildCounter &&
- mIsStartedFromActiveSession == otherSession.mIsStartedFromActiveSession &&
- mOwnerInfo == otherSession.mOwnerInfo;
- }
-
// Builds full session id recursively
private String getFullSessionId() {
// Cache mParentSession locally to prevent a concurrency problem where
@@ -204,6 +187,50 @@ public class Session {
}
@Override
+ public int hashCode() {
+ int result = mSessionId != null ? mSessionId.hashCode() : 0;
+ result = 31 * result + (mShortMethodName != null ? mShortMethodName.hashCode() : 0);
+ result = 31 * result + (int) (mExecutionStartTimeMs ^ (mExecutionStartTimeMs >>> 32));
+ result = 31 * result + (int) (mExecutionEndTimeMs ^ (mExecutionEndTimeMs >>> 32));
+ result = 31 * result + (mParentSession != null ? mParentSession.hashCode() : 0);
+ result = 31 * result + (mChildSessions != null ? mChildSessions.hashCode() : 0);
+ result = 31 * result + (mIsCompleted ? 1 : 0);
+ result = 31 * result + mChildCounter;
+ result = 31 * result + (mIsStartedFromActiveSession ? 1 : 0);
+ result = 31 * result + (mOwnerInfo != null ? mOwnerInfo.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Session session = (Session) o;
+
+ if (mExecutionStartTimeMs != session.mExecutionStartTimeMs) return false;
+ if (mExecutionEndTimeMs != session.mExecutionEndTimeMs) return false;
+ if (mIsCompleted != session.mIsCompleted) return false;
+ if (mChildCounter != session.mChildCounter) return false;
+ if (mIsStartedFromActiveSession != session.mIsStartedFromActiveSession) return false;
+ if (mSessionId != null ?
+ !mSessionId.equals(session.mSessionId) : session.mSessionId != null)
+ return false;
+ if (mShortMethodName != null ? !mShortMethodName.equals(session.mShortMethodName)
+ : session.mShortMethodName != null)
+ return false;
+ if (mParentSession != null ? !mParentSession.equals(session.mParentSession)
+ : session.mParentSession != null)
+ return false;
+ if (mChildSessions != null ? !mChildSessions.equals(session.mChildSessions)
+ : session.mChildSessions != null)
+ return false;
+ return mOwnerInfo != null ? mOwnerInfo.equals(session.mOwnerInfo)
+ : session.mOwnerInfo == null;
+
+ }
+
+ @Override
public String toString() {
if (mParentSession != null && mIsStartedFromActiveSession) {
// Log.startSession was called from within another active session. Use the parent's