org.telegram.messenger.BuildVars Java Examples

The following examples show how to use org.telegram.messenger.BuildVars. 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 Project: Telegram   Author: DrKLO   File: SerializedData.java    License: GNU General Public License v2.0 6 votes vote down vote up
public int readInt32(boolean exception) {
    try {
        int i = 0;
        for (int j = 0; j < 4; j++) {
            i |= (in.read() << (j * 8));
            len++;
        }
        return i;
    } catch (Exception e) {
        if (exception) {
            throw new RuntimeException("read int32 error", e);
        } else {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.e("read int32 error");
                FileLog.e(e);
            }
        }
    }
    return 0;
}
 
Example #2
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: WebPlayerView.java    License: 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 #3
Source Project: TelePlus-Android   Author: TelePlusDev   File: ConnectionsManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final NativeByteBuffer result)
{
    Utilities.stageQueue.postRunnable(() ->
    {
        if (result != null)
        {
            currentTask = null;
            native_applyDnsConfig(currentAccount, result.address, UserConfig.getInstance(currentAccount).getClientPhone());
        }
        else
        {
            if (BuildVars.LOGS_ENABLED)
            {
                FileLog.d("failed to get dns txt result");
                FileLog.d("start azure task");
            }
            AzureLoadTask task = new AzureLoadTask(currentAccount);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
            currentTask = task;
        }
    });
}
 
Example #4
Source Project: Telegram   Author: DrKLO   File: ConnectionsManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final NativeByteBuffer result) {
    Utilities.stageQueue.postRunnable(() -> {
        currentTask = null;
        if (result != null) {
            native_applyDnsConfig(currentAccount, result.address, AccountInstance.getInstance(currentAccount).getUserConfig().getClientPhone(), responseDate);
        } else {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("failed to get dns txt result");
                FileLog.d("start google task");
            }
            GoogleDnsLoadTask task = new GoogleDnsLoadTask(currentAccount);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
            currentTask = task;
        }
    });
}
 
Example #5
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: VoIPBaseService.java    License: 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 Project: Telegram   Author: DrKLO   File: ConnectionsManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final NativeByteBuffer result) {
    Utilities.stageQueue.postRunnable(() -> {
        currentTask = null;
        if (result != null) {
            native_applyDnsConfig(currentAccount, result.address, AccountInstance.getInstance(currentAccount).getUserConfig().getClientPhone(), responseDate);
        } else {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("failed to get google result");
                FileLog.d("start mozilla task");
            }
            MozillaDnsLoadTask task = new MozillaDnsLoadTask(currentAccount);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
            currentTask = task;
        }
    });
}
 
Example #7
Source Project: TelePlus-Android   Author: TelePlusDev   File: NativeByteBuffer.java    License: GNU General Public License v2.0 6 votes vote down vote up
public boolean readBool(boolean exception) {
    int consructor = readInt32(exception);
    if (consructor == 0x997275b5) {
        return true;
    } else if (consructor == 0xbc799737) {
        return false;
    }
    if (exception) {
        throw new RuntimeException("Not bool value!");
    } else {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Not bool value!");
        }
    }
    return false;
}
 
Example #8
Source Project: Telegram   Author: DrKLO   File: ConnectionsManager.java    License: 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;
        int constructor = buff.readInt32(true);
        final TLObject message = TLClassStore.Instance().TLdeserialize(buff, constructor, true);
        if (message instanceof TLRPC.Updates) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("java received " + message);
            }
            KeepAliveJob.finishJob();
            Utilities.stageQueue.postRunnable(() -> AccountInstance.getInstance(currentAccount).getMessagesController().processUpdates((TLRPC.Updates) message, false));
        } else {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d(String.format("java received unknown constructor 0x%x", constructor));
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example #9
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: TelegramConnectionService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request){
	if(BuildVars.LOGS_ENABLED)
		FileLog.d("onCreateIncomingConnection "/*+request*/);
	Bundle extras=request.getExtras();
	if(extras.getInt("call_type")==1){ // private
		VoIPService svc=VoIPService.getSharedInstance();
		if(svc==null)
			return null;
		if(svc.isOutgoing())
			return null;
		return svc.getConnectionAndStartCall();
	}else if(extras.getInt("call_type")==2){ // group
		/*VoIPGroupService svc=VoIPGroupService.getSharedInstance();
		if(svc==null)
			return null;
		return svc.getConnectionAndStartCall();*/
	}
	return null;
}
 
Example #10
Source Project: Telegram   Author: DrKLO   File: SerializedData.java    License: GNU General Public License v2.0 6 votes vote down vote up
public boolean readBool(boolean exception) {
    int consructor = readInt32(exception);
    if (consructor == 0x997275b5) {
        return true;
    } else if (consructor == 0xbc799737) {
        return false;
    }
    if (exception) {
        throw new RuntimeException("Not bool value!");
    } else {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Not bool value!");
        }
    }
    return false;
}
 
Example #11
Source Project: TelePlus-Android   Author: TelePlusDev   File: VoIPService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onControllerPreRelease(){
	if(needSendDebugLog){
		String debugLog=controller.getDebugLog();
		TLRPC.TL_phone_saveCallDebug req=new TLRPC.TL_phone_saveCallDebug();
		req.debug=new TLRPC.TL_dataJSON();
		req.debug.data=debugLog;
		req.peer=new TLRPC.TL_inputPhoneCall();
		req.peer.access_hash=call.access_hash;
		req.peer.id=call.id;
		ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate(){
			@Override
			public void run(TLObject response, TLRPC.TL_error error){
                   if (BuildVars.LOGS_ENABLED) {
                       FileLog.d("Sent debug logs, response=" + response);
                   }
			}
		});
	}
}
 
Example #12
Source Project: TelePlus-Android   Author: TelePlusDev   File: SerializedData.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void writeByte(int i)
{
    try
    {
        if (!justCalc)
        {
            out.writeByte((byte) i);
        }
        else
        {
            len += 1;
        }
    }
    catch (Exception e)
    {
        if (BuildVars.LOGS_ENABLED)
        {
            FileLog.e("write byte error");
        }
    }
}
 
Example #13
Source Project: TelePlus-Android   Author: TelePlusDev   File: ConnectionsManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final NativeByteBuffer result)
{
    Utilities.stageQueue.postRunnable(() ->
    {
        if (result != null)
        {
            currentTask = null;
            native_applyDnsConfig(currentAccount, result.address, UserConfig.getInstance(currentAccount).getClientPhone());
        }
        else
        {
            if (BuildVars.LOGS_ENABLED)
            {
                FileLog.d("failed to get dns txt result");
                FileLog.d("start azure task");
            }
            AzureLoadTask task = new AzureLoadTask(currentAccount);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
            currentTask = task;
        }
    });
}
 
Example #14
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: InstantCameraView.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void frameAvailable(SurfaceTexture st, Integer cameraId, long timestampInternal) {
    synchronized (sync) {
        if (!ready) {
            return;
        }
    }

    long timestamp = st.getTimestamp();
    if (timestamp == 0) {
        zeroTimeStamps++;
        if (zeroTimeStamps > 1) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("fix timestamp enabled");
            }
            timestamp = timestampInternal;
        } else {
            return;
        }
    } else {
        zeroTimeStamps = 0;
    }

    handler.sendMessage(handler.obtainMessage(MSG_VIDEOFRAME_AVAILABLE, (int) (timestamp >> 32), (int) timestamp, cameraId));
}
 
Example #15
Source Project: TelePlus-Android   Author: TelePlusDev   File: AlertsCreator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static AlertDialog showUpdateAppAlert(final Context context, final String text, boolean updateApp)
{
    if (context == null || text == null)
    {
        return null;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    builder.setMessage(text);
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    if (updateApp)
    {
        builder.setNegativeButton(LocaleController.getString("UpdateApp", R.string.UpdateApp), (dialog, which) -> Browser.openUrl(context, BuildVars.PLAYSTORE_APP_URL));
    }
    return builder.show();
}
 
Example #16
Source Project: Telegram   Author: DrKLO   File: WebPlayerView.java    License: 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 #17
Source Project: Telegram   Author: DrKLO   File: ForegroundDetector.java    License: 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 #18
Source Project: TelePlus-Android   Author: TelePlusDev   File: InstantCameraView.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void frameAvailable(SurfaceTexture st, Integer cameraId, long timestampInternal) {
    synchronized (sync) {
        if (!ready) {
            return;
        }
    }

    long timestamp = st.getTimestamp();
    if (timestamp == 0) {
        zeroTimeStamps++;
        if (zeroTimeStamps > 1) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("fix timestamp enabled");
            }
            timestamp = timestampInternal;
        } else {
            return;
        }
    } else {
        zeroTimeStamps = 0;
    }

    handler.sendMessage(handler.obtainMessage(MSG_VIDEOFRAME_AVAILABLE, (int) (timestamp >> 32), (int) timestamp, cameraId));
}
 
Example #19
Source Project: TelePlus-Android   Author: TelePlusDev   File: SerializedData.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void readBytes(byte[] b, boolean exception)
{
    try
    {
        in.read(b);
        len += b.length;
    }
    catch (Exception e)
    {
        if (exception)
        {
            throw new RuntimeException("read bytes error", e);
        }
        else
        {
            if (BuildVars.LOGS_ENABLED)
            {
                FileLog.e("read bytes error");
            }
        }
    }
}
 
Example #20
Source Project: TelePlus-Android   Author: TelePlusDev   File: SerializedData.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void writeInt64(long x, DataOutputStream out)
{
    try
    {
        for (int i = 0; i < 8; i++)
        {
            out.write((int) (x >> (i * 8)));
        }
    }
    catch (Exception e)
    {
        if (BuildVars.LOGS_ENABLED)
        {
            FileLog.e("write int64 error");
        }
    }
}
 
Example #21
Source Project: TelePlus-Android   Author: TelePlusDev   File: VoIPService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onControllerPreRelease(){
	if(needSendDebugLog){
		String debugLog=controller.getDebugLog();
		TLRPC.TL_phone_saveCallDebug req=new TLRPC.TL_phone_saveCallDebug();
		req.debug=new TLRPC.TL_dataJSON();
		req.debug.data=debugLog;
		req.peer=new TLRPC.TL_inputPhoneCall();
		req.peer.access_hash=call.access_hash;
		req.peer.id=call.id;
		ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate(){
			@Override
			public void run(TLObject response, TLRPC.TL_error error){
                   if (BuildVars.LOGS_ENABLED) {
                       FileLog.d("Sent debug logs, response=" + response);
                   }
			}
		});
	}
}
 
Example #22
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: ConnectionsManager.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final NativeByteBuffer result) {
    Utilities.stageQueue.postRunnable(() -> {
        currentTask = null;
        if (result != null) {
            native_applyDnsConfig(currentAccount, result.address, AccountInstance.getInstance(currentAccount).getUserConfig().getClientPhone(), responseDate);
        } else {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("failed to get google result");
                FileLog.d("start mozilla task");
            }
            MozillaDnsLoadTask task = new MozillaDnsLoadTask(currentAccount);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
            currentTask = task;
        }
    });
}
 
Example #23
Source Project: TelePlus-Android   Author: TelePlusDev   File: ForegroundDetector.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onActivityStopped(Activity activity)
{
    if (--refs <= 0)
    {
        enterBackgroundTime = System.currentTimeMillis();
        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 #24
Source Project: TelePlus-Android   Author: TelePlusDev   File: SQLiteCursor.java    License: GNU General Public License v2.0 6 votes vote down vote up
public boolean next() throws SQLiteException {
	int res = preparedStatement.step(preparedStatement.getStatementHandle());
	if (res == -1) {
		int repeatCount = 6;
		while (repeatCount-- != 0) {
			try {
				if (BuildVars.LOGS_ENABLED) {
					FileLog.d("sqlite busy, waiting...");
				}
				Thread.sleep(500);
				res = preparedStatement.step();
				if (res == 0) {
					break;
				}
			} catch (Exception e) {
				FileLog.e(e);
			}
		}
		if (res == -1) {
			throw new SQLiteException("sqlite busy");
		}
	}
	inRow = (res == 0);
	return inRow;
}
 
Example #25
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: NativeByteBuffer.java    License: GNU General Public License v2.0 6 votes vote down vote up
public boolean readBool(boolean exception) {
    int consructor = readInt32(exception);
    if (consructor == 0x997275b5) {
        return true;
    } else if (consructor == 0xbc799737) {
        return false;
    }
    if (exception) {
        throw new RuntimeException("Not bool value!");
    } else {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Not bool value!");
        }
    }
    return false;
}
 
Example #26
Source Project: TelePlus-Android   Author: TelePlusDev   File: SQLiteDatabase.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void close() {
	if (isOpen) {
		try {
               commitTransaction();
			closedb(sqliteHandle);
		} catch (SQLiteException e) {
			if (BuildVars.LOGS_ENABLED) {
				FileLog.e(e.getMessage(), e);
			}
		}
		isOpen = false;
	}
}
 
Example #27
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: SerializedData.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void writeByteArray(byte[] b) {
    try {
        if (b.length <= 253) {
            if (!justCalc) {
                out.write(b.length);
            } else {
                len += 1;
            }
        } else {
            if (!justCalc) {
                out.write(254);
                out.write(b.length);
                out.write(b.length >> 8);
                out.write(b.length >> 16);
            } else {
                len += 4;
            }
        }
        if (!justCalc) {
            out.write(b);
        } else {
            len += b.length;
        }
        int i = b.length <= 253 ? 1 : 4;
        while ((b.length + i) % 4 != 0) {
            if (!justCalc) {
                out.write(0);
            } else {
                len += 1;
            }
            i++;
        }
    } catch (Exception e) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("write byte array error");
            FileLog.e(e);
        }
    }
}
 
Example #28
Source Project: Telegram   Author: DrKLO   File: NativeByteBuffer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void writeBytes(byte[] b, int offset, int count) {
    try {
        if (!justCalc) {
            buffer.put(b, offset, count);
        } else {
            len += count;
        }
    } catch (Exception e) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("write raw error");
            FileLog.e(e);
        }
    }
}
 
Example #29
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: VoIPBaseService.java    License: 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 #30
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: ExternalActionActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void onPasscodePause() {
    if (lockRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(lockRunnable);
        lockRunnable = null;
    }
    if (SharedConfig.passcodeHash.length() != 0) {
        SharedConfig.lastPauseTime = (int) (SystemClock.elapsedRealtime() / 1000);
        lockRunnable = new Runnable() {
            @Override
            public void run() {
                if (lockRunnable == this) {
                    if (AndroidUtilities.needShowPasscode(true)) {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("lock app");
                        }
                        showPasscodeActivity();
                    } else {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("didn't pass lock check");
                        }
                    }
                    lockRunnable = null;
                }
            }
        };
        if (SharedConfig.appLocked) {
            AndroidUtilities.runOnUIThread(lockRunnable, 1000);
        } else if (SharedConfig.autoLockIn != 0) {
            AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000);
        }
    } else {
        SharedConfig.lastPauseTime = 0;
    }
    SharedConfig.saveConfig();
}