Merge "[Settings] replace isNonTtyOrTtyOnVolteEnabled() in WFC"
This commit is contained in:
32
src/com/android/settings/network/ims/ImsDirectQuery.java
Normal file
32
src/com/android/settings/network/ims/ImsDirectQuery.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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();
|
||||
|
||||
}
|
56
src/com/android/settings/network/ims/ImsDirectQueryImpl.java
Normal file
56
src/com/android/settings/network/ims/ImsDirectQueryImpl.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
38
src/com/android/settings/network/ims/ImsQuery.java
Normal file
38
src/com/android/settings/network/ims/ImsQuery.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
|
||||
/**
|
||||
* An interface for querying IMS, and return {@code Future<Boolean>}
|
||||
*/
|
||||
public interface ImsQuery {
|
||||
|
||||
/**
|
||||
* Interface for performing IMS status/configuration query through ExecutorService
|
||||
*
|
||||
* @param executors {@code ExecutorService} which allows to submit {@code ImsQuery} when
|
||||
* required
|
||||
* @return result of query in format of {@code Future<Boolean>}
|
||||
*/
|
||||
Future<Boolean> query(ExecutorService executors) throws RejectedExecutionException;
|
||||
|
||||
}
|
37
src/com/android/settings/network/ims/ImsQueryController.java
Normal file
37
src/com/android/settings/network/ims/ImsQueryController.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 androidx.annotation.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Controller class for querying IMS status
|
||||
*/
|
||||
abstract class ImsQueryController {
|
||||
|
||||
@VisibleForTesting
|
||||
ImsDirectQuery isSystemTtyEnabled(Context context) {
|
||||
return new ImsQuerySystemTtyStat(context);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
ImsDirectQuery isTtyOnVolteEnabled(int subId) {
|
||||
return new ImsQueryTtyOnVolteStat(subId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.telephony.ims.ImsMmTelManager;
|
||||
|
||||
|
||||
/**
|
||||
* An {@code ImsQuery} for accessing IMS tty on VoLte stat
|
||||
*/
|
||||
public class ImsQueryTtyOnVolteStat extends ImsDirectQueryImpl {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param subId subscription id
|
||||
*/
|
||||
public ImsQueryTtyOnVolteStat(int subId) {
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
private volatile int mSubId;
|
||||
|
||||
/**
|
||||
* Query running within a {@code Callable}
|
||||
*
|
||||
* @return result of query
|
||||
*/
|
||||
public Boolean call() {
|
||||
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
|
||||
return imsMmTelManager.isTtyOverVolteEnabled();
|
||||
}
|
||||
}
|
@@ -25,7 +25,7 @@ import com.android.settings.network.SubscriptionUtil;
|
||||
/**
|
||||
* Controller class for querying Wifi calling status
|
||||
*/
|
||||
public class WifiCallingQueryImsState {
|
||||
public class WifiCallingQueryImsState extends ImsQueryController {
|
||||
|
||||
private Context mContext;
|
||||
private int mSubId;
|
||||
@@ -41,6 +41,20 @@ public class WifiCallingQueryImsState {
|
||||
mSubId = subId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowance status for user to alter configuration
|
||||
*
|
||||
* @return true when changing configuration by user is allowed.
|
||||
*/
|
||||
public boolean isAllowUserControl() {
|
||||
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((!isSystemTtyEnabled(mContext).directQuery())
|
||||
|| (isTtyOnVolteEnabled(mSubId).directQuery()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user's configuration
|
||||
*
|
||||
|
@@ -21,17 +21,20 @@ import android.telephony.SubscriptionManager;
|
||||
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
|
||||
public class WifiCallingSuggestionActivity extends SettingsActivity {
|
||||
|
||||
public static boolean isSuggestionComplete(Context context) {
|
||||
final WifiCallingQueryImsState queryState =
|
||||
new WifiCallingQueryImsState(context,
|
||||
SubscriptionManager.getDefaultVoiceSubscriptionId());
|
||||
if (!ImsManager.isWfcEnabledByPlatform(context) ||
|
||||
!MobileNetworkUtils.isWfcProvisionedOnDevice(
|
||||
SubscriptionManager.getDefaultVoiceSubscriptionId())) {
|
||||
return true;
|
||||
}
|
||||
return ImsManager.isWfcEnabledByUser(context)
|
||||
&& ImsManager.isNonTtyOrTtyOnVolteEnabled(context);
|
||||
return queryState.isEnabledByUser() && queryState.isAllowUserControl();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user