Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff186345 authored by Bonian Chen's avatar Bonian Chen Committed by Android (Google) Code Review
Browse files

Merge "[Settings] replace isNonTtyOrTtyOnVolteEnabled() in WFC"

parents 2c0088be 72717cb5
Loading
Loading
Loading
Loading
+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();

}
+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();
}
+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;

}
+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);
    }
}
+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