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

The following examples show how to use org.telegram.messenger.FileLog#d() . 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 Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public CallConnection getConnectionAndStartCall(){
	if(systemCallConnection==null){
		if(BuildVars.LOGS_ENABLED)
			FileLog.d("creating call connection");
		systemCallConnection=new CallConnection();
		systemCallConnection.setInitializing();
		if(isOutgoing){
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		systemCallConnection.setAddress(Uri.fromParts("tel", "+99084"+user.id, null), TelecomManager.PRESENTATION_ALLOWED);
		systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED);
	}
	return systemCallConnection;
}
 
Example 2
Source File: TelegramConnectionService.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request){
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("onCreateOutgoingConnection "/*+request*/);
	Bundle extras=request.getExtras();
	if(extras.getInt("call_type")==1){ // private
		VoIPService svc=VoIPService.getSharedInstance();
		if(svc==null)
			return null;
		return svc.getConnectionAndStartCall();
	}else if(extras.getInt("call_type")==2){ // group
		/*VoIPGroupService svc=VoIPGroupService.getSharedInstance();
		if(svc==null)
			return null;
		if(!svc.isOutgoing())
			return null;
		return svc.getConnectionAndStartCall();*/
	}
	return null;
}
 
Example 3
Source File: WebPlayerView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(String[] result) {
    if (result[0] != null) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("start play youtube video " + result[1] + " " + result[0]);
        }
        initied = true;
        playVideoUrl = result[0];
        playVideoType = result[1];
        if (playVideoType.equals("hls")) {
            isStream = true;
        }
        if (isAutoplay) {
            preparePlayer();
        }
        showProgress(false, true);
        controlsView.show(true, true);
    } else if (!isCancelled()) {
        onInitFailed();
    }
}
 
Example 4
Source File: ForegroundDetector.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (--refs == 0) {
        enterBackgroundTime = SystemClock.elapsedRealtime();
        wasInBackground = true;
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("switch to background");
        }
        for (Listener listener : listeners) {
            try {
                listener.onBecameBackground();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }
}
 
Example 5
Source File: VoIPBaseService.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onSensorChanged(SensorEvent event) {
	if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) {
		AudioManager am=(AudioManager) getSystemService(AUDIO_SERVICE);
		if (isHeadsetPlugged || am.isSpeakerphoneOn() || (isBluetoothHeadsetConnected() && am.isBluetoothScoOn())) {
			return;
		}
		boolean newIsNear = event.values[0] < Math.min(event.sensor.getMaximumRange(), 3);
		if (newIsNear != isProximityNear) {
			if (BuildVars.LOGS_ENABLED) {
				FileLog.d("proximity " + newIsNear);
			}
			isProximityNear = newIsNear;
			try{
				if(isProximityNear){
					proximityWakelock.acquire();
				}else{
					proximityWakelock.release(1); // this is non-public API before L
				}
			}catch(Exception x){
				FileLog.e(x);
			}
		}
	}
}
 
Example 6
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public CallConnection getConnectionAndStartCall(){
	if(systemCallConnection==null){
		if(BuildVars.LOGS_ENABLED)
			FileLog.d("creating call connection");
		systemCallConnection=new CallConnection();
		systemCallConnection.setInitializing();
		if(isOutgoing){
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED);
	}
	return systemCallConnection;
}
 
Example 7
Source File: ForegroundDetector.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onActivityStarted(Activity activity) {
    if (++refs == 1) {
        if (SystemClock.elapsedRealtime() - enterBackgroundTime < 200) {
            wasInBackground = false;
        }
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("switch to foreground");
        }
        for (Listener listener : listeners) {
            try {
                listener.onBecameForeground();
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }
}
 
Example 8
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static void onUnparsedMessageReceived(long address, final int currentAccount)
{
    try
    {
        NativeByteBuffer buff = NativeByteBuffer.wrap(address);
        buff.reused = true;
        final TLObject message = TLClassStore.Instance().TLdeserialize(buff, buff.readInt32(true), true);
        if (message instanceof TLRPC.Updates)
        {
            if (BuildVars.LOGS_ENABLED)
            {
                FileLog.d("java received " + message);
            }
            KeepAliveJob.finishJob();
            Utilities.stageQueue.postRunnable(() -> MessagesController.getInstance(currentAccount).processUpdates((TLRPC.Updates) message, false));
        }
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example 9
Source File: ChatListItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
protected boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder item) {
    if (BuildVars.LOGS_ENABLED) {
        FileLog.d("end change if necessary");
    }
    Animator a = animators.remove(item);
    if (a != null) {
        a.cancel();
    }

    boolean oldItem = false;
    if (changeInfo.newHolder == item) {
        changeInfo.newHolder = null;
    } else if (changeInfo.oldHolder == item) {
        changeInfo.oldHolder = null;
        oldItem = true;
    } else {
        return false;
    }
    item.itemView.setAlpha(1);
    if (item.itemView instanceof ChatMessageCell) {
        ((ChatMessageCell) item.itemView).setAnimationOffsetX(0);
        ((ChatMessageCell) item.itemView).getTransitionParams().resetAnimation();
    } else {
        item.itemView.setTranslationX(0);
    }
    item.itemView.setTranslationY(0);
    dispatchChangeFinished(item, oldItem);

    return true;
}
 
Example 10
Source File: VoIPService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected void callFailed(int errorCode) {
	if (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 = call.access_hash;
		req.peer.id = call.id;
		req.duration = controller != null && controllerStarted ? (int) (controller.getCallDuration() / 1000) : 0;
		req.connection_id = controller != null && controllerStarted ? controller.getPreferredRelayID() : 0;
		req.reason = new TLRPC.TL_phoneCallDiscardReasonDisconnect();
		ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
			@Override
			public void run(TLObject response, TLRPC.TL_error error) {
				if (error != null) {
                       if (BuildVars.LOGS_ENABLED) {
                           FileLog.e("error on phone.discardCall: " + error);
                       }
				} else {
                       if (BuildVars.LOGS_ENABLED) {
                           FileLog.d("phone.discardCall " + response);
                       }
				}
			}
		});
	}
	super.callFailed(errorCode);
}
 
Example 11
Source File: VoIPBaseService.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
protected void updateBluetoothHeadsetState(boolean connected){
	if(connected==isBtHeadsetConnected)
		return;
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("updateBluetoothHeadsetState: "+connected);
	isBtHeadsetConnected=connected;
	final AudioManager am=(AudioManager)getSystemService(AUDIO_SERVICE);
	if(connected && !isRinging() && currentState!=0){
		if(bluetoothScoActive){
			if(BuildVars.LOGS_ENABLED)
				FileLog.d("SCO already active, setting audio routing");
			am.setSpeakerphoneOn(false);
			am.setBluetoothScoOn(true);
		}else{
			if(BuildVars.LOGS_ENABLED)
				FileLog.d("startBluetoothSco");
			needSwitchToBluetoothAfterScoActivates=true;
			// some devices ignore startBluetoothSco when called immediately after the headset is connected, so delay it
			AndroidUtilities.runOnUIThread(new Runnable(){
				@Override
				public void run(){
					try {
						am.startBluetoothSco();
					} catch (Throwable ignore) {

					}
				}
			}, 500);
		}
	}else{
		bluetoothScoActive=false;
	}
	for (StateListener l : stateListeners)
		l.onAudioSettingsChanged();
}
 
Example 12
Source File: VoIPBaseService.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onDisconnect(){
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("ConnectionService onDisconnect");
	setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
	destroy();
	systemCallConnection=null;
	hangUp();
}
 
Example 13
Source File: ChatListItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void resetAnimation(RecyclerView.ViewHolder holder) {
    if (BuildVars.LOGS_ENABLED) {
        FileLog.d("reset animation");
    }
    reset = true;
    super.resetAnimation(holder);
    reset = false;
}
 
Example 14
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onDisconnect(){
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("ConnectionService onDisconnect");
	setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
	destroy();
	systemCallConnection=null;
	hangUp();
}
 
Example 15
Source File: ChatListItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean animateRemove(RecyclerView.ViewHolder holder, ItemHolderInfo info) {
    if (BuildVars.LOGS_ENABLED) {
        FileLog.d("animate remove");
    }
    boolean rez = super.animateRemove(holder, info);
    if (rez) {
        if (info != null) {
            int fromY = info.top;
            int toY = holder.itemView.getTop();

            int fromX = info.left;
            int toX = holder.itemView.getLeft();

            int deltaX = toX - fromX;
            int deltaY = toY - fromY;

            if (deltaY != 0) {
                holder.itemView.setTranslationY(-deltaY);
            }

            if (holder.itemView instanceof ChatMessageCell) {
                ChatMessageCell chatMessageCell = (ChatMessageCell) holder.itemView;
                if (deltaX != 0) {
                    chatMessageCell.setAnimationOffsetX(-deltaX);
                }
                if (info instanceof ItemHolderInfoExtended) {
                    ItemHolderInfoExtended infoExtended = ((ItemHolderInfoExtended) info);
                    chatMessageCell.setImageCoords(infoExtended.imageX, infoExtended.imageY, infoExtended.imageWidth, infoExtended.imageHeight);
                }
            } else {
                if (deltaX != 0) {
                    holder.itemView.setTranslationX(-deltaX);
                }
            }
        }
    }
    return rez;
}
 
Example 16
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected void dispatchStateChanged(int state) {
	if (BuildVars.LOGS_ENABLED) {
		FileLog.d("== Call " + getCallID() + " state changed to " + state + " ==");
	}
	currentState = state;
	if(USE_CONNECTION_SERVICE && state==STATE_ESTABLISHED /*&& !wasEstablished*/ && systemCallConnection!=null){
		systemCallConnection.setActive();
	}
	for (int a = 0; a < stateListeners.size(); a++) {
		StateListener l = stateListeners.get(a);
		l.onStateChanged(state);
	}
}
 
Example 17
Source File: VoIPBaseService.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onDisconnect(){
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("ConnectionService onDisconnect");
	setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
	destroy();
	systemCallConnection=null;
	hangUp();
}
 
Example 18
Source File: VoIPService.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void dumpCallObject() {
    try {
        if (BuildVars.LOGS_ENABLED) {
            Field[] flds = TLRPC.PhoneCall.class.getFields();
            for (Field f : flds) {
                FileLog.d(f.getName() + " = " + f.get(call));
            }
        }
    } catch (Exception x) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e(x);
        }
    }
}
 
Example 19
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void onSilence(){
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("onSlience");
	stopRinging();
}
 
Example 20
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCallEvent(String event, Bundle extras){
	super.onCallEvent(event, extras);
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("ConnectionService onCallEvent "+event);
}