gt:                     if (initial && BuildVars.LOGS_ENABLED) {
context: /*
   * This is the source code of Telegram for Android v. 5.x.x.
   * It is licensed under GNU GPL v. 2 or later.
   * You should have received a copy of the license in this archive (see LICENSE).
   *
   * Copyright Nikolai Kudashov, 2013-2018.
   */
  
  package org.telegram.messenger.camera;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.graphics.Rect;
  import android.hardware.Camera;
  import android.media.CamcorderProfile;
  import android.media.MediaRecorder;
  import android.os.Build;
  import android.view.OrientationEventListener;
  import android.view.Surface;
  import android.view.WindowManager;
  
  import org.telegram.messenger.ApplicationLoader;
  import org.telegram.messenger.BuildVars;
  import org.telegram.messenger.FileLog;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class CameraSession {
  
      protected CameraInfo cameraInfo;
      private String currentFlashMode;
      private OrientationEventListener orientationEventListener;
      private int lastOrientation = -1;
      private int lastDisplayOrientation = -1;
      private boolean isVideo;
      private final Size pictureSize;
      private final Size previewSize;
      private final int pictureFormat;
      private boolean initied;
      private int maxZoom;
      private boolean meteringAreaSupported;
      private int currentOrientation;
      private int diffOrientation;
      private int jpegOrientation;
      private boolean sameTakePictureOrientation;
      private boolean flipFront = true;
      private float currentZoom;
      private boolean optimizeForBarcode;
      private boolean useTorch;
      private boolean isRound;
      private boolean destroyed;
  
      Camera.CameraInfo info = new Camera.CameraInfo();
  
      public static final int ORIENTATION_HYSTERESIS = 5;
  
      private Camera.AutoFocusCallback autoFocusCallback = (success, camera) -> {
          if (success) {
  
          } else {
  
          }
      };
      private int displayOrientation;
  
      public CameraSession(CameraInfo info, Size preview, Size picture, int format, boolean round) {
          previewSize = preview;
          pictureSize = picture;
          pictureFormat = format;
          cameraInfo = info;
          isRound = round;
  
          SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE);
          currentFlashMode = sharedPreferences.getString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", Camera.Parameters.FLASH_MODE_OFF);
  
          orientationEventListener = new OrientationEventListener(ApplicationLoader.applicationContext) {
              @Override
              public void onOrientationChanged(int orientation) {
                  if (orientationEventListener == null || !initied || orientation == ORIENTATION_UNKNOWN) {
                      return;
                  }
                  jpegOrientation = roundOrientation(orientation, jpegOrientation);
                  WindowManager mgr = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
                  int rotation = mgr.getDefaultDisplay().getRotation();
                  if (lastOrientation != jpegOrientation || rotation != lastDisplayOrientation) {
                      if (!isVideo) {
                          configurePhotoCamera();
                      }
                      lastDisplayOrientation = rotation;
                      lastOrientation = jpegOrientation;
                  }
              }
          };
  
          if (orientationEventListener.canDetectOrientation()) {
              orientationEventListener.enable();
          } else {
              orientationEventListener.disable();
              orientationEventListener = null;
          }
      }
  
      private int roundOrientation(int orientation, int orientationHistory) {
          boolean changeOrientation;
          if (orientationHistory == OrientationEventListener.ORIENTATION_UNKNOWN) {
              changeOrientation = true;
          } else {
              int dist = Math.abs(orientation - orientationHistory);
              dist = Math.min(dist, 360 - dist);
              changeOrientation = (dist >= 45 + ORIENTATION_HYSTERESIS);
          }
          if (changeOrientation) {
              return ((orientation + 45) / 90 * 90) % 360;
          }
          return orientationHistory;
      }
  
      public void setOptimizeForBarcode(boolean value) {
          optimizeForBarcode = value;
          configurePhotoCamera();
      }
  
      public void checkFlashMode(String mode) {
          ArrayList<String> modes = CameraController.getInstance().availableFlashModes;
          if (modes.contains(currentFlashMode)) {
              return;
          }
          currentFlashMode = mode;
          configurePhotoCamera();
          SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE);
          sharedPreferences.edit().putString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", mode).commit();
      }
  
      public void setCurrentFlashMode(String mode) {
          currentFlashMode = mode;
          configurePhotoCamera();
          SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("camera", Activity.MODE_PRIVATE);
          sharedPreferences.edit().putString(cameraInfo.frontCamera != 0 ? "flashMode_front" : "flashMode", mode).commit();
      }
  
      public void setTorchEnabled(boolean enabled) {
          try {
              currentFlashMode = enabled ? Camera.Parameters.FLASH_MODE_TORCH : Camera.Parameters.FLASH_MODE_OFF;
              configurePhotoCamera();
          } catch (Exception e) {
              FileLog.e(e);
          }
      }
  
      public String getCurrentFlashMode() {
          return currentFlashMode;
      }
  
      public String getNextFlashMode() {
          ArrayList<String> modes = CameraController.getInstance().availableFlashModes;
          for (int a = 0; a < modes.size(); a++) {
              String mode = modes.get(a);
              if (mode.equals(currentFlashMode)) {
                  if (a < modes.size() - 1) {
                      return modes.get(a + 1);
                  } else {
                      return modes.get(0);
                  }
              }
          }
          return currentFlashMode;
      }
  
      public void setInitied() {
          initied = true;
      }
  
      public boolean isInitied() {
          return initied;
      }
  
      public int getCurrentOrientation() {
          return currentOrientation;
      }
  
      public boolean isFlipFront() {
          return flipFront;
      }
  
      public void setFlipFront(boolean value) {
          flipFront = value;
      }
  
      public int getWorldAngle() {
          return diffOrientation;
      }
  
      public boolean isSameTakePictureOrientation() {
          return sameTakePictureOrientation;
      }
  
      protected void configureRoundCamera(boolean initial) {
          try {
              isVideo = true;
              Camera camera = cameraInfo.camera;
              if (camera != null) {
                  Camera.Parameters params = null;
                  try {
                      params = camera.getParameters();
                  } catch (Exception e) {
                      FileLog.e(e);
                  }
  
                  Camera.getCameraInfo(cameraInfo.getCameraId(), info);
                  updateRotation();
  
                  if (params != null) {
                      if (initial && BuildVars.LOGS_ENABLED) {
                          FileLog.d("set preview size = " + previewSize.getWidth() + " " + previewSize.getHeight());
                      }
                      params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
  