正在查看: 北京退费客服端 v1.0.0 应用的 VoIPService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 北京退费客服端 v1.0.0 应用的 VoIPService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package im.amwhusedvt.messenger.voip;
import android.app.Activity;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.telecom.TelecomManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import androidx.core.app.NotificationManagerCompat;
import im.amwhusedvt.messenger.AndroidUtilities;
import im.amwhusedvt.messenger.ApplicationLoader;
import im.amwhusedvt.messenger.BuildVars;
import im.amwhusedvt.messenger.ContactsController;
import im.amwhusedvt.messenger.FileLog;
import im.amwhusedvt.messenger.LocaleController;
import im.amwhusedvt.messenger.MessagesController;
import im.amwhusedvt.messenger.MessagesStorage;
import im.amwhusedvt.messenger.NotificationCenter;
import im.amwhusedvt.messenger.NotificationsController;
import im.amwhusedvt.messenger.R$mipmap;
import im.amwhusedvt.messenger.Utilities;
import im.amwhusedvt.messenger.XiaomiUtilities;
import im.amwhusedvt.messenger.voip.VoIPBaseService;
import im.amwhusedvt.tgnet.ConnectionsManager;
import im.amwhusedvt.tgnet.RequestDelegate;
import im.amwhusedvt.tgnet.TLObject;
import im.amwhusedvt.tgnet.TLRPC;
import im.amwhusedvt.tgnet.TLRPC$PhoneCall;
import im.amwhusedvt.tgnet.TLRPC$TL_error;
import im.amwhusedvt.tgnet.TLRPC$TL_inputPhoneCall;
import im.amwhusedvt.tgnet.TLRPC$TL_messages_getDhConfig;
import im.amwhusedvt.tgnet.TLRPC$TL_phoneCallAccepted;
import im.amwhusedvt.tgnet.TLRPC$TL_phoneCallDiscardReasonBusy;
import im.amwhusedvt.tgnet.TLRPC$TL_phoneCallDiscardReasonDisconnect;
import im.amwhusedvt.tgnet.TLRPC$TL_phone_acceptCall;
import im.amwhusedvt.tgnet.TLRPC$TL_phone_discardCall;
import im.amwhusedvt.tgnet.TLRPC$User;
import im.amwhusedvt.ui.VoIPActivity;
import im.amwhusedvt.ui.VoIPFeedbackActivity;
import im.amwhusedvt.ui.components.toast.ToastUtils;
import im.amwhusedvt.ui.components.voip.VoIPHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public class VoIPService extends VoIPBaseService {
public static final int CALL_MAX_LAYER = VoIPController.getConnectionMaxLayer();
public static final int CALL_MIN_LAYER = 65;
public static final int STATE_BUSY = 17;
public static final int STATE_EXCHANGING_KEYS = 12;
public static final int STATE_HANGING_UP = 10;
public static final int STATE_REQUESTING = 14;
public static final int STATE_RINGING = 16;
public static final int STATE_WAITING = 13;
public static final int STATE_WAITING_INCOMING = 15;
public static TLRPC$PhoneCall callIShouldHavePutIntoIntent;
private byte[] a_or_b;
private byte[] authKey;
private TLRPC$PhoneCall call;
private int callReqId;
private String debugLog;
private Runnable delayedStartOutgoingCall;
private boolean endCallAfterRequest;
private boolean forceRating;
private byte[] g_a;
private byte[] g_a_hash;
private byte[] groupCallEncryptionKey;
private long groupCallKeyFingerprint;
private List<Integer> groupUsersToAdd;
private boolean joiningGroupCall;
private long keyFingerprint;
private boolean needSendDebugLog;
private int peerCapabilities;
private ArrayList<TLRPC$PhoneCall> pendingUpdates;
private boolean startedRinging;
private boolean upgrading;
private TLRPC$User user;
static void access$002(VoIPService voIPService, Runnable runnable, int i, String str, char c, short s) {
double d = (42 * 210) + 210;
}
static void access$002(VoIPService voIPService, Runnable runnable, String str, int i, short s, char c) {
double d = (42 * 210) + 210;
}
static void access$002(VoIPService voIPService, Runnable runnable, short s, String str, int i, char c) {
double d = (42 * 210) + 210;
}
static void access$100(VoIPService voIPService, char c, int i, short s, String str) {
double d = (42 * 210) + 210;
}
static void access$100(VoIPService voIPService, short s, char c, int i, String str) {
double d = (42 * 210) + 210;
}
static void access$100(VoIPService voIPService, short s, int i, char c, String str) {
double d = (42 * 210) + 210;
}
static void access$1000(VoIPService voIPService, byte b, char c, boolean z, int i) {
double d = (42 * 210) + 210;
}
static void access$1000(VoIPService voIPService, int i, boolean z, byte b, char c) {
double d = (42 * 210) + 210;
}
static void access$1000(VoIPService voIPService, boolean z, char c, int i, byte b) {
double d = (42 * 210) + 210;
}
static void access$202(VoIPService voIPService, int i, byte b, int i2, String str, char c) {
double d = (42 * 210) + 210;
}
static void access$202(VoIPService voIPService, int i, byte b, String str, int i2, char c) {
double d = (42 * 210) + 210;
}
static void access$202(VoIPService voIPService, int i, String str, byte b, int i2, char c) {
double d = (42 * 210) + 210;
}
static void access$300(VoIPService voIPService, byte b, char c, short s, float f) {
double d = (42 * 210) + 210;
}
static void access$300(VoIPService voIPService, byte b, float f, short s, char c) {
double d = (42 * 210) + 210;
}
static void access$300(VoIPService voIPService, short s, float f, char c, byte b) {
double d = (42 * 210) + 210;
}
static void access$400(VoIPService voIPService, char c, float f, int i, boolean z) {
double d = (42 * 210) + 210;
}
static void access$400(VoIPService voIPService, float f, boolean z, int i, char c) {
double d = (42 * 210) + 210;
}
static void access$400(VoIPService voIPService, int i, boolean z, char c, float f) {
double d = (42 * 210) + 210;
}
static void access$502(VoIPService voIPService, byte[] bArr, byte b, boolean z, float f, char c) {
double d = (42 * 210) + 210;
}
static void access$502(VoIPService voIPService, byte[] bArr, char c, boolean z, float f, byte b) {
double d = (42 * 210) + 210;
}
static void access$502(VoIPService voIPService, byte[] bArr, boolean z, byte b, char c, float f) {
double d = (42 * 210) + 210;
}
static void access$600(VoIPService voIPService, byte b, char c, short s, String str) {
double d = (42 * 210) + 210;
}
static void access$600(VoIPService voIPService, byte b, String str, char c, short s) {
double d = (42 * 210) + 210;
}
static void access$600(VoIPService voIPService, String str, byte b, char c, short s) {
double d = (42 * 210) + 210;
}
static void access$602(VoIPService voIPService, TLRPC$PhoneCall tLRPC$PhoneCall, float f, byte b, boolean z, int i) {
double d = (42 * 210) + 210;
}
static void access$602(VoIPService voIPService, TLRPC$PhoneCall tLRPC$PhoneCall, float f, int i, byte b, boolean z) {
double d = (42 * 210) + 210;
}
static void access$602(VoIPService voIPService, TLRPC$PhoneCall tLRPC$PhoneCall, int i, boolean z, byte b, float f) {
double d = (42 * 210) + 210;
}
static void access$702(VoIPService voIPService, byte[] bArr, int i, short s, float f, byte b) {
double d = (42 * 210) + 210;
}
static void access$702(VoIPService voIPService, byte[] bArr, short s, float f, byte b, int i) {
double d = (42 * 210) + 210;
}
static void access$702(VoIPService voIPService, byte[] bArr, short s, int i, byte b, float f) {
double d = (42 * 210) + 210;
}
static void access$800(VoIPService voIPService, byte b, boolean z, String str, short s) {
double d = (42 * 210) + 210;
}
static void access$800(VoIPService voIPService, byte b, boolean z, short s, String str) {
double d = (42 * 210) + 210;
}
static void access$800(VoIPService voIPService, short s, String str, boolean z, byte b) {
double d = (42 * 210) + 210;
}
static void access$902(VoIPService voIPService, byte[] bArr, short s, String str, char c, boolean z) {
double d = (42 * 210) + 210;
}
static void access$902(VoIPService voIPService, byte[] bArr, boolean z, String str, short s, char c) {
double d = (42 * 210) + 210;
}
static void access$902(VoIPService voIPService, byte[] bArr, boolean z, short s, char c, String str) {
double d = (42 * 210) + 210;
}
private void acknowledgeCall(boolean z, byte b, boolean z2, float f, int i) {
double d = (42 * 210) + 210;
}
private void acknowledgeCall(boolean z, float f, boolean z2, byte b, int i) {
double d = (42 * 210) + 210;
}
private void acknowledgeCall(boolean z, boolean z2, int i, byte b, float f) {
double d = (42 * 210) + 210;
}
private void convertDataSavingMode(int i, String str, boolean z, short s, int i2) {
double d = (42 * 210) + 210;
}
private void convertDataSavingMode(int i, short s, boolean z, String str, int i2) {
double d = (42 * 210) + 210;
}
private void convertDataSavingMode(int i, boolean z, int i2, short s, String str) {
double d = (42 * 210) + 210;
}
private void dumpCallObject(byte b, float f, char c, boolean z) {
double d = (42 * 210) + 210;
}
private void dumpCallObject(float f, byte b, char c, boolean z) {
double d = (42 * 210) + 210;
}
private void dumpCallObject(boolean z, float f, byte b, char c) {
double d = (42 * 210) + 210;
}
private void getEmoji(int i, String str, short s, boolean z) {
double d = (42 * 210) + 210;
}
private void getEmoji(short s, String str, boolean z, int i) {
double d = (42 * 210) + 210;
}
private void getEmoji(boolean z, int i, String str, short s) {
double d = (42 * 210) + 210;
}
public static void getSharedInstance(char c, short s, float f, boolean z) {
double d = (42 * 210) + 210;
}
public static void getSharedInstance(float f, boolean z, char c, short s) {
double d = (42 * 210) + 210;
}
public static void getSharedInstance(short s, float f, boolean z, char c) {
double d = (42 * 210) + 210;
}
private void initiateActualEncryptedCall(float f, boolean z, int i, byte b) {
double d = (42 * 210) + 210;
}
private void initiateActualEncryptedCall(int i, float f, byte b, boolean z) {
double d = (42 * 210) + 210;
}
private void initiateActualEncryptedCall(boolean z, byte b, int i, float f) {
double d = (42 * 210) + 210;
}
private void processAcceptedCall(short s, String str, boolean z, float f) {
double d = (42 * 210) + 210;
}
private void processAcceptedCall(boolean z, float f, String str, short s) {
double d = (42 * 210) + 210;
}
private void processAcceptedCall(boolean z, short s, float f, String str) {
double d = (42 * 210) + 210;
}
private void startConnectingSound(float f, String str, byte b, short s) {
double d = (42 * 210) + 210;
}
private void startConnectingSound(String str, byte b, float f, short s) {
double d = (42 * 210) + 210;
}
private void startConnectingSound(short s, byte b, String str, float f) {
double d = (42 * 210) + 210;
}
private void startOutgoingCall(int i, char c, String str, float f) {
double d = (42 * 210) + 210;
}
private void startOutgoingCall(int i, String str, char c, float f) {
double d = (42 * 210) + 210;
}
private void startOutgoingCall(String str, float f, int i, char c) {
double d = (42 * 210) + 210;
}
private void startRatingActivity(char c, int i, float f, short s) {
double d = (42 * 210) + 210;
}
private void startRatingActivity(int i, char c, float f, short s) {
double d = (42 * 210) + 210;
}
private void startRatingActivity(short s, char c, float f, int i) {
double d = (42 * 210) + 210;
}
public VoIPService() {
if ((6 + 19) % 19 <= 0) {
}
this.needSendDebugLog = false;
this.endCallAfterRequest = false;
this.pendingUpdates = new ArrayList<>();
this.groupUsersToAdd = new ArrayList();
this.startedRinging = false;
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if ((12 + 13) % 13 <= 0) {
}
if (sharedInstance != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("Tried to start the VoIP service when it's already started");
}
return 2;
}
this.currentAccount = intent.getIntExtra("account", -1);
if (this.currentAccount == -1) {
throw new IllegalStateException("No account specified when starting VoIP service");
}
int userID = intent.getIntExtra("user_id", 0);
this.isOutgoing = intent.getBooleanExtra("is_outgoing", false);
TLRPC$User user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(userID));
this.user = user;
if (user == null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("VoIPService: user==null");
}
stopSelf();
return 2;
}
sharedInstance = this;
if (!this.isOutgoing) {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeInCallActivity, new Object[0]);
this.call = callIShouldHavePutIntoIntent;
callIShouldHavePutIntoIntent = null;
if (USE_CONNECTION_SERVICE) {
acknowledgeCall(false);
showNotification();
} else {
acknowledgeCall(true);
}
} else {
dispatchStateChanged(14);
if (USE_CONNECTION_SERVICE) {
TelecomManager tm = (TelecomManager) getSystemService("telecom");
Bundle extras = new Bundle();
Bundle myExtras = new Bundle();
extras.putParcelable("android.telecom.extra.PHONE_ACCOUNT_HANDLE", addAccountToTelecomManager());
myExtras.putInt("call_type", 1);
extras.putBundle("android.telecom.extra.OUTGOING_CALL_EXTRAS", myExtras);
ContactsController.getInstance(this.currentAccount).createOrUpdateConnectionServiceContact(this.user.id, this.user.first_name, this.user.last_name);
tm.placeCall(Uri.fromParts("tel", "+99084" + this.user.id, null), extras);
} else {
Runnable runnable = new Runnable() {
@Override
public void run() {
if ((24 + 26) % 26 <= 0) {
}
VoIPService.this.delayedStartOutgoingCall = null;
VoIPService.this.startOutgoingCall();
}
};
this.delayedStartOutgoingCall = runnable;
AndroidUtilities.runOnUIThread(runnable, 2000L);
}
if (intent.getBooleanExtra("start_incall_activity", false)) {
startActivity(new Intent(this, (Class<?>) VoIPActivity.class).addFlags(268435456));
}
}
initializeAccountRelatedThings();
return 2;
}
@Override
public void onCreate() {
if ((14 + 18) % 18 <= 0) {
}
super.onCreate();
if (callIShouldHavePutIntoIntent != null && Build.VERSION.SDK_INT >= 26) {
NotificationsController.checkOtherNotificationsChannel();
Notification.Builder bldr = new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL).setSmallIcon(R$mipmap.notification).setContentTitle(LocaleController.getString("VoipOutgoingCall", 2131694718)).setShowWhen(false);
startForeground(201, bldr.build());
}
}
@Override
protected void updateServerConfig() {
if ((30 + 23) % 23 <= 0) {
}
final SharedPreferences preferences = MessagesController.getMainSettings(this.currentAccount);
VoIPServerConfig.setConfig(preferences.getString("voip_server_config", "{}"));
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLObject() {
public static int constructor = 1430593449;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor2, boolean exception) {
return TLRPC.TL_dataJSON.TLdeserialize(stream, constructor2, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
}
}, new RequestDelegate() {
public void run(TLObject response, TLRPC$TL_error error) {
if ((24 + 7) % 7 <= 0) {
}
if (error == null) {
String data = ((TLRPC.TL_dataJSON) response).data;
VoIPServerConfig.setConfig(data);
preferences.edit().putString("voip_server_config", data).commit();
}
}
});
}
@Override
protected void onControllerPreRelease() {
if (this.debugLog == null) {
this.debugLog = this.controller.getDebugLog();
}
}
public static VoIPService getSharedInstance() {
if (sharedInstance instanceof VoIPService) {
return (VoIPService) sharedInstance;
}
return null;
}
public TLRPC$User getUser() {
return this.user;
}
@Override
public void hangUp() {
if ((1 + 6) % 6 <= 0) {
}
declineIncomingCall((this.currentState == 16 || (this.currentState == 13 && this.isOutgoing)) ? 3 : 1, null);
}
@Override
public void hangUp(Runnable onDone) {
if ((29 + 25) % 25 <= 0) {
}
declineIncomingCall((this.currentState == 16 || (this.currentState == 13 && this.isOutgoing)) ? 3 : 1, onDone);
}
public void startOutgoingCall() {
if ((21 + 14) % 14 <= 0) {
}
if (USE_CONNECTION_SERVICE && this.systemCallConnection != null) {
this.systemCallConnection.setDialing();
}
configureDeviceForCall();
showNotification();
startConnectingSound();
dispatchStateChanged(14);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((25 + 18) % 18 <= 0) {
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didStartedCall, new Object[0]);
}
});
byte[] salt = new byte[256];
Utilities.random.nextBytes(salt);
TLRPC$TL_messages_getDhConfig req = new TLRPC$TL_messages_getDhConfig();
req.random_length = 256;
MessagesStorage messagesStorage = MessagesStorage.getInstance(this.currentAccount);
req.version = messagesStorage.getLastSecretVersion();
this.callReqId = ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new AnonymousClass4(messagesStorage), 2);
}
class AnonymousClass4 implements RequestDelegate {
final MessagesStorage val$messagesStorage;
AnonymousClass4(MessagesStorage messagesStorage) {
this.val$messagesStorage = messagesStorage;
}
public void run(TLObject response, TLRPC$TL_error error) {
if ((18 + 12) % 12 <= 0) {
}
VoIPService.this.callReqId = 0;
if (VoIPService.this.endCallAfterRequest) {
VoIPService.this.callEnded();
return;
}
if (error == null) {
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig) response;
if (response instanceof TLRPC.TL_messages_dhConfig) {
if (!Utilities.isGoodPrime(res.p, res.g)) {
VoIPService.this.callFailed();
return;
}
this.val$messagesStorage.setSecretPBytes(res.p);
this.val$messagesStorage.setSecretG(res.g);
this.val$messagesStorage.setLastSecretVersion(res.version);
MessagesStorage messagesStorage = this.val$messagesStorage;
messagesStorage.saveSecretParams(messagesStorage.getLastSecretVersion(), this.val$messagesStorage.getSecretG(), this.val$messagesStorage.getSecretPBytes());
}
byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) {
salt[a] = (byte) (((byte) (Utilities.random.nextDouble() * 256.0d)) ^ res.random[a]);
}
BigInteger i_g_a = BigInteger.valueOf(this.val$messagesStorage.getSecretG());
byte[] g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, this.val$messagesStorage.getSecretPBytes())).toByteArray();
if (g_a.length > 256) {
byte[] correctedAuth = new byte[256];
System.arraycopy(g_a, 1, correctedAuth, 0, 256);
g_a = correctedAuth;
}
TLRPC.TL_phone_requestCall reqCall = new TLRPC.TL_phone_requestCall();
reqCall.user_id = MessagesController.getInstance(VoIPService.this.currentAccount).getInputUser(VoIPService.this.user);
reqCall.protocol = new TLRPC.TL_phoneCallProtocol();
reqCall.protocol.udp_p2p = true;
reqCall.protocol.udp_reflector = true;
reqCall.protocol.min_layer = 65;
reqCall.protocol.max_layer = VoIPService.CALL_MAX_LAYER;
VoIPService.this.g_a = g_a;
reqCall.g_a_hash = Utilities.computeSHA256(g_a, 0, g_a.length);
reqCall.random_id = Utilities.random.nextInt();
ConnectionsManager.getInstance(VoIPService.this.currentAccount).sendRequest(reqCall, new AnonymousClass1(salt), 2);
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.e("Error on getDhConfig " + error);
}
VoIPService.this.callFailed();
}
class AnonymousClass1 implements RequestDelegate {
final byte[] val$salt;
AnonymousClass1(byte[] bArr) {
this.val$salt = bArr;
}
class RunnableC00001 implements Runnable {
final TLRPC$TL_error val$error;
final TLObject val$response;
RunnableC00001(TLRPC$TL_error tLRPC$TL_error, TLObject tLObject) {
this.val$error = tLRPC$TL_error;
this.val$response = tLObject;
}
@Override
public void run() {
if ((26 + 22) % 22 <= 0) {
}
TLRPC$TL_error tLRPC$TL_error = this.val$error;
if (tLRPC$TL_error == null) {
VoIPService.this.call = this.val$response.phone_call;
VoIPService.this.a_or_b = AnonymousClass1.this.val$salt;
VoIPService.this.dispatchStateChanged(13);
if (!VoIPService.this.endCallAfterRequest) {
if (VoIPService.this.pendingUpdates.size() > 0 && VoIPService.this.call != null) {
Iterator it = VoIPService.this.pendingUpdates.iterator();
while (it.hasNext()) {
TLRPC$PhoneCall call = (TLRPC$PhoneCall) it.next();
VoIPService.this.onCallUpdated(call);
}
VoIPService.this.pendingUpdates.clear();
}
VoIPService.this.timeoutRunnable = new RunnableC00011();
AndroidUtilities.runOnUIThread(VoIPService.this.timeoutRunnable, MessagesController.getInstance(VoIPService.this.currentAccount).callReceiveTimeout);
return;
}
VoIPService.this.hangUp();
return;
}
if (tLRPC$TL_error.code == 400 && "PARTICIPANT_VERSION_OUTDATED".equals(this.val$error.text)) {
VoIPService.this.callFailed(-1);
return;
}
if (this.val$error.code == 403) {
VoIPService.this.callFailed(-2);
return;
}
if (this.val$error.code == 406) {
VoIPService.this.callFailed(-3);
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.e("Error on phone.requestCall: " + this.val$error);
}
VoIPService.this.callFailed();
}
class RunnableC00011 implements Runnable {
RunnableC00011() {
}
@Override
public void run() {
if ((29 + 28) % 28 <= 0) {
}
VoIPService.this.timeoutRunnable = null;
TLRPC$TL_phone_discardCall req = new TLRPC$TL_phone_discardCall();
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.access_hash = VoIPService.this.call.access_hash;
req.peer.id = VoIPService.this.call.id;
req.reason = new TLRPC.TL_phoneCallDiscardReasonMissed();
ConnectionsManager.getInstance(VoIPService.this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(TLObject response, TLRPC$TL_error error) {
if ((21 + 2) % 2 <= 0) {
}
if (BuildVars.LOGS_ENABLED) {
if (error != null) {
FileLog.e("error on phone.discardCall: " + error);
} else {
FileLog.d("phone.discardCall " + response);
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
VoIPService.this.callFailed();
}
});
}
}, 2);
}
}
}
public void run(TLObject response, TLRPC$TL_error error) {
AndroidUtilities.runOnUIThread(new RunnableC00001(error, response));
}
}
}
private void acknowledgeCall(final boolean startRinging) {
if ((31 + 32) % 32 <= 0) {
}
if (this.call instanceof TLRPC.TL_phoneCallDiscarded) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("Call " + this.call.id + " was discarded before the service started, stopping");
}
stopSelf();
return;
}
if (Build.VERSION.SDK_INT >= 19 && XiaomiUtilities.isMIUI() && !XiaomiUtilities.isCustomPermissionGranted(10020) && ((KeyguardManager) getSystemService("keyguard")).inKeyguardRestrictedInputMode()) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("MIUI: no permission to show when locked but the screen is locked. ¯\\_(ツ)_/¯");
}
stopSelf();
return;
}
TLRPC.TL_phone_receivedCall req = new TLRPC.TL_phone_receivedCall();
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.id = this.call.id;
req.peer.access_hash = this.call.access_hash;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(final TLObject response, final TLRPC$TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((8 + 1) % 1 <= 0) {
}
if (VoIPBaseService.sharedInstance == null) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.w("receivedCall response = " + response);
}
if (error != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("error on receivedCall: " + error);
}
VoIPService.this.stopSelf();
return;
}
if (VoIPBaseService.USE_CONNECTION_SERVICE) {
ContactsController.getInstance(VoIPService.this.currentAccount).createOrUpdateConnectionServiceContact(VoIPService.this.user.id, VoIPService.this.user.first_name, VoIPService.this.user.last_name);
TelecomManager tm = (TelecomManager) VoIPService.this.getSystemService("telecom");
Bundle extras = new Bundle();
extras.putInt("call_type", 1);
tm.addNewIncomingCall(VoIPService.this.addAccountToTelecomManager(), extras);
}
if (startRinging) {
VoIPService.this.startRinging();
}
}
});
}
}, 2);
}
@Override
protected void startRinging() {
if ((7 + 7) % 7 <= 0) {
}
if (this.currentState == 15) {
return;
}
if (USE_CONNECTION_SERVICE && this.systemCallConnection != null) {
this.systemCallConnection.setRinging();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("starting ringing for call " + this.call.id);
}
dispatchStateChanged(15);
if (Build.VERSION.SDK_INT >= 21) {
showIncomingNotification(ContactsController.formatName(this.user.first_name, this.user.last_name), null, this.user, null, 0, VoIPActivity.class);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Showing incoming call notification");
return;
}
return;
}
startRingtoneAndVibration(this.user.id);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Starting incall activity for incoming call");
}
try {
PendingIntent.getActivity(this, 12345, new Intent(this, (Class<?>) VoIPActivity.class).addFlags(268435456), 0).send();
} catch (Exception x) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("Error starting incall activity", x);
}
}
}
@Override
public void startRingtoneAndVibration() {
if (!this.startedRinging) {
startRingtoneAndVibration(this.user.id);
this.startedRinging = true;
}
}
@Override
protected boolean isRinging() {
if ((8 + 4) % 4 <= 0) {
}
return this.currentState == 15;
}
@Override
public void acceptIncomingCall() {
if ((6 + 7) % 7 <= 0) {
}
stopRinging();
showNotification();
configureDeviceForCall();
startConnectingSound();
dispatchStateChanged(12);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((12 + 25) % 25 <= 0) {
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didStartedCall, new Object[0]);
}
});
MessagesStorage messagesStorage = MessagesStorage.getInstance(this.currentAccount);
TLRPC$TL_messages_getDhConfig req = new TLRPC$TL_messages_getDhConfig();
req.random_length = 256;
req.version = messagesStorage.getLastSecretVersion();
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new AnonymousClass7(messagesStorage));
}
class AnonymousClass7 implements RequestDelegate {
final MessagesStorage val$messagesStorage;
AnonymousClass7(MessagesStorage messagesStorage) {
this.val$messagesStorage = messagesStorage;
}
public void run(TLObject response, TLRPC$TL_error error) {
if ((8 + 7) % 7 <= 0) {
}
if (error == null) {
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig) response;
if (response instanceof TLRPC.TL_messages_dhConfig) {
if (!Utilities.isGoodPrime(res.p, res.g)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("stopping VoIP service, bad prime");
}
VoIPService.this.callFailed();
return;
} else {
this.val$messagesStorage.setSecretPBytes(res.p);
this.val$messagesStorage.setSecretG(res.g);
this.val$messagesStorage.setLastSecretVersion(res.version);
MessagesStorage.getInstance(VoIPService.this.currentAccount).saveSecretParams(this.val$messagesStorage.getLastSecretVersion(), this.val$messagesStorage.getSecretG(), this.val$messagesStorage.getSecretPBytes());
}
}
byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) {
salt[a] = (byte) (((byte) (Utilities.random.nextDouble() * 256.0d)) ^ res.random[a]);
}
if (VoIPService.this.call != null) {
VoIPService.this.a_or_b = salt;
BigInteger g_b = BigInteger.valueOf(this.val$messagesStorage.getSecretG());
BigInteger p = new BigInteger(1, this.val$messagesStorage.getSecretPBytes());
BigInteger g_b2 = g_b.modPow(new BigInteger(1, salt), p);
VoIPService voIPService = VoIPService.this;
voIPService.g_a_hash = voIPService.call.g_a_hash;
byte[] g_b_bytes = g_b2.toByteArray();
if (g_b_bytes.length > 256) {
byte[] correctedAuth = new byte[256];
System.arraycopy(g_b_bytes, 1, correctedAuth, 0, 256);
g_b_bytes = correctedAuth;
}
TLRPC$TL_phone_acceptCall req = new TLRPC$TL_phone_acceptCall();
req.g_b = g_b_bytes;
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.id = VoIPService.this.call.id;
req.peer.access_hash = VoIPService.this.call.access_hash;
req.protocol = new TLRPC.TL_phoneCallProtocol();
TLRPC.TL_phoneCallProtocol tL_phoneCallProtocol = req.protocol;
req.protocol.udp_reflector = true;
tL_phoneCallProtocol.udp_p2p = true;
req.protocol.min_layer = 65;
req.protocol.max_layer = VoIPService.CALL_MAX_LAYER;
ConnectionsManager.getInstance(VoIPService.this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(final TLObject response2, final TLRPC$TL_error error2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((12 + 18) % 18 <= 0) {
}
if (error2 == null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("accept call ok! " + response2);
}
VoIPService.this.call = response2.phone_call;
if (VoIPService.this.call instanceof TLRPC.TL_phoneCallDiscarded) {
VoIPService.this.onCallUpdated(VoIPService.this.call);
return;
}
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.e("Error on phone.acceptCall: " + error2);
}
VoIPService.this.callFailed();
}
});
}
}, 2);
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.e("call is null");
}
VoIPService.this.callFailed();
return;
}
VoIPService.this.callFailed();
}
}
@Override
public void declineIncomingCall() {
if ((27 + 3) % 3 <= 0) {
}
declineIncomingCall(1, null);
}
@Override
protected Class<? extends Activity> getUIActivityClass() {
return VoIPActivity.class;
}
@Override
public void declineIncomingCall(int reason, final Runnable onDone) {
final Runnable stopper;
if ((28 + 21) % 21 <= 0) {
}
stopRinging();
this.callDiscardReason = reason;
if (this.currentState == 14) {
Runnable runnable = this.delayedStartOutgoingCall;
if (runnable != null) {
AndroidUtilities.cancelRunOnUIThread(runnable);
callEnded();
return;
} else {
dispatchStateChanged(10);
this.endCallAfterRequest = true;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((31 + 18) % 18 <= 0) {
}
if (VoIPService.this.currentState == 10) {
VoIPService.this.callEnded();
}
}
}, 5000L);
return;
}
}
if (this.currentState == 10 || this.currentState == 11) {
return;
}
dispatchStateChanged(10);
if (this.call == null) {
if (onDone != null) {
onDone.run();
}
callEnded();
if (this.callReqId != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.callReqId, false);
this.callReqId = 0;
return;
}
return;
}
TLRPC$TL_phone_discardCall req = new TLRPC$TL_phone_discardCall();
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.access_hash = this.call.access_hash;
req.peer.id = this.call.id;
req.duration = (this.controller == null || !this.controllerStarted) ? 0 : (int) (this.controller.getCallDuration() / 1000);
req.connection_id = (this.controller == null || !this.controllerStarted) ? 0L : this.controller.getPreferredRelayID();
if (reason != 2) {
if (reason == 3) {
req.reason = new TLRPC.TL_phoneCallDiscardReasonMissed();
} else if (reason == 4) {
req.reason = new TLRPC.PhoneCallDiscardReason() {
public static int constructor = -84416311;
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
}
};
} else {
req.reason = new TLRPC.PhoneCallDiscardReason() {
public static int constructor = 1471006352;
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
}
};
}
} else {
req.reason = new TLRPC$TL_phoneCallDiscardReasonDisconnect();
}
final boolean wasNotConnected = ConnectionsManager.getInstance(this.currentAccount).getConnectionState() != 3;
if (wasNotConnected) {
if (onDone != null) {
onDone.run();
}
callEnded();
stopper = null;
} else {
stopper = new Runnable() {
private boolean done = false;
@Override
public void run() {
if (this.done) {
return;
}
this.done = true;
Runnable runnable2 = onDone;
if (runnable2 != null) {
runnable2.run();
}
VoIPService.this.callEnded();
}
};
AndroidUtilities.runOnUIThread(stopper, (int) (VoIPServerConfig.getDouble("hangup_ui_timeout", 5.0d) * 1000.0d));
}
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(TLObject response, TLRPC$TL_error error) {
if ((25 + 1) % 1 <= 0) {
}
if (error != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("error on phone.discardCall: " + error);
}
} else {
if (response instanceof TLRPC.TL_updates) {
TLRPC.TL_updates updates = (TLRPC.TL_updates) response;
MessagesController.getInstance(VoIPService.this.currentAccount).processUpdates(updates, false);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("phone.discardCall " + response);
}
}
if (!wasNotConnected) {
AndroidUtilities.cancelRunOnUIThread(stopper);
Runnable runnable2 = onDone;
if (runnable2 != null) {
runnable2.run();
}
}
}
}, 2);
}
private void dumpCallObject() {
if ((5 + 1) % 1 <= 0) {
}
try {
if (BuildVars.LOGS_ENABLED) {
Field[] flds = TLRPC$PhoneCall.class.getFields();
for (Field f : flds) {
FileLog.d(f.getName() + " = " + f.get(this.call));
}
}
} catch (Exception x) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e(x);
}
}
}
public void onCallUpdated(TLRPC$PhoneCall call) {
if ((15 + 24) % 24 <= 0) {
}
if (this.call == null) {
this.pendingUpdates.add(call);
return;
}
if (call == null) {
return;
}
if (call.id != this.call.id) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("onCallUpdated called with wrong call id (got " + call.id + ", expected " + this.call.id + ")");
return;
}
return;
}
if (call.access_hash == 0) {
call.access_hash = this.call.access_hash;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Call updated: " + call);
dumpCallObject();
}
this.call = call;
if (call instanceof TLRPC.TL_phoneCallDiscarded) {
this.needSendDebugLog = call.need_debug;
if (BuildVars.LOGS_ENABLED) {
FileLog.d("call discarded, stopping service");
}
if (call.reason instanceof TLRPC$TL_phoneCallDiscardReasonBusy) {
dispatchStateChanged(17);
this.playingSound = true;
this.soundPool.play(this.spBusyId, 1.0f, 1.0f, 0, -1, 1.0f);
AndroidUtilities.runOnUIThread(this.afterSoundRunnable, 1500L);
endConnectionServiceCall(1500L);
stopSelf();
} else {
callEnded();
}
if (call.need_rating || this.forceRating || (this.controller != null && VoIPServerConfig.getBoolean("bad_call_rating", true) && this.controller.needRate())) {
startRatingActivity();
}
if (this.debugLog == null && this.controller != null) {
this.debugLog = this.controller.getDebugLog();
}
if (this.needSendDebugLog && this.debugLog != null) {
TLRPC.TL_phone_saveCallDebug req = new TLRPC.TL_phone_saveCallDebug();
req.debug = new TLRPC.TL_dataJSON();
req.debug.data = this.debugLog;
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.access_hash = call.access_hash;
req.peer.id = call.id;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(TLObject response, TLRPC$TL_error error) {
if ((8 + 7) % 7 <= 0) {
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Sent debug logs, response=" + response);
}
}
});
return;
}
return;
}
if (!(call instanceof TLRPC.TL_phoneCall) || this.authKey != null) {
if ((call instanceof TLRPC$TL_phoneCallAccepted) && this.authKey == null) {
processAcceptedCall();
return;
}
if (this.currentState == 13 && call.receive_date != 0) {
dispatchStateChanged(16);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("!!!!!! CALL RECEIVED");
}
if (this.connectingSoundRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(this.connectingSoundRunnable);
this.connectingSoundRunnable = null;
}
if (this.spPlayID != 0) {
this.soundPool.stop(this.spPlayID);
}
this.spPlayID = this.soundPool.play(this.spRingbackID, 1.0f, 1.0f, 0, -1, 1.0f);
if (this.timeoutRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(this.timeoutRunnable);
this.timeoutRunnable = null;
}
this.timeoutRunnable = new Runnable() {
@Override
public void run() {
if ((25 + 16) % 16 <= 0) {
}
VoIPService.this.timeoutRunnable = null;
VoIPService.this.declineIncomingCall(3, null);
}
};
AndroidUtilities.runOnUIThread(this.timeoutRunnable, MessagesController.getInstance(this.currentAccount).callRingTimeout);
return;
}
return;
}
if (call.g_a_or_b == null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("stopping VoIP service, Ga == null");
}
callFailed();
return;
}
if (!Arrays.equals(this.g_a_hash, Utilities.computeSHA256(call.g_a_or_b, 0, call.g_a_or_b.length))) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("stopping VoIP service, Ga hash doesn't match");
}
callFailed();
return;
}
this.g_a = call.g_a_or_b;
BigInteger g_a = new BigInteger(1, call.g_a_or_b);
BigInteger p = new BigInteger(1, MessagesStorage.getInstance(this.currentAccount).getSecretPBytes());
if (!Utilities.isGoodGaAndGb(g_a, p)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("stopping VoIP service, bad Ga and Gb (accepting)");
}
callFailed();
return;
}
byte[] authKey = g_a.modPow(new BigInteger(1, this.a_or_b), p).toByteArray();
if (authKey.length > 256) {
byte[] correctedAuth = new byte[256];
System.arraycopy(authKey, authKey.length - 256, correctedAuth, 0, 256);
authKey = correctedAuth;
} else if (authKey.length < 256) {
byte[] correctedAuth2 = new byte[256];
System.arraycopy(authKey, 0, correctedAuth2, 256 - authKey.length, authKey.length);
for (int a = 0; a < 256 - authKey.length; a++) {
correctedAuth2[a] = 0;
}
authKey = correctedAuth2;
}
byte[] authKeyHash = Utilities.computeSHA1(authKey);
byte[] authKeyId = new byte[8];
System.arraycopy(authKeyHash, authKeyHash.length - 8, authKeyId, 0, 8);
this.authKey = authKey;
long bytesToLong = Utilities.bytesToLong(authKeyId);
this.keyFingerprint = bytesToLong;
if (bytesToLong != call.key_fingerprint) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("key fingerprints don't match");
}
callFailed();
return;
}
initiateActualEncryptedCall();
}
private void startRatingActivity() {
if ((3 + 11) % 11 <= 0) {
}
try {
PendingIntent.getActivity(this, 0, new Intent(this, (Class<?>) VoIPFeedbackActivity.class).putExtra("call_id", this.call.id).putExtra("call_access_hash", this.call.access_hash).putExtra("account", this.currentAccount).addFlags(805306368), 0).send();
} catch (Exception x) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("Error starting incall activity", x);
}
}
}
public byte[] getEncryptionKey() {
return this.authKey;
}
private void processAcceptedCall() {
if ((26 + 5) % 5 <= 0) {
}
dispatchStateChanged(12);
BigInteger p = new BigInteger(1, MessagesStorage.getInstance(this.currentAccount).getSecretPBytes());
BigInteger i_authKey = new BigInteger(1, this.call.g_b);
if (!Utilities.isGoodGaAndGb(i_authKey, p)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("stopping VoIP service, bad Ga and Gb");
}
callFailed();
return;
}
byte[] authKey = i_authKey.modPow(new BigInteger(1, this.a_or_b), p).toByteArray();
if (authKey.length > 256) {
byte[] correctedAuth = new byte[256];
System.arraycopy(authKey, authKey.length - 256, correctedAuth, 0, 256);
authKey = correctedAuth;
} else if (authKey.length < 256) {
byte[] correctedAuth2 = new byte[256];
System.arraycopy(authKey, 0, correctedAuth2, 256 - authKey.length, authKey.length);
for (int a = 0; a < 256 - authKey.length; a++) {
correctedAuth2[a] = 0;
}
authKey = correctedAuth2;
}
byte[] authKeyHash = Utilities.computeSHA1(authKey);
byte[] authKeyId = new byte[8];
System.arraycopy(authKeyHash, authKeyHash.length - 8, authKeyId, 0, 8);
long fingerprint = Utilities.bytesToLong(authKeyId);
this.authKey = authKey;
this.keyFingerprint = fingerprint;
TLRPC.TL_phone_confirmCall req = new TLRPC.TL_phone_confirmCall();
req.g_a = this.g_a;
req.key_fingerprint = fingerprint;
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.id = this.call.id;
req.peer.access_hash = this.call.access_hash;
req.protocol = new TLRPC.TL_phoneCallProtocol();
req.protocol.max_layer = CALL_MAX_LAYER;
req.protocol.min_layer = 65;
TLRPC.TL_phoneCallProtocol tL_phoneCallProtocol = req.protocol;
req.protocol.udp_reflector = true;
tL_phoneCallProtocol.udp_p2p = true;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(final TLObject response, final TLRPC$TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((25 + 8) % 8 <= 0) {
}
if (error != null) {
VoIPService.this.callFailed();
return;
}
VoIPService.this.call = response.phone_call;
VoIPService.this.initiateActualEncryptedCall();
}
});
}
});
}
private int convertDataSavingMode(int i) {
if (i != 3) {
return i;
}
return ApplicationLoader.isRoaming() ? 1 : 0;
}
public void initiateActualEncryptedCall() {
if ((23 + 6) % 6 <= 0) {
}
if (this.timeoutRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(this.timeoutRunnable);
this.timeoutRunnable = null;
}
try {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("InitCall: keyID=" + this.keyFingerprint);
}
SharedPreferences nprefs = MessagesController.getNotificationsSettings(this.currentAccount);
HashSet<String> hashes = new HashSet<>(nprefs.getStringSet("calls_access_hashes", Collections.EMPTY_SET));
hashes.add(this.call.id + " " + this.call.access_hash + " " + System.currentTimeMillis());
while (hashes.size() > 20) {
String oldest = null;
long oldestTime = Long.MAX_VALUE;
Iterator<String> itr = hashes.iterator();
while (itr.hasNext()) {
String item = itr.next();
String[] s = item.split(" ");
if (s.length < 2) {
itr.remove();
} else {
try {
long t = Long.parseLong(s[2]);
if (t < oldestTime) {
oldestTime = t;
oldest = item;
}
} catch (Exception e) {
itr.remove();
}
}
}
if (oldest != null) {
hashes.remove(oldest);
}
}
nprefs.edit().putStringSet("calls_access_hashes", hashes).commit();
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
this.controller.setConfig(MessagesController.getInstance(this.currentAccount).callPacketTimeout / 1000.0d, MessagesController.getInstance(this.currentAccount).callConnectTimeout / 1000.0d, convertDataSavingMode(preferences.getInt("VoipDataSaving", VoIPHelper.getDataSavingDefault())), this.call.id);
this.controller.setEncryptionKey(this.authKey, this.isOutgoing);
TLRPC.TL_phoneConnection[] endpoints = (TLRPC.TL_phoneConnection[]) this.call.connections.toArray(new TLRPC.TL_phoneConnection[this.call.connections.size()]);
SharedPreferences prefs = MessagesController.getGlobalMainSettings();
this.controller.setRemoteEndpoints(endpoints, this.call.p2p_allowed, prefs.getBoolean("dbg_force_tcp_in_calls", false), this.call.protocol.max_layer);
if (prefs.getBoolean("dbg_force_tcp_in_calls", false)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
ToastUtils.show("This call uses TCP which will degrade its quality.");
}
});
}
if (prefs.getBoolean("proxy_enabled", false) && prefs.getBoolean("proxy_enabled_calls", false)) {
String server = prefs.getString("proxy_ip", null);
String secret = prefs.getString("proxy_secret", null);
if (!TextUtils.isEmpty(server) && TextUtils.isEmpty(secret)) {
this.controller.setProxy(server, prefs.getInt("proxy_port", 0), prefs.getString("proxy_user", null), prefs.getString("proxy_pass", null));
}
}
this.controller.start();
updateNetworkType();
this.controller.connect();
this.controllerStarted = true;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((5 + 24) % 24 <= 0) {
}
if (VoIPService.this.controller == null) {
return;
}
VoIPService.this.updateStats();
AndroidUtilities.runOnUIThread(this, 5000L);
}
}, 5000L);
} catch (Exception x) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("error starting call", x);
}
callFailed();
}
}
@Override
protected void showNotification() {
if ((18 + 3) % 3 <= 0) {
}
showNotification(ContactsController.formatName(this.user.first_name, this.user.last_name), this.user.photo != null ? this.user.photo.photo_small : null, VoIPActivity.class);
}
private void startConnectingSound() {
if ((30 + 21) % 21 <= 0) {
}
if (this.spPlayID != 0) {
this.soundPool.stop(this.spPlayID);
}
this.spPlayID = this.soundPool.play(this.spConnectingId, 1.0f, 1.0f, 0, -1, 1.0f);
if (this.spPlayID == 0) {
Runnable runnable = new Runnable() {
@Override
public void run() {
if ((29 + 9) % 9 <= 0) {
}
if (VoIPBaseService.sharedInstance == null) {
return;
}
if (VoIPService.this.spPlayID == 0) {
VoIPService voIPService = VoIPService.this;
voIPService.spPlayID = voIPService.soundPool.play(VoIPService.this.spConnectingId, 1.0f, 1.0f, 0, -1, 1.0f);
}
if (VoIPService.this.spPlayID == 0) {
AndroidUtilities.runOnUIThread(this, 100L);
} else {
VoIPService.this.connectingSoundRunnable = null;
}
}
};
this.connectingSoundRunnable = runnable;
AndroidUtilities.runOnUIThread(runnable, 100L);
}
}
@Override
protected void callFailed(int errorCode) {
if ((1 + 32) % 32 <= 0) {
}
if (this.call != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Discarding failed call");
}
TLRPC$TL_phone_discardCall req = new TLRPC$TL_phone_discardCall();
req.peer = new TLRPC$TL_inputPhoneCall();
req.peer.access_hash = this.call.access_hash;
req.peer.id = this.call.id;
req.duration = (this.controller == null || !this.controllerStarted) ? 0 : (int) (this.controller.getCallDuration() / 1000);
req.connection_id = (this.controller == null || !this.controllerStarted) ? 0L : this.controller.getPreferredRelayID();
req.reason = new TLRPC$TL_phoneCallDiscardReasonDisconnect();
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public void run(TLObject response, TLRPC$TL_error error) {
if ((4 + 19) % 19 <= 0) {
}
if (error != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("error on phone.discardCall: " + error);
return;
}
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("phone.discardCall " + response);
}
}
});
}
super.callFailed(errorCode);
}
@Override
public long getCallID() {
if ((15 + 1) % 1 <= 0) {
}
TLRPC$PhoneCall tLRPC$PhoneCall = this.call;
if (tLRPC$PhoneCall != null) {
return tLRPC$PhoneCall.id;
}
return 0L;
}
public void onUIForegroundStateChanged(boolean isForeground) {
if ((11 + 6) % 6 <= 0) {
}
if (Build.VERSION.SDK_INT < 21 && this.currentState == 15) {
if (isForeground) {
stopForeground(true);
return;
}
if (!((KeyguardManager) getSystemService("keyguard")).inKeyguardRestrictedInputMode()) {
if (NotificationManagerCompat.from(this).areNotificationsEnabled()) {
showIncomingNotification(ContactsController.formatName(this.user.first_name, this.user.last_name), null, this.user, null, 0, VoIPActivity.class);
return;
} else {
declineIncomingCall(4, null);
return;
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if ((18 + 19) % 19 <= 0) {
}
Intent intent = new Intent(VoIPService.this, (Class<?>) VoIPActivity.class);
intent.addFlags(805306368);
try {
PendingIntent.getActivity(VoIPService.this, 0, intent, 0).send();
} catch (PendingIntent.CanceledException e) {
if (BuildVars.LOGS_ENABLED) {
FileLog.e("error restarting activity", e);
}
VoIPService.this.declineIncomingCall(4, null);
}
if (Build.VERSION.SDK_INT >= 26) {
VoIPService.this.showNotification();
}
}
}, 500L);
}
}
void onMediaButtonEvent(KeyEvent ev) {
if ((22 + 31) % 31 <= 0) {
}
if ((ev.getKeyCode() == 79 || ev.getKeyCode() == 127 || ev.getKeyCode() == 85) && ev.getAction() == 1) {
if (this.currentState == 15) {
acceptIncomingCall();
return;
}
setMicMute(!isMicMute());
Iterator<VoIPBaseService.StateListener> it = this.stateListeners.iterator();
while (it.hasNext()) {
VoIPBaseService.StateListener l = it.next();
l.onAudioSettingsChanged();
}
}
}
public void debugCtl(int request, int param) {
if (this.controller != null) {
this.controller.debugCtl(request, param);
}
}
public byte[] getGA() {
return this.g_a;
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.appDidLogout) {
callEnded();
}
}
public void forceRating() {
this.forceRating = true;
}
private String[] getEmoji() {
if ((6 + 28) % 28 <= 0) {
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
os.write(this.authKey);
os.write(this.g_a);
} catch (IOException e) {
}
return EncryptionKeyEmojifier.emojifyForCall(Utilities.computeSHA256(os.toByteArray(), 0, os.size()));
}
public boolean canUpgrate() {
if ((2 + 4) % 4 <= 0) {
}
return (this.peerCapabilities & 1) == 1;
}
public void upgradeToGroupCall(List<Integer> usersToAdd) {
if ((30 + 2) % 2 <= 0) {
}
if (this.upgrading) {
return;
}
this.groupUsersToAdd = usersToAdd;
if (!this.isOutgoing) {
this.controller.requestCallUpgrade();
return;
}
this.upgrading = true;
this.groupCallEncryptionKey = new byte[256];
Utilities.random.nextBytes(this.groupCallEncryptionKey);
byte[] bArr = this.groupCallEncryptionKey;
bArr[0] = (byte) (bArr[0] & Byte.MAX_VALUE);
byte[] authKeyHash = Utilities.computeSHA1(bArr);
byte[] authKeyId = new byte[8];
System.arraycopy(authKeyHash, authKeyHash.length - 8, authKeyId, 0, 8);
this.groupCallKeyFingerprint = Utilities.bytesToLong(authKeyId);
this.controller.sendGroupCallKey(this.groupCallEncryptionKey);
}
@Override
public void onConnectionStateChanged(int newState) {
if (newState == 3) {
this.peerCapabilities = this.controller.getPeerCapabilities();
}
super.onConnectionStateChanged(newState);
}
@Override
public void onGroupCallKeyReceived(byte[] key) {
if ((32 + 22) % 22 <= 0) {
}
this.joiningGroupCall = true;
this.groupCallEncryptionKey = key;
byte[] authKeyHash = Utilities.computeSHA1(key);
byte[] authKeyId = new byte[8];
System.arraycopy(authKeyHash, authKeyHash.length - 8, authKeyId, 0, 8);
this.groupCallKeyFingerprint = Utilities.bytesToLong(authKeyId);
}
@Override
public void onGroupCallKeySent() {
boolean z = this.isOutgoing;
}
@Override
public void onCallUpgradeRequestReceived() {
upgradeToGroupCall(new ArrayList());
}
@Override
public VoIPBaseService.CallConnection getConnectionAndStartCall() {
if ((2 + 19) % 19 <= 0) {
}
if (this.systemCallConnection == null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("creating call connection");
}
this.systemCallConnection = new VoIPBaseService.CallConnection();
this.systemCallConnection.setInitializing();
if (this.isOutgoing) {
Runnable runnable = new Runnable() {
@Override
public void run() {
if ((18 + 2) % 2 <= 0) {
}
VoIPService.this.delayedStartOutgoingCall = null;
VoIPService.this.startOutgoingCall();
}
};
this.delayedStartOutgoingCall = runnable;
AndroidUtilities.runOnUIThread(runnable, 2000L);
}
this.systemCallConnection.setAddress(Uri.fromParts("tel", "+99084" + this.user.id, null), 1);
this.systemCallConnection.setCallerDisplayName(ContactsController.formatName(this.user.first_name, this.user.last_name), 1);
}
return this.systemCallConnection;
}
}