diff --git a/tests/robotests/src/android/hardware/usb/UsbManagerExtras.java b/tests/robotests/src/android/hardware/usb/UsbManagerExtras.java deleted file mode 100644 index b9bccd22f62..00000000000 --- a/tests/robotests/src/android/hardware/usb/UsbManagerExtras.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2010 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 android.hardware.usb; - -import android.annotation.SystemService; -import android.content.Context; -import android.hardware.usb.gadget.V1_0.GadgetFunction; - -import java.util.HashMap; -import java.util.Map; -import java.util.StringJoiner; - -/** - * Definitions that were added to UsbManager in P. - * - * Copied partially from frameworks/base/core/java/android/hardware/usb/UsbManager to - * fix issues with roboelectric during test. - */ -@SystemService(Context.USB_SERVICE) -public class UsbManagerExtras { - public static final long NONE = 0; - public static final long MTP = GadgetFunction.MTP; - public static final long PTP = GadgetFunction.PTP; - public static final long RNDIS = GadgetFunction.RNDIS; - public static final long MIDI = GadgetFunction.MIDI; - public static final long ACCESSORY = GadgetFunction.ACCESSORY; - public static final long AUDIO_SOURCE = GadgetFunction.AUDIO_SOURCE; - public static final long ADB = GadgetFunction.ADB; - - private static final long SETTABLE_FUNCTIONS = MTP | PTP | RNDIS | MIDI; - - private static final Map STR_MAP = new HashMap<>(); - - static { - STR_MAP.put(UsbManager.USB_FUNCTION_MTP, MTP); - STR_MAP.put(UsbManager.USB_FUNCTION_PTP, PTP); - STR_MAP.put(UsbManager.USB_FUNCTION_RNDIS, RNDIS); - STR_MAP.put(UsbManager.USB_FUNCTION_MIDI, MIDI); - STR_MAP.put(UsbManager.USB_FUNCTION_ACCESSORY, ACCESSORY); - STR_MAP.put(UsbManager.USB_FUNCTION_AUDIO_SOURCE, AUDIO_SOURCE); - STR_MAP.put(UsbManager.USB_FUNCTION_ADB, ADB); - } - - /** - * Returns whether the given functions are valid inputs to UsbManager. - * Currently the empty functions or any of MTP, PTP, RNDIS, MIDI are accepted. - */ - public static boolean isSettableFunctions(long functions) { - return (~SETTABLE_FUNCTIONS & functions) == 0; - } - - /** - * Returns the string representation of the given functions. - */ - public static String usbFunctionsToString(long functions) { - StringJoiner joiner = new StringJoiner(","); - if ((functions | MTP) != 0) { - joiner.add(UsbManager.USB_FUNCTION_MTP); - } - if ((functions | PTP) != 0) { - joiner.add(UsbManager.USB_FUNCTION_PTP); - } - if ((functions | RNDIS) != 0) { - joiner.add(UsbManager.USB_FUNCTION_RNDIS); - } - if ((functions | MIDI) != 0) { - joiner.add(UsbManager.USB_FUNCTION_MIDI); - } - if ((functions | ACCESSORY) != 0) { - joiner.add(UsbManager.USB_FUNCTION_ACCESSORY); - } - if ((functions | AUDIO_SOURCE) != 0) { - joiner.add(UsbManager.USB_FUNCTION_AUDIO_SOURCE); - } - if ((functions | ADB) != 0) { - joiner.add(UsbManager.USB_FUNCTION_ADB); - } - return joiner.toString(); - } - - /** - * Parses a string of usb functions and returns a mask of the same functions. - */ - public static long usbFunctionsFromString(String functions) { - if (functions == null) { - return 0; - } - long ret = 0; - for (String function : functions.split(",")) { - if (STR_MAP.containsKey(function)) { - ret |= STR_MAP.get(function); - } - } - return ret; - } -} diff --git a/tests/robotests/src/android/os/SystemUpdateManager.java b/tests/robotests/src/android/os/SystemUpdateManager.java deleted file mode 100644 index f81df3600ba..00000000000 --- a/tests/robotests/src/android/os/SystemUpdateManager.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018 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 android.os; - -/** - * Duplicate class for platform SystemUpdateManager to get around Robolectric sdk problem. - */ -public class SystemUpdateManager { - - public static final String KEY_STATUS = "status"; - public static final String KEY_TITLE = "title"; - - public static final int STATUS_UNKNOWN = 0; - public static final int STATUS_IDLE = 1; - public static final int STATUS_WAITING_DOWNLOAD = 2; - public static final int STATUS_IN_PROGRESS = 3; - public static final int STATUS_WAITING_INSTALL = 4; - public static final int STATUS_WAITING_REBOOT = 5; - - public Bundle retrieveSystemUpdateInfo() { - return null; - } -} diff --git a/tests/robotests/src/android/service/notification/NotifyingApp.java b/tests/robotests/src/android/service/notification/NotifyingApp.java deleted file mode 100644 index f36069b20c2..00000000000 --- a/tests/robotests/src/android/service/notification/NotifyingApp.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2018 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 android.service.notification; - -import android.annotation.NonNull; -import android.os.Parcel; -import android.os.Parcelable; - -import java.util.Objects; - -/** - * Stub implementation of framework's NotifyingApp for Robolectric tests. Otherwise Robolectric - * throws ClassNotFoundError. - * - * TODO: Remove this class when Robolectric supports P - */ -public final class NotifyingApp implements Comparable { - - private int mUid; - private String mPkg; - private long mLastNotified; - - public NotifyingApp() {} - - public int getUid() { - return mUid; - } - - /** - * Sets the uid of the package that sent the notification. Returns self. - */ - public NotifyingApp setUid(int mUid) { - this.mUid = mUid; - return this; - } - - public String getPackage() { - return mPkg; - } - - /** - * Sets the package that sent the notification. Returns self. - */ - public NotifyingApp setPackage(@NonNull String mPkg) { - this.mPkg = mPkg; - return this; - } - - public long getLastNotified() { - return mLastNotified; - } - - /** - * Sets the time the notification was originally sent. Returns self. - */ - public NotifyingApp setLastNotified(long mLastNotified) { - this.mLastNotified = mLastNotified; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - NotifyingApp that = (NotifyingApp) o; - return getUid() == that.getUid() - && getLastNotified() == that.getLastNotified() - && Objects.equals(mPkg, that.mPkg); - } - - @Override - public int hashCode() { - return Objects.hash(getUid(), mPkg, getLastNotified()); - } - - /** - * Sorts notifying apps from newest last notified date to oldest. - */ - @Override - public int compareTo(NotifyingApp o) { - if (getLastNotified() == o.getLastNotified()) { - if (getUid() == o.getUid()) { - return getPackage().compareTo(o.getPackage()); - } - return Integer.compare(getUid(), o.getUid()); - } - - return -Long.compare(getLastNotified(), o.getLastNotified()); - } - - @Override - public String toString() { - return "NotifyingApp{" - + "mUid=" + mUid - + ", mPkg='" + mPkg + '\'' - + ", mLastNotified=" + mLastNotified - + '}'; - } -} diff --git a/tests/robotests/src/android/service/oemlock/OemLockManager.java b/tests/robotests/src/android/service/oemlock/OemLockManager.java deleted file mode 100644 index c168089be4b..00000000000 --- a/tests/robotests/src/android/service/oemlock/OemLockManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 android.service.oemlock; - -/** - * Make OemLockManager available to Robolectric. - */ -public class OemLockManager { - public void setOemUnlockAllowedByCarrier(boolean allowed, byte[] signature) {} - - public boolean isOemUnlockAllowedByCarrier() { - return true; - } - - public void setOemUnlockAllowedByUser(boolean allowed) {} - - public boolean isOemUnlockAllowedByUser() { - return false; - } - - public boolean isOemUnlockAllowed() { - return false; - } - - public boolean isDeviceOemUnlocked() { - return false; - } -} diff --git a/tests/robotests/src/android/service/settings/suggestions/ISuggestionService.java b/tests/robotests/src/android/service/settings/suggestions/ISuggestionService.java deleted file mode 100644 index f4f5a519bd0..00000000000 --- a/tests/robotests/src/android/service/settings/suggestions/ISuggestionService.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 android.service.settings.suggestions; - -import java.util.List; - -public interface ISuggestionService { - List getSuggestions(); -} diff --git a/tests/robotests/src/android/service/settings/suggestions/Suggestion.java b/tests/robotests/src/android/service/settings/suggestions/Suggestion.java deleted file mode 100644 index 79aeb93bb24..00000000000 --- a/tests/robotests/src/android/service/settings/suggestions/Suggestion.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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 android.service.settings.suggestions; - -import android.app.PendingIntent; -import android.graphics.drawable.Icon; -import android.text.TextUtils; - -public class Suggestion { - - public static final int FLAG_HAS_BUTTON = 1 << 0; - - private final String mId; - private final CharSequence mTitle; - private final CharSequence mSummary; - private final Icon mIcon; - private final int mFlags; - private final PendingIntent mPendingIntent; - - /** - * Gets the id for the suggestion object. - */ - public String getId() { - return mId; - } - - /** - * Title of the suggestion that is shown to the user. - */ - public CharSequence getTitle() { - return mTitle; - } - - /** - * Optional summary describing what this suggestion controls. - */ - public CharSequence getSummary() { - return mSummary; - } - - /** - * Optional icon for this suggestion. - */ - public Icon getIcon() { - return mIcon; - } - - public int getFlags() { - return mFlags; - } - - /** - * The Intent to launch when the suggestion is activated. - */ - public PendingIntent getPendingIntent() { - return mPendingIntent; - } - - private Suggestion(Builder builder) { - mTitle = builder.mTitle; - mSummary = builder.mSummary; - mIcon = builder.mIcon; - mPendingIntent = builder.mPendingIntent; - mId = builder.mId; - mFlags = builder.mFlags; - } - - /** - * Builder class for {@link Suggestion}. - */ - public static class Builder { - - private final String mId; - private int mFlags; - private CharSequence mTitle; - private CharSequence mSummary; - private Icon mIcon; - private PendingIntent mPendingIntent; - - public Builder(String id) { - if (TextUtils.isEmpty(id)) { - throw new IllegalArgumentException("Suggestion id cannot be empty"); - } - mId = id; - } - - /** - * Sets suggestion title - */ - - public Builder setTitle(CharSequence title) { - mTitle = title; - return this; - } - - /** - * Sets suggestion summary - */ - public Builder setSummary(CharSequence summary) { - mSummary = summary; - return this; - } - - /** - * Sets icon for the suggestion. - */ - public Builder setIcon(Icon icon) { - mIcon = icon; - return this; - } - - public Builder setFlags(int flags) { - mFlags = flags; - return this; - } - - /** - * Sets suggestion intent - */ - public Builder setPendingIntent(PendingIntent pendingIntent) { - mPendingIntent = pendingIntent; - return this; - } - - /** - * Builds an immutable {@link Suggestion} object. - */ - public Suggestion build() { - return new Suggestion(this /* builder */); - } - } -} diff --git a/tests/robotests/src/android/util/FeatureFlagUtils.java b/tests/robotests/src/android/util/FeatureFlagUtils.java deleted file mode 100644 index e9dc9666b75..00000000000 --- a/tests/robotests/src/android/util/FeatureFlagUtils.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 android.util; - -import android.content.Context; -import android.os.SystemProperties; -import android.provider.Settings; -import android.text.TextUtils; - -import java.util.HashMap; -import java.util.Map; - -/** - * This class is only needed to get around Robolectric issue. - */ -public class FeatureFlagUtils { - public static final String FFLAG_PREFIX = "sys.fflag."; - public static final String FFLAG_OVERRIDE_PREFIX = FFLAG_PREFIX + "override."; - - /** - * Whether or not a flag is enabled. - * - * @param feature the flag name - * @return true if the flag is enabled (either by default in system, or override by user) - */ - public static boolean isEnabled(Context context, String feature) { - // Override precedence: - // Settings.Global -> sys.fflag.override.* -> sys.fflag.* - - // Step 1: check if feature flag is set in Settings.Global. - String value; - if (context != null) { - value = Settings.Global.getString(context.getContentResolver(), feature); - if (!TextUtils.isEmpty(value)) { - return Boolean.parseBoolean(value); - } - } - - // Step 2: check if feature flag has any override. Flag name: sys.fflag.override. - value = SystemProperties.get(FFLAG_OVERRIDE_PREFIX + feature); - if (!TextUtils.isEmpty(value)) { - return Boolean.parseBoolean(value); - } - // Step 3: check if feature flag has any default value. Flag name: sys.fflag. - value = SystemProperties.get(FFLAG_PREFIX + feature); - return Boolean.parseBoolean(value); - } - - /** - * Override feature flag to new state. - */ - public static void setEnabled(Context context, String feature, boolean enabled) { - SystemProperties.set(FFLAG_OVERRIDE_PREFIX + feature, enabled ? "true" : "false"); - } - - public static Map getAllFeatureFlags() { - final Map features = new HashMap<>(); - features.put(FFLAG_PREFIX + "abc", "false"); - features.put(FFLAG_OVERRIDE_PREFIX + "abc", "true"); - return features; - } -} diff --git a/tests/robotests/src/android/util/IconDrawableFactory.java b/tests/robotests/src/android/util/IconDrawableFactory.java deleted file mode 100644 index 9d0d7df2601..00000000000 --- a/tests/robotests/src/android/util/IconDrawableFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 android.util; - -import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageItemInfo; -import android.graphics.drawable.ColorDrawable; -import android.graphics.drawable.Drawable; - -/** - * This class is only needed to get around Robolectric issue. - */ -public class IconDrawableFactory { - - public static IconDrawableFactory newInstance(Context context) { - return new IconDrawableFactory(); - } - - public Drawable getBadgedIcon(ApplicationInfo appInfo) { - return getBadgedIcon(appInfo, 0); - } - - public Drawable getBadgedIcon(ApplicationInfo appInfo, int userId) { - return getBadgedIcon(appInfo, appInfo, userId); - } - - public Drawable getBadgedIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo, int userId) { - return new ColorDrawable(0); - } -}