diff options
author | maxwelb <maxwelb@google.com> | 2017-06-28 14:04:21 -0700 |
---|---|---|
committer | Brandon Maxwell <maxwelb@google.com> | 2017-06-30 14:40:31 -0700 |
commit | 8e3d56ca5de3ca651d27d560eba406be21eb7aa1 (patch) | |
tree | caf5a3cb8bd3046cfde4163e8117d45f3b58bc75 /java | |
parent | ad2cb45e7006de3fbe1d953a61c57345ca40a6a0 (diff) |
Move Session State definition into Session
The state of a session is more closely tied to the session itself,
rather than the EnrichedCallManager. The enum was originally placed in
the Manager as it was used in the API, but now that's no longer the
case.
This CL moves the Session State declaration into Session, which is a
more appropriate location.
Test: tap
PiperOrigin-RevId: 160448612
Change-Id: I907476140bc174a061d48ee8e58878af64a62b29
Diffstat (limited to 'java')
4 files changed, 43 insertions, 44 deletions
diff --git a/java/com/android/dialer/callcomposer/CallComposerActivity.java b/java/com/android/dialer/callcomposer/CallComposerActivity.java index 2f652e424..c22113fcc 100644 --- a/java/com/android/dialer/callcomposer/CallComposerActivity.java +++ b/java/com/android/dialer/callcomposer/CallComposerActivity.java @@ -64,8 +64,8 @@ import com.android.dialer.constants.Constants; import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; -import com.android.dialer.enrichedcall.EnrichedCallManager.State; import com.android.dialer.enrichedcall.Session; +import com.android.dialer.enrichedcall.Session.State; import com.android.dialer.enrichedcall.extensions.StateExtension; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; @@ -255,25 +255,25 @@ public class CallComposerActivity extends AppCompatActivity StateExtension.toString(state)); switch (state) { - case EnrichedCallManager.STATE_STARTING: + case Session.STATE_STARTING: timeoutHandler.postDelayed(sessionStartedTimedOut, getSessionStartedTimeoutMillis()); if (sendAndCallReady) { showLoadingUi(); } break; - case EnrichedCallManager.STATE_STARTED: + case Session.STATE_STARTED: timeoutHandler.removeCallbacks(sessionStartedTimedOut); if (sendAndCallReady) { sendAndCall(); } break; - case EnrichedCallManager.STATE_START_FAILED: - case EnrichedCallManager.STATE_CLOSED: + case Session.STATE_START_FAILED: + case Session.STATE_CLOSED: setFailedResultAndFinish(); break; - case EnrichedCallManager.STATE_MESSAGE_FAILED: - case EnrichedCallManager.STATE_MESSAGE_SENT: - case EnrichedCallManager.STATE_NONE: + case Session.STATE_MESSAGE_FAILED: + case Session.STATE_MESSAGE_SENT: + case Session.STATE_NONE: default: break; } @@ -385,7 +385,7 @@ public class CallComposerActivity extends AppCompatActivity private boolean sessionReady() { Session session = getEnrichedCallManager().getSession(sessionId); - return session != null && session.getState() == EnrichedCallManager.STATE_STARTED; + return session != null && session.getState() == Session.STATE_STARTED; } private void placeRCSCall(MultimediaData.Builder builder) { diff --git a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java index d341b43f9..f1057be1d 100644 --- a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java +++ b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java @@ -16,7 +16,6 @@ package com.android.dialer.enrichedcall; -import android.support.annotation.IntDef; import android.support.annotation.MainThread; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -25,8 +24,6 @@ import com.android.dialer.calldetails.CallDetailsEntries.CallDetailsEntry; import com.android.dialer.enrichedcall.historyquery.proto.HistoryResult; import com.android.dialer.enrichedcall.videoshare.VideoShareListener; import com.android.dialer.multimedia.MultimediaData; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.util.List; import java.util.Map; @@ -81,27 +78,6 @@ public interface EnrichedCallManager { @MainThread void clearCachedData(); - /** Possible states for call composer sessions. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({ - STATE_NONE, - STATE_STARTING, - STATE_STARTED, - STATE_START_FAILED, - STATE_MESSAGE_SENT, - STATE_MESSAGE_FAILED, - STATE_CLOSED, - }) - @interface State {} - - int STATE_NONE = 0; - int STATE_STARTING = STATE_NONE + 1; - int STATE_STARTED = STATE_STARTING + 1; - int STATE_START_FAILED = STATE_STARTED + 1; - int STATE_MESSAGE_SENT = STATE_START_FAILED + 1; - int STATE_MESSAGE_FAILED = STATE_MESSAGE_SENT + 1; - int STATE_CLOSED = STATE_MESSAGE_FAILED + 1; - /** * Starts a call composer session with the given remote number. * @@ -119,7 +95,7 @@ public interface EnrichedCallManager { * @param sessionId the id for the session. See {@link #startCallComposerSession(String)} * @param data the {@link MultimediaData} * @throws IllegalArgumentException if there's no open session with the given number - * @throws IllegalStateException if the session isn't in the {@link #STATE_STARTED} state + * @throws IllegalStateException if the session isn't in the {@link Session#STATE_STARTED} state */ @MainThread void sendCallComposerData(long sessionId, @NonNull MultimediaData data); diff --git a/java/com/android/dialer/enrichedcall/Session.java b/java/com/android/dialer/enrichedcall/Session.java index b3f291438..06837e399 100644 --- a/java/com/android/dialer/enrichedcall/Session.java +++ b/java/com/android/dialer/enrichedcall/Session.java @@ -16,14 +16,37 @@ package com.android.dialer.enrichedcall; +import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.android.dialer.enrichedcall.EnrichedCallManager.State; import com.android.dialer.multimedia.MultimediaData; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; /** Holds state information and data about enriched calling sessions. */ public interface Session { + /** Possible states for call composer sessions. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({ + STATE_NONE, + STATE_STARTING, + STATE_STARTED, + STATE_START_FAILED, + STATE_MESSAGE_SENT, + STATE_MESSAGE_FAILED, + STATE_CLOSED, + }) + @interface State {} + + int STATE_NONE = 0; + int STATE_STARTING = STATE_NONE + 1; + int STATE_STARTED = STATE_STARTING + 1; + int STATE_START_FAILED = STATE_STARTED + 1; + int STATE_MESSAGE_SENT = STATE_START_FAILED + 1; + int STATE_MESSAGE_FAILED = STATE_MESSAGE_SENT + 1; + int STATE_CLOSED = STATE_MESSAGE_FAILED + 1; + /** Id used for sessions that fail to start. */ long NO_SESSION_ID = -1; diff --git a/java/com/android/dialer/enrichedcall/extensions/StateExtension.java b/java/com/android/dialer/enrichedcall/extensions/StateExtension.java index 8a4f6409d..5d90829c3 100644 --- a/java/com/android/dialer/enrichedcall/extensions/StateExtension.java +++ b/java/com/android/dialer/enrichedcall/extensions/StateExtension.java @@ -18,8 +18,8 @@ package com.android.dialer.enrichedcall.extensions; import android.support.annotation.NonNull; import com.android.dialer.common.Assert; -import com.android.dialer.enrichedcall.EnrichedCallManager; -import com.android.dialer.enrichedcall.EnrichedCallManager.State; +import com.android.dialer.enrichedcall.Session; +import com.android.dialer.enrichedcall.Session.State; /** Extends the {@link State} to include a toString method. */ public class StateExtension { @@ -27,25 +27,25 @@ public class StateExtension { /** Returns the string representation for the given {@link State}. */ @NonNull public static String toString(@State int callComposerState) { - if (callComposerState == EnrichedCallManager.STATE_NONE) { + if (callComposerState == Session.STATE_NONE) { return "STATE_NONE"; } - if (callComposerState == EnrichedCallManager.STATE_STARTING) { + if (callComposerState == Session.STATE_STARTING) { return "STATE_STARTING"; } - if (callComposerState == EnrichedCallManager.STATE_STARTED) { + if (callComposerState == Session.STATE_STARTED) { return "STATE_STARTED"; } - if (callComposerState == EnrichedCallManager.STATE_START_FAILED) { + if (callComposerState == Session.STATE_START_FAILED) { return "STATE_START_FAILED"; } - if (callComposerState == EnrichedCallManager.STATE_MESSAGE_SENT) { + if (callComposerState == Session.STATE_MESSAGE_SENT) { return "STATE_MESSAGE_SENT"; } - if (callComposerState == EnrichedCallManager.STATE_MESSAGE_FAILED) { + if (callComposerState == Session.STATE_MESSAGE_FAILED) { return "STATE_MESSAGE_FAILED"; } - if (callComposerState == EnrichedCallManager.STATE_CLOSED) { + if (callComposerState == Session.STATE_CLOSED) { return "STATE_CLOSED"; } Assert.checkArgument(false, "Unexpected callComposerState: %d", callComposerState); |