GatewayInfo.java revision 8635c578f0408ca76cbaef5464d27bfde7450425
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 17package android.telecom; 18 19import android.annotation.SystemApi; 20import 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> 33 */ 34public class GatewayInfo implements Parcelable { 35 36 private final String mGatewayProviderPackageName; 37 private final Uri mGatewayAddress; 38 private final Uri mOriginalAddress; 39 40 /** @hide */ 41 @SystemApi 42 public GatewayInfo(String packageName, Uri gatewayUri, Uri originalAddress) { 43 mGatewayProviderPackageName = packageName; 44 mGatewayAddress = gatewayUri; 45 mOriginalAddress = originalAddress; 46 } 47 48 /** 49 * Package name of the gateway provider service. used to place the call with. 50 */ 51 public String getGatewayProviderPackageName() { 52 return mGatewayProviderPackageName; 53 } 54 55 /** 56 * Gateway provider address to use when actually placing the call. 57 */ 58 public Uri getGatewayAddress() { 59 return mGatewayAddress; 60 } 61 62 /** 63 * The actual call address that the user is trying to connect to via the gateway. 64 */ 65 public Uri getOriginalAddress() { 66 return mOriginalAddress; 67 } 68 69 public boolean isEmpty() { 70 return TextUtils.isEmpty(mGatewayProviderPackageName) || mGatewayAddress == null; 71 } 72 73 /** Implement the Parcelable interface */ 74 public static final Parcelable.Creator<GatewayInfo> CREATOR = 75 new Parcelable.Creator<GatewayInfo> () { 76 77 @Override 78 public GatewayInfo createFromParcel(Parcel source) { 79 String gatewayPackageName = source.readString(); 80 Uri gatewayUri = Uri.CREATOR.createFromParcel(source); 81 Uri originalAddress = Uri.CREATOR.createFromParcel(source); 82 return new GatewayInfo(gatewayPackageName, gatewayUri, originalAddress); 83 } 84 85 @Override 86 public GatewayInfo[] newArray(int size) { 87 return new GatewayInfo[size]; 88 } 89 }; 90 91 /** 92 * {@inheritDoc} 93 */ 94 @Override 95 public int describeContents() { 96 return 0; 97 } 98 99 /** 100 * {@inheritDoc} 101 */ 102 @Override 103 public void writeToParcel(Parcel destination, int flags) { 104 destination.writeString(mGatewayProviderPackageName); 105 mGatewayAddress.writeToParcel(destination, 0); 106 mOriginalAddress.writeToParcel(destination, 0); 107 } 108} 109