diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index 6c619bb172a6b..8acf5fa8bdfe6 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -45,8 +45,6 @@ public class FeatureFlagUtils { /** @hide */ public static final String SETTINGS_DO_NOT_RESTORE_PRESERVED = "settings_do_not_restore_preserved"; - /** @hide */ - public static final String SETTINGS_SCHEDULES_FLAG = "settings_schedules"; private static final Map DEFAULT_FLAGS; @@ -69,7 +67,6 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put(SETTINGS_DO_NOT_RESTORE_PRESERVED, "true"); DEFAULT_FLAGS.put("settings_tether_all_in_one", "false"); - DEFAULT_FLAGS.put(SETTINGS_SCHEDULES_FLAG, "false"); DEFAULT_FLAGS.put("settings_contextual_home2", "true"); } diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp index 4ea104705da0f..ac4e1ea11dae9 100644 --- a/packages/SettingsLib/Android.bp +++ b/packages/SettingsLib/Android.bp @@ -50,7 +50,6 @@ java_defaults { "SettingsLibAdaptiveIcon", "SettingsLibRadioButtonPreference", "SettingsLibDisplayDensityUtils", - "SettingsLibSchedulesProvider", ], } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/schedulesprovider/ScheduleInfoTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/schedulesprovider/ScheduleInfoTest.java deleted file mode 100644 index b4b910d21da81..0000000000000 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/schedulesprovider/ScheduleInfoTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2020 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.settingslib.schedulesprovider; - -import static com.google.common.truth.Truth.assertThat; - -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; - -@RunWith(RobolectricTestRunner.class) -public class ScheduleInfoTest { - private static final String TEST_TITLE = "Night Light"; - private static final String TEST_SUMMARY = "Night Light summary"; - private static final String TEST_EMPTY_SUMMARY = ""; - - private final Context mContext = RuntimeEnvironment.application; - - @Test - public void builder_usedValidArguments_isValid() { - final PendingIntent pendingIntent = createTestPendingIntent(mContext); - final ScheduleInfo info = createTestScheduleInfo(TEST_TITLE, TEST_SUMMARY, pendingIntent); - - assertThat(info).isNotNull(); - assertThat(info.isValid()).isTrue(); - } - - @Test - public void builder_useEmptySummary_isInvalid() { - final PendingIntent pendingIntent = createTestPendingIntent(mContext); - final ScheduleInfo info = createTestScheduleInfo(TEST_TITLE, TEST_EMPTY_SUMMARY, - pendingIntent); - - assertThat(info).isNotNull(); - assertThat(info.isValid()).isFalse(); - } - - @Test - public void builder_pendingIntentIsNull_isInvalid() { - final ScheduleInfo info = new ScheduleInfo.Builder() - .setTitle(TEST_TITLE) - .setSummary(TEST_SUMMARY) - .build(); - - assertThat(info).isNotNull(); - assertThat(info.isValid()).isFalse(); - } - - @Test - public void getTitle_setValidTitle_shouldReturnSameCorrectTitle() { - final PendingIntent pendingIntent = createTestPendingIntent(mContext); - final ScheduleInfo info = createTestScheduleInfo(TEST_TITLE, TEST_SUMMARY, pendingIntent); - - assertThat(info.getTitle()).isEqualTo(TEST_TITLE); - } - - @Test - public void getSummary_setValidSummary_shouldReturnSameCorrectSummary() { - final PendingIntent pendingIntent = createTestPendingIntent(mContext); - final ScheduleInfo info = createTestScheduleInfo(TEST_TITLE, TEST_SUMMARY, pendingIntent); - - assertThat(info.getSummary()).isEqualTo(TEST_SUMMARY); - } - - @Test - public void getPendingIntent_setValidPendingIntent_shouldReturnSameCorrectIntent() { - final PendingIntent pendingIntent = createTestPendingIntent(mContext); - final ScheduleInfo info = createTestScheduleInfo(TEST_TITLE, TEST_SUMMARY, pendingIntent); - - assertThat(info.getPendingIntent()).isEqualTo(pendingIntent); - } - - private static PendingIntent createTestPendingIntent(Context context) { - final Intent intent = new Intent("android.settings.NIGHT_DISPLAY_SETTINGS").addCategory( - Intent.CATEGORY_DEFAULT); - return PendingIntent.getActivity(context, 0 /* requestCode */, intent, 0 /* flags */); - } - - private static ScheduleInfo createTestScheduleInfo(String title, String summary, - PendingIntent pendingIntent) { - return new ScheduleInfo.Builder() - .setTitle(title) - .setSummary(summary) - .setPendingIntent(pendingIntent) - .build(); - } -} diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/schedulesprovider/SchedulesProviderTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/schedulesprovider/SchedulesProviderTest.java deleted file mode 100644 index 6b92082b11037..0000000000000 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/schedulesprovider/SchedulesProviderTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2020 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.settingslib.schedulesprovider; - -import static com.google.common.truth.Truth.assertThat; - -import static org.robolectric.Shadows.shadowOf; - -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; - -import java.util.ArrayList; - -@RunWith(RobolectricTestRunner.class) -public class SchedulesProviderTest { - private static final String INVALID_PACKAGE = "com.android.sunny"; - private static final String VALID_PACKAGE = "com.android.settings"; - private static final String INVALID_METHOD = "queryTestData"; - - private final Context mContext = RuntimeEnvironment.application; - - private TestSchedulesProvider mProvider; - - @Before - public void setUp() { - mProvider = Robolectric.setupContentProvider(TestSchedulesProvider.class); - shadowOf(mProvider).setCallingPackage(VALID_PACKAGE); - mProvider.setScheduleInfos(TestSchedulesProvider.createOneValidScheduleInfo(mContext)); - } - - @Test - public void call_invalidCallingPkg_returnNull() { - shadowOf(mProvider).setCallingPackage(INVALID_PACKAGE); - - final Bundle bundle = mProvider.call(SchedulesProvider.METHOD_GENERATE_SCHEDULE_INFO_LIST, - null /* arg */, null /* extras */); - - assertThat(bundle).isNull(); - } - - @Test - public void call_invalidMethod_returnBundleWithoutScheduleInfoData() { - final Bundle bundle = mProvider.call(INVALID_METHOD, null /* arg */, null /* extras */); - - assertThat(bundle).isNotNull(); - assertThat(bundle.containsKey(SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST)).isFalse(); - } - - @Test - public void call_validMethod_returnScheduleInfoData() { - final Bundle bundle = mProvider.call(SchedulesProvider.METHOD_GENERATE_SCHEDULE_INFO_LIST, - null /* arg */, null /* extras */); - - assertThat(bundle).isNotNull(); - assertThat(bundle.containsKey(SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST)).isTrue(); - final ArrayList infos = bundle.getParcelableArrayList( - SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST); - assertThat(infos).hasSize(1); - } - - @Test - public void call_addTwoValidData_returnScheduleInfoData() { - mProvider.setScheduleInfos(TestSchedulesProvider.createTwoValidScheduleInfos(mContext)); - final Bundle bundle = mProvider.call(SchedulesProvider.METHOD_GENERATE_SCHEDULE_INFO_LIST, - null /* arg */, null /* extras */); - - assertThat(bundle).isNotNull(); - assertThat(bundle.containsKey(SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST)).isTrue(); - final ArrayList infos = bundle.getParcelableArrayList( - SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST); - assertThat(infos).hasSize(2); - } - - @Test - public void call_addTwoValidDataAndOneInvalidData_returnTwoScheduleInfoData() { - mProvider.setScheduleInfos( - TestSchedulesProvider.createTwoValidAndOneInvalidScheduleInfo(mContext)); - final Bundle bundle = mProvider.call(SchedulesProvider.METHOD_GENERATE_SCHEDULE_INFO_LIST, - null /* arg */, null /* extras */); - - assertThat(bundle).isNotNull(); - assertThat(bundle.containsKey(SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST)).isTrue(); - final ArrayList infos = bundle.getParcelableArrayList( - SchedulesProvider.BUNDLE_SCHEDULE_INFO_LIST); - assertThat(infos).hasSize(2); - } - - private static class TestSchedulesProvider extends SchedulesProvider { - private ArrayList mScheduleInfos = new ArrayList<>(); - - @Override - public ArrayList getScheduleInfoList() { - return mScheduleInfos; - } - - void setScheduleInfos(ArrayList scheduleInfos) { - mScheduleInfos = scheduleInfos; - } - - private static ArrayList createOneValidScheduleInfo(Context context) { - final ArrayList scheduleInfos = new ArrayList<>(); - - final ScheduleInfo info = new ScheduleInfo.Builder().setTitle("Night Light").setSummary( - "This a sunny test").setPendingIntent(createTestPendingIntent(context, - "android.settings.NIGHT_DISPLAY_SETTINGS")).build(); - scheduleInfos.add(info); - - return scheduleInfos; - } - - private static ArrayList createTwoValidScheduleInfos(Context context) { - final ArrayList scheduleInfos = new ArrayList<>(); - ScheduleInfo info = new ScheduleInfo.Builder().setTitle("Night Light").setSummary( - "This a sunny test").setPendingIntent(createTestPendingIntent(context, - "android.settings.NIGHT_DISPLAY_SETTINGS")).build(); - scheduleInfos.add(info); - - info = new ScheduleInfo.Builder().setTitle("Display").setSummary( - "Display summary").setPendingIntent( - createTestPendingIntent(context, "android.settings.DISPLAY_SETTINGS")).build(); - scheduleInfos.add(info); - - return scheduleInfos; - } - - private static ArrayList createTwoValidAndOneInvalidScheduleInfo( - Context context) { - final ArrayList scheduleInfos = new ArrayList<>(); - ScheduleInfo info = new ScheduleInfo.Builder().setTitle("Night Light").setSummary( - "This a sunny test").setPendingIntent(createTestPendingIntent(context, - "android.settings.NIGHT_DISPLAY_SETTINGS")).build(); - scheduleInfos.add(info); - - info = new ScheduleInfo.Builder().setTitle("Display").setSummary( - "Display summary").setPendingIntent( - createTestPendingIntent(context, "android.settings.DISPLAY_SETTINGS")).build(); - scheduleInfos.add(info); - - info = new ScheduleInfo.Builder().setTitle("").setSummary( - "Display summary").setPendingIntent( - createTestPendingIntent(context, "android.settings.DISPLAY_SETTINGS")).build(); - scheduleInfos.add(info); - - return scheduleInfos; - } - - private static PendingIntent createTestPendingIntent(Context context, String action) { - final Intent intent = new Intent(action).addCategory(Intent.CATEGORY_DEFAULT); - return PendingIntent.getActivity(context, 0 /* requestCode */, intent, 0 /* flags */); - } - } -}