initAndroidEnv function

Future<void> initAndroidEnv(
  1. EnvOptions options
)

Implementation

Future<void> initAndroidEnv(EnvOptions options) async {
  if (options.enableLogCallback == true) {
    if (options.enableLocalLogPrint == true) {
      BDUploadLog.setLogPrintType(await BDUploadLog.LOG_PRINT_BOTH);
    } else {
      BDUploadLog.setLogPrintType(await BDUploadLog.LOG_PRINT_CALL_BACK);
    }
  } else {
    if (options.enableLocalLogPrint == true) {
      BDUploadLog.setLogPrintType(await BDUploadLog.LOG_PRINT_LOCAL);
    } else {
      BDUploadLog.setLogPrintType(await BDUploadLog.LOG_PRINT_NONE);
    }
  }
  if (options.debugLogLevel == true) {
    BDUploadLog.turnOn(await BDUploadLog.LOG_DEBUG, 1);
    BDUploadUtil.setEnableNativeLog(true);
  }
  ConfigBuilder builder = ConfigBuilder();
  final applicationContext = await NativeVariables.getApplicationContext();
  await builder.setApplicationContext(applicationContext);
  await builder.setAppID(options.appID);
  await builder.setAppChannel(options.appChannel ?? '');
  await builder.setAppVersion(options.appVersion ?? '');
  if (options.appName != null) {
    await builder.setAppName(options.appName ?? "");
  }
  await builder.setOpenUploadCloudControl(
    options.useImageXCloudControl == true,
  );
  if (options.openAppLog == true) {
    await Env.openAppLog(true);
    if (options.autoStartAppLog == false) {
      await builder.setAutoStartAppLog(false);
    }
  }
  if (options.deviceID != null) {
    LogConfigBuilder logConfigBuilder = LogConfigBuilder(applicationContext);
    await logConfigBuilder.setDeviceID(options.deviceID!);
    final logConfig = await logConfigBuilder.build();
    builder.setLogConfig(logConfig);
  }

  final config = await builder.build();
  await Env.init(config);
}