async adbPrepareProfileDir()

in src/extension-runners/firefox-android.js [338:393]


  async adbPrepareProfileDir() {
    const {
      adbUtils,
      selectedAdbDevice,
      selectedFirefoxApk,
      params: { customPrefs, firefoxApp, adbRemoveOldArtifacts },
    } = this;
    // Create the preferences file and the Fennec temporary profile.
    log.debug(`Preparing a temporary profile for ${selectedFirefoxApk}...`);

    const profile = await firefoxApp.createProfile({
      app: 'fennec',
      customPrefs,
    });

    // Check if there are any artifacts dirs from previous runs and
    // automatically remove them if adbRemoteOldArtifacts is true.
    const foundOldArtifacts = await adbUtils.detectOrRemoveOldArtifacts(
      selectedAdbDevice,
      adbRemoveOldArtifacts,
    );

    if (foundOldArtifacts) {
      if (adbRemoveOldArtifacts) {
        log.info(
          'Old web-ext artifacts have been found and removed ' +
            `from ${selectedAdbDevice} device`,
        );
      } else {
        log.warn(
          `Old artifacts directories have been found on ${selectedAdbDevice} ` +
            'device. Use --adb-remove-old-artifacts to remove them automatically.',
        );
      }
    }

    // Choose a artifacts dir name for the assets pushed to the
    // Android device.
    this.selectedArtifactsDir =
      await adbUtils.getOrCreateArtifactsDir(selectedAdbDevice);

    const deviceProfileDir = this.getDeviceProfileDir();

    await adbUtils.runShellCommand(selectedAdbDevice, [
      'mkdir',
      '-p',
      deviceProfileDir,
    ]);
    await adbUtils.pushFile(
      selectedAdbDevice,
      path.join(profile.profileDir, 'user.js'),
      `${deviceProfileDir}/user.js`,
    );

    log.debug(`Created temporary profile at ${deviceProfileDir}.`);
  }