Eric Erfanian | ccca315 | 2017-02-22 16:32:36 -0800 | [diff] [blame] | 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.voicemailomtp; |
| 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 | |
| 98 | // Other |
| 99 | OTHER_SOURCE_REMOVED(Type.OTHER, false), |
| 100 | |
| 101 | // VVM3 |
| 102 | VVM3_NEW_USER_SETUP_FAILED, |
| 103 | // Table 4. client internal error handling |
| 104 | VVM3_VMG_DNS_FAILURE, |
| 105 | VVM3_SPG_DNS_FAILURE, |
| 106 | VVM3_VMG_CONNECTION_FAILED, |
| 107 | VVM3_SPG_CONNECTION_FAILED, |
| 108 | VVM3_VMG_TIMEOUT, |
| 109 | VVM3_STATUS_SMS_TIMEOUT, |
| 110 | |
| 111 | VVM3_SUBSCRIBER_PROVISIONED, |
| 112 | VVM3_SUBSCRIBER_BLOCKED, |
| 113 | VVM3_SUBSCRIBER_UNKNOWN; |
| 114 | |
| 115 | public static class Type { |
| 116 | |
| 117 | @Retention(RetentionPolicy.SOURCE) |
| 118 | @IntDef({CONFIGURATION, DATA_CHANNEL, NOTIFICATION_CHANNEL, OTHER}) |
| 119 | public @interface Values { |
| 120 | |
| 121 | } |
| 122 | |
| 123 | public static final int CONFIGURATION = 1; |
| 124 | public static final int DATA_CHANNEL = 2; |
| 125 | public static final int NOTIFICATION_CHANNEL = 3; |
| 126 | public static final int OTHER = 4; |
| 127 | } |
| 128 | |
| 129 | private final int mType; |
| 130 | private final boolean mIsSuccess; |
| 131 | |
| 132 | OmtpEvents(int type, boolean isSuccess) { |
| 133 | mType = type; |
| 134 | mIsSuccess = isSuccess; |
| 135 | } |
| 136 | |
| 137 | OmtpEvents(int type) { |
| 138 | mType = type; |
| 139 | mIsSuccess = false; |
| 140 | } |
| 141 | |
| 142 | OmtpEvents() { |
| 143 | mType = Type.OTHER; |
| 144 | mIsSuccess = false; |
| 145 | } |
| 146 | |
| 147 | @Type.Values |
| 148 | public int getType() { |
| 149 | return mType; |
| 150 | } |
| 151 | |
| 152 | public boolean isSuccess() { |
| 153 | return mIsSuccess; |
| 154 | } |
| 155 | |
| 156 | } |