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