diff options
author | Tobias Sargeant <tobiasjs@google.com> | 2018-11-27 10:23:08 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2018-11-27 10:23:08 +0000 |
commit | 687df69505131ca7d2cd87a2704837a04c34119b (patch) | |
tree | b1f476baed8684f436f423978d972487d2b6d5be /src/org | |
parent | e227daebe38b7f5e35115c49562f6b6a109ffb15 (diff) | |
download | webview_support_interfaces-687df69505131ca7d2cd87a2704837a04c34119b.tar.gz |
[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: Nate Fischer <ntfschr@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#611061}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c6e72efa6dba0e0ffff040451707dcbc71df3e89
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java | 17 | ||||
-rw-r--r-- | src/org/chromium/support_lib_boundary/util/Features.java | 3 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java b/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java index 566535b..6badd3a 100644 --- a/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java +++ b/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java @@ -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); } } diff --git a/src/org/chromium/support_lib_boundary/util/Features.java b/src/org/chromium/support_lib_boundary/util/Features.java index 59ce1df..b382c0b 100644 --- a/src/org/chromium/support_lib_boundary/util/Features.java +++ b/src/org/chromium/support_lib_boundary/util/Features.java @@ -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() {} |