feat(A11yFeedback): Pixel overlay to expose the feedback bucket ID

This change introduces a feature provider for Pixel overlays, allowing
customization of the feedback bucket ID on Android.

Bug: 393980229
Test: Manual testing for Pixel and non-Pixel overlay in real device
Test: atest AccessibilitySettingsTest
            FeedbackManagerTest
Flag: com.android.server.accessibility.enable_low_vision_generic_feedback
Change-Id: Ieeb1dba4de5c13a275e66781621cbfcca7219a5e
This commit is contained in:
Menghan Li
2025-02-14 03:01:41 +00:00
parent c86e2f3472
commit 6b916e6f29
10 changed files with 178 additions and 32 deletions

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2025 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.accessibility;
import android.content.ComponentName;
import androidx.annotation.Nullable;
/**
* Provider for Accessibility feedback related features.
*/
public interface AccessibilityFeedbackFeatureProvider {
/**
* Returns value according to the {@code componentName}.
*
* @param componentName the component name of the downloaded service or activity
* @return Feedback bucket ID
*/
@Nullable
String getCategory(@Nullable ComponentName componentName);
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2025 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.accessibility;
import android.content.ComponentName;
import androidx.annotation.Nullable;
/** Default implementation of {@link AccessibilityFeedbackFeatureProvider}. */
public class AccessibilityFeedbackFeatureProviderImpl implements
AccessibilityFeedbackFeatureProvider{
@Override
@Nullable
public String getCategory(@Nullable ComponentName componentName) {
return "";
}
}

View File

@@ -16,6 +16,7 @@
package com.android.settings.accessibility;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.text.TextUtils;
@@ -23,6 +24,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.server.accessibility.Flags;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.DeviceInfoUtils;
import java.lang.ref.WeakReference;
@@ -33,14 +35,11 @@ import java.lang.ref.WeakReference;
*/
public class FeedbackManager {
// TODO(b/393980229): Add a feature provider for Pixel overlay to expose the feedback bucket ID
static final String ACCESSIBILITY_FEEDBACK_REQUEST_BUCKET_ID =
"com.google.android.settings.intelligence.ACCESSIBILITY_FEEDBACK_REQUEST";
static final String CATEGORY_TAG = "category_tag";
private static final int FEEDBACK_INTENT_RESULT_CODE = 0;
private final WeakReference<Activity> mActivityWeakReference;
@Nullable private final String mFeedbackReporterPackage;
@Nullable private final String mReporterPackage;
@Nullable private final String mCategoryTag;
/**
@@ -49,14 +48,36 @@ public class FeedbackManager {
* @param activity The activity context. A WeakReference is used to prevent memory leaks.
*/
public FeedbackManager(@Nullable Activity activity) {
this(activity, DeviceInfoUtils.getFeedbackReporterPackage(activity));
this(activity, /* componentName= */ null);
}
/**
* Constructs a new FeedbackManager.
*
* @param activity The activity context. A WeakReference is used to prevent memory leaks.
* @param componentName The component name associated with the feedback.
*/
public FeedbackManager(@Nullable Activity activity, @Nullable ComponentName componentName) {
this(activity,
DeviceInfoUtils.getFeedbackReporterPackage(activity),
FeatureFactory.getFeatureFactory()
.getAccessibilityFeedbackFeatureProvider()
.getCategory(componentName));
}
/**
* Constructs a new FeedbackManager. This constructor is visible for testing.
*
* @param activity The activity context. A WeakReference is used to prevent memory leaks.
* @param reporterPackage The package name of the feedback reporter.
* @param category The feedback bucket ID.
*/
@VisibleForTesting
public FeedbackManager(@Nullable Activity activity, @Nullable String feedbackReporterPackage) {
public FeedbackManager(@Nullable Activity activity, @Nullable String reporterPackage,
@Nullable String category) {
this.mActivityWeakReference = new WeakReference<>(activity);
this.mFeedbackReporterPackage = feedbackReporterPackage;
this.mCategoryTag = ACCESSIBILITY_FEEDBACK_REQUEST_BUCKET_ID;
this.mReporterPackage = reporterPackage;
this.mCategoryTag = category;
}
/**
@@ -69,7 +90,9 @@ public class FeedbackManager {
return false;
}
return !TextUtils.isEmpty(mFeedbackReporterPackage) && mActivityWeakReference.get() != null;
return !TextUtils.isEmpty(mReporterPackage)
&& !TextUtils.isEmpty(mCategoryTag)
&& mActivityWeakReference.get() != null;
}
/**
@@ -87,7 +110,7 @@ public class FeedbackManager {
}
final Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
intent.setPackage(mFeedbackReporterPackage);
intent.setPackage(mReporterPackage);
intent.putExtra(CATEGORY_TAG, mCategoryTag);
activity.startActivityForResult(intent, FEEDBACK_INTENT_RESULT_CODE);
return true;

View File

@@ -16,6 +16,7 @@
package com.android.settings.overlay
import android.content.Context
import com.android.settings.accessibility.AccessibilityFeedbackFeatureProvider
import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
import com.android.settings.accounts.AccountFeatureProvider
@@ -133,6 +134,11 @@ abstract class FeatureFactory {
*/
abstract val securitySettingsFeatureProvider: SecuritySettingsFeatureProvider
/**
* Retrieves implementation for Accessibility feedback category feature.
*/
abstract val accessibilityFeedbackFeatureProvider: AccessibilityFeedbackFeatureProvider
/**
* Retrieves implementation for Accessibility search index feature.
*/

View File

@@ -20,6 +20,8 @@ import android.content.Context
import android.net.ConnectivityManager
import android.net.VpnManager
import android.os.UserManager
import com.android.settings.accessibility.AccessibilityFeedbackFeatureProvider
import com.android.settings.accessibility.AccessibilityFeedbackFeatureProviderImpl
import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
import com.android.settings.accessibility.AccessibilityMetricsFeatureProviderImpl
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
@@ -165,6 +167,9 @@ open class FeatureFactoryImpl : FeatureFactory() {
SecuritySettingsFeatureProviderImpl()
}
override val accessibilityFeedbackFeatureProvider: AccessibilityFeedbackFeatureProvider
by lazy { AccessibilityFeedbackFeatureProviderImpl() }
override val accessibilitySearchFeatureProvider: AccessibilitySearchFeatureProvider by lazy {
AccessibilitySearchFeatureProviderImpl()
}