• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.voicemail.impl;
18 
19 import android.support.annotation.IntDef;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 
23 /**
24  * Events internal to the OMTP client. These should be translated into {@link
25  * android.provider.VoicemailContract.Status} error codes before writing into the voicemail status
26  * table.
27  */
28 public enum OmtpEvents {
29 
30   // Configuration State
31   CONFIG_REQUEST_STATUS_SUCCESS(Type.CONFIGURATION, true),
32 
33   CONFIG_PIN_SET(Type.CONFIGURATION, true),
34   // The voicemail PIN is replaced with a generated PIN, user should change it.
35   CONFIG_DEFAULT_PIN_REPLACED(Type.CONFIGURATION, true),
36   CONFIG_ACTIVATING(Type.CONFIGURATION, true),
37   // There are already activation records, this is only a book-keeping activation.
38   CONFIG_ACTIVATING_SUBSEQUENT(Type.CONFIGURATION, true),
39   CONFIG_STATUS_SMS_TIME_OUT(Type.CONFIGURATION),
40   CONFIG_SERVICE_NOT_AVAILABLE(Type.CONFIGURATION),
41 
42   // Data channel State
43 
44   // A new sync has started, old errors in data channel should be cleared.
45   DATA_IMAP_OPERATION_STARTED(Type.DATA_CHANNEL, true),
46   // Successfully downloaded/uploaded data from the server, which means the data channel is clear.
47   DATA_IMAP_OPERATION_COMPLETED(Type.DATA_CHANNEL, true),
48   // The port provided in the STATUS SMS is invalid.
49   DATA_INVALID_PORT(Type.DATA_CHANNEL),
50   // No connection to the internet, and the carrier requires cellular data
51   DATA_NO_CONNECTION_CELLULAR_REQUIRED(Type.DATA_CHANNEL),
52   // No connection to the internet.
53   DATA_NO_CONNECTION(Type.DATA_CHANNEL),
54   // Address lookup for the server hostname failed. DNS error?
55   DATA_CANNOT_RESOLVE_HOST_ON_NETWORK(Type.DATA_CHANNEL),
56   // All destination address that resolves to the server hostname are rejected or timed out
57   DATA_ALL_SOCKET_CONNECTION_FAILED(Type.DATA_CHANNEL),
58   // Failed to establish SSL with the server, either with a direct SSL connection or by
59   // STARTTLS command
60   DATA_CANNOT_ESTABLISH_SSL_SESSION(Type.DATA_CHANNEL),
61   // Identity of the server cannot be verified.
62   DATA_SSL_INVALID_HOST_NAME(Type.DATA_CHANNEL),
63   // The server rejected our username/password
64   DATA_BAD_IMAP_CREDENTIAL(Type.DATA_CHANNEL),
65 
66   DATA_AUTH_UNKNOWN_USER(Type.DATA_CHANNEL),
67   DATA_AUTH_UNKNOWN_DEVICE(Type.DATA_CHANNEL),
68   DATA_AUTH_INVALID_PASSWORD(Type.DATA_CHANNEL),
69   DATA_AUTH_MAILBOX_NOT_INITIALIZED(Type.DATA_CHANNEL),
70   DATA_AUTH_SERVICE_NOT_PROVISIONED(Type.DATA_CHANNEL),
71   DATA_AUTH_SERVICE_NOT_ACTIVATED(Type.DATA_CHANNEL),
72   DATA_AUTH_USER_IS_BLOCKED(Type.DATA_CHANNEL),
73 
74   // A command to the server didn't result with an "OK" or continuation request
75   DATA_REJECTED_SERVER_RESPONSE(Type.DATA_CHANNEL),
76   // The server did not greet us with a "OK", possibly not a IMAP server.
77   DATA_INVALID_INITIAL_SERVER_RESPONSE(Type.DATA_CHANNEL),
78   // An IOException occurred while trying to open an ImapConnection
79   // TODO: reduce scope
80   DATA_IOE_ON_OPEN(Type.DATA_CHANNEL),
81   // The SELECT command on a mailbox is rejected
82   DATA_MAILBOX_OPEN_FAILED(Type.DATA_CHANNEL),
83   // An IOException has occurred
84   // TODO: reduce scope
85   DATA_GENERIC_IMAP_IOE(Type.DATA_CHANNEL),
86   // An SslException has occurred while opening an ImapConnection
87   // TODO: reduce scope
88   DATA_SSL_EXCEPTION(Type.DATA_CHANNEL),
89 
90   // Notification Channel
91 
92   // Cell signal restored, can received VVM SMSs
93   NOTIFICATION_IN_SERVICE(Type.NOTIFICATION_CHANNEL, true),
94   // Cell signal lost, cannot received VVM SMSs
95   NOTIFICATION_SERVICE_LOST(Type.NOTIFICATION_CHANNEL, false),
96 
97   // Other
98   OTHER_SOURCE_REMOVED(Type.OTHER, false),
99 
100   // VVM3
101   VVM3_NEW_USER_SETUP_FAILED,
102   // Table 4. client internal error handling
103   VVM3_VMG_DNS_FAILURE,
104   VVM3_SPG_DNS_FAILURE,
105   VVM3_VMG_CONNECTION_FAILED,
106   VVM3_SPG_CONNECTION_FAILED,
107   VVM3_VMG_TIMEOUT,
108   VVM3_STATUS_SMS_TIMEOUT,
109 
110   VVM3_SUBSCRIBER_PROVISIONED,
111   VVM3_SUBSCRIBER_BLOCKED,
112   VVM3_SUBSCRIBER_UNKNOWN;
113 
114   public static class Type {
115 
116     @Retention(RetentionPolicy.SOURCE)
117     @IntDef({CONFIGURATION, DATA_CHANNEL, NOTIFICATION_CHANNEL, OTHER})
118     public @interface Values {}
119 
120     public static final int CONFIGURATION = 1;
121     public static final int DATA_CHANNEL = 2;
122     public static final int NOTIFICATION_CHANNEL = 3;
123     public static final int OTHER = 4;
124   }
125 
126   private final int type;
127   private final boolean isSuccess;
128 
OmtpEvents(int type, boolean isSuccess)129   OmtpEvents(int type, boolean isSuccess) {
130     this.type = type;
131     this.isSuccess = isSuccess;
132   }
133 
OmtpEvents(int type)134   OmtpEvents(int type) {
135     this.type = type;
136     isSuccess = false;
137   }
138 
OmtpEvents()139   OmtpEvents() {
140     type = Type.OTHER;
141     isSuccess = false;
142   }
143 
144   @Type.Values
getType()145   public int getType() {
146     return type;
147   }
148 
isSuccess()149   public boolean isSuccess() {
150     return isSuccess;
151   }
152 }
153