Snap for 5351881 from 8758f631c8 to qt-release
Change-Id: I91e160c0bc713ddb33aa007bbdb099fd0c712a5e
This commit is contained in:
@@ -932,8 +932,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$ManageApplicationsActivity"
|
android:name="Settings$ManageApplicationsActivity"
|
||||||
android:label="@string/applications_settings"
|
android:label="@string/applications_settings">
|
||||||
android:parentActivityName="Settings">
|
|
||||||
<intent-filter android:priority="1">
|
<intent-filter android:priority="1">
|
||||||
<action android:name="android.settings.APPLICATION_SETTINGS" />
|
<action android:name="android.settings.APPLICATION_SETTINGS" />
|
||||||
<action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
|
<action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
|
||||||
@@ -1306,8 +1305,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$UsageAccessSettingsActivity"
|
android:name="Settings$UsageAccessSettingsActivity"
|
||||||
android:label="@string/usage_access_title"
|
android:label="@string/usage_access_title">
|
||||||
android:parentActivityName="Settings">
|
|
||||||
<intent-filter android:priority="1">
|
<intent-filter android:priority="1">
|
||||||
<action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
|
<action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -1362,6 +1360,20 @@
|
|||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="Settings$AccessibilityDetailsSettingsActivity"
|
||||||
|
android:label="@string/accessibility_settings"
|
||||||
|
android:permission="android.permission.OPEN_ACCESSIBILITY_DETAILS_SETTINGS">
|
||||||
|
<intent-filter android:priority="1">
|
||||||
|
<action android:name="android.settings.ACCESSIBILITY_DETAILS_SETTINGS" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
android:value="com.android.settings.accessibility.AccessibilityDetailsSettingsFragment" />
|
||||||
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
|
android:value="true" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".accessibility.AccessibilitySettingsForSetupWizardActivity"
|
<activity android:name=".accessibility.AccessibilitySettingsForSetupWizardActivity"
|
||||||
android:icon="@drawable/ic_accessibility_suggestion"
|
android:icon="@drawable/ic_accessibility_suggestion"
|
||||||
android:label="@string/vision_settings_title"
|
android:label="@string/vision_settings_title"
|
||||||
|
|||||||
@@ -17,11 +17,12 @@
|
|||||||
android:width="32dp"
|
android:width="32dp"
|
||||||
android:height="32dp"
|
android:height="32dp"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24"
|
||||||
|
android:tint="?android:attr/colorAccent">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#ff4285f4"
|
android:fillColor="#FF000000"
|
||||||
android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10c5.52,0 10,-4.48 10,-10C22,6.48 17.52,2 12,2zM7.07,18.28c0.43,-0.9 3.05,-1.78 4.93,-1.78s4.51,0.88 4.93,1.78C15.57,19.36 13.86,20 12,20S8.43,19.36 7.07,18.28zM18.36,16.83c-1.43,-1.74 -4.9,-2.33 -6.36,-2.33s-4.93,0.59 -6.36,2.33C4.62,15.49 4,13.82 4,12c0,-4.41 3.59,-8 8,-8c4.41,0 8,3.59 8,8C20,13.82 19.38,15.49 18.36,16.83z"/>
|
android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10c5.52,0 10,-4.48 10,-10C22,6.48 17.52,2 12,2zM7.07,18.28c0.43,-0.9 3.05,-1.78 4.93,-1.78s4.51,0.88 4.93,1.78C15.57,19.36 13.86,20 12,20S8.43,19.36 7.07,18.28zM18.36,16.83c-1.43,-1.74 -4.9,-2.33 -6.36,-2.33s-4.93,0.59 -6.36,2.33C4.62,15.49 4,13.82 4,12c0,-4.41 3.59,-8 8,-8c4.41,0 8,3.59 8,8C20,13.82 19.38,15.49 18.36,16.83z"/>
|
||||||
<path
|
<path
|
||||||
android:fillColor="#ff4285f4"
|
android:fillColor="#FF000000"
|
||||||
android:pathData="M12,6c-1.94,0 -3.5,1.56 -3.5,3.5S10.06,13 12,13c1.94,0 3.5,-1.56 3.5,-3.5S13.94,6 12,6zM12,11c-0.83,0 -1.5,-0.67 -1.5,-1.5C10.5,8.67 11.17,8 12,8c0.83,0 1.5,0.67 1.5,1.5C13.5,10.33 12.83,11 12,11z"/>
|
android:pathData="M12,6c-1.94,0 -3.5,1.56 -3.5,3.5S10.06,13 12,13c1.94,0 3.5,-1.56 3.5,-3.5S13.94,6 12,6zM12,11c-0.83,0 -1.5,-0.67 -1.5,-1.5C10.5,8.67 11.17,8 12,8c0.83,0 1.5,0.67 1.5,1.5C13.5,10.33 12.83,11 12,11z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@@ -330,6 +330,9 @@
|
|||||||
<!-- Whether device_model should be shown or not. -->
|
<!-- Whether device_model should be shown or not. -->
|
||||||
<bool name="config_show_device_model">true</bool>
|
<bool name="config_show_device_model">true</bool>
|
||||||
|
|
||||||
|
<!-- Whether top_level_accessibility should be shown or not. -->
|
||||||
|
<bool name="config_show_top_level_accessibility">true</bool>
|
||||||
|
|
||||||
<!-- Whether top_level_battery should be shown or not. -->
|
<!-- Whether top_level_battery should be shown or not. -->
|
||||||
<bool name="config_show_top_level_battery">true</bool>
|
<bool name="config_show_top_level_battery">true</bool>
|
||||||
|
|
||||||
|
|||||||
@@ -1859,7 +1859,7 @@
|
|||||||
<!-- This string asks the user whether or not to allow an app to disable WiFi. [CHAR LIMIT=NONE] -->
|
<!-- This string asks the user whether or not to allow an app to disable WiFi. [CHAR LIMIT=NONE] -->
|
||||||
<string name="wifi_ask_disable"><xliff:g id="requester" example="FancyApp">%s</xliff:g> wants to turn off Wi-Fi</string>
|
<string name="wifi_ask_disable"><xliff:g id="requester" example="FancyApp">%s</xliff:g> wants to turn off Wi-Fi</string>
|
||||||
|
|
||||||
<!-- Debugging developer settings: Enable ART verifier for Debuggable Apps [CHAR LIMIT=40] -->
|
<!-- Debugging developer settings: Enable ART verifier for Debuggable Apps [CHAR LIMIT=67] -->
|
||||||
<string name="art_verifier_for_debuggable_title">Verify bytecode of debuggable apps</string>
|
<string name="art_verifier_for_debuggable_title">Verify bytecode of debuggable apps</string>
|
||||||
<!-- Debugging developer settings: Enable ART verifier for Debuggable Apps [CHAR LIMIT=NONE] -->
|
<!-- Debugging developer settings: Enable ART verifier for Debuggable Apps [CHAR LIMIT=NONE] -->
|
||||||
<string name="art_verifier_for_debuggable_summary">Allow ART to verify bytecode for debuggable apps</string>
|
<string name="art_verifier_for_debuggable_summary">Allow ART to verify bytecode for debuggable apps</string>
|
||||||
@@ -2107,7 +2107,7 @@
|
|||||||
<string name="wifi_ip_settings">IP settings</string>
|
<string name="wifi_ip_settings">IP settings</string>
|
||||||
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
|
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
|
||||||
<string name="wifi_privacy_settings">Privacy</string>
|
<string name="wifi_privacy_settings">Privacy</string>
|
||||||
<!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=25] -->
|
<!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=40] -->
|
||||||
<string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
|
<string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
|
||||||
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
|
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
|
||||||
<string name="wifi_dpp_add_device_to_network">Add a device</string>
|
<string name="wifi_dpp_add_device_to_network">Add a device</string>
|
||||||
@@ -7092,8 +7092,8 @@
|
|||||||
<!-- Search keyword for face settings. -->
|
<!-- Search keyword for face settings. -->
|
||||||
<string name="keywords_face_settings">face</string>
|
<string name="keywords_face_settings">face</string>
|
||||||
|
|
||||||
<!-- Search keyword for fingerprint settings. -->
|
<!-- Search keyword for fingerprint settings. [CHAR_LIMIT=NONE]-->
|
||||||
<string name="keywords_fingerprint_settings">fingerprint</string>
|
<string name="keywords_fingerprint_settings">fingerprint, add fingerprint</string>
|
||||||
|
|
||||||
<!-- Search keywords for adaptive brightness setting [CHAR LIMIT=NONE]-->
|
<!-- Search keywords for adaptive brightness setting [CHAR LIMIT=NONE]-->
|
||||||
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
|
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
|
||||||
|
|||||||
@@ -123,7 +123,8 @@
|
|||||||
android:summary="@string/accessibility_settings_summary"
|
android:summary="@string/accessibility_settings_summary"
|
||||||
android:icon="@drawable/ic_homepage_accessibility"
|
android:icon="@drawable/ic_homepage_accessibility"
|
||||||
android:order="-20"
|
android:order="-20"
|
||||||
android:fragment="com.android.settings.accessibility.AccessibilitySettings"/>
|
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
|
||||||
|
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="top_level_system"
|
android:key="top_level_system"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
|
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class DevelopmentSettingsDashboardActivity extends SettingsActivity { /* empty */ }
|
public static class DevelopmentSettingsDashboardActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
|
public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
public static class AccessibilityDetailsSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
|||||||
@@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.accessibilityservice.AccessibilityServiceInfo;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
|
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class AccessibilityDetailsSettingsFragment extends InstrumentedFragment {
|
||||||
|
|
||||||
|
private final static String TAG = "A11yDetailsSettings";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.ACCESSIBILITY_DETAILS_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// In case the Intent doesn't have component name, go to a11y services list.
|
||||||
|
final String extraComponentName = getActivity().getIntent().getStringExtra(
|
||||||
|
Intent.EXTRA_COMPONENT_NAME);
|
||||||
|
if (extraComponentName == null) {
|
||||||
|
Log.w(TAG, "Open accessibility services list due to no component name.");
|
||||||
|
openAccessibilitySettingsAndFinish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case the A11yServiceInfo doesn't exist, go to ally services list.
|
||||||
|
final ComponentName componentName = ComponentName.unflattenFromString(extraComponentName);
|
||||||
|
final AccessibilityServiceInfo info = getAccessibilityServiceInfo(componentName);
|
||||||
|
if (info == null) {
|
||||||
|
Log.w(TAG, "Open accessibility services list due to invalid component name.");
|
||||||
|
openAccessibilitySettingsAndFinish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case this accessibility service isn't permitted, go to a11y services list.
|
||||||
|
if (!isServiceAllowed(componentName.getPackageName())) {
|
||||||
|
Log.w(TAG,
|
||||||
|
"Open accessibility services list due to target accessibility service is "
|
||||||
|
+ "prohibited by Device Admin.");
|
||||||
|
openAccessibilitySettingsAndFinish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
openAccessibilityDetailsSettingsAndFinish(buildArguments(info));
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void openAccessibilitySettingsAndFinish() {
|
||||||
|
new SubSettingLauncher(getActivity())
|
||||||
|
.setDestination(AccessibilitySettings.class.getName())
|
||||||
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
|
.launch();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void openAccessibilityDetailsSettingsAndFinish(Bundle arguments) {
|
||||||
|
new SubSettingLauncher(getActivity())
|
||||||
|
.setDestination(ToggleAccessibilityServicePreferenceFragment.class.getName())
|
||||||
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
|
.setArguments(arguments)
|
||||||
|
.launch();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isServiceAllowed(String packageName) {
|
||||||
|
final DevicePolicyManager dpm = getContext().getSystemService(DevicePolicyManager.class);
|
||||||
|
final List<String> permittedServices = dpm.getPermittedAccessibilityServices(
|
||||||
|
UserHandle.myUserId());
|
||||||
|
return (permittedServices == null || permittedServices.contains(packageName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private AccessibilityServiceInfo getAccessibilityServiceInfo(ComponentName componentName) {
|
||||||
|
if (componentName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<AccessibilityServiceInfo> serviceInfos = AccessibilityManager.getInstance(
|
||||||
|
getActivity()).getInstalledAccessibilityServiceList();
|
||||||
|
final int serviceInfoCount = serviceInfos.size();
|
||||||
|
for (int i = 0; i < serviceInfoCount; i++) {
|
||||||
|
AccessibilityServiceInfo serviceInfo = serviceInfos.get(i);
|
||||||
|
ResolveInfo resolveInfo = serviceInfo.getResolveInfo();
|
||||||
|
if (componentName.getPackageName().equals(resolveInfo.serviceInfo.packageName)
|
||||||
|
&& componentName.getClassName().equals(resolveInfo.serviceInfo.name)) {
|
||||||
|
return serviceInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bundle buildArguments(AccessibilityServiceInfo info) {
|
||||||
|
final ResolveInfo resolveInfo = info.getResolveInfo();
|
||||||
|
final String title = resolveInfo.loadLabel(getActivity().getPackageManager()).toString();
|
||||||
|
final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
|
||||||
|
final String packageName = serviceInfo.packageName;
|
||||||
|
final ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
|
||||||
|
|
||||||
|
final List<AccessibilityServiceInfo> enabledServiceInfos = AccessibilityManager.getInstance(
|
||||||
|
getActivity()).getEnabledAccessibilityServiceList(
|
||||||
|
AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
|
||||||
|
final Set<ComponentName> enabledServices =
|
||||||
|
AccessibilityUtils.getEnabledServicesFromSettings(getActivity());
|
||||||
|
final boolean serviceEnabled = enabledServices.contains(componentName);
|
||||||
|
String description = info.loadDescription(getActivity().getPackageManager());
|
||||||
|
if (TextUtils.isEmpty(description)) {
|
||||||
|
description = getString(R.string.accessibility_service_default_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceEnabled && AccessibilityUtils.hasServiceCrashed(
|
||||||
|
packageName, serviceInfo.name, enabledServiceInfos)) {
|
||||||
|
// Update the summaries for services that have crashed.
|
||||||
|
description = getString(R.string.accessibility_description_state_stopped);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Bundle extras = new Bundle();
|
||||||
|
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
|
||||||
|
componentName.flattenToString());
|
||||||
|
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, serviceEnabled);
|
||||||
|
extras.putString(AccessibilitySettings.EXTRA_TITLE, title);
|
||||||
|
extras.putParcelable(AccessibilitySettings.EXTRA_RESOLVE_INFO, resolveInfo);
|
||||||
|
extras.putString(AccessibilitySettings.EXTRA_SUMMARY, description);
|
||||||
|
|
||||||
|
final String settingsClassName = info.getSettingsActivityName();
|
||||||
|
if (!TextUtils.isEmpty(settingsClassName)) {
|
||||||
|
extras.putString(AccessibilitySettings.EXTRA_SETTINGS_TITLE,
|
||||||
|
getString(R.string.accessibility_menu_item_settings));
|
||||||
|
extras.putString(AccessibilitySettings.EXTRA_SETTINGS_COMPONENT_NAME,
|
||||||
|
new ComponentName(packageName, settingsClassName).flattenToString());
|
||||||
|
}
|
||||||
|
extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
|
||||||
|
|
||||||
|
return extras;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finish() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.Context;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
public class TopLevelAccessibilityPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
|
public TopLevelAccessibilityPreferenceController(Context context,
|
||||||
|
String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return mContext.getResources().getBoolean(R.bool.config_show_top_level_accessibility)
|
||||||
|
? AVAILABLE_UNSEARCHABLE
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -29,6 +29,8 @@ import com.android.internal.util.CollectionUtils;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Abstract base controller for the default app shortcut preferences that launches the default app
|
* Abstract base controller for the default app shortcut preferences that launches the default app
|
||||||
* settings with the corresponding default app highlighted.
|
* settings with the corresponding default app highlighted.
|
||||||
@@ -41,6 +43,8 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
|||||||
|
|
||||||
private final RoleManager mRoleManager;
|
private final RoleManager mRoleManager;
|
||||||
|
|
||||||
|
private boolean mRoleVisible;
|
||||||
|
|
||||||
private boolean mAppQualified;
|
private boolean mAppQualified;
|
||||||
|
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
@@ -56,8 +60,13 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
|||||||
|
|
||||||
final PermissionControllerManager permissionControllerManager =
|
final PermissionControllerManager permissionControllerManager =
|
||||||
mContext.getSystemService(PermissionControllerManager.class);
|
mContext.getSystemService(PermissionControllerManager.class);
|
||||||
permissionControllerManager.isApplicationQualifiedForRole(mRoleName, mPackageName,
|
final Executor executor = mContext.getMainExecutor();
|
||||||
mContext.getMainExecutor(), qualified -> {
|
permissionControllerManager.isRoleVisible(mRoleName, executor, visible -> {
|
||||||
|
mRoleVisible = visible;
|
||||||
|
refreshAvailability();
|
||||||
|
});
|
||||||
|
permissionControllerManager.isApplicationQualifiedForRole(mRoleName, mPackageName, executor,
|
||||||
|
qualified -> {
|
||||||
mAppQualified = qualified;
|
mAppQualified = qualified;
|
||||||
refreshAvailability();
|
refreshAvailability();
|
||||||
});
|
});
|
||||||
@@ -85,7 +94,7 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre
|
|||||||
if (mContext.getSystemService(UserManager.class).isManagedProfile()) {
|
if (mContext.getSystemService(UserManager.class).isManagedProfile()) {
|
||||||
return DISABLED_FOR_USER;
|
return DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
return mAppQualified ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
return mRoleVisible && mAppQualified ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ public class AppOpsState {
|
|||||||
|
|
||||||
}
|
}
|
||||||
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
|
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
|
||||||
permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0, -1, null);
|
permOps.get(k), AppOpsManager.MODE_ALLOWED);
|
||||||
dummyOps.add(opEntry);
|
dummyOps.add(opEntry);
|
||||||
addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
|
addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
|
||||||
packageName == null ? 0 : opToOrder[opEntry.getOp()]);
|
packageName == null ? 0 : opToOrder[opEntry.getOp()]);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.android.settings.Settings;
|
|||||||
import com.android.settings.TestingSettings;
|
import com.android.settings.TestingSettings;
|
||||||
import com.android.settings.TetherSettings;
|
import com.android.settings.TetherSettings;
|
||||||
import com.android.settings.TrustedCredentialsSettings;
|
import com.android.settings.TrustedCredentialsSettings;
|
||||||
|
import com.android.settings.accessibility.AccessibilityDetailsSettingsFragment;
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
|
||||||
import com.android.settings.accessibility.CaptionPropertiesFragment;
|
import com.android.settings.accessibility.CaptionPropertiesFragment;
|
||||||
@@ -178,6 +179,7 @@ public class SettingsGateway {
|
|||||||
UsageAccessDetails.class.getName(),
|
UsageAccessDetails.class.getName(),
|
||||||
PrivacySettings.class.getName(),
|
PrivacySettings.class.getName(),
|
||||||
DeviceAdminSettings.class.getName(),
|
DeviceAdminSettings.class.getName(),
|
||||||
|
AccessibilityDetailsSettingsFragment.class.getName(),
|
||||||
AccessibilitySettings.class.getName(),
|
AccessibilitySettings.class.getName(),
|
||||||
AccessibilitySettingsForSetupWizard.class.getName(),
|
AccessibilitySettingsForSetupWizard.class.getName(),
|
||||||
CaptionPropertiesFragment.class.getName(),
|
CaptionPropertiesFragment.class.getName(),
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<bool name="config_show_reset_dashboard">false</bool>
|
<bool name="config_show_reset_dashboard">false</bool>
|
||||||
<bool name="config_show_system_update_settings">false</bool>
|
<bool name="config_show_system_update_settings">false</bool>
|
||||||
<bool name="config_show_device_model">false</bool>
|
<bool name="config_show_device_model">false</bool>
|
||||||
|
<bool name="config_show_top_level_accessibility">false</bool>
|
||||||
<bool name="config_show_top_level_battery">false</bool>
|
<bool name="config_show_top_level_battery">false</bool>
|
||||||
<bool name="config_show_top_level_connected_devices">false</bool>
|
<bool name="config_show_top_level_connected_devices">false</bool>
|
||||||
<bool name="config_show_top_level_display">false</bool>
|
<bool name="config_show_top_level_display">false</bool>
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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 org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.shadow.api.Shadow;
|
||||||
|
import org.robolectric.shadows.ShadowAccessibilityManager;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class AccessibilityDetailsSettingsFragmentTest {
|
||||||
|
private final static String PACKAGE_NAME = "com.foo.bar";
|
||||||
|
private final static String CLASS_NAME = PACKAGE_NAME + ".fake_a11y_service";
|
||||||
|
private final static String COMPONENT_NAME = PACKAGE_NAME + "/" + CLASS_NAME;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private AccessibilityDetailsSettingsFragment mFragment;
|
||||||
|
private ShadowAccessibilityManager mShadowAccessibilityManager;
|
||||||
|
@Mock private FragmentActivity mActivity;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
mFragment = spy(new AccessibilityDetailsSettingsFragment());
|
||||||
|
mShadowAccessibilityManager = Shadow.extract(AccessibilityManager.getInstance(mContext));
|
||||||
|
mShadowAccessibilityManager.setInstalledAccessibilityServiceList(getMockServiceList());
|
||||||
|
|
||||||
|
doReturn(mActivity).when(mFragment).getActivity();
|
||||||
|
doReturn(mContext).when(mFragment).getContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_hasValidExtraComponentName_shouldOpenAccessibilityDetailsSettings() {
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
intent.putExtra(Intent.EXTRA_COMPONENT_NAME, COMPONENT_NAME);
|
||||||
|
doReturn(intent).when(mActivity).getIntent();
|
||||||
|
|
||||||
|
mFragment.onCreate(Bundle.EMPTY);
|
||||||
|
|
||||||
|
verify(mFragment).openAccessibilityDetailsSettingsAndFinish(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_hasInvalidExtraComponentName_shouldOpenAccessibilityServicesList() {
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
intent.putExtra(Intent.EXTRA_COMPONENT_NAME, PACKAGE_NAME + "/.service");
|
||||||
|
doReturn(intent).when(mActivity).getIntent();
|
||||||
|
|
||||||
|
mFragment.onCreate(Bundle.EMPTY);
|
||||||
|
|
||||||
|
verify(mFragment).openAccessibilitySettingsAndFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_hasNoExtraComponentName_shouldOpenAccessibilityServicesList() {
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
doReturn(intent).when(mActivity).getIntent();
|
||||||
|
|
||||||
|
mFragment.onCreate(Bundle.EMPTY);
|
||||||
|
|
||||||
|
verify(mFragment).openAccessibilitySettingsAndFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onCreate_extraComponentNameIsDisallowed_shouldOpenAccessibilityServicesList() {
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
intent.putExtra(Intent.EXTRA_COMPONENT_NAME, COMPONENT_NAME);
|
||||||
|
doReturn(intent).when(mActivity).getIntent();
|
||||||
|
doReturn(false).when(mFragment).isServiceAllowed(any());
|
||||||
|
|
||||||
|
mFragment.onCreate(Bundle.EMPTY);
|
||||||
|
|
||||||
|
verify(mFragment).openAccessibilitySettingsAndFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private AccessibilityServiceInfo getMockAccessibilityServiceInfo() {
|
||||||
|
final ApplicationInfo applicationInfo = new ApplicationInfo();
|
||||||
|
final ServiceInfo serviceInfo = new ServiceInfo();
|
||||||
|
applicationInfo.packageName = PACKAGE_NAME;
|
||||||
|
serviceInfo.packageName = PACKAGE_NAME;
|
||||||
|
serviceInfo.name = CLASS_NAME;
|
||||||
|
serviceInfo.applicationInfo = applicationInfo;
|
||||||
|
|
||||||
|
final ResolveInfo resolveInfo = new ResolveInfo();
|
||||||
|
resolveInfo.serviceInfo = serviceInfo;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final AccessibilityServiceInfo info = new AccessibilityServiceInfo(resolveInfo,
|
||||||
|
mContext);
|
||||||
|
ComponentName componentName = ComponentName.unflattenFromString(COMPONENT_NAME);
|
||||||
|
info.setComponentName(componentName);
|
||||||
|
return info;
|
||||||
|
} catch (XmlPullParserException | IOException e) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AccessibilityServiceInfo> getMockServiceList() {
|
||||||
|
final List<AccessibilityServiceInfo> infoList = new ArrayList<>();
|
||||||
|
infoList.add(getMockAccessibilityServiceInfo());
|
||||||
|
return infoList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 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.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.annotation.Implementation;
|
||||||
|
import org.robolectric.annotation.Implements;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class TopLevelAccessibilityPreferenceControllerTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private TopLevelAccessibilityPreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mController = new TopLevelAccessibilityPreferenceController(mContext, "test_key");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailibilityStatus_availableByDefault() {
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(qualifiers = "mcc999")
|
||||||
|
public void getAvailabilityStatus_unsupportedWhenSet() {
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -101,35 +101,72 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
getAvailabilityStatus_noCallbackForIsApplicationNotQualifiedForRole_shouldReturnUnsupported() {
|
getAvailabilityStatus_noCallback_shouldReturnUnsupported() {
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void
|
||||||
|
getAvailabilityStatus_noCallbackForIsRoleNotVisible_shouldReturnUnsupported() {
|
||||||
|
setApplicationIsQualifiedForRole(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_RoleIsNotVisible_shouldReturnUnsupported() {
|
||||||
|
setRoleIsVisible(false);
|
||||||
|
setApplicationIsQualifiedForRole(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void
|
||||||
|
getAvailabilityStatus_noCallbackForIsApplicationQualifiedForRole_shouldReturnUnsupported() {
|
||||||
|
setRoleIsVisible(true);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_applicationIsNotQualifiedForRole_shouldReturnUnsupported() {
|
public void getAvailabilityStatus_applicationIsNotQualifiedForRole_shouldReturnUnsupported() {
|
||||||
final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
|
setRoleIsVisible(true);
|
||||||
Consumer.class);
|
setApplicationIsQualifiedForRole(false);
|
||||||
verify(mPermissionControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
|
|
||||||
TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture());
|
|
||||||
final Consumer<Boolean> callback = callbackCaptor.getValue();
|
|
||||||
callback.accept(false);
|
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
DefaultAppShortcutPreferenceControllerBase.UNSUPPORTED_ON_DEVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_applicationIsQualifiedForRole_shouldReturnAvailable() {
|
public void getAvailabilityStatus_RoleVisibleAndApplicationQualified_shouldReturnAvailable() {
|
||||||
|
setRoleIsVisible(true);
|
||||||
|
setApplicationIsQualifiedForRole(true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
DefaultAppShortcutPreferenceControllerBase.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRoleIsVisible(boolean visible) {
|
||||||
|
final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
|
||||||
|
Consumer.class);
|
||||||
|
verify(mPermissionControllerManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class),
|
||||||
|
callbackCaptor.capture());
|
||||||
|
final Consumer<Boolean> callback = callbackCaptor.getValue();
|
||||||
|
callback.accept(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setApplicationIsQualifiedForRole(boolean qualified) {
|
||||||
final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
|
final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
|
||||||
Consumer.class);
|
Consumer.class);
|
||||||
verify(mPermissionControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
|
verify(mPermissionControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
|
||||||
TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture());
|
TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture());
|
||||||
final Consumer<Boolean> callback = callbackCaptor.getValue();
|
final Consumer<Boolean> callback = callbackCaptor.getValue();
|
||||||
callback.accept(true);
|
callback.accept(qualified);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
|
||||||
DefaultAppShortcutPreferenceControllerBase.AVAILABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
|
import android.app.AppOpsManager.OpEntry;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
@@ -144,7 +145,7 @@ public class MockLocationAppPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AppOpsManager.OpEntry createOpEntry(int opMode) {
|
private AppOpsManager.OpEntry createOpEntry(int opMode) {
|
||||||
return new AppOpsManager.OpEntry(0, opMode, 0l /* time */, 0 /* rejectTime */,
|
return new OpEntry(0, false, opMode, null /*accessTimes*/, null /*rejectTimes*/,
|
||||||
0 /* duration */, 0 /* proxyUid */, null /* proxyPackage */);
|
null /*durations*/, null /* proxyUids */, null /* proxyPackages */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,13 +77,16 @@ public class RestrictAppPreferenceControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
final AppOpsManager.OpEntry allowOpEntry = new AppOpsManager.OpEntry(
|
final AppOpsManager.OpEntry allowOpEntry = new AppOpsManager.OpEntry(
|
||||||
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_ALLOWED, 0, 0, 0, 0, "");
|
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, false, AppOpsManager.MODE_ALLOWED,
|
||||||
|
null /*accessTimes*/, null /*rejectTimes*/, null /*durations*/,
|
||||||
|
null /* proxyUids */, null /* proxyPackages */);
|
||||||
final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
|
final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
|
||||||
allowOps.add(allowOpEntry);
|
allowOps.add(allowOpEntry);
|
||||||
final AppOpsManager.OpEntry restrictedOpEntry = new AppOpsManager.OpEntry(
|
final AppOpsManager.OpEntry restrictedOpEntry = new AppOpsManager.OpEntry(
|
||||||
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, "");
|
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, false, AppOpsManager.MODE_IGNORED,
|
||||||
|
null /*accessTimes*/, null /*rejectTimes*/, null /*durations*/,
|
||||||
|
null /* proxyUids */, null /* proxyPackages */);
|
||||||
final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
|
final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
|
||||||
restrictedOps.add(restrictedOpEntry);
|
restrictedOps.add(restrictedOpEntry);
|
||||||
mAllowedPackageOps = new AppOpsManager.PackageOps(
|
mAllowedPackageOps = new AppOpsManager.PackageOps(
|
||||||
|
|||||||
Reference in New Issue
Block a user