Snap for 13076573 from be9c39f0aa to 25Q2-release
Change-Id: I06ad0e0cee2e3d375f7ed299ccbf8062da4cfe56
This commit is contained in:
17
res/drawable/storage_progress_bar.xml
Normal file
17
res/drawable/storage_progress_bar.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="@color/settingslib_materialColorSurfaceContainerHighest" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="@color/settingslib_materialColorPrimary" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -74,7 +74,8 @@
|
||||
android:max="100"
|
||||
android:layout_below="@android:id/title"
|
||||
app:layout_constraintTop_toBottomOf="@android:id/title"
|
||||
style="?android:attr/progressBarStyleHorizontal" />
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:progressDrawable="@drawable/storage_progress_bar" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -5167,6 +5167,8 @@
|
||||
<string name="accessibility_feedback_summary">Help improve by taking a survey</string>
|
||||
<!-- Summary for the accessibility feedback preference is disabled. [CHAR LIMIT=100] -->
|
||||
<string name="accessibility_feedback_disabled_summary">No surveys available</string>
|
||||
<!-- The menu item to start the feedback process for the accessibility [CHAR LIMIT=30] -->
|
||||
<string name="accessibility_send_feedback_title">Send feedback</string>
|
||||
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
|
||||
<string name="user_installed_services_category_title">Downloaded apps</string>
|
||||
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
android:key="mobile_network_spn"
|
||||
android:title="@string/mobile_network_spn_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
settings:controller="com.android.settings.network.telephony.MobileNetworkSpnPreferenceController"
|
||||
settings:allowDividerAbove="true" />
|
||||
|
||||
@@ -60,7 +59,6 @@
|
||||
android:key="phone_number"
|
||||
android:title="@string/status_number"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
settings:controller="com.android.settings.network.telephony.MobileNetworkPhoneNumberPreferenceController"
|
||||
settings:allowDividerBelow="true"
|
||||
settings:enableCopying="true"/>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
android:order="3"
|
||||
android:title="@string/status_number"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
settings:isPreferenceVisible="@bool/config_show_sim_info"
|
||||
settings:controller="com.android.settings.deviceinfo.PhoneNumberPreferenceController"
|
||||
settings:enableCopying="true"/>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
android:icon="@drawable/ic_storage"
|
||||
android:order="3"
|
||||
settings:controller="com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController"/>
|
||||
<com.android.settings.widget.CardPreference
|
||||
<com.android.settingslib.widget.CardPreference
|
||||
android:key="free_up_space"
|
||||
android:order="4"
|
||||
android:title="@string/storage_free_up_space_title"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 "";
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,9 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -101,6 +104,8 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
// presentation.
|
||||
private static final long DELAY_UPDATE_SERVICES_MILLIS = 1000;
|
||||
|
||||
static final int MENU_ID_SEND_FEEDBACK = 0;
|
||||
|
||||
private final Handler mHandler = new Handler();
|
||||
|
||||
private final Runnable mUpdateRunnable = new Runnable() {
|
||||
@@ -143,8 +148,9 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
AccessibilitySettingsContentObserver mSettingsContentObserver;
|
||||
private AccessibilitySettingsContentObserver mSettingsContentObserver;
|
||||
|
||||
private FeedbackManager mFeedbackManager;
|
||||
|
||||
private final Map<String, PreferenceCategory> mCategoryToPrefCategoryMap =
|
||||
new ArrayMap<>();
|
||||
@@ -245,6 +251,24 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
if (getFeedbackManager().isAvailable()) {
|
||||
menu.add(Menu.NONE, MENU_ID_SEND_FEEDBACK, Menu.NONE,
|
||||
getPrefContext().getText(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
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.accessibility_settings;
|
||||
@@ -255,6 +279,18 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setFeedbackManager(FeedbackManager feedbackManager) {
|
||||
this.mFeedbackManager = feedbackManager;
|
||||
}
|
||||
|
||||
private FeedbackManager getFeedbackManager() {
|
||||
if (mFeedbackManager == null) {
|
||||
mFeedbackManager = new FeedbackManager(getActivity());
|
||||
}
|
||||
return mFeedbackManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summary for the current state of this accessibilityService.
|
||||
*
|
||||
|
||||
118
src/com/android/settings/accessibility/FeedbackManager.java
Normal file
118
src/com/android/settings/accessibility/FeedbackManager.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Manages the feedback flow. This class is responsible for checking feedback availability and
|
||||
* sending feedback. Uses a WeakReference to the Activity to prevent memory leaks.
|
||||
*/
|
||||
public class FeedbackManager {
|
||||
|
||||
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 mReporterPackage;
|
||||
@Nullable private final String mCategoryTag;
|
||||
|
||||
/**
|
||||
* Constructs a new FeedbackManager.
|
||||
*
|
||||
* @param activity The activity context. A WeakReference is used to prevent memory leaks.
|
||||
*/
|
||||
public FeedbackManager(@Nullable Activity 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 reporterPackage,
|
||||
@Nullable String category) {
|
||||
this.mActivityWeakReference = new WeakReference<>(activity);
|
||||
this.mReporterPackage = reporterPackage;
|
||||
this.mCategoryTag = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if feedback is available on the device.
|
||||
*
|
||||
* @return {@code true} if feedback is available, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
if (!Flags.enableLowVisionGenericFeedback()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !TextUtils.isEmpty(mReporterPackage)
|
||||
&& !TextUtils.isEmpty(mCategoryTag)
|
||||
&& mActivityWeakReference.get() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends feedback using the available feedback reporter. This will start the feedback
|
||||
* activity. It is the responsibility of the calling activity to handle the result
|
||||
* code {@link #FEEDBACK_INTENT_RESULT_CODE} if necessary.
|
||||
*
|
||||
* @return {@code true} if the feedback intent was successfully started, {@code false}
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean sendFeedback() {
|
||||
Activity activity = mActivityWeakReference.get();
|
||||
if (!isAvailable() || activity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
|
||||
intent.setPackage(mReporterPackage);
|
||||
intent.putExtra(CATEGORY_TAG, mCategoryTag);
|
||||
activity.startActivityForResult(intent, FEEDBACK_INTENT_RESULT_CODE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
||||
final SatelliteSettingPreferenceController satelliteSettingPreferenceController = use(
|
||||
SatelliteSettingPreferenceController.class);
|
||||
if (satelliteSettingPreferenceController != null) {
|
||||
satelliteSettingPreferenceController.init(mSubId);
|
||||
satelliteSettingPreferenceController.initialize(mSubId);
|
||||
}
|
||||
|
||||
use(ApnPreferenceController.class).init(mSubId);
|
||||
|
||||
@@ -160,7 +160,7 @@ public class SatelliteSettingPreferenceController extends
|
||||
*
|
||||
* @param subId subscription ID.
|
||||
*/
|
||||
public void init(int subId) {
|
||||
public void initialize(int subId) {
|
||||
logd("init(), subId=" + subId);
|
||||
mSubId = subId;
|
||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -21,7 +21,11 @@ import static com.android.internal.accessibility.common.ShortcutConstants.UserSh
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
@@ -43,6 +47,8 @@ import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -107,13 +113,15 @@ public class AccessibilitySettingsTest {
|
||||
private static final String EMPTY_STRING = "";
|
||||
private static final String DEFAULT_SUMMARY = "default summary";
|
||||
private static final String DEFAULT_DESCRIPTION = "default description";
|
||||
private static final String DEFAULT_CATEGORY = "default category";
|
||||
private static final String DEFAULT_LABEL = "default label";
|
||||
private static final Boolean SERVICE_ENABLED = true;
|
||||
private static final Boolean SERVICE_DISABLED = false;
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
@Spy
|
||||
private final AccessibilityServiceInfo mServiceInfo = getMockAccessibilityServiceInfo(
|
||||
@@ -121,7 +129,13 @@ public class AccessibilitySettingsTest {
|
||||
private ShadowAccessibilityManager mShadowAccessibilityManager;
|
||||
@Mock
|
||||
private LocalBluetoothManager mLocalBluetoothManager;
|
||||
@Mock
|
||||
private Menu mMenu;
|
||||
@Mock
|
||||
private MenuItem mMenuItem;
|
||||
|
||||
private ActivityController<SettingsActivity> mActivityController;
|
||||
|
||||
private AccessibilitySettings mFragment;
|
||||
|
||||
@Before
|
||||
@@ -438,6 +452,66 @@ public class AccessibilitySettingsTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void onCreateOptionsMenu_enableLowVisionGenericFeedback_shouldAddSendFeedbackMenu() {
|
||||
setupFragment();
|
||||
mFragment.setFeedbackManager(
|
||||
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
||||
|
||||
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
||||
|
||||
verify(mMenu).add(anyInt(), eq(AccessibilitySettings.MENU_ID_SEND_FEEDBACK),
|
||||
anyInt(), eq(mContext.getText(R.string.accessibility_send_feedback_title)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void onCreateOptionsMenu_disableLowVisionGenericFeedback_shouldNotAddSendFeedbackMenu() {
|
||||
setupFragment();
|
||||
mFragment.setFeedbackManager(
|
||||
new FeedbackManager(mFragment.getActivity(), PACKAGE_NAME, DEFAULT_CATEGORY));
|
||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
||||
|
||||
mFragment.onCreateOptionsMenu(mMenu, /* inflater= */ null);
|
||||
|
||||
verify(mMenu, never()).add(anyInt(), eq(AccessibilitySettings.MENU_ID_SEND_FEEDBACK),
|
||||
anyInt(), eq(mContext.getText(R.string.accessibility_send_feedback_title)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void onOptionsItemSelected_enableLowVisionGenericFeedback_shouldStartSendFeedback() {
|
||||
setupFragment();
|
||||
mFragment.setFeedbackManager(
|
||||
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);
|
||||
|
||||
mFragment.onOptionsItemSelected(mMenuItem);
|
||||
|
||||
Intent startedIntent = shadowOf(mFragment.getActivity()).getNextStartedActivity();
|
||||
assertThat(startedIntent).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void onOptionsItemSelected_disableLowVisionGenericFeedback_shouldNotStartSendFeedback() {
|
||||
setupFragment();
|
||||
mFragment.setFeedbackManager(
|
||||
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);
|
||||
|
||||
mFragment.onOptionsItemSelected(mMenuItem);
|
||||
|
||||
Intent startedIntent = shadowOf(mFragment.getActivity()).getNextStartedActivity();
|
||||
assertThat(startedIntent).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccessibilityMenuInSystem_IncludedInInteractionControl() {
|
||||
mShadowAccessibilityManager.setInstalledAccessibilityServiceList(
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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 static com.android.settings.accessibility.FeedbackManager.CATEGORY_TAG;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import com.android.server.accessibility.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.Shadows;
|
||||
|
||||
/** Tests for {@link FeedbackManager}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class FeedbackManagerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
private static final String PACKAGE_NAME = "test.feedback.package";
|
||||
private static final String DEFAULT_CATEGORY = "default category";
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mActivity = Robolectric.buildActivity(Activity.class).create().get();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void isAvailable_enableLowVisionGenericFeedbackWithValidParams_returnsTrue() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, PACKAGE_NAME, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void isAvailable_disableLowVisionGenericFeedback_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, PACKAGE_NAME, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void isAvailable_withNullCategory_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, PACKAGE_NAME, /* category= */ null);
|
||||
|
||||
assertThat(feedbackManager.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void isAvailable_withNullReporterPackage_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, /* reporterPackage= */ null, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void isAvailable_withNullActivity_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(/* activity= */ null, PACKAGE_NAME, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void sendFeedback_enableLowVisionGenericFeedbackWithValidParams_success() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, PACKAGE_NAME, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.sendFeedback()).isTrue();
|
||||
|
||||
Intent startedIntent = Shadows.shadowOf(mActivity).getNextStartedActivity();
|
||||
assertThat(startedIntent).isNotNull();
|
||||
assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_BUG_REPORT);
|
||||
assertThat(startedIntent.getPackage()).isEqualTo(PACKAGE_NAME);
|
||||
Bundle extras = startedIntent.getExtras();
|
||||
assertThat(extras).isNotNull();
|
||||
assertThat(extras.getString(CATEGORY_TAG)).isEqualTo(DEFAULT_CATEGORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void sendFeedback_disableLowVisionGenericFeedback_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, PACKAGE_NAME, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.sendFeedback()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void sendFeedback_withNullCategory_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, PACKAGE_NAME, /* category= */ null);
|
||||
|
||||
assertThat(feedbackManager.sendFeedback()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void sendFeedback_withNullReporterPackage_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(mActivity, /* reporterPackage= */ null, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.sendFeedback()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_LOW_VISION_GENERIC_FEEDBACK)
|
||||
public void sendFeedback_withNullActivity_returnsFalse() {
|
||||
FeedbackManager feedbackManager =
|
||||
new FeedbackManager(/* activity= */ null, PACKAGE_NAME, DEFAULT_CATEGORY);
|
||||
|
||||
assertThat(feedbackManager.sendFeedback()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
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;
|
||||
@@ -103,6 +104,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
|
||||
public DisplayFeatureProvider mDisplayFeatureProvider;
|
||||
public SyncAcrossDevicesFeatureProvider mSyncAcrossDevicesFeatureProvider;
|
||||
public AccessibilityFeedbackFeatureProvider mAccessibilityFeedbackFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -340,5 +342,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public SyncAcrossDevicesFeatureProvider getSyncAcrossDevicesFeatureProvider() {
|
||||
return mSyncAcrossDevicesFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibilityFeedbackFeatureProvider getAccessibilityFeedbackFeatureProvider() {
|
||||
return mAccessibilityFeedbackFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.testutils
|
||||
|
||||
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
|
||||
@@ -125,6 +126,8 @@ class FakeFeatureFactory : FeatureFactory() {
|
||||
get() = TODO("Not yet implemented")
|
||||
override val securitySettingsFeatureProvider: SecuritySettingsFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val accessibilityFeedbackFeatureProvider: AccessibilityFeedbackFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val accessibilitySearchFeatureProvider: AccessibilitySearchFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val accessibilityMetricsFeatureProvider: AccessibilityMetricsFeatureProvider
|
||||
|
||||
@@ -48,7 +48,6 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.internal.telephony.flags.Flags;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -167,7 +166,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
@Test
|
||||
@EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
|
||||
public void onResume_registerTelephonyCallback_success() {
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
mController.onResume(null);
|
||||
|
||||
verify(mTelephonyManager).registerTelephonyCallback(any(), any());
|
||||
@@ -176,7 +175,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
@Test
|
||||
@EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
|
||||
public void getAvailabilityStatus_unregisterTelephonyCallback_success() {
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
mController.onPause(null);
|
||||
|
||||
verify(mTelephonyManager).unregisterTelephonyCallback(any());
|
||||
@@ -185,7 +184,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
@Test
|
||||
@EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
|
||||
public void getAvailabilityStatus_hasServiceDataType_showDataUi() {
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY);
|
||||
preference.setTitle("test title");
|
||||
@@ -194,14 +193,13 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
|
||||
new int[]{SERVICE_TYPE_SMS, SERVICE_TYPE_DATA});
|
||||
|
||||
assertThat(preference.getTitle()).isEqualTo(
|
||||
mContext.getString(R.string.title_satellite_setting_connectivity));
|
||||
assertThat(preference.getTitle()).isEqualTo("Satellite connectivity");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.settings.flags.Flags.FLAG_SATELLITE_OEM_SETTINGS_UX_MIGRATION)
|
||||
public void getAvailabilityStatus_onlyHasServiceSmsType_showSmsUi() {
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY);
|
||||
preference.setTitle("test title");
|
||||
@@ -210,8 +208,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mController.mCarrierRoamingNtnModeCallback.onCarrierRoamingNtnAvailableServicesChanged(
|
||||
new int[]{SERVICE_TYPE_SMS});
|
||||
|
||||
assertThat(preference.getTitle()).isEqualTo(
|
||||
mContext.getString(R.string.satellite_setting_title));
|
||||
assertThat(preference.getTitle()).isEqualTo("Satellite messaging");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,14 +217,14 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mCarrierConfig.putBoolean(
|
||||
KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL,
|
||||
false);
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
Preference preference = new Preference(mContext);
|
||||
preference.setKey(KEY);
|
||||
preference.setTitle("test title");
|
||||
mController.updateState(preference);
|
||||
|
||||
assertThat(preference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.satellite_setting_summary_without_entitlement));
|
||||
"Send and receive text messages by satellite. Contact your carrier for details.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,7 +236,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mCarrierConfig.putInt(
|
||||
CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
|
||||
CARRIER_ROAMING_NTN_CONNECT_MANUAL);
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||
Preference preference = new Preference(mContext);
|
||||
@@ -250,7 +247,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mController.displayPreference(preferenceScreen);
|
||||
|
||||
assertThat(preference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.satellite_setting_enabled_summary));
|
||||
"Send and receive text messages by satellite. Included with your account.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -262,7 +259,7 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mCarrierConfig.putInt(
|
||||
CarrierConfigManager.KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT,
|
||||
CARRIER_ROAMING_NTN_CONNECT_MANUAL);
|
||||
mController.init(TEST_SUB_ID);
|
||||
mController.initialize(TEST_SUB_ID);
|
||||
PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||
Preference preference = new Preference(mContext);
|
||||
@@ -273,6 +270,6 @@ public class SatelliteSettingsPreferenceControllerTest {
|
||||
mController.displayPreference(preferenceScreen);
|
||||
|
||||
assertThat(preference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.satellite_setting_disabled_summary));
|
||||
"Send and receive text messages by satellite. Not included with your account.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
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;
|
||||
@@ -102,6 +103,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
|
||||
public DisplayFeatureProvider mDisplayFeatureProvider;
|
||||
public SyncAcrossDevicesFeatureProvider mSyncAcrossDevicesFeatureProvider;
|
||||
public AccessibilityFeedbackFeatureProvider mAccessibilityFeedbackFeatureProvider;
|
||||
|
||||
/** Call this in {@code @Before} method of the test class to use fake factory. */
|
||||
public static FakeFeatureFactory setupForTest() {
|
||||
@@ -341,4 +343,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public SyncAcrossDevicesFeatureProvider getSyncAcrossDevicesFeatureProvider() {
|
||||
return mSyncAcrossDevicesFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibilityFeedbackFeatureProvider getAccessibilityFeedbackFeatureProvider() {
|
||||
return mAccessibilityFeedbackFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user