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