feat(A11yFeedback): Implements page ID to feedback bucket ID mapping
This change adds a new API to a Pixel overlay feature provider, allowing Android to map page IDs to feedback bucket IDs. 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: I8a110b08816cac9c8a8e8c3e1218530fffb6f121
This commit is contained in:
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,11 +23,11 @@ import androidx.annotation.Nullable;
|
|||||||
public interface AccessibilityFeedbackFeatureProvider {
|
public interface AccessibilityFeedbackFeatureProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns value according to the {@code componentName}.
|
* Returns value according to the {@code pageId}.
|
||||||
*
|
*
|
||||||
* @param componentName the component name of the downloaded service or activity
|
* @param pageId The unique identifier of the page.
|
||||||
* @return Feedback bucket ID
|
* @return Feedback bucket ID associated with the page, or {@code null} if is not found.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
String getCategory(@Nullable ComponentName componentName);
|
String getCategory(int pageId);
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
/** Default implementation of {@link AccessibilityFeedbackFeatureProvider}. */
|
/** Default implementation of {@link AccessibilityFeedbackFeatureProvider}. */
|
||||||
@@ -25,7 +23,7 @@ public class AccessibilityFeedbackFeatureProviderImpl implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getCategory(@Nullable ComponentName componentName) {
|
public String getCategory(int pageId) {
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -255,7 +255,7 @@ public class AccessibilitySettings extends DashboardFragment implements
|
|||||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
if (getFeedbackManager().isAvailable()) {
|
if (getFeedbackManager().isAvailable()) {
|
||||||
menu.add(Menu.NONE, MENU_ID_SEND_FEEDBACK, Menu.NONE,
|
menu.add(Menu.NONE, MENU_ID_SEND_FEEDBACK, Menu.NONE,
|
||||||
getPrefContext().getText(R.string.accessibility_send_feedback_title));
|
R.string.accessibility_send_feedback_title);
|
||||||
}
|
}
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public class AccessibilitySettings extends DashboardFragment implements
|
|||||||
|
|
||||||
private FeedbackManager getFeedbackManager() {
|
private FeedbackManager getFeedbackManager() {
|
||||||
if (mFeedbackManager == null) {
|
if (mFeedbackManager == null) {
|
||||||
mFeedbackManager = new FeedbackManager(getActivity());
|
mFeedbackManager = new FeedbackManager(getActivity(), SettingsEnums.ACCESSIBILITY);
|
||||||
}
|
}
|
||||||
return mFeedbackManager;
|
return mFeedbackManager;
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
@@ -46,23 +45,14 @@ public class FeedbackManager {
|
|||||||
* Constructs a new FeedbackManager.
|
* Constructs a new FeedbackManager.
|
||||||
*
|
*
|
||||||
* @param activity The activity context. A WeakReference is used to prevent memory leaks.
|
* @param activity The activity context. A WeakReference is used to prevent memory leaks.
|
||||||
|
* @param pageId The unique identifier of the page associated with the feedback.
|
||||||
*/
|
*/
|
||||||
public FeedbackManager(@Nullable Activity activity) {
|
public FeedbackManager(@Nullable Activity activity, int pageId) {
|
||||||
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,
|
this(activity,
|
||||||
DeviceInfoUtils.getFeedbackReporterPackage(activity),
|
DeviceInfoUtils.getFeedbackReporterPackage(activity),
|
||||||
FeatureFactory.getFeatureFactory()
|
FeatureFactory.getFeatureFactory()
|
||||||
.getAccessibilityFeedbackFeatureProvider()
|
.getAccessibilityFeedbackFeatureProvider()
|
||||||
.getCategory(componentName));
|
.getCategory(pageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,7 +22,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -458,12 +457,10 @@ public class AccessibilitySettingsTest {
|
|||||||
setupFragment();
|
setupFragment();
|
||||||
mFragment.setFeedbackManager(
|
mFragment.setFeedbackManager(
|
||||||
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
||||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
|
||||||
|
|
||||||
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
||||||
|
|
||||||
verify(mMenu).add(anyInt(), eq(AccessibilitySettings.MENU_ID_SEND_FEEDBACK),
|
verify(mMenu).add(anyInt(), anyInt(), anyInt(), anyInt());
|
||||||
anyInt(), eq(mContext.getText(R.string.accessibility_send_feedback_title)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -472,12 +469,10 @@ public class AccessibilitySettingsTest {
|
|||||||
setupFragment();
|
setupFragment();
|
||||||
mFragment.setFeedbackManager(
|
mFragment.setFeedbackManager(
|
||||||
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
||||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
|
||||||
|
|
||||||
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
||||||
|
|
||||||
verify(mMenu, never()).add(anyInt(), eq(AccessibilitySettings.MENU_ID_SEND_FEEDBACK),
|
verify(mMenu, never()).add(anyInt(), anyInt(), anyInt(), anyInt());
|
||||||
anyInt(), eq(mContext.getText(R.string.accessibility_send_feedback_title)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -486,8 +481,6 @@ public class AccessibilitySettingsTest {
|
|||||||
setupFragment();
|
setupFragment();
|
||||||
mFragment.setFeedbackManager(
|
mFragment.setFeedbackManager(
|
||||||
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
||||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
|
||||||
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
|
||||||
when(mMenuItem.getItemId()).thenReturn(AccessibilitySettings.MENU_ID_SEND_FEEDBACK);
|
when(mMenuItem.getItemId()).thenReturn(AccessibilitySettings.MENU_ID_SEND_FEEDBACK);
|
||||||
|
|
||||||
mFragment.onOptionsItemSelected(mMenuItem);
|
mFragment.onOptionsItemSelected(mMenuItem);
|
||||||
@@ -502,8 +495,6 @@ public class AccessibilitySettingsTest {
|
|||||||
setupFragment();
|
setupFragment();
|
||||||
mFragment.setFeedbackManager(
|
mFragment.setFeedbackManager(
|
||||||
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
||||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
|
||||||
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
|
||||||
when(mMenuItem.getItemId()).thenReturn(AccessibilitySettings.MENU_ID_SEND_FEEDBACK);
|
when(mMenuItem.getItemId()).thenReturn(AccessibilitySettings.MENU_ID_SEND_FEEDBACK);
|
||||||
|
|
||||||
mFragment.onOptionsItemSelected(mMenuItem);
|
mFragment.onOptionsItemSelected(mMenuItem);
|
||||||
|
Reference in New Issue
Block a user