Home | History | Annotate | Download | only in enrichedcall
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.dialer.enrichedcall;
     18 
     19 import android.support.annotation.IntDef;
     20 import android.support.annotation.NonNull;
     21 import android.support.annotation.Nullable;
     22 import com.android.dialer.multimedia.MultimediaData;
     23 import java.lang.annotation.Retention;
     24 import java.lang.annotation.RetentionPolicy;
     25 
     26 /** Holds state information and data about enriched calling sessions. */
     27 public interface Session {
     28 
     29   /** Possible states for call composer sessions. */
     30   @Retention(RetentionPolicy.SOURCE)
     31   @IntDef({
     32     STATE_NONE,
     33     STATE_STARTING,
     34     STATE_STARTED,
     35     STATE_START_FAILED,
     36     STATE_MESSAGE_SENT,
     37     STATE_MESSAGE_FAILED,
     38     STATE_CLOSED,
     39   })
     40   @interface State {}
     41 
     42   int STATE_NONE = 0;
     43   int STATE_STARTING = STATE_NONE + 1;
     44   int STATE_STARTED = STATE_STARTING + 1;
     45   int STATE_START_FAILED = STATE_STARTED + 1;
     46   int STATE_MESSAGE_SENT = STATE_START_FAILED + 1;
     47   int STATE_MESSAGE_FAILED = STATE_MESSAGE_SENT + 1;
     48   int STATE_CLOSED = STATE_MESSAGE_FAILED + 1;
     49 
     50   /** Id used for sessions that fail to start. */
     51   long NO_SESSION_ID = -1;
     52 
     53   /**
     54    * An id for the specific case when sending a message fails so early that a message id isn't
     55    * created.
     56    */
     57   String MESSAGE_ID_COULD_NOT_CREATE_ID = "messageIdCouldNotCreateId";
     58 
     59   /**
     60    * Returns the id associated with this session, or {@link #NO_SESSION_ID} if this represents a
     61    * session that failed to start.
     62    */
     63   long getSessionId();
     64 
     65   /** Returns the id of the dialer call associated with this session, or null if there isn't one. */
     66   @Nullable
     67   String getUniqueDialerCallId();
     68 
     69   void setUniqueDialerCallId(@NonNull String id);
     70 
     71   /** Returns the number associated with the remote end of this session. */
     72   @NonNull
     73   String getRemoteNumber();
     74 
     75   /** Returns the {@link State} for this session. */
     76   @State
     77   int getState();
     78 
     79   /** Returns the {@link MultimediaData} associated with this session. */
     80   @NonNull
     81   MultimediaData getMultimediaData();
     82 
     83   /** Returns type of this session, based on some arbitrarily defined type. */
     84   int getType();
     85 
     86   /**
     87    * Sets the {@link MultimediaData} for this session.
     88    *
     89    *
     90    * @throws IllegalArgumentException if the type is invalid
     91    */
     92   void setSessionData(@NonNull MultimediaData multimediaData, int type);
     93 }
     94