1 /* 2 * Copyright (C) 2016 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 17 package android.telecom; 18 19 import android.annotation.SystemApi; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 import java.util.ArrayList; 24 import java.util.List; 25 26 /** 27 * @hide 28 */ 29 @SystemApi 30 public final class TelecomAnalytics implements Parcelable { 31 public static final Parcelable.Creator<TelecomAnalytics> CREATOR = 32 new Parcelable.Creator<TelecomAnalytics> () { 33 34 @Override 35 public TelecomAnalytics createFromParcel(Parcel in) { 36 return new TelecomAnalytics(in); 37 } 38 39 @Override 40 public TelecomAnalytics[] newArray(int size) { 41 return new TelecomAnalytics[size]; 42 } 43 }; 44 45 public static final class SessionTiming extends TimedEvent<Integer> implements Parcelable { 46 public static final Parcelable.Creator<SessionTiming> CREATOR = 47 new Parcelable.Creator<SessionTiming> () { 48 49 @Override 50 public SessionTiming createFromParcel(Parcel in) { 51 return new SessionTiming(in); 52 } 53 54 @Override 55 public SessionTiming[] newArray(int size) { 56 return new SessionTiming[size]; 57 } 58 }; 59 60 public static final int ICA_ANSWER_CALL = 1; 61 public static final int ICA_REJECT_CALL = 2; 62 public static final int ICA_DISCONNECT_CALL = 3; 63 public static final int ICA_HOLD_CALL = 4; 64 public static final int ICA_UNHOLD_CALL = 5; 65 public static final int ICA_MUTE = 6; 66 public static final int ICA_SET_AUDIO_ROUTE = 7; 67 public static final int ICA_CONFERENCE = 8; 68 69 public static final int CSW_HANDLE_CREATE_CONNECTION_COMPLETE = 100; 70 public static final int CSW_SET_ACTIVE = 101; 71 public static final int CSW_SET_RINGING = 102; 72 public static final int CSW_SET_DIALING = 103; 73 public static final int CSW_SET_DISCONNECTED = 104; 74 public static final int CSW_SET_ON_HOLD = 105; 75 public static final int CSW_REMOVE_CALL = 106; 76 public static final int CSW_SET_IS_CONFERENCED = 107; 77 public static final int CSW_ADD_CONFERENCE_CALL = 108; 78 79 private int mId; 80 private long mTime; 81 82 public SessionTiming(int id, long time) { 83 this.mId = id; 84 this.mTime = time; 85 } 86 87 private SessionTiming(Parcel in) { 88 mId = in.readInt(); 89 mTime = in.readLong(); 90 } 91 92 @Override 93 public Integer getKey() { 94 return mId; 95 } 96 97 @Override 98 public long getTime() { 99 return mTime; 100 } 101 102 @Override 103 public int describeContents() { 104 return 0; 105 } 106 107 @Override 108 public void writeToParcel(Parcel out, int flags) { 109 out.writeInt(mId); 110 out.writeLong(mTime); 111 } 112 } 113 114 private List<SessionTiming> mSessionTimings; 115 private List<ParcelableCallAnalytics> mCallAnalytics; 116 117 public TelecomAnalytics(List<SessionTiming> sessionTimings, 118 List<ParcelableCallAnalytics> callAnalytics) { 119 this.mSessionTimings = sessionTimings; 120 this.mCallAnalytics = callAnalytics; 121 } 122 123 private TelecomAnalytics(Parcel in) { 124 mSessionTimings = new ArrayList<>(); 125 in.readTypedList(mSessionTimings, SessionTiming.CREATOR); 126 mCallAnalytics = new ArrayList<>(); 127 in.readTypedList(mCallAnalytics, ParcelableCallAnalytics.CREATOR); 128 } 129 130 public List<SessionTiming> getSessionTimings() { 131 return mSessionTimings; 132 } 133 134 public List<ParcelableCallAnalytics> getCallAnalytics() { 135 return mCallAnalytics; 136 } 137 138 @Override 139 public int describeContents() { 140 return 0; 141 } 142 143 @Override 144 public void writeToParcel(Parcel out, int flags) { 145 out.writeTypedList(mSessionTimings); 146 out.writeTypedList(mCallAnalytics); 147 } 148 } 149