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 java.util.HashMap; 19 import java.util.Map; 20 21 /** 22 * Wrapper class to hold relevant OMTP constants as defined in the OMTP spec. 23 * <p> 24 * In essence this is a programmatic representation of the relevant portions of OMTP spec. 25 */ 26 public class OmtpConstants { 27 public static final String SMS_FIELD_SEPARATOR = ";"; 28 public static final String SMS_KEY_VALUE_SEPARATOR = "="; 29 public static final String SMS_PREFIX_SEPARATOR = ":"; 30 31 public static final String CLIENT_PREFIX = "//VVM"; 32 public static final String SYNC_SMS_PREFIX = CLIENT_PREFIX + ":SYNC:"; 33 public static final String STATUS_SMS_PREFIX = CLIENT_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 public static final String PROTOCOL_VERSION1_2 = "12"; 41 public static final String PROTOCOL_VERSION1_3 = "13"; 42 43 ///////////////////////// Client/Mobile originated SMS ////////////////////// 44 45 /** Mobile Originated requests */ 46 public static final String ACTIVATE_REQUEST = "Activate"; 47 public static final String DEACTIVATE_REQUEST = "Deactivate"; 48 public static final String STATUS_REQUEST = "Status"; 49 50 /** fields that can be present in a Mobile Originated OMTP SMS */ 51 public static final String CLIENT_TYPE = "ct"; 52 public static final String APPLICATION_PORT = "pt"; 53 public static final String PROTOCOL_VERSION = "pv"; 54 55 56 //////////////////////////////// Sync SMS fields //////////////////////////// 57 58 /** 59 * Sync SMS fields. 60 * <p> 61 * Each string constant is the field's key in the SMS body which is used by the parser to 62 * identify the field's value, if present, in the SMS body. 63 */ 64 65 /** 66 * The event that triggered this SYNC SMS. 67 * See {@link OmtpConstants#SYNC_TRIGGER_EVENT_VALUES} 68 */ 69 public static final String SYNC_TRIGGER_EVENT = "ev"; 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 public static final String SENDER = "s"; 76 public static final String TIME = "dt"; 77 78 /** 79 * SYNC message trigger events. 80 * <p> 81 * These are the possible values of {@link OmtpConstants#SYNC_TRIGGER_EVENT}. 82 */ 83 public static final String NEW_MESSAGE = "NM"; 84 public static final String MAILBOX_UPDATE = "MBU"; 85 public static final String GREETINGS_UPDATE = "GU"; 86 87 public static final String[] SYNC_TRIGGER_EVENT_VALUES = { 88 NEW_MESSAGE, 89 MAILBOX_UPDATE, 90 GREETINGS_UPDATE 91 }; 92 93 /** 94 * Content types supported by OMTP VVM. 95 * <p> 96 * These are the possible values of {@link OmtpConstants#CONTENT_TYPE}. 97 */ 98 public static final String VOICE = "v"; 99 public static final String VIDEO = "o"; 100 public static final String FAX = "f"; 101 /** Voice message deposited by an external application */ 102 public static final String INFOTAINMENT = "i"; 103 /** Empty Call Capture - i.e. voicemail with no voice message. */ 104 public static final String ECC = "e"; 105 106 public static final String[] CONTENT_TYPE_VALUES = {VOICE, VIDEO, FAX, INFOTAINMENT, ECC}; 107 108 ////////////////////////////// Status SMS fields //////////////////////////// 109 110 /** 111 * Status SMS fields. 112 * <p> 113 * Each string constant is the field's key in the SMS body which is used by the parser to 114 * identify the field's value, if present, in the SMS body. 115 */ 116 /** See {@link OmtpConstants#PROVISIONING_STATUS_VALUES} */ 117 public static final String PROVISIONING_STATUS = "st"; 118 /** See {@link OmtpConstants#RETURN_CODE_VALUES} */ 119 public static final String RETURN_CODE = "rc"; 120 /** URL to send users to for activation VVM */ 121 public static final String SUBSCRIPTION_URL = "rs"; 122 /** IMAP4/SMTP server IP address or fully qualified domain name */ 123 public static final String SERVER_ADDRESS = "srv"; 124 /** Phone number to access voicemails through Telephony User Interface */ 125 public static final String TUI_ACCESS_NUMBER = "tui"; 126 /** Number to send client origination SMS */ 127 public static final String CLIENT_SMS_DESTINATION_NUMBER = "dn"; 128 public static final String IMAP_PORT = "ipt"; 129 public static final String IMAP_USER_NAME = "u"; 130 public static final String IMAP_PASSWORD = "pw"; 131 public static final String SMTP_PORT = "spt"; 132 public static final String SMTP_USER_NAME = "smtp_u"; 133 public static final String SMTP_PASSWORD = "smtp_pw"; 134 135 /** 136 * User provisioning status values. 137 * <p> 138 * Referred by {@link OmtpConstants#PROVISIONING_STATUS}. 139 */ 140 // TODO: As per the spec the code could be either be with or w/o quotes = "N"/N). Currently 141 // this only handles the w/o quotes values. 142 public static final String SUBSCRIBER_NEW = "N"; 143 public static final String SUBSCRIBER_READY = "R"; 144 public static final String SUBSCRIBER_PROVISIONED = "P"; 145 public static final String SUBSCRIBER_UNKNOWN = "U"; 146 public static final String SUBSCRIBER_BLOCKED = "B"; 147 148 public static final String[] PROVISIONING_STATUS_VALUES = { 149 SUBSCRIBER_NEW, 150 SUBSCRIBER_READY, 151 SUBSCRIBER_PROVISIONED, 152 SUBSCRIBER_UNKNOWN, 153 SUBSCRIBER_BLOCKED 154 }; 155 156 /** 157 * The return code included in a status message. 158 * <p> 159 * These are the possible values of {@link OmtpConstants#RETURN_CODE}. 160 */ 161 public static final String SUCCESS = "0"; 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 /** 182 * A map of all the field keys to the possible values they can have. 183 */ 184 public static final Map<String, String[]> possibleValuesMap = new HashMap<String, String[]>() {{ 185 put(SYNC_TRIGGER_EVENT, SYNC_TRIGGER_EVENT_VALUES); 186 put(CONTENT_TYPE, CONTENT_TYPE_VALUES); 187 put(PROVISIONING_STATUS, PROVISIONING_STATUS_VALUES); 188 put(RETURN_CODE, RETURN_CODE_VALUES); 189 }}; 190 191 /** Indicates the client is Google visual voicemail version 1.0. */ 192 public static final String CLIENT_TYPE_GOOGLE_10 = "google.vvm.10"; 193 } 194