summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--telephony/java/android/telephony/ClientRequestStats.aidl22
-rw-r--r--telephony/java/android/telephony/ClientRequestStats.java175
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java23
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl11
4 files changed, 231 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/ClientRequestStats.aidl b/telephony/java/android/telephony/ClientRequestStats.aidl
new file mode 100644
index 000000000000..206ee705614e
--- /dev/null
+++ b/telephony/java/android/telephony/ClientRequestStats.aidl
@@ -0,0 +1,22 @@
+/*
+** Copyright 2016, 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;
+
+/**
+ * @hide
+ */
+parcelable ClientRequestStats;
diff --git a/telephony/java/android/telephony/ClientRequestStats.java b/telephony/java/android/telephony/ClientRequestStats.java
new file mode 100644
index 000000000000..381c847d4db4
--- /dev/null
+++ b/telephony/java/android/telephony/ClientRequestStats.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2016 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;
+import android.telephony.TelephonyHistogram;
+import android.util.SparseArray;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Parcelable class to store Client request statistics information.
+ *
+ * @hide
+ */
+public final class ClientRequestStats implements Parcelable {
+ public static final Parcelable.Creator<ClientRequestStats> CREATOR =
+ new Parcelable.Creator<ClientRequestStats>() {
+
+ public ClientRequestStats createFromParcel(Parcel in) {
+ return new ClientRequestStats(in);
+ }
+
+ public ClientRequestStats[] newArray(int size) {
+ return new ClientRequestStats[size];
+ }
+ };
+ private static final int REQUEST_HISTOGRAM_BUCKET_COUNT = 5;
+ private String mCallingPackage;
+ /* completed requests wake lock time in milli seconds */
+ private long mCompletedRequestsWakelockTime = 0;
+ private long mCompletedRequestsCount = 0;
+ private long mPendingRequestsWakelockTime = 0;
+ private long mPendingRequestsCount = 0;
+ private SparseArray<TelephonyHistogram> mRequestHistograms =
+ new SparseArray<TelephonyHistogram>();
+
+ public ClientRequestStats(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public ClientRequestStats() {
+ }
+
+ public ClientRequestStats(ClientRequestStats clientRequestStats) {
+ mCallingPackage = clientRequestStats.getCallingPackage();
+ mCompletedRequestsCount = clientRequestStats.getCompletedRequestsCount();
+ mCompletedRequestsWakelockTime = clientRequestStats.getCompletedRequestsWakelockTime();
+ mPendingRequestsCount = clientRequestStats.getPendingRequestsCount();
+ mPendingRequestsWakelockTime = clientRequestStats.getPendingRequestsWakelockTime();
+
+ List<TelephonyHistogram> list = clientRequestStats.getRequestHistograms();
+ for (TelephonyHistogram entry : list) {
+ mRequestHistograms.put(entry.getId(), entry);
+ }
+ }
+
+ public String getCallingPackage() {
+ return mCallingPackage;
+ }
+
+ public void setCallingPackage(String mCallingPackage) {
+ this.mCallingPackage = mCallingPackage;
+ }
+
+ public long getCompletedRequestsWakelockTime() {
+ return mCompletedRequestsWakelockTime;
+ }
+
+ public void addCompletedWakelockTime(long completedRequestsWakelockTime) {
+ this.mCompletedRequestsWakelockTime += completedRequestsWakelockTime;
+ }
+
+ public long getPendingRequestsWakelockTime() {
+ return mPendingRequestsWakelockTime;
+ }
+
+ public void setPendingRequestsWakelockTime(long pendingRequestsWakelockTime) {
+ this.mPendingRequestsWakelockTime = pendingRequestsWakelockTime;
+ }
+
+ public long getCompletedRequestsCount() {
+ return mCompletedRequestsCount;
+ }
+
+ public void incrementCompletedRequestsCount() {
+ this.mCompletedRequestsCount++;
+ }
+
+ public long getPendingRequestsCount() {
+ return mPendingRequestsCount;
+ }
+
+ public void setPendingRequestsCount(long pendingRequestsCount) {
+ this.mPendingRequestsCount = pendingRequestsCount;
+ }
+
+ public List<TelephonyHistogram> getRequestHistograms() {
+ List<TelephonyHistogram> list;
+ synchronized (mRequestHistograms) {
+ list = new ArrayList<>(mRequestHistograms.size());
+ for (int i = 0; i < mRequestHistograms.size(); i++) {
+ TelephonyHistogram entry = new TelephonyHistogram(mRequestHistograms.valueAt(i));
+ list.add(entry);
+ }
+ }
+ return list;
+ }
+
+ public void updateRequestHistograms(int requestId, int time) {
+ synchronized (mRequestHistograms) {
+ TelephonyHistogram entry = mRequestHistograms.get(requestId);
+ if (entry == null) {
+ entry = new TelephonyHistogram(TelephonyHistogram.TELEPHONY_CATEGORY_RIL,
+ requestId, REQUEST_HISTOGRAM_BUCKET_COUNT);
+ mRequestHistograms.put(requestId, entry);
+ }
+ entry.addTimeTaken(time);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "ClientRequestStats{" +
+ "mCallingPackage='" + mCallingPackage + '\'' +
+ ", mCompletedRequestsWakelockTime=" + mCompletedRequestsWakelockTime +
+ ", mCompletedRequestsCount=" + mCompletedRequestsCount +
+ ", mPendingRequestsWakelockTime=" + mPendingRequestsWakelockTime +
+ ", mPendingRequestsCount=" + mPendingRequestsCount +
+ '}';
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public void readFromParcel(Parcel in) {
+ mCallingPackage = in.readString();
+ mCompletedRequestsWakelockTime = in.readLong();
+ mCompletedRequestsCount = in.readLong();
+ mPendingRequestsWakelockTime = in.readLong();
+ mPendingRequestsCount = in.readLong();
+ ArrayList<TelephonyHistogram> requestHistograms = new ArrayList<TelephonyHistogram>();
+ in.readTypedList(requestHistograms, TelephonyHistogram.CREATOR);
+ for (TelephonyHistogram h : requestHistograms) {
+ mRequestHistograms.put(h.getId(), h);
+ }
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mCallingPackage);
+ dest.writeLong(mCompletedRequestsWakelockTime);
+ dest.writeLong(mCompletedRequestsCount);
+ dest.writeLong(mPendingRequestsWakelockTime);
+ dest.writeLong(mPendingRequestsCount);
+ dest.writeTypedList(getRequestHistograms());
+ }
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 1554868c30f2..fcae4c30ea70 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -39,6 +39,7 @@ import android.os.SystemProperties;
import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+import android.telephony.ClientRequestStats;
import android.telephony.TelephonyHistogram;
import android.telephony.ims.feature.ImsFeature;
import android.util.Log;
@@ -5844,5 +5845,27 @@ public class TelephonyManager {
Log.e(TAG, "Error calling ITelephony#setPolicyDataEnabled", e);
}
}
+
+ /**
+ * Get Client request stats which will contain statistical information
+ * on each request made by client.
+ * Callers require either READ_PRIVILEGED_PHONE_STATE or
+ * READ_PHONE_STATE to retrieve the information.
+ * @param subId sub id
+ * @return List of Client Request Stats
+ * @hide
+ */
+ public List<ClientRequestStats> getClientRequestStats(int subId) {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.getClientRequestStats(getOpPackageName(), subId);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#getClientRequestStats", e);
+ }
+
+ return null;
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index d406cb07fc45..19885966084c 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -24,6 +24,7 @@ import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.CellInfo;
+import android.telephony.ClientRequestStats;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.ModemActivityInfo;
import android.telephony.NeighboringCellInfo;
@@ -1192,4 +1193,14 @@ interface ITelephony {
* @hide
*/
void setPolicyDataEnabled(boolean enabled, int subId);
+
+
+ /**
+ * Get Client request stats which will contain statistical information
+ * on each request made by client.
+ * @param callingPackage package making the call.
+ * @param subId Subscription index
+ * @hide
+ */
+ List<ClientRequestStats> getClientRequestStats(String callingPackage, int subid);
}