Loading src/com/android/settings/applications/AccessibilityServiceInfoWrapper.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.applications; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; /** * This interface replicates a subset of the * {@link android.accessibilityservice.AccessibilityServiceInfo}. The interface * exists so that we can use a thin wrapper around it in production code and a mock in tests. * We cannot directly mock or shadow it, because some of the methods we rely on are newer than * the API version supported by Robolectric. */ public interface AccessibilityServiceInfoWrapper { /** * Returns the real {@code AccessibilityServiceInfo} object. */ AccessibilityServiceInfo getAccessibilityServiceInfo(); ComponentName getComponentName(); } src/com/android/settings/applications/AccessibilityServiceInfoWrapperImpl.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.applications; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; public class AccessibilityServiceInfoWrapperImpl implements AccessibilityServiceInfoWrapper { private final AccessibilityServiceInfo mServiceInfo; public AccessibilityServiceInfoWrapperImpl(AccessibilityServiceInfo serviceInfo) { mServiceInfo = serviceInfo; } @Override public AccessibilityServiceInfo getAccessibilityServiceInfo() { return mServiceInfo; } @Override public ComponentName getComponentName() { return mServiceInfo.getComponentName(); } } src/com/android/settings/search/ResultPayload.java +12 −5 Original line number Diff line number Diff line Loading @@ -66,10 +66,11 @@ public class ResultPayload implements Parcelable { * Enumerates the possible values for the Availability of a setting. */ @IntDef({Availability.AVAILABLE, Availability.DISABLED_DEPENDENCY, Availability.DISABLED_DEPENDENT_SETTING, Availability.DISABLED_DEPENDENT_APP, Availability.DISABLED_UNSUPPORTED, Availability.RESOURCE_CONTENTION, Availability.INTENT_ONLY,}) Availability.INTENT_ONLY}) @Retention(RetentionPolicy.SOURCE) public @interface Availability { /** Loading @@ -78,9 +79,10 @@ public class ResultPayload implements Parcelable { int AVAILABLE = 0; /** * The setting has a dependency which is currently disabled, blocking access. * The setting has a dependency in settings app which is currently disabled, blocking * access. */ int DISABLED_DEPENDENCY = 1; int DISABLED_DEPENDENT_SETTING = 1; /** * The setting is not supported by the device. Loading @@ -93,10 +95,15 @@ public class ResultPayload implements Parcelable { */ int RESOURCE_CONTENTION = 3; /** * The setting is disabled because corresponding app is disabled */ int DISABLED_DEPENDENT_APP = 4; /** * This setting is supported on the device but cannot be changed inline. */ int INTENT_ONLY = 4; int INTENT_ONLY = 5; } @IntDef({SettingsSource.UNKNOWN, SettingsSource.SYSTEM, SettingsSource.SECURE, Loading tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityManager.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.testutils.shadow; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; import android.view.accessibility.AccessibilityManager; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import java.util.ArrayList; import java.util.List; @Implements(AccessibilityManager.class) public class ShadowAccessibilityManager { private static final List<AccessibilityServiceInfo> mInstalledAccessibilityList = new ArrayList<>(); public static void addAccessibilityService(String serviceName) { AccessibilityServiceInfo serviceInfo = new AccessibilityServiceInfo(); serviceInfo.setComponentName(ComponentName.unflattenFromString(serviceName)); mInstalledAccessibilityList.add(serviceInfo); } @Implementation public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() { return mInstalledAccessibilityList; } } tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityServiceInfoWrapperImpl.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.testutils.shadow; import android.content.ComponentName; import com.android.settings.applications.AccessibilityServiceInfoWrapperImpl; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; @Implements(AccessibilityServiceInfoWrapperImpl.class) public class ShadowAccessibilityServiceInfoWrapperImpl { private static ComponentName sComponentName; public static void setComponentName(String componentName) { sComponentName = ComponentName.unflattenFromString(componentName);; } @Implementation public ComponentName getComponentName() { return sComponentName; } } Loading
src/com/android/settings/applications/AccessibilityServiceInfoWrapper.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.applications; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; /** * This interface replicates a subset of the * {@link android.accessibilityservice.AccessibilityServiceInfo}. The interface * exists so that we can use a thin wrapper around it in production code and a mock in tests. * We cannot directly mock or shadow it, because some of the methods we rely on are newer than * the API version supported by Robolectric. */ public interface AccessibilityServiceInfoWrapper { /** * Returns the real {@code AccessibilityServiceInfo} object. */ AccessibilityServiceInfo getAccessibilityServiceInfo(); ComponentName getComponentName(); }
src/com/android/settings/applications/AccessibilityServiceInfoWrapperImpl.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.applications; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; public class AccessibilityServiceInfoWrapperImpl implements AccessibilityServiceInfoWrapper { private final AccessibilityServiceInfo mServiceInfo; public AccessibilityServiceInfoWrapperImpl(AccessibilityServiceInfo serviceInfo) { mServiceInfo = serviceInfo; } @Override public AccessibilityServiceInfo getAccessibilityServiceInfo() { return mServiceInfo; } @Override public ComponentName getComponentName() { return mServiceInfo.getComponentName(); } }
src/com/android/settings/search/ResultPayload.java +12 −5 Original line number Diff line number Diff line Loading @@ -66,10 +66,11 @@ public class ResultPayload implements Parcelable { * Enumerates the possible values for the Availability of a setting. */ @IntDef({Availability.AVAILABLE, Availability.DISABLED_DEPENDENCY, Availability.DISABLED_DEPENDENT_SETTING, Availability.DISABLED_DEPENDENT_APP, Availability.DISABLED_UNSUPPORTED, Availability.RESOURCE_CONTENTION, Availability.INTENT_ONLY,}) Availability.INTENT_ONLY}) @Retention(RetentionPolicy.SOURCE) public @interface Availability { /** Loading @@ -78,9 +79,10 @@ public class ResultPayload implements Parcelable { int AVAILABLE = 0; /** * The setting has a dependency which is currently disabled, blocking access. * The setting has a dependency in settings app which is currently disabled, blocking * access. */ int DISABLED_DEPENDENCY = 1; int DISABLED_DEPENDENT_SETTING = 1; /** * The setting is not supported by the device. Loading @@ -93,10 +95,15 @@ public class ResultPayload implements Parcelable { */ int RESOURCE_CONTENTION = 3; /** * The setting is disabled because corresponding app is disabled */ int DISABLED_DEPENDENT_APP = 4; /** * This setting is supported on the device but cannot be changed inline. */ int INTENT_ONLY = 4; int INTENT_ONLY = 5; } @IntDef({SettingsSource.UNKNOWN, SettingsSource.SYSTEM, SettingsSource.SECURE, Loading
tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityManager.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.testutils.shadow; import android.accessibilityservice.AccessibilityServiceInfo; import android.content.ComponentName; import android.view.accessibility.AccessibilityManager; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import java.util.ArrayList; import java.util.List; @Implements(AccessibilityManager.class) public class ShadowAccessibilityManager { private static final List<AccessibilityServiceInfo> mInstalledAccessibilityList = new ArrayList<>(); public static void addAccessibilityService(String serviceName) { AccessibilityServiceInfo serviceInfo = new AccessibilityServiceInfo(); serviceInfo.setComponentName(ComponentName.unflattenFromString(serviceName)); mInstalledAccessibilityList.add(serviceInfo); } @Implementation public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() { return mInstalledAccessibilityList; } }
tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityServiceInfoWrapperImpl.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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.testutils.shadow; import android.content.ComponentName; import com.android.settings.applications.AccessibilityServiceInfoWrapperImpl; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; @Implements(AccessibilityServiceInfoWrapperImpl.class) public class ShadowAccessibilityServiceInfoWrapperImpl { private static ComponentName sComponentName; public static void setComponentName(String componentName) { sComponentName = ComponentName.unflattenFromString(componentName);; } @Implementation public ComponentName getComponentName() { return sComponentName; } }