blob: da2b998b636315c2f20686bc859733d09dd685eb [file] [log] [blame]
Eric Erfanianccca3152017-02-22 16:32:36 -08001/*
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 */
16package com.android.voicemailomtp;
17
18import android.support.annotation.IntDef;
19import java.lang.annotation.Retention;
20import java.lang.annotation.RetentionPolicy;
21import java.util.HashMap;
22import java.util.Map;
23
24/**
25 * Wrapper class to hold relevant OMTP constants as defined in the OMTP spec. <p> In essence this is
26 * a programmatic representation of the relevant portions of OMTP spec.
27 */
28public class OmtpConstants {
29 public static final String SMS_FIELD_SEPARATOR = ";";
30 public static final String SMS_KEY_VALUE_SEPARATOR = "=";
31 public static final String SMS_PREFIX_SEPARATOR = ":";
32
33 public static final String SYNC_SMS_PREFIX = "SYNC";
34 public static final String STATUS_SMS_PREFIX = "STATUS";
35
36 // This is the format designated by the OMTP spec.
37 public static final String DATE_TIME_FORMAT = "dd/MM/yyyy HH:mm Z";
38
39 /** OMTP protocol versions. */
40 public static final String PROTOCOL_VERSION1_1 = "11";
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 public static final String DEACTIVATE_REQUEST = "Deactivate";
49 public static final String STATUS_REQUEST = "Status";
50
51 /** fields that can be present in a Mobile Originated OMTP SMS */
52 public static final String CLIENT_TYPE = "ct";
53 public static final String APPLICATION_PORT = "pt";
54 public static final String PROTOCOL_VERSION = "pv";
55
56
57 //////////////////////////////// Sync SMS fields ////////////////////////////
58
59 /**
60 * Sync SMS fields.
61 * <p>
62 * Each string constant is the field's key in the SMS body which is used by the parser to
63 * identify the field's value, if present, in the SMS body.
64 */
65
66 /**
67 * The event that triggered this SYNC SMS.
68 * See {@link OmtpConstants#SYNC_TRIGGER_EVENT_VALUES}
69 */
70 public static final String SYNC_TRIGGER_EVENT = "ev";
71 public static final String MESSAGE_UID = "id";
72 public static final String MESSAGE_LENGTH = "l";
73 public static final String NUM_MESSAGE_COUNT = "c";
74 /** See {@link OmtpConstants#CONTENT_TYPE_VALUES} */
75 public static final String CONTENT_TYPE = "t";
76 public static final String SENDER = "s";
77 public static final String TIME = "dt";
78
79 /**
80 * SYNC message trigger events.
81 * <p>
82 * These are the possible values of {@link OmtpConstants#SYNC_TRIGGER_EVENT}.
83 */
84 public static final String NEW_MESSAGE = "NM";
85 public static final String MAILBOX_UPDATE = "MBU";
86 public static final String GREETINGS_UPDATE = "GU";
87
88 public static final String[] SYNC_TRIGGER_EVENT_VALUES = {
89 NEW_MESSAGE,
90 MAILBOX_UPDATE,
91 GREETINGS_UPDATE
92 };
93
94 /**
95 * Content types supported by OMTP VVM.
96 * <p>
97 * These are the possible values of {@link OmtpConstants#CONTENT_TYPE}.
98 */
99 public static final String VOICE = "v";
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 * <p>
114 * 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 public static final String TUI_PASSWORD_LENGTH = "pw_len";
128 /** Number to send client origination SMS */
129 public static final String CLIENT_SMS_DESTINATION_NUMBER = "dn";
130 public static final String IMAP_PORT = "ipt";
131 public static final String IMAP_USER_NAME = "u";
132 public static final String IMAP_PASSWORD = "pw";
133 public static final String SMTP_PORT = "spt";
134 public static final String SMTP_USER_NAME = "smtp_u";
135 public static final String SMTP_PASSWORD = "smtp_pw";
136
137 /**
138 * User provisioning status values.
139 * <p>
140 * Referred by {@link OmtpConstants#PROVISIONING_STATUS}.
141 */
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 /**
192 * IMAP command extensions
193 */
194
195 /**
196 * OMTP spec v1.3 2.3.1 Change password request syntax
197 *
198 * This changes the PIN to access the Telephone User Interface, the traditional voicemail
199 * system.
200 */
201 public static final String IMAP_CHANGE_TUI_PWD_FORMAT = "XCHANGE_TUI_PWD PWD=%1$s OLD_PWD=%2$s";
202
203 /**
204 * OMTP spec v1.3 2.4.1 Change languate request syntax
205 *
206 * This changes the language in the Telephone User Interface.
207 */
208 public static final String IMAP_CHANGE_VM_LANG_FORMAT = "XCHANGE_VM_LANG LANG=%1$s";
209
210 /**
211 * OMTP spec v1.3 2.5.1 Close NUT Request syntax
212 *
213 * This disables the new user tutorial, the message played to new users calling in the Telephone
214 * User Interface.
215 */
216 public static final String IMAP_CLOSE_NUT = "XCLOSE_NUT";
217
218 /**
219 * Possible NO responses for CHANGE_TUI_PWD
220 */
221
222 public static final String RESPONSE_CHANGE_PIN_TOO_SHORT = "password too short";
223 public static final String RESPONSE_CHANGE_PIN_TOO_LONG = "password too long";
224 public static final String RESPONSE_CHANGE_PIN_TOO_WEAK = "password too weak";
225 public static final String RESPONSE_CHANGE_PIN_MISMATCH = "old password mismatch";
226 public static final String RESPONSE_CHANGE_PIN_INVALID_CHARACTER =
227 "password contains invalid characters";
228
229 @Retention(RetentionPolicy.SOURCE)
230 @IntDef(value = {CHANGE_PIN_SUCCESS, CHANGE_PIN_TOO_SHORT, CHANGE_PIN_TOO_LONG,
231 CHANGE_PIN_TOO_WEAK, CHANGE_PIN_MISMATCH, CHANGE_PIN_INVALID_CHARACTER,
232 CHANGE_PIN_SYSTEM_ERROR})
233
234 public @interface ChangePinResult {
235
236 }
237
238 public static final int CHANGE_PIN_SUCCESS = 0;
239 public static final int CHANGE_PIN_TOO_SHORT = 1;
240 public static final int CHANGE_PIN_TOO_LONG = 2;
241 public static final int CHANGE_PIN_TOO_WEAK = 3;
242 public static final int CHANGE_PIN_MISMATCH = 4;
243 public static final int CHANGE_PIN_INVALID_CHARACTER = 5;
244 public static final int CHANGE_PIN_SYSTEM_ERROR = 6;
245
246 /** Indicates the client is Google visual voicemail version 1.0. */
247 public static final String CLIENT_TYPE_GOOGLE_10 = "google.vvm.10";
248}