Java Code Examples for org.telegram.tgnet.TLRPC#TL_phone_receivedCall

The following examples show how to use org.telegram.tgnet.TLRPC#TL_phone_receivedCall . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void acknowledgeCall(final boolean startRinging){
	if(call instanceof TLRPC.TL_phoneCallDiscarded){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("Call " + call.id + " was discarded before the service started, stopping");
           }
		stopSelf();
		return;
	}
	TLRPC.TL_phone_receivedCall req = new TLRPC.TL_phone_receivedCall();
	req.peer = new TLRPC.TL_inputPhoneCall();
	req.peer.id = call.id;
	req.peer.access_hash = call.access_hash;
	ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
		@Override
		public void run(final TLObject response, final TLRPC.TL_error error) {
			AndroidUtilities.runOnUIThread(new Runnable(){
				@Override
				public void run(){
					if(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);
                           }
						stopSelf();
					}else{
						if(USE_CONNECTION_SERVICE){
							TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
							Bundle extras=new Bundle();
							extras.putInt("call_type", 1);
							tm.addNewIncomingCall(addAccountToTelecomManager(), extras);
						}
						if(startRinging)
							startRinging();
					}
				}
			});
		}
	}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 2
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void acknowledgeCall(final boolean startRinging){
	if(call instanceof TLRPC.TL_phoneCallDiscarded){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("Call " + call.id + " was discarded before the service started, stopping");
           }
		stopSelf();
		return;
	}
	TLRPC.TL_phone_receivedCall req = new TLRPC.TL_phone_receivedCall();
	req.peer = new TLRPC.TL_inputPhoneCall();
	req.peer.id = call.id;
	req.peer.access_hash = call.access_hash;
	ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
		@Override
		public void run(final TLObject response, final TLRPC.TL_error error) {
			AndroidUtilities.runOnUIThread(new Runnable(){
				@Override
				public void run(){
					if(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);
                           }
						stopSelf();
					}else{
						if(USE_CONNECTION_SERVICE){
							TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
							Bundle extras=new Bundle();
							extras.putInt("call_type", 1);
							tm.addNewIncomingCall(addAccountToTelecomManager(), extras);
						}
						if(startRinging)
							startRinging();
					}
				}
			});
		}
	}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 3
Source File: VoIPService.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void acknowledgeCall(final boolean startRinging){
	if(call instanceof TLRPC.TL_phoneCallDiscarded){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("Call " + call.id + " was discarded before the service started, stopping");
           }
		stopSelf();
		return;
	}
	if(Build.VERSION.SDK_INT>=19 && XiaomiUtilities.isMIUI() && !XiaomiUtilities.isCustomPermissionGranted(XiaomiUtilities.OP_SHOW_WHEN_LOCKED)){
		if(((KeyguardManager)getSystemService(KEYGUARD_SERVICE)).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 = call.id;
	req.peer.access_hash = call.access_hash;
	ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
		@Override
		public void run(final TLObject response, final TLRPC.TL_error error) {
			AndroidUtilities.runOnUIThread(new Runnable(){
				@Override
				public void run(){
					if(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);
                           }
						stopSelf();
					}else{
						if(USE_CONNECTION_SERVICE){
							ContactsController.getInstance(currentAccount).createOrUpdateConnectionServiceContact(user.id, user.first_name, user.last_name);
							TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
							Bundle extras=new Bundle();
							extras.putInt("call_type", 1);
							tm.addNewIncomingCall(addAccountToTelecomManager(), extras);
						}
						if(startRinging)
							startRinging();
					}
				}
			});
		}
	}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 4
Source File: VoIPService.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void acknowledgeCall(final boolean startRinging){
	if(call instanceof TLRPC.TL_phoneCallDiscarded){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("Call " + call.id + " was discarded before the service started, stopping");
           }
		stopSelf();
		return;
	}
	if(Build.VERSION.SDK_INT>=19 && XiaomiUtilities.isMIUI() && !XiaomiUtilities.isCustomPermissionGranted(XiaomiUtilities.OP_SHOW_WHEN_LOCKED)){
		if(((KeyguardManager)getSystemService(KEYGUARD_SERVICE)).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 = call.id;
	req.peer.access_hash = call.access_hash;
	ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
		@Override
		public void run(final TLObject response, final TLRPC.TL_error error) {
			AndroidUtilities.runOnUIThread(new Runnable(){
				@Override
				public void run(){
					if(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);
                           }
						stopSelf();
					}else{
						if(USE_CONNECTION_SERVICE){
							ContactsController.getInstance(currentAccount).createOrUpdateConnectionServiceContact(user.id, user.first_name, user.last_name);
							TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
							Bundle extras=new Bundle();
							extras.putInt("call_type", 1);
							tm.addNewIncomingCall(addAccountToTelecomManager(), extras);
						}
						if(startRinging)
							startRinging();
					}
				}
			});
		}
	}, ConnectionsManager.RequestFlagFailOnServerErrors);
}