blob: 3efab0f1e7ca0ca94b335a7dfe242ecebafaf8c0 [file] [log] [blame]
Yorke Lee93fb1d02014-03-19 11:47:02 -07001/*
2 * Copyright 2014, 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
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Yorke Lee93fb1d02014-03-19 11:47:02 -070018
Nancy Chen9d568c02014-09-08 14:17:59 -070019import android.annotation.SystemApi;
Yorke Lee93fb1d02014-03-19 11:47:02 -070020import android.net.Uri;
21import android.os.Parcel;
22import android.os.Parcelable;
23import android.text.TextUtils;
24
25/**
26 * When calls are made, they may contain gateway information for services which route phone calls
27 * through their own service/numbers. The data consists of a number to call and the package name of
28 * the service. This data is used in two ways:
29 * <ol>
30 * <li> Call the appropriate routing number
31 * <li> Display information about how the call is being routed to the user
32 * </ol>
Tyler Gunn711d876fd2014-09-19 11:17:02 -070033 * @hide
Yorke Lee93fb1d02014-03-19 11:47:02 -070034 */
Tyler Gunn711d876fd2014-09-19 11:17:02 -070035@SystemApi
Yorke Lee93fb1d02014-03-19 11:47:02 -070036public class GatewayInfo implements Parcelable {
37
38 private final String mGatewayProviderPackageName;
Nancy Chen9d568c02014-09-08 14:17:59 -070039 private final Uri mGatewayAddress;
40 private final Uri mOriginalAddress;
Yorke Lee93fb1d02014-03-19 11:47:02 -070041
42 /** @hide */
Nancy Chen9d568c02014-09-08 14:17:59 -070043 @SystemApi
44 public GatewayInfo(String packageName, Uri gatewayUri, Uri originalAddress) {
Yorke Lee93fb1d02014-03-19 11:47:02 -070045 mGatewayProviderPackageName = packageName;
Nancy Chen9d568c02014-09-08 14:17:59 -070046 mGatewayAddress = gatewayUri;
47 mOriginalAddress = originalAddress;
Yorke Lee93fb1d02014-03-19 11:47:02 -070048 }
49
50 /**
51 * Package name of the gateway provider service. used to place the call with.
52 */
53 public String getGatewayProviderPackageName() {
54 return mGatewayProviderPackageName;
55 }
56
57 /**
Nancy Chen9d568c02014-09-08 14:17:59 -070058 * Gateway provider address to use when actually placing the call.
Yorke Lee93fb1d02014-03-19 11:47:02 -070059 */
Nancy Chen9d568c02014-09-08 14:17:59 -070060 public Uri getGatewayAddress() {
61 return mGatewayAddress;
Yorke Lee93fb1d02014-03-19 11:47:02 -070062 }
63
64 /**
Nancy Chen9d568c02014-09-08 14:17:59 -070065 * The actual call address that the user is trying to connect to via the gateway.
Yorke Lee93fb1d02014-03-19 11:47:02 -070066 */
Nancy Chen9d568c02014-09-08 14:17:59 -070067 public Uri getOriginalAddress() {
68 return mOriginalAddress;
Yorke Lee93fb1d02014-03-19 11:47:02 -070069 }
70
71 public boolean isEmpty() {
Nancy Chen9d568c02014-09-08 14:17:59 -070072 return TextUtils.isEmpty(mGatewayProviderPackageName) || mGatewayAddress == null;
Yorke Lee93fb1d02014-03-19 11:47:02 -070073 }
74
75 /** Implement the Parcelable interface */
76 public static final Parcelable.Creator<GatewayInfo> CREATOR =
77 new Parcelable.Creator<GatewayInfo> () {
78
79 @Override
80 public GatewayInfo createFromParcel(Parcel source) {
81 String gatewayPackageName = source.readString();
82 Uri gatewayUri = Uri.CREATOR.createFromParcel(source);
Nancy Chen9d568c02014-09-08 14:17:59 -070083 Uri originalAddress = Uri.CREATOR.createFromParcel(source);
84 return new GatewayInfo(gatewayPackageName, gatewayUri, originalAddress);
Yorke Lee93fb1d02014-03-19 11:47:02 -070085 }
86
87 @Override
88 public GatewayInfo[] newArray(int size) {
89 return new GatewayInfo[size];
90 }
91 };
92
93 /**
94 * {@inheritDoc}
95 */
96 @Override
97 public int describeContents() {
98 return 0;
99 }
100
101 /**
102 * {@inheritDoc}
103 */
104 @Override
105 public void writeToParcel(Parcel destination, int flags) {
106 destination.writeString(mGatewayProviderPackageName);
Nancy Chen9d568c02014-09-08 14:17:59 -0700107 mGatewayAddress.writeToParcel(destination, 0);
108 mOriginalAddress.writeToParcel(destination, 0);
Yorke Lee93fb1d02014-03-19 11:47:02 -0700109 }
110}