Search in sources :

Example 1 with CallForwardingInfo

use of android.telephony.CallForwardingInfo in project android_packages_apps_Settings by omnirom.

the class SmartForwardingUtils method getAllSlotCallForwardingStatus.

public static CallForwardingInfo[] getAllSlotCallForwardingStatus(Context context, SubscriptionManager sm, TelephonyManager tm) {
    int phoneCount = tm.getActiveModemCount();
    CallForwardingInfo[] allStatus = new CallForwardingInfo[phoneCount];
    for (int i = 0; i < phoneCount; i++) {
        int subId = sm.getSubscriptionIds(i)[0];
        CallForwardingInfo callWaitingStatus = getBackupCallForwardingStatus(context, subId);
        allStatus[i] = callWaitingStatus;
    }
    return allStatus;
}
Also used : CallForwardingInfo(android.telephony.CallForwardingInfo)

Example 2 with CallForwardingInfo

use of android.telephony.CallForwardingInfo in project android_packages_apps_Settings by omnirom.

the class SmartForwardingActivity method disableSmartForwarding.

public void disableSmartForwarding() {
    TelephonyManager tm = getSystemService(TelephonyManager.class);
    SubscriptionManager sm = getSystemService(SubscriptionManager.class);
    boolean[] callWaitingStatus = getAllSlotCallWaitingStatus(this, sm, tm);
    CallForwardingInfo[] callForwardingInfo = getAllSlotCallForwardingStatus(this, sm, tm);
    // Disable feature
    ListenableFuture disableTask = service.submit(new DisableSmartForwardingTask(tm, callWaitingStatus, callForwardingInfo));
    Futures.addCallback(disableTask, new FutureCallback() {

        @Override
        public void onSuccess(Object result) {
            clearAllBackupData(SmartForwardingActivity.this, sm, tm);
        }

        @Override
        public void onFailure(Throwable t) {
            Log.e(TAG, "Disable Feature exception" + t);
        }
    }, ContextCompat.getMainExecutor(this));
}
Also used : CallForwardingInfo(android.telephony.CallForwardingInfo) TelephonyManager(android.telephony.TelephonyManager) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SubscriptionManager(android.telephony.SubscriptionManager) FutureCallback(com.google.common.util.concurrent.FutureCallback)

Example 3 with CallForwardingInfo

use of android.telephony.CallForwardingInfo in project android_packages_apps_Settings by omnirom.

the class SmartForwardingUtils method getBackupCallForwardingStatus.

public static CallForwardingInfo getBackupCallForwardingStatus(Context context, int subId) {
    SharedPreferences preferences = context.getSharedPreferences(SMART_FORWARDING_PREF + subId, Context.MODE_PRIVATE);
    if (preferences.contains(CALL_FORWARDING_ENABLED_KEY)) {
        boolean enabled = preferences.getBoolean(CALL_FORWARDING_ENABLED_KEY, false);
        int reason = preferences.getInt(CALL_FORWARDING_REASON_KEY, CallForwardingInfo.REASON_UNCONDITIONAL);
        String number = preferences.getString(CALL_FORWARDING_NUMBER_KEY, "");
        int time = preferences.getInt(CALL_FORWARDING_TIME_KEY, 1);
        return new CallForwardingInfo(enabled, reason, number, time);
    } else {
        return null;
    }
}
Also used : CallForwardingInfo(android.telephony.CallForwardingInfo) SharedPreferences(android.content.SharedPreferences)

Aggregations

CallForwardingInfo (android.telephony.CallForwardingInfo)3 SharedPreferences (android.content.SharedPreferences)1 SubscriptionManager (android.telephony.SubscriptionManager)1 TelephonyManager (android.telephony.TelephonyManager)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1