Remove more wrappers

Bug: 76167422
Test: make RunSettingsRoboTests -j40
Change-Id: I0dc42c483ae92d508dec94e42573b55ced0e4bb0
This commit is contained in:
Fan Zhang
2018-03-30 11:33:08 -07:00
parent e645558049
commit c0c3eaa66c
19 changed files with 130 additions and 358 deletions

View File

@@ -1,40 +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.content.pm.ActivityInfo;
/**
* This class replicates a subset of the android.content.pm.ActivityInfo. The class
* exists so that we can use a thin wrapper around the ActivityInfo in production code and a mock in
* tests.
*/
public class ActivityInfoWrapper {
private final ActivityInfo mInfo;
public ActivityInfoWrapper(ActivityInfo info) {
mInfo = info;
}
/**
* Returns whether this activity supports picture-in-picture.
*/
public boolean supportsPictureInPicture() {
return mInfo.supportsPictureInPicture();
}
}

View File

@@ -1,55 +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.os.RemoteException;
import android.view.IWindowManager;
/**
* This class replicates a subset of the android.view.IWindowManager. The class
* exists so that we can use a thin wrapper around the IWindowManager in production code
* and a mock in tests.
*/
public class IWindowManagerWrapper {
private final IWindowManager mWindowManager;
public IWindowManagerWrapper(IWindowManager wm) {
mWindowManager = wm;
}
/**
* Returns true if window trace is enabled.
*/
public boolean isWindowTraceEnabled() throws RemoteException {
return mWindowManager.isWindowTraceEnabled();
}
/**
* Starts a window trace.
*/
public void startWindowTrace() throws RemoteException {
mWindowManager.startWindowTrace();
}
/**
* Stops a window trace.
*/
public void stopWindowTrace() throws RemoteException {
mWindowManager.stopWindowTrace();
}
}

View File

@@ -1,85 +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.util.KeyValueListParser;
/**
* This class replicates a subset of the {@link KeyValueListParser}. The class
* exists so that we can use a thin wrapper around the PM in production code and a mock in tests.
* We cannot directly mock or shadow the {@link KeyValueListParser}, because some of the methods
* we rely on are newer than the API version supported by Robolectric.
*/
public class KeyValueListParserWrapper {
private KeyValueListParser mParser;
public KeyValueListParserWrapper(KeyValueListParser parser) {
mParser = parser;
}
/**
* Get real {@link KeyValueListParser}
*/
public KeyValueListParser getKeyValueListParser() {
return mParser;
}
/**
* Resets the parser with a new string to parse. The string is expected to be in the following
* format:
* <pre>key1=value,key2=value,key3=value</pre>
*
* where the delimiter is a comma.
*
* @param str the string to parse.
* @throws IllegalArgumentException if the string is malformed.
*/
public void setString(String str) throws IllegalArgumentException {
mParser.setString(str);
}
/**
* Get the value for key as a boolean.
* @param key The key to lookup.
* @param defaultValue The value to return if the key was not found.
* @return the boolean value associated with the key.
*/
public boolean getBoolean(String key, boolean defaultValue) {
return mParser.getBoolean(key, defaultValue);
}
/**
* Get the value for key as a string.
* @param key The key to lookup.
* @param defaultValue The value to return if the key was not found.
* @return the string value associated with the key.
*/
public String getString(String key, String defaultValue) {
return mParser.getString(key, defaultValue);
}
/**
* Get the value for key as a long.
* @param key The key to lookup.
* @param defaultValue The value to return if the key was not found, or the value was not a
* long.
* @return the long value associated with the key.
*/
public long getLong(String key, long defaultValue) {
return mParser.getLong(key, defaultValue);
}
}

View File

@@ -1,38 +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.os.RecoverySystem;
/**
* This class replicates a subset of the {@link RecoverySystem}.
* The interface exists so that we can use a thin wrapper around the RecoverySystem in
* production code and a mock in tests.
*/
public class RecoverySystemWrapper {
/**
* Returns whether wipe Euicc data successfully or not.
*
* @param packageName the package name of the caller app.
*/
public boolean wipeEuiccData(
Context context, final String packageName) {
return RecoverySystem.wipeEuiccData(context, packageName);
}
}

View File

@@ -1,15 +0,0 @@
package com.android.settings.wrapper;
import android.content.Context;
import com.android.settingslib.RestrictedLockUtils;
/**
* Wrapper class needed to be able to test classes which use RestrictedLockUtils methods.
* Unfortunately there is no way to deal with this until robolectric is updated due to the fact
* that it is a static method and it uses new API's.
*/
public class RestrictedLockUtilsWrapper {
public boolean hasBaseUserRestriction(Context context, String userRestriction, int userId) {
return RestrictedLockUtils.hasBaseUserRestriction(context, userRestriction, userId);
}
}