diff --git a/src/com/android/settings/network/ims/ImsDirectQuery.java b/src/com/android/settings/network/ims/ImsDirectQuery.java deleted file mode 100644 index 4c6a932e125..00000000000 --- a/src/com/android/settings/network/ims/ImsDirectQuery.java +++ /dev/null @@ -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(); - -} diff --git a/src/com/android/settings/network/ims/ImsDirectQueryImpl.java b/src/com/android/settings/network/ims/ImsDirectQueryImpl.java deleted file mode 100644 index cff8461f500..00000000000 --- a/src/com/android/settings/network/ims/ImsDirectQueryImpl.java +++ /dev/null @@ -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 { - - /** - * 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} - */ - public Future 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(); -} diff --git a/src/com/android/settings/network/ims/ImsQuery.java b/src/com/android/settings/network/ims/ImsQuery.java index 1462718971a..dcb6eeeb648 100644 --- a/src/com/android/settings/network/ims/ImsQuery.java +++ b/src/com/android/settings/network/ims/ImsQuery.java @@ -16,23 +16,17 @@ 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} + * An interface for direct querying IMS, and return {@link boolean} */ 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 - * required - * @return result of query in format of {@code Future} + * @return result of query in boolean */ - Future query(ExecutorService executors) throws RejectedExecutionException; + boolean query(); } diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java index 651c4222366..83d6578982a 100644 --- a/src/com/android/settings/network/ims/ImsQueryController.java +++ b/src/com/android/settings/network/ims/ImsQueryController.java @@ -16,8 +16,6 @@ package com.android.settings.network.ims; -import android.content.Context; - import androidx.annotation.VisibleForTesting; /** @@ -26,12 +24,7 @@ import androidx.annotation.VisibleForTesting; abstract class ImsQueryController { @VisibleForTesting - ImsDirectQuery isSystemTtyEnabled(Context context) { - return new ImsQuerySystemTtyStat(context); - } - - @VisibleForTesting - ImsDirectQuery isTtyOnVolteEnabled(int subId) { + ImsQuery isTtyOnVolteEnabled(int subId) { return new ImsQueryTtyOnVolteStat(subId); } } diff --git a/src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java b/src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java deleted file mode 100644 index 4239b16e220..00000000000 --- a/src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java +++ /dev/null @@ -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); - } -} diff --git a/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java b/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java index a371ce7d080..c2d655f5120 100644 --- a/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java +++ b/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java @@ -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 @@ -35,11 +35,11 @@ public class ImsQueryTtyOnVolteStat extends ImsDirectQueryImpl { private volatile int mSubId; /** - * Query running within a {@code Callable} + * Implementation of interface {@link ImsQuery#query()} * * @return result of query */ - public Boolean call() { + public boolean query() { final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId); return imsMmTelManager.isTtyOverVolteEnabled(); } diff --git a/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java b/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java index 20e8c05009e..6d699e36c7b 100644 --- a/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java +++ b/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java @@ -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 @@ -35,11 +35,11 @@ public class ImsQueryVtUserSetting extends ImsDirectQueryImpl { private volatile int mSubId; /** - * Query running within a {@code Callable} + * Implementation of interface {@link ImsQuery#query()} * * @return result of query */ - public Boolean call() { + public boolean query() { final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId); return imsMmTelManager.isVtSettingEnabled(); } diff --git a/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java b/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java index 86e25e67e70..22d2c676b79 100644 --- a/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java +++ b/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java @@ -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 @@ -35,11 +35,11 @@ public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl { private volatile int mSubId; /** - * Query running within a {@code Callable} + * Implementation of interface {@link ImsQuery#query()} * * @return result of query */ - public Boolean call() { + public boolean query() { final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId); return imsMmTelManager.isVoWiFiSettingEnabled(); } diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java index b999cda95ff..320aa26b216 100644 --- a/src/com/android/settings/network/ims/VolteQueryImsState.java +++ b/src/com/android/settings/network/ims/VolteQueryImsState.java @@ -17,8 +17,11 @@ package com.android.settings.network.ims; import android.content.Context; +import android.telecom.TelecomManager; import android.telephony.SubscriptionManager; +import androidx.annotation.VisibleForTesting; + import com.android.ims.ImsManager; import com.android.settings.network.SubscriptionUtil; @@ -34,7 +37,7 @@ public class VolteQueryImsState extends ImsQueryController { /** * Constructor * - * @param context {@code Context} + * @param context {@link Context} * @param subId subscription's id */ public VolteQueryImsState(Context context, int subId) { @@ -52,8 +55,14 @@ public class VolteQueryImsState extends ImsQueryController { return false; } - return ((!isSystemTtyEnabled(mContext).directQuery()) - || (isTtyOnVolteEnabled(mSubId).directQuery())); + return ((!isTtyEnabled(mContext)) + || (isTtyOnVolteEnabled(mSubId).query())); + } + + @VisibleForTesting + boolean isTtyEnabled(Context context) { + final TelecomManager telecomManager = context.getSystemService(TelecomManager.class); + return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF); } /** diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java index ca8deea8d2e..5ac07a34668 100644 --- a/src/com/android/settings/network/ims/VtQueryImsState.java +++ b/src/com/android/settings/network/ims/VtQueryImsState.java @@ -17,6 +17,7 @@ package com.android.settings.network.ims; import android.content.Context; +import android.telecom.TelecomManager; import android.telephony.SubscriptionManager; import androidx.annotation.VisibleForTesting; @@ -32,7 +33,7 @@ public class VtQueryImsState extends ImsQueryController { /** * Constructor * - * @param context {@code Context} + * @param context {@link Context} * @param subId subscription's id */ public VtQueryImsState(Context context, int subId) { @@ -44,7 +45,7 @@ public class VtQueryImsState extends ImsQueryController { * Implementation of ImsQueryController#isEnabledByUser(int subId) */ @VisibleForTesting - ImsDirectQuery isEnabledByUser(int subId) { + ImsQuery isEnabledByUser(int subId) { return new ImsQueryVtUserSetting(subId); } @@ -57,8 +58,14 @@ public class VtQueryImsState extends ImsQueryController { if (!SubscriptionManager.isValidSubscriptionId(mSubId)) { return false; } - return ((!isSystemTtyEnabled(mContext).directQuery()) - || (isTtyOnVolteEnabled(mSubId).directQuery())); + return ((!isTtyEnabled(mContext)) + || (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)) { return false; } - return isEnabledByUser(mSubId).directQuery(); + return isEnabledByUser(mSubId).query(); } } diff --git a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java index f8b076781ca..e1b3bbfe3d0 100644 --- a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java +++ b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java @@ -17,6 +17,7 @@ package com.android.settings.network.ims; import android.content.Context; +import android.telecom.TelecomManager; import android.telephony.SubscriptionManager; import androidx.annotation.VisibleForTesting; @@ -32,7 +33,7 @@ public class WifiCallingQueryImsState extends ImsQueryController { /** * Constructor * - * @param context {@code Context} + * @param context {@link Context} * @param subId subscription's id */ public WifiCallingQueryImsState(Context context, int subId) { @@ -44,7 +45,7 @@ public class WifiCallingQueryImsState extends ImsQueryController { * Implementation of ImsQueryController#isEnabledByUser(int subId) */ @VisibleForTesting - ImsDirectQuery isEnabledByUser(int subId) { + ImsQuery isEnabledByUser(int subId) { return new ImsQueryWfcUserSetting(subId); } @@ -58,8 +59,14 @@ public class WifiCallingQueryImsState extends ImsQueryController { return false; } - return ((!isSystemTtyEnabled(mContext).directQuery()) - || (isTtyOnVolteEnabled(mSubId).directQuery())); + return ((!isTtyEnabled(mContext)) + || (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)) { return false; } - return isEnabledByUser(mSubId).directQuery(); + return isEnabledByUser(mSubId).query(); } }