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