Merge changes from topic "remove_wrappers" into pi-dev
* changes: Remove wrapper class for NotificationGroup. Remove more wrappers in favor of new Robolectric support
This commit is contained in:
committed by
Android (Google) Code Review
commit
e6a18f8105
@@ -1,47 +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 com.android.settings.wrapper;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.content.ComponentName;
|
||||
|
||||
/**
|
||||
* This class replicates a subset of the
|
||||
* {@link android.accessibilityservice.AccessibilityServiceInfo}. The class
|
||||
* 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 class AccessibilityServiceInfoWrapper {
|
||||
|
||||
private final AccessibilityServiceInfo mServiceInfo;
|
||||
|
||||
public AccessibilityServiceInfoWrapper(AccessibilityServiceInfo serviceInfo) {
|
||||
mServiceInfo = serviceInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the real {@code AccessibilityServiceInfo} object.
|
||||
*/
|
||||
public AccessibilityServiceInfo getAccessibilityServiceInfo() {
|
||||
return mServiceInfo;
|
||||
}
|
||||
|
||||
public ComponentName getComponentName() {
|
||||
return mServiceInfo.getComponentName();
|
||||
}
|
||||
}
|
||||
@@ -1,64 +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 com.android.settings.wrapper;
|
||||
|
||||
import android.app.NotificationChannelGroup;
|
||||
|
||||
/**
|
||||
* Wrapper for {@link NotificationChannelGroup} until roboletric supports O MR1.
|
||||
*/
|
||||
public class NotificationChannelGroupWrapper {
|
||||
|
||||
private final NotificationChannelGroup mGroup;
|
||||
|
||||
public NotificationChannelGroupWrapper(NotificationChannelGroup group) {
|
||||
mGroup = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the real group object so we can call APIs directly on it.
|
||||
*/
|
||||
public NotificationChannelGroup getGroup() {
|
||||
return mGroup;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
if (mGroup != null) {
|
||||
return mGroup.getDescription();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDescription(String desc) {
|
||||
if (mGroup != null) {
|
||||
mGroup.setDescription(desc);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
if (mGroup != null) {
|
||||
return mGroup.isBlocked();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
if (mGroup != null) {
|
||||
mGroup.setBlocked(blocked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +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 com.android.settings.wrapper;
|
||||
|
||||
import android.os.PowerManager;
|
||||
|
||||
/**
|
||||
* This class replicates a subset of the android.os.PowerManager. The class exists so that we can
|
||||
* use a thin wrapper around the PowerManager in production code and a mock in tests. We cannot
|
||||
* directly mock or shadow the PowerManager, because some of the methods we rely on are newer than
|
||||
* the API version supported by Robolectric or are hidden.
|
||||
*/
|
||||
public class PowerManagerWrapper {
|
||||
private final PowerManager mPowerManager;
|
||||
|
||||
public PowerManagerWrapper(PowerManager powerManager) {
|
||||
mPowerManager = powerManager;
|
||||
}
|
||||
|
||||
public int getMinimumScreenBrightnessSetting() {
|
||||
return mPowerManager.getMinimumScreenBrightnessSetting();
|
||||
}
|
||||
|
||||
public int getMaximumScreenBrightnessSetting() {
|
||||
return mPowerManager.getMaximumScreenBrightnessSetting();
|
||||
}
|
||||
|
||||
public int getMinimumScreenBrightnessForVrSetting() {
|
||||
return mPowerManager.getMinimumScreenBrightnessForVrSetting();
|
||||
}
|
||||
|
||||
public int getMaximumScreenBrightnessForVrSetting() {
|
||||
return mPowerManager.getMaximumScreenBrightnessForVrSetting();
|
||||
}
|
||||
}
|
||||
@@ -1,54 +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 com.android.settings.wrapper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.print.PrintJob;
|
||||
import android.print.PrintManager;
|
||||
import android.printservice.PrintServiceInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Wrapper class for {@link PrintManager}. This is necessary to increase testability in Robolectric.
|
||||
*/
|
||||
public class PrintManagerWrapper {
|
||||
|
||||
private final PrintManager mPrintManager;
|
||||
|
||||
public PrintManagerWrapper(Context context) {
|
||||
mPrintManager = ((PrintManager) context.getSystemService(Context.PRINT_SERVICE))
|
||||
.getGlobalPrintManagerForUser(context.getUserId());
|
||||
}
|
||||
|
||||
public List<PrintServiceInfo> getPrintServices(int selectionFlags) {
|
||||
return mPrintManager.getPrintServices(selectionFlags);
|
||||
}
|
||||
|
||||
public void addPrintJobStateChanegListener(PrintManager.PrintJobStateChangeListener listener) {
|
||||
mPrintManager.addPrintJobStateChangeListener(listener);
|
||||
}
|
||||
|
||||
public void removePrintJobStateChangeListener(
|
||||
PrintManager.PrintJobStateChangeListener listener) {
|
||||
mPrintManager.removePrintJobStateChangeListener(listener);
|
||||
}
|
||||
|
||||
public List<PrintJob> getPrintJobs() {
|
||||
return mPrintManager.getPrintJobs();
|
||||
}
|
||||
}
|
||||
@@ -1,30 +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 com.android.settings.wrapper;
|
||||
|
||||
import android.hardware.usb.UsbManager;
|
||||
|
||||
public class UsbManagerWrapper {
|
||||
private UsbManager mUsbManager;
|
||||
|
||||
public UsbManagerWrapper(UsbManager manager) {
|
||||
mUsbManager = manager;
|
||||
}
|
||||
|
||||
public long getCurrentFunctions() {
|
||||
return mUsbManager.getCurrentFunctions();
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.android.settings.wrapper;
|
||||
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
/**
|
||||
* Wrapper around {@link WifiManager} to facilitate unit testing.
|
||||
*
|
||||
* TODO: delete this class once robolectric supports Android O
|
||||
*/
|
||||
public class WifiManagerWrapper {
|
||||
private final WifiManager mWifiManager;
|
||||
|
||||
public WifiManagerWrapper(WifiManager wifiManager) {
|
||||
mWifiManager = wifiManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the real WifiManager
|
||||
* @return the real WifiManager
|
||||
*/
|
||||
public WifiManager getWifiManager() {
|
||||
return mWifiManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link WifiManager#getCurrentNetworkWpsNfcConfigurationToken}
|
||||
*/
|
||||
public String getCurrentNetworkWpsNfcConfigurationToken() {
|
||||
return mWifiManager.getCurrentNetworkWpsNfcConfigurationToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link WifiManager#removePasspointConfiguration}
|
||||
*/
|
||||
public void removePasspointConfiguration(String fqdn) {
|
||||
mWifiManager.removePasspointConfiguration(fqdn);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link WifiManager#forget}
|
||||
*/
|
||||
public void forget(int netId, WifiManager.ActionListener listener) {
|
||||
mWifiManager.forget(netId, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link WifiManager#save}
|
||||
*/
|
||||
public void save(WifiConfiguration config, WifiManager.ActionListener listener) {
|
||||
mWifiManager.save(config, listener);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user