[Settings] Code refactor for IMS part
Return boolean in method names starting with "is". Bug: 140542283 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gBasePreferenceControllerTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gLteSliceHelperTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=VideoCallingPreferenceControllerTest Change-Id: I2a9ca9ae829f0dcda478f3343cd50e61f441a9a7
This commit is contained in:
@@ -47,13 +47,15 @@ abstract class ImsQueryController {
|
||||
mTransportType = transportType;
|
||||
}
|
||||
|
||||
abstract boolean isEnabledByUser(int subId);
|
||||
|
||||
@VisibleForTesting
|
||||
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||
return new ImsQueryTtyOnVolteStat(subId);
|
||||
boolean isTtyOnVolteEnabled(int subId) {
|
||||
return (new ImsQueryTtyOnVolteStat(subId)).query();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
ImsQuery isProvisionedOnDevice(int subId) {
|
||||
return new ImsQueryProvisioningStat(subId, mCapability, mTech);
|
||||
boolean isProvisionedOnDevice(int subId) {
|
||||
return (new ImsQueryProvisioningStat(subId, mCapability, mTech)).query();
|
||||
}
|
||||
}
|
||||
|
@@ -55,8 +55,8 @@ public class VolteQueryImsState extends ImsQueryController {
|
||||
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||
*/
|
||||
@VisibleForTesting
|
||||
ImsQuery isEnabledByUser(int subId) {
|
||||
return new ImsQueryEnhanced4gLteModeUserSetting(subId);
|
||||
boolean isEnabledByUser(int subId) {
|
||||
return (new ImsQueryEnhanced4gLteModeUserSetting(subId)).query();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -77,7 +77,7 @@ public class VolteQueryImsState extends ImsQueryController {
|
||||
}
|
||||
|
||||
return imsManager.isVolteEnabledByPlatform()
|
||||
&& isProvisionedOnDevice(mSubId).query();
|
||||
&& isProvisionedOnDevice(mSubId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public class VolteQueryImsState extends ImsQueryController {
|
||||
}
|
||||
|
||||
return ((!isTtyEnabled(mContext))
|
||||
|| (isTtyOnVolteEnabled(mSubId).query()));
|
||||
|| (isTtyOnVolteEnabled(mSubId)));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -119,6 +119,6 @@ public class VolteQueryImsState extends ImsQueryController {
|
||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
return false;
|
||||
}
|
||||
return isEnabledByUser(mSubId).query();
|
||||
return isEnabledByUser(mSubId);
|
||||
}
|
||||
}
|
||||
|
@@ -55,8 +55,8 @@ public class VtQueryImsState extends ImsQueryController {
|
||||
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||
*/
|
||||
@VisibleForTesting
|
||||
ImsQuery isEnabledByUser(int subId) {
|
||||
return new ImsQueryVtUserSetting(subId);
|
||||
boolean isEnabledByUser(int subId) {
|
||||
return (new ImsQueryVtUserSetting(subId)).query();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -77,7 +77,7 @@ public class VtQueryImsState extends ImsQueryController {
|
||||
}
|
||||
|
||||
return imsManager.isVtEnabledByPlatform()
|
||||
&& isProvisionedOnDevice(mSubId).query()
|
||||
&& isProvisionedOnDevice(mSubId)
|
||||
&& MobileNetworkUtils.isImsServiceStateReady(imsManager);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class VtQueryImsState extends ImsQueryController {
|
||||
return false;
|
||||
}
|
||||
return ((!isTtyEnabled(mContext))
|
||||
|| (isTtyOnVolteEnabled(mSubId).query()));
|
||||
|| (isTtyOnVolteEnabled(mSubId)));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -109,6 +109,6 @@ public class VtQueryImsState extends ImsQueryController {
|
||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
return false;
|
||||
}
|
||||
return isEnabledByUser(mSubId).query();
|
||||
return isEnabledByUser(mSubId);
|
||||
}
|
||||
}
|
||||
|
@@ -55,8 +55,8 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||
*/
|
||||
@VisibleForTesting
|
||||
ImsQuery isEnabledByUser(int subId) {
|
||||
return new ImsQueryWfcUserSetting(subId);
|
||||
boolean isEnabledByUser(int subId) {
|
||||
return (new ImsQueryWfcUserSetting(subId)).query();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -77,7 +77,7 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
}
|
||||
|
||||
return imsManager.isWfcEnabledByPlatform()
|
||||
&& isProvisionedOnDevice(mSubId).query();
|
||||
&& isProvisionedOnDevice(mSubId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
}
|
||||
|
||||
return ((!isTtyEnabled(mContext))
|
||||
|| (isTtyOnVolteEnabled(mSubId).query()));
|
||||
|| (isTtyOnVolteEnabled(mSubId)));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -119,6 +119,6 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
return false;
|
||||
}
|
||||
return isEnabledByUser(mSubId).query();
|
||||
return isEnabledByUser(mSubId);
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.network.ims;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class MockImsQueryResult {
|
||||
|
||||
public static class BooleanResult implements ImsQuery {
|
||||
private boolean mResult;
|
||||
|
||||
public BooleanResult(boolean result) {
|
||||
super();
|
||||
mResult = result;
|
||||
}
|
||||
|
||||
public boolean query() {
|
||||
return mResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -27,9 +27,9 @@ import com.android.ims.ImsManager;
|
||||
*/
|
||||
public class MockVolteQueryImsState extends VolteQueryImsState {
|
||||
|
||||
private ImsQuery mIsTtyOnVolteEnabled;
|
||||
private ImsQuery mIsProvisionedOnDevice;
|
||||
private ImsQuery mIsEnabledByUser;
|
||||
private Boolean mIsTtyOnVolteEnabled;
|
||||
private Boolean mIsProvisionedOnDevice;
|
||||
private Boolean mIsEnabledByUser;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -46,11 +46,11 @@ public class MockVolteQueryImsState extends VolteQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsTtyOnVolteEnabled(boolean enabled) {
|
||||
mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
|
||||
mIsTtyOnVolteEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||
boolean isTtyOnVolteEnabled(int subId) {
|
||||
if (mIsTtyOnVolteEnabled != null) {
|
||||
return mIsTtyOnVolteEnabled;
|
||||
}
|
||||
@@ -58,11 +58,11 @@ public class MockVolteQueryImsState extends VolteQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsProvisionedOnDevice(boolean isProvisioned) {
|
||||
mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
|
||||
mIsProvisionedOnDevice = isProvisioned;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isProvisionedOnDevice(int subId) {
|
||||
boolean isProvisionedOnDevice(int subId) {
|
||||
if (mIsProvisionedOnDevice != null) {
|
||||
return mIsProvisionedOnDevice;
|
||||
}
|
||||
@@ -70,11 +70,11 @@ public class MockVolteQueryImsState extends VolteQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsEnabledByUser(boolean enabled) {
|
||||
mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
|
||||
mIsEnabledByUser = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isEnabledByUser(int subId) {
|
||||
boolean isEnabledByUser(int subId) {
|
||||
if (mIsEnabledByUser != null) {
|
||||
return mIsEnabledByUser;
|
||||
}
|
||||
|
@@ -26,9 +26,9 @@ import com.android.ims.ImsManager;
|
||||
*/
|
||||
public class MockVtQueryImsState extends VtQueryImsState {
|
||||
|
||||
private ImsQuery mIsTtyOnVolteEnabled;
|
||||
private ImsQuery mIsProvisionedOnDevice;
|
||||
private ImsQuery mIsEnabledByUser;
|
||||
private Boolean mIsTtyOnVolteEnabled;
|
||||
private Boolean mIsProvisionedOnDevice;
|
||||
private Boolean mIsEnabledByUser;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -45,11 +45,11 @@ public class MockVtQueryImsState extends VtQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsTtyOnVolteEnabled(boolean enabled) {
|
||||
mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
|
||||
mIsTtyOnVolteEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||
boolean isTtyOnVolteEnabled(int subId) {
|
||||
if (mIsTtyOnVolteEnabled != null) {
|
||||
return mIsTtyOnVolteEnabled;
|
||||
}
|
||||
@@ -57,11 +57,11 @@ public class MockVtQueryImsState extends VtQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsProvisionedOnDevice(boolean isProvisioned) {
|
||||
mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
|
||||
mIsProvisionedOnDevice = isProvisioned;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isProvisionedOnDevice(int subId) {
|
||||
boolean isProvisionedOnDevice(int subId) {
|
||||
if (mIsProvisionedOnDevice != null) {
|
||||
return mIsProvisionedOnDevice;
|
||||
}
|
||||
@@ -69,11 +69,11 @@ public class MockVtQueryImsState extends VtQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsEnabledByUser(boolean enabled) {
|
||||
mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
|
||||
mIsEnabledByUser = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isEnabledByUser(int subId) {
|
||||
boolean isEnabledByUser(int subId) {
|
||||
if (mIsEnabledByUser != null) {
|
||||
return mIsEnabledByUser;
|
||||
}
|
||||
|
@@ -26,9 +26,9 @@ import com.android.ims.ImsManager;
|
||||
*/
|
||||
public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
||||
|
||||
private ImsQuery mIsTtyOnVolteEnabled;
|
||||
private ImsQuery mIsProvisionedOnDevice;
|
||||
private ImsQuery mIsEnabledByUser;
|
||||
private Boolean mIsTtyOnVolteEnabled;
|
||||
private Boolean mIsProvisionedOnDevice;
|
||||
private Boolean mIsEnabledByUser;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -45,11 +45,11 @@ public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsTtyOnVolteEnabled(boolean enabled) {
|
||||
mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
|
||||
mIsTtyOnVolteEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||
boolean isTtyOnVolteEnabled(int subId) {
|
||||
if (mIsTtyOnVolteEnabled != null) {
|
||||
return mIsTtyOnVolteEnabled;
|
||||
}
|
||||
@@ -57,11 +57,11 @@ public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsProvisionedOnDevice(boolean isProvisioned) {
|
||||
mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
|
||||
mIsProvisionedOnDevice = isProvisioned;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isProvisionedOnDevice(int subId) {
|
||||
boolean isProvisionedOnDevice(int subId) {
|
||||
if (mIsProvisionedOnDevice != null) {
|
||||
return mIsProvisionedOnDevice;
|
||||
}
|
||||
@@ -69,11 +69,11 @@ public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
|
||||
}
|
||||
|
||||
public void setIsEnabledByUser(boolean enabled) {
|
||||
mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
|
||||
mIsEnabledByUser = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
ImsQuery isEnabledByUser(int subId) {
|
||||
boolean isEnabledByUser(int subId) {
|
||||
if (mIsEnabledByUser != null) {
|
||||
return mIsEnabledByUser;
|
||||
}
|
||||
|
Reference in New Issue
Block a user