fuchsia_workflow.dart 1.93 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8
import 'package:meta/meta.dart';

9
import '../base/context.dart';
10
import '../base/platform.dart';
11
import '../doctor_validator.dart';
12 13
import '../features.dart';
import 'fuchsia_sdk.dart';
14 15

/// The [FuchsiaWorkflow] instance.
16
FuchsiaWorkflow get fuchsiaWorkflow => context.get<FuchsiaWorkflow>();
17 18 19 20 21 22

/// The Fuchsia-specific implementation of a [Workflow].
///
/// This workflow assumes development within the fuchsia source tree,
/// including a working fx command-line tool in the user's PATH.
class FuchsiaWorkflow implements Workflow {
23 24 25 26 27 28 29 30 31 32 33
  FuchsiaWorkflow({
    @required Platform platform,
    @required FeatureFlags featureFlags,
    @required FuchsiaArtifacts fuchsiaArtifacts,
  }) : _platform = platform,
       _featureFlags = featureFlags,
       _fuchsiaArtifacts = fuchsiaArtifacts;

  final Platform _platform;
  final FeatureFlags _featureFlags;
  final FuchsiaArtifacts _fuchsiaArtifacts;
34 35

  @override
36
  bool get appliesToHostPlatform => _featureFlags.isFuchsiaEnabled && (_platform.isLinux || _platform.isMacOS);
37

38 39 40 41 42 43 44 45 46
  bool get shouldUseDeviceFinder {
    final String useDeviceFinder = _platform.environment.containsKey('FUCHSIA_DISABLED_ffx_discovery')
      ? _platform.environment['FUCHSIA_DISABLED_ffx_discovery'] : '0';
    if (useDeviceFinder == '1') {
      return true;
    }
    return false;
  }

47 48
  @override
  bool get canListDevices {
49 50 51 52
    if (shouldUseDeviceFinder) {
      return _fuchsiaArtifacts.devFinder != null;
    }
    return _fuchsiaArtifacts.ffx != null;
53 54 55 56
  }

  @override
  bool get canLaunchDevices {
57 58 59 60
    if (shouldUseDeviceFinder) {
      return _fuchsiaArtifacts.devFinder != null && _fuchsiaArtifacts.sshConfig != null;
    }
    return _fuchsiaArtifacts.ffx != null && _fuchsiaArtifacts.sshConfig != null;
61 62 63 64 65
  }

  @override
  bool get canListEmulators => false;
}