Merge "Remove legacy flag for time feedback" into main

This commit is contained in:
Kanyinsola Fapohunda
2025-02-28 07:31:15 -08:00
committed by Android (Google) Code Review
5 changed files with 32 additions and 101 deletions

View File

@@ -1,52 +0,0 @@
/*
* 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.settings.datetime;
import static android.provider.DeviceConfig.NAMESPACE_SYSTEM_TIME;
import android.provider.DeviceConfig;
import com.android.settings.flags.Flags;
/** A class to avoid duplication of launch-control logic for "time feedback" support. */
final class DateTimeLaunchUtils {
/**
* A {@link DeviceConfig} flag that influences whether the settings entries related to help and
* feedback are supported on this device / for this user.
*/
public static final String KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED =
"time_help_and_feedback_feature_supported";
private DateTimeLaunchUtils() {}
static boolean isFeedbackFeatureSupported() {
// Support is determined according to:
// 1) A build-time flag to determine release feature availability.
// 2) A runtime / server-side flag to determine which devices / who gets to see the feature.
// This is launch control for limiting the feedback to droidfooding.
return isFeedbackFeatureSupportedThisRelease() && isFeedbackFeatureSupportedOnThisDevice();
}
private static boolean isFeedbackFeatureSupportedThisRelease() {
return Flags.datetimeFeedback();
}
private static boolean isFeedbackFeatureSupportedOnThisDevice() {
boolean defaultIsSupported = false;
return DeviceConfig.getBoolean(
NAMESPACE_SYSTEM_TIME, KEY_HELP_AND_FEEDBACK_FEATURE_SUPPORTED, defaultIsSupported);
}
}

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import androidx.annotation.NonNull;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.flags.Flags;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
@@ -48,7 +49,7 @@ public class TimeFeedbackPreferenceCategoryController extends BasePreferenceCont
@Override
public int getAvailabilityStatus() {
// Firstly, hide the category if it is not enabled by flags.
if (!isTimeFeedbackFeatureEnabled()) {
if (!Flags.datetimeFeedback()) {
return UNSUPPORTED_ON_DEVICE;
}
@@ -60,8 +61,4 @@ public class TimeFeedbackPreferenceCategoryController extends BasePreferenceCont
}
return UNSUPPORTED_ON_DEVICE;
}
protected boolean isTimeFeedbackFeatureEnabled() {
return DateTimeLaunchUtils.isFeedbackFeatureSupported();
}
}

View File

@@ -32,6 +32,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.flags.Flags;
import java.net.URISyntaxException;
@@ -47,7 +48,6 @@ public class TimeFeedbackPreferenceController
private final PackageManager mPackageManager;
private final String mIntentUri;
private final int mAvailabilityStatus;
public TimeFeedbackPreferenceController(Context context, String preferenceKey) {
this(context, context.getPackageManager(), preferenceKey, context.getResources().getString(
@@ -60,7 +60,6 @@ public class TimeFeedbackPreferenceController
super(context, preferenceKey);
mPackageManager = packageManager;
mIntentUri = intentUri;
mAvailabilityStatus = TextUtils.isEmpty(mIntentUri) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
/**
@@ -75,13 +74,12 @@ public class TimeFeedbackPreferenceController
@Override
public int getAvailabilityStatus() {
if (!DateTimeLaunchUtils.isFeedbackFeatureSupported()) {
if (!Flags.datetimeFeedback() || TextUtils.isEmpty(mIntentUri)) {
return UNSUPPORTED_ON_DEVICE;
}
if (!isTimeFeedbackTargetAvailable()) {
} else if (!isTimeFeedbackTargetAvailable()) {
return CONDITIONALLY_UNAVAILABLE;
}
return mAvailabilityStatus;
return AVAILABLE;
}
@Override