Added flag and tests for SubscriptionPlan changes
Adding a flag and supporting tests for changes to SubscriptionPlan to
provide a subscription status and the plan's end date if available.
Flag: com.android.internal.telephony.flags.subscription_plan_allow_status_and_end_date
NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
# OWNER=jmattis TARGET=25Q2
> +flag {
> + name: "subscription_plan_allow_status_and_end_date"
> + namespace: "telephony"
> + description: "Provide APIs to retrieve the status and recurrence rule info on a subscription plan"
> + bug: "357272015"
> +}
> +
> --- /dev/null
> +++ tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionPlanTest.java
> +/*
> + * Copyright (C) 2024 The Android Open Source Project
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +package com.android.internal.telephony.subscription;
> +
> +import static android.telephony.SubscriptionPlan.SUBSCRIPTION_STATUS_ACTIVE;
> +
> +import static com.google.common.truth.Truth.assertThat;
> +
> +import static org.junit.Assert.assertNull;
> +import static org.junit.Assert.assertThrows;
> +
> +import android.platform.test.annotations.RequiresFlagsEnabled;
> +import android.telephony.SubscriptionPlan;
> +import android.testing.AndroidTestingRunner;
> +
> +import com.android.internal.telephony.flags.Flags;
> +
> +import org.junit.Test;
> +import org.junit.runner.RunWith;
> +
> +import java.time.Period;
> +import java.time.ZonedDateTime;
> +
> +@RunWith(AndroidTestingRunner.class)
> +public class SubscriptionPlanTest {
> + private static final ZonedDateTime ZONED_DATE_TIME_START =
> + ZonedDateTime.parse("2007-03-14T00:00:00.000Z");
> +
> + @Test
> + @RequiresFlagsEnabled(Flags.FLAG_SUBSCRIPTION_PLAN_ALLOW_STATUS_AND_END_DATE)
> + public void testBuilderExpirationDateSetsCorrectly() {
> + ZonedDateTime endDate = ZonedDateTime.parse("2024-11-07T00:00:00.000Z");
> +
> + SubscriptionPlan planNonRecurring = SubscriptionPlan.Builder
> + .createNonrecurring(ZONED_DATE_TIME_START, endDate)
> + .setTitle("unit test")
> + .build();
> + SubscriptionPlan planRecurring = SubscriptionPlan.Builder
> + .createRecurring(ZONED_DATE_TIME_START, Period.ofMonths(1))
> + .setTitle("unit test")
> + .build();
> +
> + assertThat(planNonRecurring.getPlanEndDate()).isEqualTo(endDate);
> + assertNull(planRecurring.getPlanEndDate());
> + }
> +
> + @Test
> + @RequiresFlagsEnabled(Flags.FLAG_SUBSCRIPTION_PLAN_ALLOW_STATUS_AND_END_DATE)
> + public void testBuilderValidSubscriptionStatusSetsCorrectly() {
> + @SubscriptionPlan.SubscriptionStatus int status = SUBSCRIPTION_STATUS_ACTIVE;
> +
> + SubscriptionPlan plan = SubscriptionPlan.Builder
> + .createRecurring(ZONED_DATE_TIME_START, Period.ofMonths(1))
> + .setSubscriptionStatus(status)
> + .setTitle("unit test")
> + .build();
> +
> + assertThat(plan.getSubscriptionStatus()).isEqualTo(status);
> + }
> +
> + @Test
> + @RequiresFlagsEnabled(Flags.FLAG_SUBSCRIPTION_PLAN_ALLOW_STATUS_AND_END_DATE)
> + public void testBuilderInvalidSubscriptionStatusThrowsError() {
> + int minInvalid = -1;
> + int maxInvalid = 5;
> +
> + assertThrows(IllegalArgumentException.class, () -> {
> + SubscriptionPlan.Builder
> + .createRecurring(ZONED_DATE_TIME_START, Period.ofMonths(1))
> + .setSubscriptionStatus(minInvalid)
> + .setTitle("unit test")
> + .build();
> + });
> +
> + assertThrows(IllegalArgumentException.class, () -> {
> + SubscriptionPlan.Builder
> + .createRecurring(ZONED_DATE_TIME_START, Period.ofMonths(1))
> + .setSubscriptionStatus(maxInvalid)
> + .setTitle("unit test")
> + .build();
> + });
> + }
> +}
Original patch:
From 52a56a8a Mon Sep 17 00:00:00 2001
From: James Mattis <jmattis@google.com>
Date: Fri, 08 Nov 2024 15:22:25 -0800
Subject: [PATCH] Added flag and tests for SubscriptionPlan changes
Adding a flag and supporting tests for changes to SubscriptionPlan to
provide a subscription status and the plan's end date if available.
Flag: com.android.internal.telephony.flags.subscription_plan_allow_status_and_end_date
Test: atest phone FrameworksTelephonyTests:SubscriptionPlanTest
Bug: 357272015
Change-Id: I25b70907eda6b3bcbf34f786ed86d64432c7331f
---
Result patch:
diff --git a/flags/subscription.aconfig b/flags/subscription.aconfig
index 9a5dabc..986c1ff 100644
--- a/flags/subscription.aconfig
+++ b/flags/subscription.aconfig
@@ -66,6 +66,14 @@
}
}
+# OWNER=jmattis TARGET=25Q2
+flag {
+ name: "subscription_plan_allow_status_and_end_date"
+ namespace: "telephony"
+ description: "Provide APIs to retrieve the status and recurrence rule info on a subscription plan"
+ bug: "357272015"
+}
+
# OWNER=songferngwang TARGET=24Q3
flag {
name: "reset_primary_sim_default_values"
diff --git a/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionPlanTest.java b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionPlanTest.java
new file mode 100644
index 0000000..2c13d3b
--- /dev/null
+++ b/tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionPlanTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (th
[[[Result patch trimmed due to size. Decoded string size: 4627. Decoded string SHA1: 113ac5bf92fb7e337643f59287d57cbf1f65914d.]]]
Test: atest phone FrameworksTelephonyTests:SubscriptionPlanTest
Bug: 357272015
Merged-In: I25b70907eda6b3bcbf34f786ed86d64432c7331f
Change-Id: I25b70907eda6b3bcbf34f786ed86d64432c7331f
Loading
Please register or sign in to comment