Loading src/com/android/settings/network/ims/ImsDirectQuery.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * 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(); } src/com/android/settings/network/ims/ImsDirectQueryImpl.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * 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(); } src/com/android/settings/network/ims/ImsQuery.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* * 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; } src/com/android/settings/network/ims/ImsQueryController.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * 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); } } src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * 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); } } Loading
src/com/android/settings/network/ims/ImsDirectQuery.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * 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(); }
src/com/android/settings/network/ims/ImsDirectQueryImpl.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * 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(); }
src/com/android/settings/network/ims/ImsQuery.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* * 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; }
src/com/android/settings/network/ims/ImsQueryController.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * 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); } }
src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * 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); } }