Home | History | Annotate | Download | only in impl
      1 /*
      2  * Copyright (C) 2015 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 package com.android.voicemail.impl;
     17 
     18 import android.support.annotation.IntDef;
     19 import java.lang.annotation.Retention;
     20 import java.lang.annotation.RetentionPolicy;
     21 
     22 /**
     23  * Wrapper class to hold relevant OMTP constants as defined in the OMTP spec.
     24  *
     25  * <p>In essence this is a programmatic representation of the relevant portions of OMTP spec.
     26  */
     27 public class OmtpConstants {
     28   public static final String SMS_FIELD_SEPARATOR = ";";
     29   public static final String SMS_KEY_VALUE_SEPARATOR = "=";
     30   public static final String SMS_PREFIX_SEPARATOR = ":";
     31 
     32   public static final String SYNC_SMS_PREFIX = "SYNC";
     33   public static final String STATUS_SMS_PREFIX = "STATUS";
     34 
     35   // This is the format designated by the OMTP spec.
     36   public static final String DATE_TIME_FORMAT = "dd/MM/yyyy HH:mm Z";
     37 
     38   /** OMTP protocol versions. */
     39   public static final String PROTOCOL_VERSION1_1 = "11";
     40 
     41   public static final String PROTOCOL_VERSION1_2 = "12";
     42   public static final String PROTOCOL_VERSION1_3 = "13";
     43 
     44   ///////////////////////// Client/Mobile originated SMS //////////////////////
     45 
     46   /** Mobile Originated requests */
     47   public static final String ACTIVATE_REQUEST = "Activate";
     48 
     49   public static final String DEACTIVATE_REQUEST = "Deactivate";
     50   public static final String STATUS_REQUEST = "Status";
     51 
     52   /** fields that can be present in a Mobile Originated OMTP SMS */
     53   public static final String CLIENT_TYPE = "ct";
     54 
     55   public static final String APPLICATION_PORT = "pt";
     56   public static final String PROTOCOL_VERSION = "pv";
     57 
     58   //////////////////////////////// Sync SMS fields ////////////////////////////
     59 
     60   /**
     61    * Sync SMS fields.
     62    *
     63    * <p>Each string constant is the field's key in the SMS body which is used by the parser to
     64    * identify the field's value, if present, in the SMS body.
     65    */
     66 
     67   /** The event that triggered this SYNC SMS. See {@link OmtpConstants#SYNC_TRIGGER_EVENT_VALUES} */
     68   public static final String SYNC_TRIGGER_EVENT = "ev";
     69 
     70   public static final String MESSAGE_UID = "id";
     71   public static final String MESSAGE_LENGTH = "l";
     72   public static final String NUM_MESSAGE_COUNT = "c";
     73   /** See {@link OmtpConstants#CONTENT_TYPE_VALUES} */
     74   public static final String CONTENT_TYPE = "t";
     75 
     76   public static final String SENDER = "s";
     77   public static final String TIME = "dt";
     78 
     79   /**
     80    * SYNC message trigger events.
     81    *
     82    * <p>These are the possible values of {@link OmtpConstants#SYNC_TRIGGER_EVENT}.
     83    */
     84   public static final String NEW_MESSAGE = "NM";
     85 
     86   public static final String MAILBOX_UPDATE = "MBU";
     87   public static final String GREETINGS_UPDATE = "GU";
     88 
     89   public static final String[] SYNC_TRIGGER_EVENT_VALUES = {
     90     NEW_MESSAGE, MAILBOX_UPDATE, GREETINGS_UPDATE
     91   };
     92 
     93   /**
     94    * Content types supported by OMTP VVM.
     95    *
     96    * <p>These are the possible values of {@link OmtpConstants#CONTENT_TYPE}.
     97    */
     98   public static final String VOICE = "v";
     99 
    100   public static final String VIDEO = "o";
    101   public static final String FAX = "f";
    102   /** Voice message deposited by an external application */
    103   public static final String INFOTAINMENT = "i";
    104   /** Empty Call Capture - i.e. voicemail with no voice message. */
    105   public static final String ECC = "e";
    106 
    107   public static final String[] CONTENT_TYPE_VALUES = {VOICE, VIDEO, FAX, INFOTAINMENT, ECC};
    108 
    109   ////////////////////////////// Status SMS fields ////////////////////////////
    110 
    111   /**
    112    * Status SMS fields.
    113    *
    114    * <p>Each string constant is the field's key in the SMS body which is used by the parser to
    115    * identify the field's value, if present, in the SMS body.
    116    */
    117   /** See {@link OmtpConstants#PROVISIONING_STATUS_VALUES} */
    118   public static final String PROVISIONING_STATUS = "st";
    119   /** See {@link OmtpConstants#RETURN_CODE_VALUES} */
    120   public static final String RETURN_CODE = "rc";
    121   /** URL to send users to for activation VVM */
    122   public static final String SUBSCRIPTION_URL = "rs";
    123   /** IMAP4/SMTP server IP address or fully qualified domain name */
    124   public static final String SERVER_ADDRESS = "srv";
    125   /** Phone number to access voicemails through Telephony User Interface */
    126   public static final String TUI_ACCESS_NUMBER = "tui";
    127 
    128   public static final String TUI_PASSWORD_LENGTH = "pw_len";
    129   /** Number to send client origination SMS */
    130   public static final String CLIENT_SMS_DESTINATION_NUMBER = "dn";
    131 
    132   public static final String IMAP_PORT = "ipt";
    133   public static final String IMAP_USER_NAME = "u";
    134   public static final String IMAP_PASSWORD = "pw";
    135   public static final String SMTP_PORT = "spt";
    136   public static final String SMTP_USER_NAME = "smtp_u";
    137   public static final String SMTP_PASSWORD = "smtp_pw";
    138 
    139   /**
    140    * User provisioning status values.
    141    *
    142    * <p>Referred by {@link OmtpConstants#PROVISIONING_STATUS}.
    143    */
    144   public static final String SUBSCRIBER_NEW = "N";
    145 
    146   public static final String SUBSCRIBER_READY = "R";
    147   public static final String SUBSCRIBER_PROVISIONED = "P";
    148   public static final String SUBSCRIBER_UNKNOWN = "U";
    149   public static final String SUBSCRIBER_BLOCKED = "B";
    150 
    151   public static final String[] PROVISIONING_STATUS_VALUES = {
    152     SUBSCRIBER_NEW, SUBSCRIBER_READY, SUBSCRIBER_PROVISIONED, SUBSCRIBER_UNKNOWN, SUBSCRIBER_BLOCKED
    153   };
    154 
    155   /**
    156    * The return code included in a status message.
    157    *
    158    * <p>These are the possible values of {@link OmtpConstants#RETURN_CODE}.
    159    */
    160   public static final String SUCCESS = "0";
    161 
    162   public static final String SYSTEM_ERROR = "1";
    163   public static final String SUBSCRIBER_ERROR = "2";
    164   public static final String MAILBOX_UNKNOWN = "3";
    165   public static final String VVM_NOT_ACTIVATED = "4";
    166   public static final String VVM_NOT_PROVISIONED = "5";
    167   public static final String VVM_CLIENT_UKNOWN = "6";
    168   public static final String VVM_MAILBOX_NOT_INITIALIZED = "7";
    169 
    170   public static final String[] RETURN_CODE_VALUES = {
    171     SUCCESS,
    172     SYSTEM_ERROR,
    173     SUBSCRIBER_ERROR,
    174     MAILBOX_UNKNOWN,
    175     VVM_NOT_ACTIVATED,
    176     VVM_NOT_PROVISIONED,
    177     VVM_CLIENT_UKNOWN,
    178     VVM_MAILBOX_NOT_INITIALIZED,
    179   };
    180 
    181   /** IMAP command extensions */
    182 
    183   /**
    184    * OMTP spec v1.3 2.3.1 Change password request syntax
    185    *
    186    * <p>This changes the PIN to access the Telephone User Interface, the traditional voicemail
    187    * system.
    188    */
    189   public static final String IMAP_CHANGE_TUI_PWD_FORMAT = "XCHANGE_TUI_PWD PWD=%1$s OLD_PWD=%2$s";
    190 
    191   /**
    192    * OMTP spec v1.3 2.4.1 Change languate request syntax
    193    *
    194    * <p>This changes the language in the Telephone User Interface.
    195    */
    196   public static final String IMAP_CHANGE_VM_LANG_FORMAT = "XCHANGE_VM_LANG LANG=%1$s";
    197 
    198   /**
    199    * OMTP spec v1.3 2.5.1 Close NUT Request syntax
    200    *
    201    * <p>This disables the new user tutorial, the message played to new users calling in the
    202    * Telephone User Interface.
    203    */
    204   public static final String IMAP_CLOSE_NUT = "XCLOSE_NUT";
    205 
    206   /** Possible NO responses for CHANGE_TUI_PWD */
    207   public static final String RESPONSE_CHANGE_PIN_TOO_SHORT = "password too short";
    208 
    209   public static final String RESPONSE_CHANGE_PIN_TOO_LONG = "password too long";
    210   public static final String RESPONSE_CHANGE_PIN_TOO_WEAK = "password too weak";
    211   public static final String RESPONSE_CHANGE_PIN_MISMATCH = "old password mismatch";
    212   public static final String RESPONSE_CHANGE_PIN_INVALID_CHARACTER =
    213       "password contains invalid characters";
    214 
    215   @Retention(RetentionPolicy.SOURCE)
    216   @IntDef(
    217     value = {
    218       CHANGE_PIN_SUCCESS,
    219       CHANGE_PIN_TOO_SHORT,
    220       CHANGE_PIN_TOO_LONG,
    221       CHANGE_PIN_TOO_WEAK,
    222       CHANGE_PIN_MISMATCH,
    223       CHANGE_PIN_INVALID_CHARACTER,
    224       CHANGE_PIN_SYSTEM_ERROR
    225     }
    226   )
    227   public @interface ChangePinResult {}
    228 
    229   public static final int CHANGE_PIN_SUCCESS = 0;
    230   public static final int CHANGE_PIN_TOO_SHORT = 1;
    231   public static final int CHANGE_PIN_TOO_LONG = 2;
    232   public static final int CHANGE_PIN_TOO_WEAK = 3;
    233   public static final int CHANGE_PIN_MISMATCH = 4;
    234   public static final int CHANGE_PIN_INVALID_CHARACTER = 5;
    235   public static final int CHANGE_PIN_SYSTEM_ERROR = 6;
    236 
    237   /** Indicates the client is Google visual voicemail version 1.0. */
    238   public static final String CLIENT_TYPE_GOOGLE_10 = "google.vvm.10";
    239 }
    240