OSDN Git Service

Moved data connection response into system api.
authorJack Yu <jackyu@google.com>
Thu, 30 Nov 2017 22:03:58 +0000 (14:03 -0800)
committerJack Yu <jackyu@google.com>
Fri, 8 Dec 2017 21:28:07 +0000 (13:28 -0800)
This is a preliminary step for IWLAN refactoring, where data response
will be one of the parameter in data service callback.

Test: Telephony sanity tests
bug: 64132030
Merged-In: I7eb5318cd75ca3b7a29d5bf0da18d6b29a228ee1
Change-Id: I7eb5318cd75ca3b7a29d5bf0da18d6b29a228ee1
(cherry picked from commit e44609b15866d080e0f8813b99d04b51a6f32929)

Android.mk
api/system-current.txt
telephony/java/android/telephony/data/DataCallResponse.aidl [new file with mode: 0644]
telephony/java/android/telephony/data/DataCallResponse.java [new file with mode: 0644]
telephony/java/android/telephony/data/InterfaceAddress.aidl [new file with mode: 0644]
telephony/java/android/telephony/data/InterfaceAddress.java [new file with mode: 0644]

index 6b13708..7c186b7 100644 (file)
@@ -46,6 +46,7 @@ aidl_files := \
        frameworks/base/telephony/java/android/telephony/NeighboringCellInfo.aidl \
        frameworks/base/telephony/java/android/telephony/ModemActivityInfo.aidl \
        frameworks/base/telephony/java/android/telephony/UiccAccessRule.aidl \
+       frameworks/base/telephony/java/android/telephony/data/DataCallResponse.aidl \
        frameworks/base/telephony/java/android/telephony/data/DataProfile.aidl \
        frameworks/base/telephony/java/android/telephony/euicc/DownloadableSubscription.aidl \
        frameworks/base/telephony/java/android/telephony/euicc/EuiccInfo.aidl \
index 2e9d88f..3a71189 100644 (file)
@@ -4057,6 +4057,25 @@ package android.telephony {
 
 package android.telephony.data {
 
+  public final class DataCallResponse implements android.os.Parcelable {
+    ctor public DataCallResponse(int, int, int, int, java.lang.String, java.lang.String, java.util.List<android.telephony.data.InterfaceAddress>, java.util.List<java.net.InetAddress>, java.util.List<java.net.InetAddress>, java.util.List<java.lang.String>, int);
+    ctor public DataCallResponse(android.os.Parcel);
+    method public int describeContents();
+    method public int getActive();
+    method public java.util.List<android.telephony.data.InterfaceAddress> getAddresses();
+    method public int getCallId();
+    method public java.util.List<java.net.InetAddress> getDnses();
+    method public java.util.List<java.net.InetAddress> getGateways();
+    method public java.lang.String getIfname();
+    method public int getMtu();
+    method public java.util.List<java.lang.String> getPcscfs();
+    method public int getStatus();
+    method public int getSuggestedRetryTime();
+    method public java.lang.String getType();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.telephony.data.DataCallResponse> CREATOR;
+  }
+
   public final class DataProfile implements android.os.Parcelable {
     ctor public DataProfile(int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, int, int, int, int, boolean, int, java.lang.String, int, int, java.lang.String, java.lang.String, boolean);
     ctor public DataProfile(android.os.Parcel);
@@ -4086,6 +4105,17 @@ package android.telephony.data {
     field public static final int TYPE_COMMON = 0; // 0x0
   }
 
+  public final class InterfaceAddress implements android.os.Parcelable {
+    ctor public InterfaceAddress(java.net.InetAddress, int);
+    ctor public InterfaceAddress(java.lang.String, int) throws java.net.UnknownHostException;
+    ctor public InterfaceAddress(android.os.Parcel);
+    method public int describeContents();
+    method public java.net.InetAddress getAddress();
+    method public int getNetworkPrefixLength();
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator<android.telephony.data.InterfaceAddress> CREATOR;
+  }
+
 }
 
 package android.telephony.ims {
diff --git a/telephony/java/android/telephony/data/DataCallResponse.aidl b/telephony/java/android/telephony/data/DataCallResponse.aidl
new file mode 100644 (file)
index 0000000..e4cfd69
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @hide */
+package android.telephony.data;
+
+parcelable DataCallResponse;
diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java
new file mode 100644 (file)
index 0000000..8cdad3f
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2009 Qualcomm Innovation Center, Inc.  All Rights Reserved.
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.data;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description of the response of a setup data call connection request.
+ *
+ * @hide
+ */
+@SystemApi
+public final class DataCallResponse implements Parcelable {
+    private final int mStatus;
+    private final int mSuggestedRetryTime;
+    private final int mCid;
+    private final int mActive;
+    private final String mType;
+    private final String mIfname;
+    private final List<InterfaceAddress> mAddresses;
+    private final List<InetAddress> mDnses;
+    private final List<InetAddress> mGateways;
+    private final List<String> mPcscfs;
+    private final int mMtu;
+
+    /**
+     * @param status Data call fail cause. 0 indicates no error.
+     * @param suggestedRetryTime The suggested data retry time in milliseconds.
+     * @param cid The unique id of the data connection.
+     * @param active Data connection active status. 0 = inactive, 1 = active/physical link down,
+     *               2 = active/physical link up.
+     * @param type The connection protocol, should be one of the PDP_type values in TS 27.007
+     *             section 10.1.1. For example, "IP", "IPV6", "IPV4V6", or "PPP".
+     * @param ifname The network interface name.
+     * @param addresses A list of addresses with optional "/" prefix length, e.g.,
+     *                  "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". Typically 1 IPv4 or 1 IPv6 or
+     *                  one of each. If the prefix length is absent the addresses are assumed to be
+     *                  point to point with IPv4 having a prefix length of 32 and IPv6 128.
+     * @param dnses A list of DNS server addresses, e.g., "192.0.1.3" or
+     *              "192.0.1.11 2001:db8::1". Null if no dns server addresses returned.
+     * @param gateways A list of default gateway addresses, e.g., "192.0.1.3" or
+     *                 "192.0.1.11 2001:db8::1". When null, the addresses represent point to point
+     *                 connections.
+     * @param pcscfs A list of Proxy Call State Control Function address via PCO(Protocol
+     *               Configuration Option) for IMS client.
+     * @param mtu MTU (Maximum transmission unit) received from network Value <= 0 means network has
+     *            either not sent a value or sent an invalid value.
+     */
+    public DataCallResponse(int status, int suggestedRetryTime, int cid, int active,
+                            @Nullable String type, @Nullable String ifname,
+                            @Nullable List<InterfaceAddress> addresses,
+                            @Nullable List<InetAddress> dnses,
+                            @Nullable List<InetAddress> gateways,
+                            @Nullable List<String> pcscfs, int mtu) {
+        mStatus = status;
+        mSuggestedRetryTime = suggestedRetryTime;
+        mCid = cid;
+        mActive = active;
+        mType = (type == null) ? "" : type;
+        mIfname = (ifname == null) ? "" : ifname;
+        mAddresses = (addresses == null) ? new ArrayList<>() : addresses;
+        mDnses = (dnses == null) ? new ArrayList<>() : dnses;
+        mGateways = (gateways == null) ? new ArrayList<>() : gateways;
+        mPcscfs = (pcscfs == null) ? new ArrayList<>() : pcscfs;
+        mMtu = mtu;
+    }
+
+    public DataCallResponse(Parcel source) {
+        mStatus = source.readInt();
+        mSuggestedRetryTime = source.readInt();
+        mCid = source.readInt();
+        mActive = source.readInt();
+        mType = source.readString();
+        mIfname = source.readString();
+        mAddresses = new ArrayList<>();
+        source.readList(mAddresses, InterfaceAddress.class.getClassLoader());
+        mDnses = new ArrayList<>();
+        source.readList(mDnses, InetAddress.class.getClassLoader());
+        mGateways = new ArrayList<>();
+        source.readList(mGateways, InetAddress.class.getClassLoader());
+        mPcscfs = new ArrayList<>();
+        source.readList(mPcscfs, InetAddress.class.getClassLoader());
+        mMtu = source.readInt();
+    }
+
+    /**
+     * @return Data call fail cause. 0 indicates no error.
+     */
+    public int getStatus() { return mStatus; }
+
+    /**
+     * @return The suggested data retry time in milliseconds.
+     */
+    public int getSuggestedRetryTime() { return mSuggestedRetryTime; }
+
+
+    /**
+     * @return The unique id of the data connection.
+     */
+    public int getCallId() { return mCid; }
+
+    /**
+     * @return 0 = inactive, 1 = active/physical link down, 2 = active/physical link up.
+     */
+    public int getActive() { return mActive; }
+
+    /**
+     * @return The connection protocol, should be one of the PDP_type values in TS 27.007 section
+     * 10.1.1. For example, "IP", "IPV6", "IPV4V6", or "PPP".
+     */
+    @NonNull
+    public String getType() { return mType; }
+
+    /**
+     * @return The network interface name.
+     */
+    @NonNull
+    public String getIfname() { return mIfname; }
+
+    /**
+     * @return A list of {@link InterfaceAddress}
+     */
+    @NonNull
+    public List<InterfaceAddress> getAddresses() { return mAddresses; }
+
+    /**
+     * @return A list of DNS server addresses, e.g., "192.0.1.3" or
+     * "192.0.1.11 2001:db8::1". Empty list if no dns server addresses returned.
+     */
+    @NonNull
+    public List<InetAddress> getDnses() { return mDnses; }
+
+    /**
+     * @return A list of default gateway addresses, e.g., "192.0.1.3" or
+     * "192.0.1.11 2001:db8::1". Empty list if the addresses represent point to point connections.
+     */
+    @NonNull
+    public List<InetAddress> getGateways() { return mGateways; }
+
+    /**
+     * @return A list of Proxy Call State Control Function address via PCO(Protocol Configuration
+     * Option) for IMS client.
+     */
+    @NonNull
+    public List<String> getPcscfs() { return mPcscfs; }
+
+    /**
+     * @return MTU received from network Value <= 0 means network has either not sent a value or
+     * sent an invalid value
+     */
+    public int getMtu() { return mMtu; }
+
+    @Override
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        sb.append("DataCallResponse: {")
+           .append(" status=").append(mStatus)
+           .append(" retry=").append(mSuggestedRetryTime)
+           .append(" cid=").append(mCid)
+           .append(" active=").append(mActive)
+           .append(" type=").append(mType)
+           .append(" ifname=").append(mIfname)
+           .append(" mtu=").append(mMtu)
+           .append(" addresses=").append(mAddresses)
+           .append(" dnses=").append(mDnses)
+           .append(" gateways=").append(mGateways)
+           .append(" pcscf=").append(mPcscfs)
+           .append("}");
+        return sb.toString();
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mStatus);
+        dest.writeInt(mSuggestedRetryTime);
+        dest.writeInt(mCid);
+        dest.writeInt(mActive);
+        dest.writeString(mType);
+        dest.writeString(mIfname);
+        dest.writeList(mAddresses);
+        dest.writeList(mDnses);
+        dest.writeList(mGateways);
+        dest.writeList(mPcscfs);
+        dest.writeInt(mMtu);
+    }
+
+    public static final Parcelable.Creator<DataCallResponse> CREATOR =
+            new Parcelable.Creator<DataCallResponse>() {
+                @Override
+                public DataCallResponse createFromParcel(Parcel source) {
+                    return new DataCallResponse(source);
+                }
+
+                @Override
+                public DataCallResponse[] newArray(int size) {
+                    return new DataCallResponse[size];
+                }
+            };
+}
\ No newline at end of file
diff --git a/telephony/java/android/telephony/data/InterfaceAddress.aidl b/telephony/java/android/telephony/data/InterfaceAddress.aidl
new file mode 100644 (file)
index 0000000..d750363
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @hide */
+package android.telephony.data;
+
+parcelable InterfaceAddress;
diff --git a/telephony/java/android/telephony/data/InterfaceAddress.java b/telephony/java/android/telephony/data/InterfaceAddress.java
new file mode 100644 (file)
index 0000000..947d0ff
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.data;
+
+import android.annotation.SystemApi;
+import android.net.NetworkUtils;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * This class represents a Network Interface address. In short it's an IP address, a subnet mask
+ * when the address is an IPv4 one. An IP address and a network prefix length in the case of IPv6
+ * address.
+ *
+ * @hide
+ */
+@SystemApi
+public final class InterfaceAddress implements Parcelable {
+
+    private final InetAddress mInetAddress;
+
+    private final int mPrefixLength;
+
+    /**
+     * @param inetAddress A {@link InetAddress} of the address
+     * @param prefixLength The network prefix length for this address.
+     */
+    public InterfaceAddress(InetAddress inetAddress, int prefixLength) {
+        mInetAddress = inetAddress;
+        mPrefixLength = prefixLength;
+    }
+
+    /**
+     * @param address The address in string format
+     * @param prefixLength The network prefix length for this address.
+     * @throws UnknownHostException
+     */
+    public InterfaceAddress(String address, int prefixLength) throws UnknownHostException {
+        InetAddress ia;
+        try {
+            ia = NetworkUtils.numericToInetAddress(address);
+        } catch (IllegalArgumentException e) {
+            throw new UnknownHostException("Non-numeric ip addr=" + address);
+        }
+        mInetAddress = ia;
+        mPrefixLength = prefixLength;
+    }
+
+    public InterfaceAddress(Parcel source) {
+        mInetAddress = (InetAddress) source.readSerializable();
+        mPrefixLength = source.readInt();
+    }
+
+    /**
+     * @return an InetAddress for this address.
+     */
+    public InetAddress getAddress() { return mInetAddress; }
+
+    /**
+     * @return The network prefix length for this address.
+     */
+    public int getNetworkPrefixLength() { return mPrefixLength; }
+
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public String toString() {
+        return mInetAddress + "/" + mPrefixLength;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeSerializable(mInetAddress);
+        dest.writeInt(mPrefixLength);
+    }
+
+    public static final Parcelable.Creator<InterfaceAddress> CREATOR =
+            new Parcelable.Creator<InterfaceAddress>() {
+        @Override
+        public InterfaceAddress createFromParcel(Parcel source) {
+            return new InterfaceAddress(source);
+        }
+
+        @Override
+        public InterfaceAddress[] newArray(int size) {
+            return new InterfaceAddress[size];
+        }
+    };
+}