diff options
author | Evan Charlton <evanc@google.com> | 2014-04-16 13:14:39 -0700 |
---|---|---|
committer | Evan Charlton <evanc@google.com> | 2014-04-16 13:14:39 -0700 |
commit | a3db73388562d335864d646441dedd1fa2071e9b (patch) | |
tree | 9c1fbd5a557e2755e8726625e478b57ba0a96232 /telephony | |
parent | cd254448c1d630b60231143a8e56c26a74762e3a (diff) | |
parent | 8d966e4243f7729d76f298ad1e06ef40ec4ee40f (diff) | |
download | frameworks_base-a3db73388562d335864d646441dedd1fa2071e9b.zip frameworks_base-a3db73388562d335864d646441dedd1fa2071e9b.tar.gz frameworks_base-a3db73388562d335864d646441dedd1fa2071e9b.tar.bz2 |
resolved conflicts for merge of 8d966e42 to master-nova
Change-Id: Ibcc7d1eb4f0349e90b8e97d5235a08efb8226ef6
Diffstat (limited to 'telephony')
5 files changed, 195 insertions, 1 deletions
diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl b/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl new file mode 100644 index 0000000..70fbb11 --- /dev/null +++ b/telephony/java/android/telephony/DataConnectionRealTimeInfo.aidl @@ -0,0 +1,20 @@ +/* +** +** Copyright 2007, 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; + +parcelable DataConnectionRealTimeInfo; diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java new file mode 100644 index 0000000..4a9ae39 --- /dev/null +++ b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2014 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; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Data connection real time information + * + * TODO: How to handle multiple subscriptions? + */ +public class DataConnectionRealTimeInfo implements Parcelable { + private long mTime; // Time the info was collected since boot in nanos; + + public static int DC_POWER_STATE_LOW = 1; + public static int DC_POWER_STATE_MEDIUM = 2; + public static int DC_POWER_STATE_HIGH = 3; + public static int DC_POWER_STATE_UNKNOWN = Integer.MAX_VALUE; + + private int mDcPowerState; // DC_POWER_STATE_[LOW | MEDIUM | HIGH | UNKNOWN] + + /** + * Constructor + * + * @hide + */ + public DataConnectionRealTimeInfo(long time, int dcPowerState) { + mTime = time; + mDcPowerState = dcPowerState; + } + + /** + * Constructor + * + * @hide + */ + public DataConnectionRealTimeInfo() { + mTime = Long.MAX_VALUE; + mDcPowerState = DC_POWER_STATE_UNKNOWN; + } + + /** + * Construct a PreciseCallState object from the given parcel. + */ + private DataConnectionRealTimeInfo(Parcel in) { + mTime = in.readLong(); + mDcPowerState = in.readInt(); + } + + /** + * @return time the information was collected or Long.MAX_VALUE if unknown + */ + public long getTime() { + return mTime; + } + + /** + * @return DC_POWER_STATE_[LOW | MEDIUM | HIGH | UNKNOWN] + */ + public int getDcPowerState() { + return mDcPowerState; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeLong(mTime); + out.writeInt(mDcPowerState); + } + + public static final Parcelable.Creator<DataConnectionRealTimeInfo> CREATOR + = new Parcelable.Creator<DataConnectionRealTimeInfo>() { + + @Override + public DataConnectionRealTimeInfo createFromParcel(Parcel in) { + return new DataConnectionRealTimeInfo(in); + } + + @Override + public DataConnectionRealTimeInfo[] newArray(int size) { + return new DataConnectionRealTimeInfo[size]; + } + }; + + @Override + public int hashCode() { + final long prime = 17; + long result = 1; + result = (prime * result) + mTime; + result += (prime * result) + mDcPowerState; + return (int)result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DataConnectionRealTimeInfo other = (DataConnectionRealTimeInfo) obj; + return (mTime == other.mTime) + && (mDcPowerState == other.mDcPowerState); + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + + sb.append("mTime=").append(mTime); + sb.append(" mDcPowerState=").append(mDcPowerState); + + return sb.toString(); + } +} diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index bb3f132..7c5c648 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -188,6 +188,17 @@ public class PhoneStateListener { */ public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000; + /** + * Listen for real time info for all data connections (cellular)). + * {@more} + * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE + * READ_PRECISE_PHONE_STATE} + * + * @see #onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo) + * @hide + */ + public static final int LISTEN_DATA_CONNECTION_REAL_TIME_INFO = 0x00002000; + public PhoneStateListener() { } @@ -335,6 +346,16 @@ public class PhoneStateListener { } /** + * Callback invoked when data connection state changes with precise information. + * + * @hide + */ + public void onDataConnectionRealTimeInfoChanged( + DataConnectionRealTimeInfo dcRtInfo) { + // default implementation empty + } + + /** * The callback methods need to be called on the handler thread where * this object was created. If the binder did that for us it'd be nice. */ @@ -396,6 +417,12 @@ public class PhoneStateListener { Message.obtain(mHandler, LISTEN_PRECISE_DATA_CONNECTION_STATE, 0, 0, dataConnectionState).sendToTarget(); } + + public void onDataConnectionRealTimeInfoChanged( + DataConnectionRealTimeInfo dcRtInfo) { + Message.obtain(mHandler, LISTEN_DATA_CONNECTION_REAL_TIME_INFO, 0, 0, + dcRtInfo).sendToTarget(); + } }; Handler mHandler = new Handler() { @@ -441,6 +468,11 @@ public class PhoneStateListener { break; case LISTEN_PRECISE_DATA_CONNECTION_STATE: PhoneStateListener.this.onPreciseDataConnectionStateChanged((PreciseDataConnectionState)msg.obj); + break; + case LISTEN_DATA_CONNECTION_REAL_TIME_INFO: + PhoneStateListener.this.onDataConnectionRealTimeInfoChanged( + (DataConnectionRealTimeInfo)msg.obj); + break; } } }; diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index f228d4e..3f36645 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -20,6 +20,7 @@ import android.os.Bundle; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.CellInfo; +import android.telephony.DataConnectionRealTimeInfo; import android.telephony.PreciseCallState; import android.telephony.PreciseDataConnectionState; @@ -39,5 +40,6 @@ oneway interface IPhoneStateListener { void onCellInfoChanged(in List<CellInfo> cellInfo); void onPreciseCallStateChanged(in PreciseCallState callState); void onPreciseDataConnectionStateChanged(in PreciseDataConnectionState dataConnectionState); + void onDataConnectionRealTimeInfoChanged(in DataConnectionRealTimeInfo dcRtInfo); } diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 546ce17..8ea9b0d 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -20,9 +20,10 @@ import android.content.Intent; import android.net.LinkProperties; import android.net.LinkCapabilities; import android.os.Bundle; +import android.telephony.CellInfo; +import android.telephony.DataConnectionRealTimeInfo; import android.telephony.ServiceState; import android.telephony.SignalStrength; -import android.telephony.CellInfo; import com.android.internal.telephony.IPhoneStateListener; interface ITelephonyRegistry { @@ -46,4 +47,5 @@ interface ITelephonyRegistry { void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause); void notifyPreciseDataConnectionFailed(String reason, String apnType, String apn, String failCause); + void notifyDataConnectionRealTimeInfo(in DataConnectionRealTimeInfo dcRtInfo); } |