That fuck shit the fascists are using
at master 172 lines 4.8 kB view raw
1package org.tm.archive.ringrtc; 2 3import android.os.Parcel; 4import android.os.Parcelable; 5 6import androidx.annotation.NonNull; 7import androidx.annotation.Nullable; 8 9import org.signal.core.util.logging.Log; 10import org.signal.ringrtc.CallId; 11import org.signal.ringrtc.Remote; 12import org.tm.archive.recipients.Recipient; 13import org.tm.archive.recipients.RecipientId; 14 15/** 16 * Container class that represents the remote peer and current state 17 * of a video/voice call. 18 * 19 * The class is also Parcelable for passing around via an Intent. 20 */ 21public final class RemotePeer implements Remote, Parcelable 22{ 23 private static final String TAG = Log.tag(RemotePeer.class); 24 25 public static final CallId NO_CALL_ID = new CallId(-1L); 26 public static final CallId GROUP_CALL_ID = new CallId(-2L); 27 28 @NonNull private final RecipientId recipientId; 29 @NonNull private CallState callState; 30 @NonNull private CallId callId; 31 private long callStartTimestamp; 32 33 public RemotePeer(@NonNull RecipientId recipientId) { 34 this(recipientId, new CallId(-1L)); 35 } 36 37 public RemotePeer(@NonNull RecipientId recipientId, @NonNull CallId callId) { 38 this.recipientId = recipientId; 39 this.callState = CallState.IDLE; 40 this.callId = callId; 41 this.callStartTimestamp = 0; 42 } 43 44 private RemotePeer(@NonNull Parcel in) { 45 this.recipientId = RecipientId.CREATOR.createFromParcel(in); 46 this.callState = CallState.values()[in.readInt()]; 47 this.callId = new CallId(in.readLong()); 48 this.callStartTimestamp = in.readLong(); 49 } 50 51 public @NonNull CallId getCallId() { 52 return callId; 53 } 54 55 public void setCallId(@NonNull CallId callId) { 56 this.callId = callId; 57 } 58 59 public void setCallStartTimestamp(long callStartTimestamp) { 60 this.callStartTimestamp = callStartTimestamp; 61 } 62 63 public long getCallStartTimestamp() { 64 return callStartTimestamp; 65 } 66 67 public @NonNull CallState getState() { 68 return callState; 69 } 70 71 public @NonNull RecipientId getId() { 72 return recipientId; 73 } 74 75 public @NonNull Recipient getRecipient() { 76 return Recipient.resolved(recipientId); 77 } 78 79 @Override 80 public String toString() { 81 return "recipientId: " + this.recipientId + 82 ", callId: " + this.callId + 83 ", state: " + this.callState; 84 } 85 86 @Override 87 public boolean recipientEquals(Remote obj) { 88 if (obj != null && this.getClass() == obj.getClass()) { 89 RemotePeer that = (RemotePeer)obj; 90 return this.recipientId.equals(that.recipientId); 91 } 92 93 return false; 94 } 95 96 public boolean callIdEquals(@Nullable RemotePeer remotePeer) { 97 return remotePeer != null && this.callId.equals(remotePeer.callId); 98 } 99 100 public void dialing() { 101 if (callState != CallState.IDLE) { 102 throw new IllegalStateException("Cannot transition to DIALING from state: " + callState); 103 } 104 105 this.callState = CallState.DIALING; 106 } 107 108 public void answering() { 109 if (callState != CallState.IDLE) { 110 throw new IllegalStateException("Cannot transition to ANSWERING from state: " + callState); 111 } 112 113 this.callState = CallState.ANSWERING; 114 } 115 116 public void remoteRinging() { 117 if (callState != CallState.DIALING) { 118 throw new IllegalStateException("Cannot transition to REMOTE_RINGING from state: " + callState); 119 } 120 121 this.callState = CallState.REMOTE_RINGING; 122 } 123 124 public void localRinging() { 125 if (callState != CallState.ANSWERING) { 126 throw new IllegalStateException("Cannot transition to LOCAL_RINGING from state: " + callState); 127 } 128 129 this.callState = CallState.LOCAL_RINGING; 130 } 131 132 public void connected() { 133 if (callState != CallState.REMOTE_RINGING && callState != CallState.LOCAL_RINGING) { 134 throw new IllegalStateException("Cannot transition outgoing call to CONNECTED from state: " + callState); 135 } 136 137 this.callState = CallState.CONNECTED; 138 } 139 140 public void receivedBusy() { 141 if (callState != CallState.DIALING) { 142 Log.w(TAG, "RECEIVED_BUSY from unexpected state: " + callState); 143 } 144 145 this.callState = CallState.RECEIVED_BUSY; 146 } 147 148 @Override 149 public int describeContents() { 150 return 0; 151 } 152 153 @Override 154 public void writeToParcel(@NonNull Parcel dest, int flags) { 155 recipientId.writeToParcel(dest, flags); 156 dest.writeInt(callState.ordinal()); 157 dest.writeLong(callId.longValue()); 158 dest.writeLong(callStartTimestamp); 159 } 160 161 public static final Creator<RemotePeer> CREATOR = new Creator<RemotePeer>() { 162 @Override 163 public RemotePeer createFromParcel(@NonNull Parcel in) { 164 return new RemotePeer(in); 165 } 166 167 @Override 168 public RemotePeer[] newArray(int size) { 169 return new RemotePeer[size]; 170 } 171 }; 172}