Commit c6e72efa authored by Tobias Sargeant's avatar Tobias Sargeant Committed by Commit Bot

[supportlib] Support a :dev feature suffix.

:dev suffixed features will only be available if the device is
userdebug. This makes it possible to develop support library changes in
multiple steps, and then expose the feature with a final CL that removes
the suffix, without running the risk that applications will
inadvertently release code depending on the behaviour of an in-progress
implementation of a feature.

Bug: 908648
Change-Id: Iae98386992eb113356cf74be3eda125af10d867a
Reviewed-on: https://chromium-review.googlesource.com/c/1349327
Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611061}
parent cfea7015
......@@ -10,6 +10,8 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collection;
/**
* A set of utility methods used for calling across the support library boundary.
......@@ -129,14 +131,21 @@ public class BoundaryInterfaceReflectionUtil {
}
}
private static boolean isDebuggable() {
return !Build.TYPE.equals("user");
}
/**
* Check whether a set of features {@param features} contains a certain feature {@param
* soughtFeature}.
*/
public static boolean containsFeature(Collection<String> features, String soughtFeature) {
assert !soughtFeature.endsWith(Features.DEV_SUFFIX);
return features.contains(soughtFeature)
|| (isDebuggable() && features.contains(soughtFeature + Features.DEV_SUFFIX));
}
public static boolean containsFeature(String[] features, String soughtFeature) {
for (String feature : features) {
if (feature.equals(soughtFeature)) return true;
}
return false;
return containsFeature(Arrays.asList(features), soughtFeature);
}
}
......@@ -10,6 +10,9 @@ package org.chromium.support_lib_boundary.util;
* Chromium can share its definition.
*/
public class Features {
// Features suffixed with DEV will only be visible on debug devices.
public static final String DEV_SUFFIX = ":dev";
// This class just contains constants representing features.
private Features() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment