UssdResponse.java revision 19ba736c22869ec678ce0a79858ab3624fedee1b
1/*
2 * Copyright (C) 2006 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
17package android.telephony;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21import android.text.TextUtils;
22
23/**
24 * Represents the Ussd response, including
25 * the message and the return code.
26 * @hide
27 */
28public final class UssdResponse implements Parcelable {
29    private CharSequence mReturnMessage;
30    private String mUssdRequest;
31
32
33    /**
34     * Implement the Parcelable interface
35     */
36    @Override
37    public void writeToParcel(Parcel dest, int flags) {
38        dest.writeString(mUssdRequest);
39        TextUtils.writeToParcel(mReturnMessage, dest, 0);
40    }
41
42    public String getUssdRequest() {
43        return mUssdRequest;
44    }
45
46    public CharSequence getReturnMessage() {
47        return mReturnMessage;
48    }
49
50    /**
51     * Implement the Parcelable interface
52     */
53    @Override
54    public int describeContents() {
55        return 0;
56    }
57
58    /**
59     * * Initialize the object from the request and return message.
60     */
61    public UssdResponse(String ussdRequest, CharSequence returnMessage) {
62        mUssdRequest = ussdRequest;
63        mReturnMessage = returnMessage;
64    }
65
66    public static final Parcelable.Creator<UssdResponse> CREATOR = new Creator<UssdResponse>() {
67
68        @Override
69        public UssdResponse createFromParcel(Parcel in) {
70            String request = in.readString();
71            CharSequence message = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
72            return new UssdResponse(request, message);
73        }
74
75        @Override
76        public UssdResponse[] newArray(int size) {
77            return new UssdResponse[size];
78        }
79    };
80}
81