feat(A11yFeedback): Add feedback entry for downloaded Accessibility

This entry point allows users to access in the action bar.
Visibility is controlled by the aconfig and FeedbackManager#isAvailable

Bug: 393980229
Test: Manual testing on Pixel and non-Pixel devices
Test: atest ToggleFeaturePreferenceFragmentTest
Flag: com.android.server.accessibility.enable_low_vision_generic_feedback
Change-Id: Ie6dfb6a887fe5a894622e86bab39878f8adea758
This commit is contained in:
Menghan Li
2025-03-04 09:20:33 +00:00
parent bcddc529ba
commit 9ffca7cbfc
9 changed files with 143 additions and 2 deletions

View File

@@ -232,6 +232,7 @@ public class AccessibilityDetailsSettingsFragment extends InstrumentedFragment {
.getAccessibilityMetricsFeatureProvider()
.getDownloadedFeatureMetricsCategory(componentName);
extras.putInt(AccessibilitySettings.EXTRA_METRICS_CATEGORY, metricsCategory);
extras.putInt(AccessibilitySettings.EXTRA_FEEDBACK_CATEGORY, metricsCategory);
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
extras.putInt(AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES, info.getAnimatedImageRes());

View File

@@ -97,6 +97,7 @@ public class AccessibilitySettings extends DashboardFragment implements
static final String EXTRA_HTML_DESCRIPTION = "html_description";
static final String EXTRA_TIME_FOR_LOGGING = "start_time_to_log_a11y_tool";
static final String EXTRA_METRICS_CATEGORY = "metrics_category";
static final String EXTRA_FEEDBACK_CATEGORY = "feedback_category";
// Timeout before we update the services if packages are added/removed
// since the AccessibilityManagerService has to do that processing first

View File

@@ -57,6 +57,11 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
return getArguments().getInt(AccessibilitySettings.EXTRA_METRICS_CATEGORY);
}
@Override
public int getFeedbackCategory() {
return getArguments().getInt(AccessibilitySettings.EXTRA_FEEDBACK_CATEGORY);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -217,6 +217,7 @@ public class RestrictedPreferenceHelper {
extras.putInt(AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES, imageRes);
extras.putString(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, htmlDescription);
extras.putInt(AccessibilitySettings.EXTRA_METRICS_CATEGORY, metricsCategory);
extras.putInt(AccessibilitySettings.EXTRA_FEEDBACK_CATEGORY, metricsCategory);
}
/**

View File

@@ -73,6 +73,11 @@ public class ToggleAccessibilityServicePreferenceFragment extends
return getArguments().getInt(AccessibilitySettings.EXTRA_METRICS_CATEGORY);
}
@Override
public int getFeedbackCategory() {
return getArguments().getInt(AccessibilitySettings.EXTRA_FEEDBACK_CATEGORY);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@@ -40,6 +40,9 @@ import android.service.quicksettings.TileService;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
@@ -48,6 +51,7 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -89,6 +93,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
// <img src="R.drawable.fileName"/>, a11y settings will get the resources successfully.
private static final String IMG_PREFIX = "R.drawable.";
private static final String DRAWABLE_FOLDER = "drawable";
static final int MENU_ID_SEND_FEEDBACK = 0;
protected TopIntroPreference mTopIntroPreference;
protected SettingsMainSwitchPreference mToggleServiceSwitchPreference;
@@ -102,6 +107,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
protected Intent mSettingsIntent;
// The mComponentName maybe null, such as Magnify
protected ComponentName mComponentName;
@Nullable private FeedbackManager mFeedbackManager;
protected CharSequence mFeatureName;
protected Uri mImageUri;
protected CharSequence mHtmlDescription;
@@ -240,6 +246,24 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
removeActionBarToggleSwitch();
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
if (getFeedbackManager().isAvailable()) {
menu.add(Menu.NONE, MENU_ID_SEND_FEEDBACK, Menu.NONE,
R.string.accessibility_send_feedback_title);
}
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == MENU_ID_SEND_FEEDBACK) {
getFeedbackManager().sendFeedback();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public int getDialogMetricsCategory(int dialogId) {
switch (dialogId) {
@@ -739,4 +763,28 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
super.onCreateRecyclerView(inflater, parent, savedInstanceState);
return AccessibilityFragmentUtils.addCollectionInfoToAccessibilityDelegate(recyclerView);
}
@VisibleForTesting
void setFeedbackManager(FeedbackManager feedbackManager) {
this.mFeedbackManager = feedbackManager;
}
private FeedbackManager getFeedbackManager() {
if (mFeedbackManager == null) {
mFeedbackManager = new FeedbackManager(getActivity(), getFeedbackCategory());
}
return mFeedbackManager;
}
/**
* Returns the category of the feedback page.
*
* <p>By default, this method returns {@link SettingsEnums#PAGE_UNKNOWN}. This indicates that
* the feedback category is unknown, and the absence of a feedback menu.
*
* @return The feedback category, which is {@link SettingsEnums#PAGE_UNKNOWN} by default.
*/
protected int getFeedbackCategory() {
return SettingsEnums.PAGE_UNKNOWN;
}
}

View File

@@ -79,6 +79,12 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizard
return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
}
@Override
public int getFeedbackCategory() {
// The feedback options should not be displayed on the setup wizard page.
return SettingsEnums.PAGE_UNKNOWN;
}
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.

View File

@@ -79,6 +79,12 @@ public class ToggleSelectToSpeakPreferenceFragmentForSetupWizard
return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK;
}
@Override
public int getFeedbackCategory() {
// The feedback options should not be displayed on the setup wizard page.
return SettingsEnums.PAGE_UNKNOWN;
}
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.