rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | #ifndef SMSCBCMASINFO_H_ |
| 18 | #define SMSCBCMASINFO_H_ |
| 19 | |
| 20 | #include <string> |
| 21 | class SmsCbCmasInfo { |
| 22 | public: |
| 23 | SmsCbCmasInfo(int messageClass, int category, int responseType, int severity, |
| 24 | int urgency, int certainty); |
| 25 | virtual ~SmsCbCmasInfo(); |
| 26 | |
| 27 | // CMAS message class (in GSM/UMTS message identifier or CDMA service category). |
| 28 | |
| 29 | /** Presidential-level alert (Korean Public Alert System Class 0 message). */ |
| 30 | static constexpr int CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT = 0x00; |
| 31 | |
| 32 | /** Extreme threat to life and property (Korean Public Alert System Class 1 message). */ |
| 33 | static constexpr int CMAS_CLASS_EXTREME_THREAT = 0x01; |
| 34 | |
| 35 | /** Severe threat to life and property (Korean Public Alert System Class 1 message). */ |
| 36 | static constexpr int CMAS_CLASS_SEVERE_THREAT = 0x02; |
| 37 | |
| 38 | /** Child abduction emergency (AMBER Alert). */ |
| 39 | static constexpr int CMAS_CLASS_CHILD_ABDUCTION_EMERGENCY = 0x03; |
| 40 | |
| 41 | /** CMAS test message. */ |
| 42 | static constexpr int CMAS_CLASS_REQUIRED_MONTHLY_TEST = 0x04; |
| 43 | |
| 44 | /** CMAS exercise. */ |
| 45 | static constexpr int CMAS_CLASS_CMAS_EXERCISE = 0x05; |
| 46 | |
| 47 | /** CMAS category for operator defined use. */ |
| 48 | static constexpr int CMAS_CLASS_OPERATOR_DEFINED_USE = 0x06; |
| 49 | |
| 50 | /** CMAS category for warning types that are reserved for future extension. */ |
| 51 | static constexpr int CMAS_CLASS_UNKNOWN = -1; |
| 52 | |
| 53 | // CMAS alert category (in CDMA type 1 elements record). |
| 54 | |
| 55 | /** CMAS alert category: Geophysical including landslide. */ |
| 56 | static constexpr int CMAS_CATEGORY_GEO = 0x00; |
| 57 | |
| 58 | /** CMAS alert category: Meteorological including flood. */ |
| 59 | static constexpr int CMAS_CATEGORY_MET = 0x01; |
| 60 | |
| 61 | /** CMAS alert category: General emergency and public safety. */ |
| 62 | static constexpr int CMAS_CATEGORY_SAFETY = 0x02; |
| 63 | |
| 64 | /** CMAS alert category: Law enforcement, military, homeland/local/private security. */ |
| 65 | static constexpr int CMAS_CATEGORY_SECURITY = 0x03; |
| 66 | |
| 67 | /** CMAS alert category: Rescue and recovery. */ |
| 68 | static constexpr int CMAS_CATEGORY_RESCUE = 0x04; |
| 69 | |
| 70 | /** CMAS alert category: Fire suppression and rescue. */ |
| 71 | static constexpr int CMAS_CATEGORY_FIRE = 0x05; |
| 72 | |
| 73 | /** CMAS alert category: Medical and public health. */ |
| 74 | static constexpr int CMAS_CATEGORY_HEALTH = 0x06; |
| 75 | |
| 76 | /** CMAS alert category: Pollution and other environmental. */ |
| 77 | static constexpr int CMAS_CATEGORY_ENV = 0x07; |
| 78 | |
| 79 | /** CMAS alert category: Public and private transportation. */ |
| 80 | static constexpr int CMAS_CATEGORY_TRANSPORT = 0x08; |
| 81 | |
| 82 | /** CMAS alert category: Utility, telecom, other non-transport infrastructure. */ |
| 83 | static constexpr int CMAS_CATEGORY_INFRA = 0x09; |
| 84 | |
| 85 | /** CMAS alert category: Chem, bio, radiological, nuclear, high explosive threat or attack. */ |
| 86 | static constexpr int CMAS_CATEGORY_CBRNE = 0x0a; |
| 87 | |
| 88 | /** CMAS alert category: Other events. */ |
| 89 | static constexpr int CMAS_CATEGORY_OTHER = 0x0b; |
| 90 | |
| 91 | /** |
| 92 | * CMAS alert category is unknown. The category is only available for CDMA broadcasts |
| 93 | * containing a type 1 elements record, so GSM and UMTS broadcasts always return unknown. |
| 94 | */ |
| 95 | static constexpr int CMAS_CATEGORY_UNKNOWN = -1; |
| 96 | |
| 97 | // CMAS response type (in CDMA type 1 elements record). |
| 98 | |
| 99 | /** CMAS response type: Take shelter in place. */ |
| 100 | static constexpr int CMAS_RESPONSE_TYPE_SHELTER = 0x00; |
| 101 | |
| 102 | /** CMAS response type: Evacuate (Relocate). */ |
| 103 | static constexpr int CMAS_RESPONSE_TYPE_EVACUATE = 0x01; |
| 104 | |
| 105 | /** CMAS response type: Make preparations. */ |
| 106 | static constexpr int CMAS_RESPONSE_TYPE_PREPARE = 0x02; |
| 107 | |
| 108 | /** CMAS response type: Execute a pre-planned activity. */ |
| 109 | static constexpr int CMAS_RESPONSE_TYPE_EXECUTE = 0x03; |
| 110 | |
| 111 | /** CMAS response type: Attend to information sources. */ |
| 112 | static constexpr int CMAS_RESPONSE_TYPE_MONITOR = 0x04; |
| 113 | |
| 114 | /** CMAS response type: Avoid hazard. */ |
| 115 | static constexpr int CMAS_RESPONSE_TYPE_AVOID = 0x05; |
| 116 | |
| 117 | /** CMAS response type: Evaluate the information in this message (not for public warnings). */ |
| 118 | static constexpr int CMAS_RESPONSE_TYPE_ASSESS = 0x06; |
| 119 | |
| 120 | /** CMAS response type: No action recommended. */ |
| 121 | static constexpr int CMAS_RESPONSE_TYPE_NONE = 0x07; |
| 122 | |
| 123 | /** |
| 124 | * CMAS response type is unknown. The response type is only available for CDMA broadcasts |
| 125 | * containing a type 1 elements record, so GSM and UMTS broadcasts always return unknown. |
| 126 | */ |
| 127 | static constexpr int CMAS_RESPONSE_TYPE_UNKNOWN = -1; |
| 128 | |
| 129 | // 4-bit CMAS severity (in GSM/UMTS message identifier or CDMA type 1 elements record). |
| 130 | |
| 131 | /** CMAS severity type: Extraordinary threat to life or property. */ |
| 132 | static constexpr int CMAS_SEVERITY_EXTREME = 0x0; |
| 133 | |
| 134 | /** CMAS severity type: Significant threat to life or property. */ |
| 135 | static constexpr int CMAS_SEVERITY_SEVERE = 0x1; |
| 136 | |
| 137 | /** |
| 138 | * CMAS alert severity is unknown. The severity is available for CDMA warning alerts |
| 139 | * containing a type 1 elements record and for all GSM and UMTS alerts except for the |
| 140 | * Presidential-level alert class (Korean Public Alert System Class 0). |
| 141 | */ |
| 142 | static constexpr int CMAS_SEVERITY_UNKNOWN = -1; |
| 143 | |
| 144 | // CMAS urgency (in GSM/UMTS message identifier or CDMA type 1 elements record). |
| 145 | |
| 146 | /** CMAS urgency type: Responsive action should be taken immediately. */ |
| 147 | static constexpr int CMAS_URGENCY_IMMEDIATE = 0x0; |
| 148 | |
| 149 | /** CMAS urgency type: Responsive action should be taken within the next hour. */ |
| 150 | static constexpr int CMAS_URGENCY_EXPECTED = 0x1; |
| 151 | |
| 152 | /** |
| 153 | * CMAS alert urgency is unknown. The urgency is available for CDMA warning alerts |
| 154 | * containing a type 1 elements record and for all GSM and UMTS alerts except for the |
| 155 | * Presidential-level alert class (Korean Public Alert System Class 0). |
| 156 | */ |
| 157 | static constexpr int CMAS_URGENCY_UNKNOWN = -1; |
| 158 | |
| 159 | // CMAS certainty (in GSM/UMTS message identifier or CDMA type 1 elements record). |
| 160 | |
| 161 | /** CMAS certainty type: Determined to have occurred or to be ongoing. */ |
| 162 | static constexpr int CMAS_CERTAINTY_OBSERVED = 0x0; |
| 163 | |
| 164 | /** CMAS certainty type: Likely (probability > ~50%). */ |
| 165 | static constexpr int CMAS_CERTAINTY_LIKELY = 0x1; |
| 166 | |
| 167 | /** |
| 168 | * CMAS alert certainty is unknown. The certainty is available for CDMA warning alerts |
| 169 | * containing a type 1 elements record and for all GSM and UMTS alerts except for the |
| 170 | * Presidential-level alert class (Korean Public Alert System Class 0). |
| 171 | */ |
| 172 | static constexpr int CMAS_CERTAINTY_UNKNOWN = -1; |
| 173 | |
| 174 | /** |
| 175 | * Returns the CMAS message class, e.g. {@link #CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT}. |
| 176 | * @return one of the {@code CMAS_CLASS} values |
| 177 | */ |
| 178 | int getMessageClass() { |
| 179 | return mMessageClass; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Returns the CMAS category, e.g. {@link #CMAS_CATEGORY_GEO}. |
| 184 | * @return one of the {@code CMAS_CATEGORY} values |
| 185 | */ |
| 186 | int getCategory() { |
| 187 | return mCategory; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Returns the CMAS response type, e.g. {@link #CMAS_RESPONSE_TYPE_SHELTER}. |
| 192 | * @return one of the {@code CMAS_RESPONSE_TYPE} values |
| 193 | */ |
| 194 | int getResponseType() { |
| 195 | return mResponseType; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Returns the CMAS severity, e.g. {@link #CMAS_SEVERITY_EXTREME}. |
| 200 | * @return one of the {@code CMAS_SEVERITY} values |
| 201 | */ |
| 202 | int getSeverity() { |
| 203 | return mSeverity; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Returns the CMAS urgency, e.g. {@link #CMAS_URGENCY_IMMEDIATE}. |
| 208 | * @return one of the {@code CMAS_URGENCY} values |
| 209 | */ |
| 210 | int getUrgency() { |
| 211 | return mUrgency; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Returns the CMAS certainty, e.g. {@link #CMAS_CERTAINTY_OBSERVED}. |
| 216 | * @return one of the {@code CMAS_CERTAINTY} values |
| 217 | */ |
| 218 | int getCertainty() { |
| 219 | return mCertainty; |
| 220 | } |
| 221 | |
| 222 | std::string toString() { |
| 223 | return "SmsCbCmasInfo{messageClass=" + std::to_string(mMessageClass) |
| 224 | + ", category=" + std::to_string(mCategory) + ", responseType=" |
| 225 | + std::to_string(mResponseType) + ", severity=" |
| 226 | + std::to_string(mSeverity) + ", urgency=" + std::to_string(mUrgency) |
| 227 | + ", certainty=" + std::to_string(mCertainty) + '}'; |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Describe the kinds of special objects contained in the marshalled representation. |
| 232 | * @return a bitmask indicating this Parcelable contains no special objects |
| 233 | */ |
| 234 | int describeContents() { |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | private: |
| 239 | /** CMAS message class. */ |
| 240 | int mMessageClass; |
| 241 | |
| 242 | /** CMAS category. */ |
| 243 | int mCategory; |
| 244 | |
| 245 | /** CMAS response type. */ |
| 246 | int mResponseType; |
| 247 | |
| 248 | /** CMAS severity. */ |
| 249 | int mSeverity; |
| 250 | |
| 251 | /** CMAS urgency. */ |
| 252 | int mUrgency; |
| 253 | |
| 254 | /** CMAS certainty. */ |
| 255 | int mCertainty; |
| 256 | }; |
| 257 | |
| 258 | #endif /* SMSCBCMASINFO_H_ */ |