// Path: accelerator-core/src/main/java/com/opentok/accelerator/core/GlobalLogLevel.java
// public class GlobalLogLevel {
//   public static short sMaxLogLevel = 0xFF;
// }
// 
// Path: accelerator-core/src/main/java/com/opentok/accelerator/core/utils/LogWrapper.java
// public class LogWrapper {
// 
//   public static final short LOG_ERROR = 0x1;
//   public static final short LOG_WARN = 0x2;
//   public static final short LOG_INFO = 0x4;
//   public static final short LOG_DEBUG = 0x8;
//   public static final short LOG_VERBOSE = 0x10;
// 
//   protected interface RunnableLogger {
//     void log(String tag, String message);
//     void log(String tag, String message, Exception e);
//   }
// 
//   /**
//    * Protected and not final to allow modification by subclasses
//    */
//   protected static SparseArray<RunnableLogger> sLoggers = new SparseArray<RunnableLogger>() {
//     {
//       append(LOG_ERROR, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.e(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.e(tag, message, e);
//         }
//       });
// 
//       append(LOG_WARN, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.w(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.w(tag, message, e);
//         }
//       });
// 
//       append(LOG_INFO, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.i(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.i(tag, message, e);
//         }
//       });
// 
//       append(LOG_DEBUG, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.d(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.d(tag, message, e);
//         }
//       });
// 
//       append(LOG_VERBOSE, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.v(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.v(tag, message, e);
//         }
//       });
//     }
//   };
// 
//   private short mCurrentLogLevel;
// 
//   public void setLogLevel(short logLevel) {
//     mCurrentLogLevel = logLevel;
//   }
// 
//   public void enableLevels(short levels) {
//     mCurrentLogLevel |= levels;
//   }
// 
//   public void disableLevels(short levels) {
//     mCurrentLogLevel |= (0xFF ^ levels);
//   }
// 
//   public LogWrapper(short logLevel) {
//     setLogLevel(logLevel);
//   }
// 
//   private void log(short level, Object... messages) {
//     RunnableLogger logger;
//     if ((mCurrentLogLevel & level) == 0 || (logger = sLoggers.get(level)) == null) {
//       return;
//     }
//     String logTag = null;
//     StringBuilder message = new StringBuilder();
//     Exception e = null;
//     for(Object element: messages) {
//       if (element instanceof Exception) {
//         e = (Exception) element;
//       } else {
//         if (element == null) {
//           element = "null";
//         }
//         if (logTag == null) {
//           logTag = element.toString();
//         } else {
//           message.append(element.toString());
//         }
//       }
//     }
//     if (e != null) {
//       logger.log(logTag, message.toString(), e);
//     } else {
//       logger.log(logTag, message.toString());
//     }
//   }
// 
//   public void e(Object... messages) {
//     log(LOG_ERROR, messages);
//   }
// 
//   public void d(Object... messages) {
//     log(LOG_DEBUG, messages);
//   }
// 
//   public void w(Object... messages) {
//     log(LOG_WARN, messages);
//   }
// 
//   public void i(Object... messages) {
//     log(LOG_INFO, messages);
//   }
//   public void v(Object... messages) {
//     log(LOG_VERBOSE, messages);
//   }
// 
// }


import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.media.ImageReader;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.opentok.accelerator.core.GlobalLogLevel;
import com.opentok.accelerator.core.utils.LogWrapper;
package com.opentok.accelerator.core.screensharing;


/**
 * Represents a headless fragment to enable the screensharing by default
 */
public class ScreenSharingFragment extends Fragment {

    private static final String LOG_TAG = ScreenSharingFragment.class.getSimpleName();
    private static final short LOCAL_LOG_LEVEL = 0xFF;
    private static final LogWrapper LOG =
            new LogWrapper((short)(GlobalLogLevel.sMaxLogLevel & LOCAL_LOG_LEVEL));
    public static void setLogLevel(short logLevel) {
        LOG.setLogLevel(logLevel);
    }


    private static final String ERROR = "ScreenSharing error";
    private static final int REQUEST_MEDIA_PROJECTION = 1;

    public ViewGroup getScreen() {
        return mScreen;
    }

    private ViewGroup mScreen;

    private VirtualDisplay mVirtualDisplay;
    private int mDensity;
    private int mWidth;
    private int mHeight;

    private MediaProjectionManager mMediaProjectionManager;
    private MediaProjection mMediaProjection;
// Path: accelerator-core/src/main/java/com/opentok/accelerator/core/GlobalLogLevel.java
// public class GlobalLogLevel {
//   public static short sMaxLogLevel = 0xFF;
// }
// 
// Path: accelerator-core/src/main/java/com/opentok/accelerator/core/utils/LogWrapper.java
// public class LogWrapper {
// 
//   public static final short LOG_ERROR = 0x1;
//   public static final short LOG_WARN = 0x2;
//   public static final short LOG_INFO = 0x4;
//   public static final short LOG_DEBUG = 0x8;
//   public static final short LOG_VERBOSE = 0x10;
// 
//   protected interface RunnableLogger {
//     void log(String tag, String message);
//     void log(String tag, String message, Exception e);
//   }
// 
//   /**
//    * Protected and not final to allow modification by subclasses
//    */
//   protected static SparseArray<RunnableLogger> sLoggers = new SparseArray<RunnableLogger>() {
//     {
//       append(LOG_ERROR, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.e(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.e(tag, message, e);
//         }
//       });
// 
//       append(LOG_WARN, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.w(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.w(tag, message, e);
//         }
//       });
// 
//       append(LOG_INFO, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.i(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.i(tag, message, e);
//         }
//       });
// 
//       append(LOG_DEBUG, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.d(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.d(tag, message, e);
//         }
//       });
// 
//       append(LOG_VERBOSE, new RunnableLogger() {
//         @Override
//         public void log(String tag, String message) {
//           Log.v(tag, message);
//         }
// 
//         @Override
//         public void log(String tag, String message, Exception e) {
//           Log.v(tag, message, e);
//         }
//       });
//     }
//   };
// 
//   private short mCurrentLogLevel;
// 
//   public void setLogLevel(short logLevel) {
//     mCurrentLogLevel = logLevel;
//   }
// 
//   public void enableLevels(short levels) {
//     mCurrentLogLevel |= levels;
//   }
// 
//   public void disableLevels(short levels) {
//     mCurrentLogLevel |= (0xFF ^ levels);
//   }
// 
//   public LogWrapper(short logLevel) {
//     setLogLevel(logLevel);
//   }
// 
//   private void log(short level, Object... messages) {
//     RunnableLogger logger;
//     if ((mCurrentLogLevel & level) == 0 || (logger = sLoggers.get(level)) == null) {
//       return;
//     }
//     String logTag = null;
//     StringBuilder message = new StringBuilder();
//     Exception e = null;
//     for(Object element: messages) {
//       if (element instanceof Exception) {
//         e = (Exception) element;
//       } else {
//         if (element == null) {
//           element = "null";
//         }
//         if (logTag == null) {
//           logTag = element.toString();
//         } else {
//           message.append(element.toString());
//         }
//       }
//     }
//     if (e != null) {
//       logger.log(logTag, message.toString(), e);
//     } else {
//       logger.log(logTag, message.toString());
//     }
//   }
// 
//   public void e(Object... messages) {
//     log(LOG_ERROR, messages);
//   }
// 
//   public void d(Object... messages) {
//     log(LOG_DEBUG, messages);
//   }
// 
//   public void w(Object... messages) {
//     log(LOG_WARN, messages);
//   }
// 
//   public void i(Object... messages) {
//     log(LOG_INFO, messages);
//   }
//   public void v(Object... messages) {
//     log(LOG_VERBOSE, messages);
//   }
// 
// }


// Path: accelerator-core/src/main/java/com/opentok/accelerator/core/screensharing/ScreenSharingFragment.java
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.media.ImageReader;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.opentok.accelerator.core.GlobalLogLevel;
import com.opentok.accelerator.core.utils.LogWrapper;

package com.opentok.accelerator.core.screensharing;


/**
 * Represents a headless fragment to enable the screensharing by default
 */
public class ScreenSharingFragment extends Fragment {

    private static final String LOG_TAG = ScreenSharingFragment.class.getSimpleName();
    private static final short LOCAL_LOG_LEVEL = 0xFF;
    private static final LogWrapper LOG =
            new LogWrapper((short)(GlobalLogLevel.sMaxLogLevel & LOCAL_LOG_LEVEL));
    public static void setLogLevel(short logLevel) {
        LOG.setLogLevel(logLevel);
    }


    private static final String ERROR = "ScreenSharing error";
    private static final int REQUEST_MEDIA_PROJECTION = 1;

    public ViewGroup getScreen() {
        return mScreen;
    }

    private ViewGroup mScreen;

    private VirtualDisplay mVirtualDisplay;
    private int mDensity;
    private int mWidth;
    private int mHeight;

    private MediaProjectionManager mMediaProjectionManager;
    private MediaProjection mMediaProjection;
    private ImageReader mImageReader;