blob: fb9dab859bbdf23e98ffb0166c0fb6ed4bb4137e [file] [log] [blame]
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LIBSEGMENTATION_FEATURE_MANAGEMENT_INTERFACE_H_
#define LIBSEGMENTATION_FEATURE_MANAGEMENT_INTERFACE_H_
#include <set>
#include <string>
namespace segmentation {
// Copy of protobuf usage interface to avoid including the autogenerate
// protobuf
enum FeatureUsage {
USAGE_UNSPECIFIED = 0,
USAGE_LOCAL = 1,
USAGE_CHROME = 2,
USAGE_ANDROID = 3,
};
class FeatureManagementInterface {
public:
virtual ~FeatureManagementInterface() = default;
// Check if a feature can be enabled on the device.
//
// @param name The name of the feature to check
// @return |false| if the feature should not be used, |true| otherwise.
virtual bool IsFeatureEnabled(const std::string& name) = 0;
// Return the feature level for the device
//
// @return 0 when no additional features can be used,
// >0 when some feature can be used.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum FeatureLevel {
FEATURE_LEVEL_UNKNOWN = 0,
FEATURE_LEVEL_VALID_OFFSET = 1,
FEATURE_LEVEL_0 = 1,
FEATURE_LEVEL_1 = 2,
kMaxValue = FEATURE_LEVEL_1, // keep this in sync with the actual max
// value. Used for UMA metrics.
};
virtual FeatureLevel GetFeatureLevel() = 0;
// Return the max feature level for any device.
virtual FeatureLevel GetMaxFeatureLevel() = 0;
// Return the scope level for the device
//
// @return 0 when its unknown.
// > 0 otherwise.
enum ScopeLevel {
SCOPE_LEVEL_UNKNOWN = 0,
SCOPE_LEVEL_VALID_OFFSET = 1,
SCOPE_LEVEL_0 = 1,
SCOPE_LEVEL_1 = 2,
};
virtual ScopeLevel GetScopeLevel() = 0;
// List features supported on the device.
// |usage| narrows down the list to a specific subsystem (ChromeOS, Chrome
// or Android).
virtual const std::set<std::string> ListFeatures(
const FeatureUsage usage) = 0;
};
} // namespace segmentation
#endif // LIBSEGMENTATION_FEATURE_MANAGEMENT_INTERFACE_H_