diff options
| author | 2016-01-12 15:32:58 -0800 | |
|---|---|---|
| committer | 2016-01-15 12:43:27 -0800 | |
| commit | 0464b9ba16ea49f7bff55d7d85231c6dd832b58e (patch) | |
| tree | f625c8b4b435086d8bb5db152685856fbbbe7a4b | |
| parent | b05fd8860f847996acc5f001492a30562b199c95 (diff) | |
Add method to dump Telecom analytics
Add dumpAnalytics in TelecomManager to allow the connectivity stats
service to access Telecom analytics for uploading.
Change-Id: I197d6af340fac7f38b28bb44a476b5e694db4dba
| -rw-r--r-- | api/system-current.txt | 30 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/ParcelableCallAnalytics.aidl | 22 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/ParcelableCallAnalytics.java | 184 | ||||
| -rw-r--r-- | telecomm/java/android/telecom/TelecomManager.java | 22 | ||||
| -rw-r--r-- | telecomm/java/com/android/internal/telecom/ITelecomService.aidl | 6 |
5 files changed, 264 insertions, 0 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 8d4caefa3c74..237690566cd6 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -37525,6 +37525,35 @@ package android.telecom { method public abstract void onVideoQualityChanged(int); } + public class ParcelableCallAnalytics implements android.os.Parcelable { + ctor public ParcelableCallAnalytics(long, long, int, boolean, boolean, int, int, boolean, java.lang.String, boolean); + ctor public ParcelableCallAnalytics(android.os.Parcel); + method public int describeContents(); + method public long getCallDurationMillis(); + method public int getCallTechnologies(); + method public int getCallTerminationCode(); + method public int getCallType(); + method public java.lang.String getConnectionService(); + method public long getStartTimeMillis(); + method public boolean isAdditionalCall(); + method public boolean isCreatedFromExistingConnection(); + method public boolean isEmergencyCall(); + method public boolean isInterrupted(); + method public void writeToParcel(android.os.Parcel, int); + field public static final int CALLTYPE_INCOMING = 1; // 0x1 + field public static final int CALLTYPE_OUTGOING = 2; // 0x2 + field public static final int CALLTYPE_UNKNOWN = 0; // 0x0 + field public static final int CDMA_PHONE = 1; // 0x1 + field public static final android.os.Parcelable.Creator<android.telecom.ParcelableCallAnalytics> CREATOR; + field public static final int GSM_PHONE = 2; // 0x2 + field public static final int IMS_PHONE = 4; // 0x4 + field public static final long MILLIS_IN_1_SECOND = 1000L; // 0x3e8L + field public static final long MILLIS_IN_5_MINUTES = 300000L; // 0x493e0L + field public static final int SIP_PHONE = 8; // 0x8 + field public static final int STILL_CONNECTED = -1; // 0xffffffff + field public static final int THIRD_PARTY_PHONE = 16; // 0x10 + } + public final deprecated class Phone { method public final void addListener(android.telecom.Phone.Listener); method public final boolean canAddCall(); @@ -37742,6 +37771,7 @@ package android.telecom { method public void cancelMissedCallsNotification(); method public deprecated void clearAccounts(); method public void clearPhoneAccounts(); + method public java.util.List<android.telecom.ParcelableCallAnalytics> dumpAnalytics(); method public void enablePhoneAccount(android.telecom.PhoneAccountHandle, boolean); method public boolean endCall(); method public android.net.Uri getAdnUriForPhoneAccount(android.telecom.PhoneAccountHandle); diff --git a/telecomm/java/android/telecom/ParcelableCallAnalytics.aidl b/telecomm/java/android/telecom/ParcelableCallAnalytics.aidl new file mode 100644 index 000000000000..b7e78d1959fc --- /dev/null +++ b/telecomm/java/android/telecom/ParcelableCallAnalytics.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.telecom; + +/** + * {@hide} + */ +parcelable ParcelableCallAnalytics; diff --git a/telecomm/java/android/telecom/ParcelableCallAnalytics.java b/telecomm/java/android/telecom/ParcelableCallAnalytics.java new file mode 100644 index 000000000000..e7c967260532 --- /dev/null +++ b/telecomm/java/android/telecom/ParcelableCallAnalytics.java @@ -0,0 +1,184 @@ +/* + * 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.telecom; + +import android.annotation.SystemApi; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * @hide + */ +@SystemApi +public class ParcelableCallAnalytics implements Parcelable { + public static final int CALLTYPE_UNKNOWN = 0; + public static final int CALLTYPE_INCOMING = 1; + public static final int CALLTYPE_OUTGOING = 2; + + // Constants for call technology + public static final int CDMA_PHONE = 0x1; + public static final int GSM_PHONE = 0x2; + public static final int IMS_PHONE = 0x4; + public static final int SIP_PHONE = 0x8; + public static final int THIRD_PARTY_PHONE = 0x10; + + public static final long MILLIS_IN_5_MINUTES = 1000 * 60 * 5; + public static final long MILLIS_IN_1_SECOND = 1000; + + public static final int STILL_CONNECTED = -1; + + public static final Parcelable.Creator<ParcelableCallAnalytics> CREATOR = + new Parcelable.Creator<ParcelableCallAnalytics> () { + + @Override + public ParcelableCallAnalytics createFromParcel(Parcel in) { + return new ParcelableCallAnalytics(in); + } + + @Override + public ParcelableCallAnalytics[] newArray(int size) { + return new ParcelableCallAnalytics[size]; + } + }; + + // The start time of the call in milliseconds since Jan. 1, 1970, rounded to the nearest + // 5 minute increment. + private final long startTimeMillis; + + // The duration of the call, in milliseconds. + private final long callDurationMillis; + + // ONE OF calltype_unknown, calltype_incoming, or calltype_outgoing + private final int callType; + + // true if the call came in while another call was in progress or if the user dialed this call + // while in the middle of another call. + private final boolean isAdditionalCall; + + // true if the call was interrupted by an incoming or outgoing call. + private final boolean isInterrupted; + + // bitmask denoting which technologies a call used. + private final int callTechnologies; + + // Any of the DisconnectCause codes, or STILL_CONNECTED. + private final int callTerminationCode; + + // Whether the call is an emergency call + private final boolean isEmergencyCall; + + // The package name of the connection service that this call used. + private final String connectionService; + + // Whether the call object was created from an existing connection. + private final boolean isCreatedFromExistingConnection; + + public ParcelableCallAnalytics(long startTimeMillis, long callDurationMillis, int callType, + boolean isAdditionalCall, boolean isInterrupted, int callTechnologies, + int callTerminationCode, boolean isEmergencyCall, String connectionService, + boolean isCreatedFromExistingConnection) { + this.startTimeMillis = startTimeMillis; + this.callDurationMillis = callDurationMillis; + this.callType = callType; + this.isAdditionalCall = isAdditionalCall; + this.isInterrupted = isInterrupted; + this.callTechnologies = callTechnologies; + this.callTerminationCode = callTerminationCode; + this.isEmergencyCall = isEmergencyCall; + this.connectionService = connectionService; + this.isCreatedFromExistingConnection = isCreatedFromExistingConnection; + } + + public ParcelableCallAnalytics(Parcel in) { + startTimeMillis = in.readLong(); + callDurationMillis = in.readLong(); + callType = in.readInt(); + isAdditionalCall = readByteAsBoolean(in); + isInterrupted = readByteAsBoolean(in); + callTechnologies = in.readInt(); + callTerminationCode = in.readInt(); + isEmergencyCall = readByteAsBoolean(in); + connectionService = in.readString(); + isCreatedFromExistingConnection = readByteAsBoolean(in); + } + + public void writeToParcel(Parcel out, int flags) { + out.writeLong(startTimeMillis); + out.writeLong(callDurationMillis); + out.writeInt(callType); + writeBooleanAsByte(out, isAdditionalCall); + writeBooleanAsByte(out, isInterrupted); + out.writeInt(callTechnologies); + out.writeInt(callTerminationCode); + writeBooleanAsByte(out, isEmergencyCall); + out.writeString(connectionService); + writeBooleanAsByte(out, isCreatedFromExistingConnection); + } + + public long getStartTimeMillis() { + return startTimeMillis; + } + + public long getCallDurationMillis() { + return callDurationMillis; + } + + public int getCallType() { + return callType; + } + + public boolean isAdditionalCall() { + return isAdditionalCall; + } + + public boolean isInterrupted() { + return isInterrupted; + } + + public int getCallTechnologies() { + return callTechnologies; + } + + public int getCallTerminationCode() { + return callTerminationCode; + } + + public boolean isEmergencyCall() { + return isEmergencyCall; + } + + public String getConnectionService() { + return connectionService; + } + + public boolean isCreatedFromExistingConnection() { + return isCreatedFromExistingConnection; + } + + @Override + public int describeContents() { + return 0; + } + + private static void writeBooleanAsByte(Parcel out, boolean b) { + out.writeByte((byte) (b ? 1 : 0)); + } + + private static boolean readByteAsBoolean(Parcel in) { + return (in.readByte() == 1); + } +} diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 9eb166596132..d45b26fd4650 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -14,6 +14,7 @@ package android.telecom; +import android.Manifest; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.content.ComponentName; @@ -1377,6 +1378,27 @@ public class TelecomManager { } } + /** + * Dumps telecom analytics for uploading. + * + * @return + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.DUMP) + public List<ParcelableCallAnalytics> dumpAnalytics() { + ITelecomService service = getTelecomService(); + List<ParcelableCallAnalytics> result = null; + if (service != null) { + try { + result = service.dumpCallAnalytics(); + } catch (RemoteException e) { + Log.e(TAG, "Error dumping call analytics", e); + } + } + return result; + } + private ITelecomService getTelecomService() { if (mTelecomServiceOverride != null) { return mTelecomServiceOverride; diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl index 856e21043a8d..af36b3e41eb2 100644 --- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl +++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl @@ -17,6 +17,7 @@ package com.android.internal.telecom; import android.content.ComponentName; +import android.telecom.ParcelableCallAnalytics; import android.telecom.PhoneAccountHandle; import android.net.Uri; import android.os.Bundle; @@ -143,6 +144,11 @@ interface ITelecomService { */ String getSystemDialerPackage(); + /** + * @see TelecomServiceImpl#dumpCallAnalytics + */ + List<ParcelableCallAnalytics> dumpCallAnalytics(); + // // Internal system apis relating to call management. // |