Home | History | Annotate | Download | only in mapservice
      1 /*
      2  * Copyright (C) 2015 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.google.android.auto.mapservice;
     18 
     19 import android.os.Parcel;
     20 import android.os.Parcelable;
     21 
     22 public final class BluetoothMapMessage implements Parcelable {
     23     /** Types of Messages. */
     24     public static final int TYPE_SMS_GSM = 1;
     25     public static final int TYPE_SMS_CDMA = 2;
     26     public static final int TYPE_MMS = 3;
     27     public static final int TYPE_UNKNOWN = 99;
     28 
     29     /** Status of the message. */
     30     public static final int STATUS_READ = 1;
     31     public static final int STATUS_UNREAD = 2;
     32     public static final int STATUS_UNKNOWN = 99;
     33 
     34     // Defines the various metadata field for the message.
     35 
     36     // If defined, represents a decimal separated number representation.
     37     private int mStatus;
     38     private int mType;
     39     private String mFolder;
     40     private int mBodyLength;
     41     // When sending a message mRecipient must be populated, and while receiving a message mSender
     42     // must be populated.
     43     private String mSender;
     44     private String mRecipient;
     45 
     46     // Not used currently.
     47     private int mLanguage;
     48     private String mVersion;
     49 
     50     // Actual message content.
     51     private String mMessage;
     52 
     53     public static final Parcelable.Creator<BluetoothMapMessage> CREATOR =
     54         new Parcelable.Creator<BluetoothMapMessage>() {
     55         public BluetoothMapMessage createFromParcel(Parcel in) {
     56             return new BluetoothMapMessage(in);
     57         }
     58 
     59         public BluetoothMapMessage[] newArray(int size) {
     60             return new BluetoothMapMessage[size];
     61         }
     62     };
     63 
     64     public BluetoothMapMessage() { }
     65 
     66     public void setRecipient(String recipient) {
     67         mRecipient = recipient;
     68     }
     69 
     70     public String getRecipient() {
     71         return mRecipient;
     72     }
     73 
     74     public void setSender(String sender) {
     75         mSender = sender;
     76     }
     77 
     78     public String getSender() {
     79         return mSender;
     80     }
     81 
     82     public void setType(int type) {
     83         mType = type;
     84     }
     85 
     86     public int getType() {
     87         return mType;
     88     }
     89 
     90     public void setStatus(int status) {
     91         mStatus = status;
     92     }
     93 
     94     public  int getStatus() {
     95         return mStatus;
     96     }
     97 
     98     public void setFolder(String folder) {
     99         mFolder = folder;
    100     }
    101 
    102     public String getFolder() {
    103         return mFolder;
    104     }
    105 
    106     public void setMessage(String message) {
    107         mMessage = message;
    108     }
    109 
    110     public String getMessage() {
    111         return mMessage;
    112     }
    113 
    114     private BluetoothMapMessage(Parcel in) {
    115         readFromParcel(in);
    116     }
    117 
    118     public void writeToParcel(Parcel out, int flags) {
    119         // Write metadata.
    120         out.writeInt(mStatus);
    121         out.writeInt(mType);
    122         out.writeString(mFolder);
    123         out.writeInt(mBodyLength);
    124         // Currently not in use.
    125         out.writeInt(mLanguage);
    126         out.writeString(mVersion);
    127 
    128         // Write sender/receiver info.
    129         out.writeString(mSender);
    130         out.writeString(mRecipient);
    131 
    132         // Actual message.
    133         out.writeString(mMessage);
    134     }
    135 
    136     public int describeContents() {
    137       return 0;
    138     }
    139 
    140     public void readFromParcel(Parcel in) {
    141         // Read metadata.
    142         mStatus = in.readInt();
    143         mType = in.readInt();
    144         mFolder = in.readString();
    145         mBodyLength = in.readInt();
    146         // Currently not used metadata.
    147         mLanguage = in.readInt();
    148         mVersion = in.readString();
    149 
    150         // Read sender/receiver info.
    151         mSender = in.readString();
    152         mRecipient = in.readString();
    153 
    154         // Read actual content.
    155         mMessage = in.readString();
    156     }
    157 
    158     public String toString() {
    159         return "Message:\nSender: " + mSender+ "\nMessage: " + mMessage;
    160     }
    161 }
    162