[Settings] Replace ImsDirectQuery
This is a code refactor to replace 1. Legacy ImsQuery into ImsExecutorQuery 2. ImsDirectQuery into ImsQuery 3. SystemTty into Tty Bug: 140542283 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gBasePreferenceControllerTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gLteSliceHelperTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=VideoCallingPreferenceControllerTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingPreferenceControllerTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSettingsForSubTest Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingSliceHelperTest Change-Id: I239021c60fff47de307ac7e21641bee56e205861
This commit is contained in:
@@ -1,32 +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;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for direct querying IMS, and return {@code boolean}
|
|
||||||
*/
|
|
||||||
public interface ImsDirectQuery {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for performing IMS status/configuration query through public APIs
|
|
||||||
*
|
|
||||||
* @return result of query in boolean
|
|
||||||
*/
|
|
||||||
boolean directQuery();
|
|
||||||
|
|
||||||
}
|
|
@@ -1,56 +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 java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An implementation of {@code ImsQuery} and {@code ImsDirectQuery}.
|
|
||||||
*/
|
|
||||||
abstract class ImsDirectQueryImpl implements ImsQuery, ImsDirectQuery, Callable<Boolean> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of interface {@code ImsQuery}
|
|
||||||
*
|
|
||||||
* @param executors {@code ExecutorService} which allows to submit {@code ImsQuery} when
|
|
||||||
* required
|
|
||||||
* @return result of query in format of {@code Future<Boolean>}
|
|
||||||
*/
|
|
||||||
public Future<Boolean> query(ExecutorService executors) throws RejectedExecutionException {
|
|
||||||
return executors.submit(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of interface {@code ImsDirectQuery}
|
|
||||||
*
|
|
||||||
* @return result of query
|
|
||||||
*/
|
|
||||||
public boolean directQuery() {
|
|
||||||
return call();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query running within a {@code Callable}
|
|
||||||
*
|
|
||||||
* @return result of query
|
|
||||||
*/
|
|
||||||
public abstract Boolean call();
|
|
||||||
}
|
|
@@ -16,23 +16,17 @@
|
|||||||
|
|
||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for querying IMS, and return {@code Future<Boolean>}
|
* An interface for direct querying IMS, and return {@link boolean}
|
||||||
*/
|
*/
|
||||||
public interface ImsQuery {
|
public interface ImsQuery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for performing IMS status/configuration query through ExecutorService
|
* Interface for performing IMS status/configuration query through public APIs
|
||||||
*
|
*
|
||||||
* @param executors {@code ExecutorService} which allows to submit {@code ImsQuery} when
|
* @return result of query in boolean
|
||||||
* required
|
|
||||||
* @return result of query in format of {@code Future<Boolean>}
|
|
||||||
*/
|
*/
|
||||||
Future<Boolean> query(ExecutorService executors) throws RejectedExecutionException;
|
boolean query();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,12 +24,7 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
abstract class ImsQueryController {
|
abstract class ImsQueryController {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ImsDirectQuery isSystemTtyEnabled(Context context) {
|
ImsQuery isTtyOnVolteEnabled(int subId) {
|
||||||
return new ImsQuerySystemTtyStat(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
ImsDirectQuery isTtyOnVolteEnabled(int subId) {
|
|
||||||
return new ImsQueryTtyOnVolteStat(subId);
|
return new ImsQueryTtyOnVolteStat(subId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,47 +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 android.content.Context;
|
|
||||||
import android.telecom.TelecomManager;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An {@code ImsQuery} for accessing system TTY stat
|
|
||||||
*/
|
|
||||||
public class ImsQuerySystemTtyStat extends ImsDirectQueryImpl {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param context context of activity
|
|
||||||
*/
|
|
||||||
public ImsQuerySystemTtyStat(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
private volatile Context mContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query running within a {@code Callable}
|
|
||||||
*
|
|
||||||
* @return result of query
|
|
||||||
*/
|
|
||||||
public Boolean call() {
|
|
||||||
final TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
|
|
||||||
return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -20,9 +20,9 @@ import android.telephony.ims.ImsMmTelManager;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@code ImsQuery} for accessing IMS tty on VoLte stat
|
* An {@link ImsQuery} for accessing IMS tty on VoLte stat
|
||||||
*/
|
*/
|
||||||
public class ImsQueryTtyOnVolteStat extends ImsDirectQueryImpl {
|
public class ImsQueryTtyOnVolteStat implements ImsQuery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -35,11 +35,11 @@ public class ImsQueryTtyOnVolteStat extends ImsDirectQueryImpl {
|
|||||||
private volatile int mSubId;
|
private volatile int mSubId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query running within a {@code Callable}
|
* Implementation of interface {@link ImsQuery#query()}
|
||||||
*
|
*
|
||||||
* @return result of query
|
* @return result of query
|
||||||
*/
|
*/
|
||||||
public Boolean call() {
|
public boolean query() {
|
||||||
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||||
return imsMmTelManager.isTtyOverVolteEnabled();
|
return imsMmTelManager.isTtyOverVolteEnabled();
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,9 @@ import android.telephony.ims.ImsMmTelManager;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@code ImsQuery} for accessing IMS VT enabled settings from user
|
* An {@link ImsQuery} for accessing IMS VT enabled settings from user
|
||||||
*/
|
*/
|
||||||
public class ImsQueryVtUserSetting extends ImsDirectQueryImpl {
|
public class ImsQueryVtUserSetting implements ImsQuery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -35,11 +35,11 @@ public class ImsQueryVtUserSetting extends ImsDirectQueryImpl {
|
|||||||
private volatile int mSubId;
|
private volatile int mSubId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query running within a {@code Callable}
|
* Implementation of interface {@link ImsQuery#query()}
|
||||||
*
|
*
|
||||||
* @return result of query
|
* @return result of query
|
||||||
*/
|
*/
|
||||||
public Boolean call() {
|
public boolean query() {
|
||||||
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||||
return imsMmTelManager.isVtSettingEnabled();
|
return imsMmTelManager.isVtSettingEnabled();
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,9 @@ import android.telephony.ims.ImsMmTelManager;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@code ImsQuery} for accessing IMS WFC enabled settings from user
|
* An {@link ImsQuery} for accessing IMS WFC enabled settings from user
|
||||||
*/
|
*/
|
||||||
public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl {
|
public class ImsQueryWfcUserSetting implements ImsQuery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -35,11 +35,11 @@ public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl {
|
|||||||
private volatile int mSubId;
|
private volatile int mSubId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query running within a {@code Callable}
|
* Implementation of interface {@link ImsQuery#query()}
|
||||||
*
|
*
|
||||||
* @return result of query
|
* @return result of query
|
||||||
*/
|
*/
|
||||||
public Boolean call() {
|
public boolean query() {
|
||||||
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||||
return imsMmTelManager.isVoWiFiSettingEnabled();
|
return imsMmTelManager.isVoWiFiSettingEnabled();
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,11 @@
|
|||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.ims.ImsManager;
|
import com.android.ims.ImsManager;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
|
||||||
@@ -34,7 +37,7 @@ public class VolteQueryImsState extends ImsQueryController {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param context {@code Context}
|
* @param context {@link Context}
|
||||||
* @param subId subscription's id
|
* @param subId subscription's id
|
||||||
*/
|
*/
|
||||||
public VolteQueryImsState(Context context, int subId) {
|
public VolteQueryImsState(Context context, int subId) {
|
||||||
@@ -52,8 +55,14 @@ public class VolteQueryImsState extends ImsQueryController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((!isSystemTtyEnabled(mContext).directQuery())
|
return ((!isTtyEnabled(mContext))
|
||||||
|| (isTtyOnVolteEnabled(mSubId).directQuery()));
|
|| (isTtyOnVolteEnabled(mSubId).query()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isTtyEnabled(Context context) {
|
||||||
|
final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
|
||||||
|
return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -32,7 +33,7 @@ public class VtQueryImsState extends ImsQueryController {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param context {@code Context}
|
* @param context {@link Context}
|
||||||
* @param subId subscription's id
|
* @param subId subscription's id
|
||||||
*/
|
*/
|
||||||
public VtQueryImsState(Context context, int subId) {
|
public VtQueryImsState(Context context, int subId) {
|
||||||
@@ -44,7 +45,7 @@ public class VtQueryImsState extends ImsQueryController {
|
|||||||
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ImsDirectQuery isEnabledByUser(int subId) {
|
ImsQuery isEnabledByUser(int subId) {
|
||||||
return new ImsQueryVtUserSetting(subId);
|
return new ImsQueryVtUserSetting(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +58,14 @@ public class VtQueryImsState extends ImsQueryController {
|
|||||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ((!isSystemTtyEnabled(mContext).directQuery())
|
return ((!isTtyEnabled(mContext))
|
||||||
|| (isTtyOnVolteEnabled(mSubId).directQuery()));
|
|| (isTtyOnVolteEnabled(mSubId).query()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isTtyEnabled(Context context) {
|
||||||
|
final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
|
||||||
|
return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +77,6 @@ public class VtQueryImsState extends ImsQueryController {
|
|||||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isEnabledByUser(mSubId).directQuery();
|
return isEnabledByUser(mSubId).query();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.network.ims;
|
package com.android.settings.network.ims;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -32,7 +33,7 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param context {@code Context}
|
* @param context {@link Context}
|
||||||
* @param subId subscription's id
|
* @param subId subscription's id
|
||||||
*/
|
*/
|
||||||
public WifiCallingQueryImsState(Context context, int subId) {
|
public WifiCallingQueryImsState(Context context, int subId) {
|
||||||
@@ -44,7 +45,7 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
|||||||
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
* Implementation of ImsQueryController#isEnabledByUser(int subId)
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ImsDirectQuery isEnabledByUser(int subId) {
|
ImsQuery isEnabledByUser(int subId) {
|
||||||
return new ImsQueryWfcUserSetting(subId);
|
return new ImsQueryWfcUserSetting(subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +59,14 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((!isSystemTtyEnabled(mContext).directQuery())
|
return ((!isTtyEnabled(mContext))
|
||||||
|| (isTtyOnVolteEnabled(mSubId).directQuery()));
|
|| (isTtyOnVolteEnabled(mSubId).query()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isTtyEnabled(Context context) {
|
||||||
|
final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
|
||||||
|
return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,6 +78,6 @@ public class WifiCallingQueryImsState extends ImsQueryController {
|
|||||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isEnabledByUser(mSubId).directQuery();
|
return isEnabledByUser(mSubId).query();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user