Java Code Examples for org.telegram.messenger.FileLog#w()

The following examples show how to use org.telegram.messenger.FileLog#w() . 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: VoIPHelper.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static int getDataSavingDefault() {
	boolean low = DownloadController.getInstance(0).lowPreset.lessCallData,
			medium = DownloadController.getInstance(0).mediumPreset.lessCallData,
			high = DownloadController.getInstance(0).highPreset.lessCallData;
	if (!low && !medium && !high) {
		return TgVoip.DATA_SAVING_NEVER;
	} else if (low && !medium && !high) {
		return TgVoip.DATA_SAVING_ROAMING;
	} else if (low && medium && !high) {
		return TgVoip.DATA_SAVING_MOBILE;
	} else if (low && medium && high) {
		return TgVoip.DATA_SAVING_ALWAYS;
	}
	if (BuildVars.LOGS_ENABLED)
		FileLog.w("Invalid call data saving preset configuration: " + low + "/" + medium + "/" + high);
	return TgVoip.DATA_SAVING_NEVER;
}
 
Example 2
Source File: VoIPHelper.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static int getDataSavingDefault() {
	boolean low = DownloadController.getInstance(0).lowPreset.lessCallData,
			medium = DownloadController.getInstance(0).mediumPreset.lessCallData,
			high = DownloadController.getInstance(0).highPreset.lessCallData;
	if (!low && !medium && !high) {
		return TgVoip.DATA_SAVING_NEVER;
	} else if (low && !medium && !high) {
		return TgVoip.DATA_SAVING_ROAMING;
	} else if (low && medium && !high) {
		return TgVoip.DATA_SAVING_MOBILE;
	} else if (low && medium && high) {
		return TgVoip.DATA_SAVING_ALWAYS;
	}
	if (BuildVars.LOGS_ENABLED)
		FileLog.w("Invalid call data saving preset configuration: " + low + "/" + medium + "/" + high);
	return TgVoip.DATA_SAVING_NEVER;
}
 
Example 3
Source File: TelegramConnectionService.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onDestroy(){
	super.onDestroy();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService destroyed");
}
 
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);
}
 
Example 5
Source File: VoIPService.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@SuppressLint("MissingPermission")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	if(sharedInstance!=null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.e("Tried to start the VoIP service when it's already started");
           }
		return START_NOT_STICKY;
	}

	currentAccount=intent.getIntExtra("account", -1);
	if(currentAccount==-1)
		throw new IllegalStateException("No account specified when starting VoIP service");
	int userID=intent.getIntExtra("user_id", 0);
	isOutgoing = intent.getBooleanExtra("is_outgoing", false);
	user = MessagesController.getInstance(currentAccount).getUser(userID);

	if(user==null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("VoIPService: user==null");
           }
		stopSelf();
		return START_NOT_STICKY;
	}
	sharedInstance = this;

	if (isOutgoing) {
		dispatchStateChanged(STATE_REQUESTING);
		if(USE_CONNECTION_SERVICE){
			TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
			Bundle extras=new Bundle();
			Bundle myExtras=new Bundle();
			extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, addAccountToTelecomManager());
			myExtras.putInt("call_type", 1);
			extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, myExtras);
			ContactsController.getInstance(currentAccount).createOrUpdateConnectionServiceContact(user.id, user.first_name, user.last_name);
			tm.placeCall(Uri.fromParts("tel", "+99084"+user.id, null), extras);
		}else{
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		if (intent.getBooleanExtra("start_incall_activity", false)) {
			startActivity(new Intent(this, VoIPActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
		}
	} else {
		NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeInCallActivity);
		call = callIShouldHavePutIntoIntent;
		callIShouldHavePutIntoIntent = null;
		if(USE_CONNECTION_SERVICE){
			acknowledgeCall(false);
			showNotification();
		}else{
			acknowledgeCall(true);
		}
	}
	initializeAccountRelatedThings();

	return START_NOT_STICKY;
}
 
Example 6
Source File: TelegramConnectionService.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onDestroy(){
	super.onDestroy();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService destroyed");
}
 
Example 7
Source File: TelegramConnectionService.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService created");
}
 
Example 8
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 9
Source File: VoIPService.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@SuppressLint("MissingPermission")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	if(sharedInstance!=null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.e("Tried to start the VoIP service when it's already started");
           }
		return START_NOT_STICKY;
	}

	currentAccount=intent.getIntExtra("account", -1);
	if(currentAccount==-1)
		throw new IllegalStateException("No account specified when starting VoIP service");
	int userID=intent.getIntExtra("user_id", 0);
	isOutgoing = intent.getBooleanExtra("is_outgoing", false);
	user = MessagesController.getInstance(currentAccount).getUser(userID);

	if(user==null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("VoIPService: user==null");
           }
		stopSelf();
		return START_NOT_STICKY;
	}
	sharedInstance = this;

	if (isOutgoing) {
		dispatchStateChanged(STATE_REQUESTING);
		if(USE_CONNECTION_SERVICE){
			TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
			Bundle extras=new Bundle();
			Bundle myExtras=new Bundle();
			extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, addAccountToTelecomManager());
			myExtras.putInt("call_type", 1);
			extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, myExtras);
			ContactsController.getInstance(currentAccount).createOrUpdateConnectionServiceContact(user.id, user.first_name, user.last_name);
			tm.placeCall(Uri.fromParts("tel", "+99084"+user.id, null), extras);
		}else{
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		if (intent.getBooleanExtra("start_incall_activity", false)) {
			startActivity(new Intent(this, VoIPActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
		}
	} else {
		NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeInCallActivity);
		call = callIShouldHavePutIntoIntent;
		callIShouldHavePutIntoIntent = null;
		if(USE_CONNECTION_SERVICE){
			acknowledgeCall(false);
			showNotification();
		}else{
			acknowledgeCall(true);
		}
	}
	initializeAccountRelatedThings();

	return START_NOT_STICKY;
}
 
Example 10
Source File: TelegramConnectionService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService created");
}
 
Example 11
Source File: TelegramConnectionService.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService created");
}
 
Example 12
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 13
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@SuppressLint("MissingPermission")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	if(sharedInstance!=null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.e("Tried to start the VoIP service when it's already started");
           }
		return START_NOT_STICKY;
	}

	currentAccount=intent.getIntExtra("account", -1);
	if(currentAccount==-1)
		throw new IllegalStateException("No account specified when starting VoIP service");
	int userID=intent.getIntExtra("user_id", 0);
	isOutgoing = intent.getBooleanExtra("is_outgoing", false);
	user = MessagesController.getInstance(currentAccount).getUser(userID);

	if(user==null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("VoIPService: user==null");
           }
		stopSelf();
		return START_NOT_STICKY;
	}
	sharedInstance = this;

	if (isOutgoing) {
		dispatchStateChanged(STATE_REQUESTING);
		if(USE_CONNECTION_SERVICE){
			TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
			Bundle extras=new Bundle();
			Bundle myExtras=new Bundle();
			extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, addAccountToTelecomManager());
			myExtras.putInt("call_type", 1);
			extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, myExtras);
			tm.placeCall(Uri.fromParts("sip", UserConfig.getInstance(currentAccount).getClientUserId()+";user="+user.id, null), extras);
		}else{
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		if (intent.getBooleanExtra("start_incall_activity", false)) {
			startActivity(new Intent(this, VoIPActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
		}
	} else {
		NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeInCallActivity);
		call = callIShouldHavePutIntoIntent;
		callIShouldHavePutIntoIntent = null;
		if(USE_CONNECTION_SERVICE){
			acknowledgeCall(false);
			showNotification();
		}else{
			acknowledgeCall(true);
		}
	}
	initializeAccountRelatedThings();

	return START_NOT_STICKY;
}
 
Example 14
Source File: TelegramConnectionService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onDestroy(){
	super.onDestroy();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService destroyed");
}
 
Example 15
Source File: TelegramConnectionService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(){
	super.onCreate();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService created");
}
 
Example 16
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 17
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@SuppressLint("MissingPermission")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
	if(sharedInstance!=null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.e("Tried to start the VoIP service when it's already started");
           }
		return START_NOT_STICKY;
	}

	currentAccount=intent.getIntExtra("account", -1);
	if(currentAccount==-1)
		throw new IllegalStateException("No account specified when starting VoIP service");
	int userID=intent.getIntExtra("user_id", 0);
	isOutgoing = intent.getBooleanExtra("is_outgoing", false);
	user = MessagesController.getInstance(currentAccount).getUser(userID);

	if(user==null){
           if (BuildVars.LOGS_ENABLED) {
               FileLog.w("VoIPService: user==null");
           }
		stopSelf();
		return START_NOT_STICKY;
	}
	sharedInstance = this;

	if (isOutgoing) {
		dispatchStateChanged(STATE_REQUESTING);
		if(USE_CONNECTION_SERVICE){
			TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
			Bundle extras=new Bundle();
			Bundle myExtras=new Bundle();
			extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, addAccountToTelecomManager());
			myExtras.putInt("call_type", 1);
			extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, myExtras);
			tm.placeCall(Uri.fromParts("sip", UserConfig.getInstance(currentAccount).getClientUserId()+";user="+user.id, null), extras);
		}else{
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		if (intent.getBooleanExtra("start_incall_activity", false)) {
			startActivity(new Intent(this, VoIPActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
		}
	} else {
		NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeInCallActivity);
		call = callIShouldHavePutIntoIntent;
		callIShouldHavePutIntoIntent = null;
		if(USE_CONNECTION_SERVICE){
			acknowledgeCall(false);
			showNotification();
		}else{
			acknowledgeCall(true);
		}
	}
	initializeAccountRelatedThings();

	return START_NOT_STICKY;
}
 
Example 18
Source File: TelegramConnectionService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onDestroy(){
	super.onDestroy();
	if(BuildVars.LOGS_ENABLED)
		FileLog.w("ConnectionService destroyed");
}