Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 1 | /* |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 18 | |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 20 | import android.net.Uri; |
| 21 | import android.os.Parcel; |
| 22 | import android.os.Parcelable; |
| 23 | import 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 Gunn | 711d876fd | 2014-09-19 11:17:02 -0700 | [diff] [blame^] | 33 | * @hide |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 34 | */ |
Tyler Gunn | 711d876fd | 2014-09-19 11:17:02 -0700 | [diff] [blame^] | 35 | @SystemApi |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 36 | public class GatewayInfo implements Parcelable { |
| 37 | |
| 38 | private final String mGatewayProviderPackageName; |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 39 | private final Uri mGatewayAddress; |
| 40 | private final Uri mOriginalAddress; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 41 | |
| 42 | /** @hide */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 43 | @SystemApi |
| 44 | public GatewayInfo(String packageName, Uri gatewayUri, Uri originalAddress) { |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 45 | mGatewayProviderPackageName = packageName; |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 46 | mGatewayAddress = gatewayUri; |
| 47 | mOriginalAddress = originalAddress; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 48 | } |
| 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 Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 58 | * Gateway provider address to use when actually placing the call. |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 59 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 60 | public Uri getGatewayAddress() { |
| 61 | return mGatewayAddress; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /** |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 65 | * The actual call address that the user is trying to connect to via the gateway. |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 66 | */ |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 67 | public Uri getOriginalAddress() { |
| 68 | return mOriginalAddress; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | public boolean isEmpty() { |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 72 | return TextUtils.isEmpty(mGatewayProviderPackageName) || mGatewayAddress == null; |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 73 | } |
| 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 Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 83 | Uri originalAddress = Uri.CREATOR.createFromParcel(source); |
| 84 | return new GatewayInfo(gatewayPackageName, gatewayUri, originalAddress); |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 85 | } |
| 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 Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 107 | mGatewayAddress.writeToParcel(destination, 0); |
| 108 | mOriginalAddress.writeToParcel(destination, 0); |
Yorke Lee | 93fb1d0 | 2014-03-19 11:47:02 -0700 | [diff] [blame] | 109 | } |
| 110 | } |