summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFarruh Habibullaev <farruhh@google.com>2021-10-11 15:21:42 -0700
committerFarruh Habibullaev <farruhh@google.com>2021-10-21 19:11:02 +0000
commitbe587aee040a7740121538d2031f53ebe7e2c56b (patch)
tree56bce195e1b24ee3bcabf9322343c47cb513aa7c
parenta67dcffa639174b24ef02ee71091dd2d1fbfd85c (diff)
downloadsetupwizard-be587aee040a7740121538d2031f53ebe7e2c56b.tar.gz
Add the version support on FeatureResolver.java without modifying
its existing contract to - support gModalVersion(); Test: modified FeatureResolverTest.java to unit test the functionality accordingly. Test: Manually tested it. Change-Id: Ia1fb4c4048cd493a7db1fad571194cc79d02ba10 Bug: b/201835961
-rw-r--r--library/main/src/com/android/car/setupwizardlib/util/FeatureResolver.java37
-rw-r--r--library/main/tests/robotests/src/com/android/car/setupwizardlib/util/FeatureResolverTest.java12
2 files changed, 23 insertions, 26 deletions
diff --git a/library/main/src/com/android/car/setupwizardlib/util/FeatureResolver.java b/library/main/src/com/android/car/setupwizardlib/util/FeatureResolver.java
index 98f467a..8f0114f 100644
--- a/library/main/src/com/android/car/setupwizardlib/util/FeatureResolver.java
+++ b/library/main/src/com/android/car/setupwizardlib/util/FeatureResolver.java
@@ -38,8 +38,8 @@ public class FeatureResolver {
static final String AUTHORITY =
CarSetupWizardUiUtils.SETUP_WIZARD_PACKAGE + ".feature_management";
static final String GET_FEATURE_VERSION_METHOD = "getFeatureVersion";
- static final String GET_FEATURE_ENABLEMENT_METHOD = "getFeatureEnablement";
static final String SPLIT_NAV_LAYOUT_FEATURE = "split_nav_layout";
+ static final String G_MODAL_FEATURE = "g_modal";
static final String VALUE = "value";
private Context mContext;
@@ -65,12 +65,11 @@ public class FeatureResolver {
*/
public boolean isSplitNavLayoutFeatureEnabled() {
Bundle bundle;
- String bundleKey = SPLIT_NAV_LAYOUT_FEATURE.concat(GET_FEATURE_ENABLEMENT_METHOD);
- if (mResultMap.containsKey(bundleKey)) {
- bundle = mResultMap.get(bundleKey);
+ if (mResultMap.containsKey(SPLIT_NAV_LAYOUT_FEATURE)) {
+ bundle = mResultMap.get(SPLIT_NAV_LAYOUT_FEATURE);
} else {
- bundle = getFeatureBundle(SPLIT_NAV_LAYOUT_FEATURE, GET_FEATURE_ENABLEMENT_METHOD);
- mResultMap.put(bundleKey, bundle);
+ bundle = getFeatureBundle(SPLIT_NAV_LAYOUT_FEATURE);
+ mResultMap.put(SPLIT_NAV_LAYOUT_FEATURE, bundle);
}
boolean isSplitNavLayoutFeatureEnabled = bundle != null
&& bundle.getBoolean(VALUE, false);
@@ -79,35 +78,33 @@ public class FeatureResolver {
}
/**
- * Returns the enabled version number of split-nav layout
+ * Returns the gModalVersion
*/
- public int getSplitNavLayoutFeatureVersion() {
+ public int getGModalVersion() {
Bundle bundle;
- String bundleKey = SPLIT_NAV_LAYOUT_FEATURE.concat(GET_FEATURE_VERSION_METHOD);
- if (mResultMap.containsKey(bundleKey)) {
- bundle = mResultMap.get(bundleKey);
+ if (mResultMap.containsKey(G_MODAL_FEATURE)) {
+ bundle = mResultMap.get(G_MODAL_FEATURE);
} else {
- bundle = getFeatureBundle(SPLIT_NAV_LAYOUT_FEATURE, GET_FEATURE_VERSION_METHOD);
- mResultMap.put(bundleKey, bundle);
+ bundle = getFeatureBundle(G_MODAL_FEATURE);
+ mResultMap.put(G_MODAL_FEATURE, bundle);
}
- int splitNavLayoutFeatureVersion = bundle != null
- ? bundle.getInt(VALUE, 0) : 0;
- Log.v(TAG, String.format("splitNavLayoutFeatureVersion: %s", splitNavLayoutFeatureVersion));
- return splitNavLayoutFeatureVersion;
+ int gModalVersion = bundle != null ? bundle.getInt(VALUE, 0) : 0;
+ Log.v(TAG, String.format("gModalVersion: %s", gModalVersion));
+ return gModalVersion;
}
- private Bundle getFeatureBundle(String feature, String method) {
+ private Bundle getFeatureBundle(String feature) {
try {
Uri contentUri =
new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(AUTHORITY)
- .appendPath(method)
+ .appendPath(GET_FEATURE_VERSION_METHOD)
.build();
return mContext.getContentResolver().call(
contentUri,
- method,
+ GET_FEATURE_VERSION_METHOD,
feature,
/* extras= */ null);
} catch (IllegalArgumentException exception) {
diff --git a/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/FeatureResolverTest.java b/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/FeatureResolverTest.java
index 046a9f7..6951030 100644
--- a/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/FeatureResolverTest.java
+++ b/library/main/tests/robotests/src/com/android/car/setupwizardlib/util/FeatureResolverTest.java
@@ -104,32 +104,32 @@ public class FeatureResolverTest extends BaseRobolectricTest {
}
@Test
- public void testGetSplitNavLayoutFeatureVersion_whenVersionNumber1() {
+ public void testGetGModalVersion_whenVersionNumber1() {
Bundle bundle = new Bundle();
bundle.putInt(VALUE, 1);
doReturn(bundle).when(mContentResolver).call((Uri) any(), any(), any(), any());
- int splitNavLayoutFeatureVersion = mFeatureResolver.getSplitNavLayoutFeatureVersion();
+ int splitNavLayoutFeatureVersion = mFeatureResolver.getGModalVersion();
assertThat(splitNavLayoutFeatureVersion).isEqualTo(1);
}
@Test
- public void testGetSplitNavLayoutFeatureVersion_whenVersionNumber0() {
+ public void testGModalVersion_whenVersionNumber0() {
Bundle bundle = new Bundle();
bundle.putInt(VALUE, 0);
doReturn(bundle).when(mContentResolver).call((Uri) any(), any(), any(), any());
- int splitNavLayoutFeatureVersion = mFeatureResolver.getSplitNavLayoutFeatureVersion();
+ int splitNavLayoutFeatureVersion = mFeatureResolver.getGModalVersion();
assertThat(splitNavLayoutFeatureVersion).isEqualTo(0);
}
@Test
- public void testGetSplitNavLayoutFeatureVersion_whenReturnsBundleNull() {
+ public void testGetGModalVersion_whenReturnsBundleNull() {
doReturn(null).when(mContentResolver).call((Uri) any(), any(), any(), any());
- int splitNavLayoutFeatureVersion = mFeatureResolver.getSplitNavLayoutFeatureVersion();
+ int splitNavLayoutFeatureVersion = mFeatureResolver.getGModalVersion();
assertThat(splitNavLayoutFeatureVersion).isEqualTo(0);
}