Search in sources :

Example 51 with TelecomManager

use of android.telecom.TelecomManager in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method stopLockTaskMode.

@Override
public void stopLockTaskMode() {
    final TaskRecord lockTask = mStackSupervisor.getLockedTaskLocked();
    if (lockTask == null) {
        // Our work here is done.
        return;
    }
    final int callingUid = Binder.getCallingUid();
    final int lockTaskUid = lockTask.mLockTaskUid;
    final int lockTaskModeState = mStackSupervisor.getLockTaskModeState();
    if (lockTaskModeState == ActivityManager.LOCK_TASK_MODE_NONE) {
        // Done.
        return;
    } else {
        // {@link MANAGE_ACTIVITY_STACKS} can stop any lock task.
        if (checkCallingPermission(MANAGE_ACTIVITY_STACKS) != PERMISSION_GRANTED && callingUid != lockTaskUid && (lockTaskUid != 0 || callingUid != lockTask.effectiveUid)) {
            throw new SecurityException("Invalid uid, expected " + lockTaskUid + " callingUid=" + callingUid + " effectiveUid=" + lockTask.effectiveUid);
        }
    }
    long ident = Binder.clearCallingIdentity();
    try {
        Log.d(TAG, "stopLockTaskMode");
        // Stop lock task
        synchronized (this) {
            mStackSupervisor.setLockTaskModeLocked(null, ActivityManager.LOCK_TASK_MODE_NONE, "stopLockTask", true);
        }
        TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        if (tm != null) {
            tm.showInCallScreen(false);
        }
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
Also used : Point(android.graphics.Point) TelecomManager(android.telecom.TelecomManager)

Example 52 with TelecomManager

use of android.telecom.TelecomManager in project android_frameworks_base by DirtyUnicorns.

the class ZenModeFiltering method isDefaultPhoneApp.

private boolean isDefaultPhoneApp(String pkg) {
    if (mDefaultPhoneApp == null) {
        final TelecomManager telecomm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        mDefaultPhoneApp = telecomm != null ? telecomm.getDefaultPhoneApp() : null;
        if (DEBUG)
            Slog.d(TAG, "Default phone app: " + mDefaultPhoneApp);
    }
    return pkg != null && mDefaultPhoneApp != null && pkg.equals(mDefaultPhoneApp.getPackageName());
}
Also used : TelecomManager(android.telecom.TelecomManager)

Example 53 with TelecomManager

use of android.telecom.TelecomManager in project android_frameworks_base by DirtyUnicorns.

the class TelecomLoaderService method updateSimCallManagerPermissions.

private void updateSimCallManagerPermissions(PackageManagerInternal packageManagerInternal, int userId) {
    TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
    PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
    if (phoneAccount != null) {
        Slog.i(TAG, "updating sim call manager permissions for userId:" + userId);
        String packageName = phoneAccount.getComponentName().getPackageName();
        packageManagerInternal.grantDefaultPermissionsToDefaultSimCallManager(packageName, userId);
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelecomManager(android.telecom.TelecomManager)

Example 54 with TelecomManager

use of android.telecom.TelecomManager in project android_frameworks_base by AOSPA.

the class SimSwitchController method setVoicePref.

private void setVoicePref(int slotId) {
    final TelecomManager telecomManager = TelecomManager.from(mContext);
    int subId = -1;
    logd("Setting voice pref slotId " + slotId);
    if (mSubInfoList != null) {
        int subInfoLength = mSubInfoList.size();
        for (int i = 0; i < subInfoLength; ++i) {
            final SubscriptionInfo sir = mSubInfoList.get(i);
            if (sir != null && sir.getSimSlotIndex() == slotId) {
                subId = sir.getSubscriptionId();
                logd("Setting voice pref slotId " + slotId + " subId " + subId);
                PhoneAccountHandle phoneAccountHandle = subscriptionIdToPhoneAccountHandle(subId);
                telecomManager.setUserSelectedOutgoingPhoneAccount(phoneAccountHandle);
                break;
            }
        }
    }
    updateViews(slotId);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) SubscriptionInfo(android.telephony.SubscriptionInfo) TelecomManager(android.telecom.TelecomManager)

Example 55 with TelecomManager

use of android.telecom.TelecomManager in project android_frameworks_base by AOSPA.

the class SimSwitchController method getVoicePrefSlot.

private int getVoicePrefSlot() {
    final TelecomManager telecomManager = TelecomManager.from(mContext);
    final PhoneAccountHandle phoneAccount = telecomManager.getUserSelectedOutgoingPhoneAccount();
    final TelephonyManager telephonyManager = TelephonyManager.from(mContext);
    int slotId = -1;
    if (phoneAccount == null) {
        logd("Get voice pref slotId " + slotId);
        return slotId;
    }
    PhoneAccount phoneaccount = telecomManager.getPhoneAccount(phoneAccount);
    if (phoneaccount != null && (mSubInfoList != null)) {
        int subId = telephonyManager.getSubIdForPhoneAccount(phoneaccount);
        int subInfoLength = mSubInfoList.size();
        for (int i = 0; i < subInfoLength; ++i) {
            final SubscriptionInfo sir = mSubInfoList.get(i);
            if (sir != null && sir.getSubscriptionId() == subId) {
                slotId = sir.getSimSlotIndex();
                break;
            }
        }
    }
    logd("Get voice pref slotId " + slotId);
    return slotId;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelephonyManager(android.telephony.TelephonyManager) SubscriptionInfo(android.telephony.SubscriptionInfo) TelecomManager(android.telecom.TelecomManager)

Aggregations

TelecomManager (android.telecom.TelecomManager)86 PhoneAccountHandle (android.telecom.PhoneAccountHandle)45 PhoneAccount (android.telecom.PhoneAccount)30 TelephonyManager (android.telephony.TelephonyManager)17 SubscriptionInfo (android.telephony.SubscriptionInfo)11 KeyEvent (android.view.KeyEvent)9 ArrayList (java.util.ArrayList)9 AlertDialog (android.app.AlertDialog)8 ActivityNotFoundException (android.content.ActivityNotFoundException)8 DialogInterface (android.content.DialogInterface)8 Message (android.os.Message)8 SubscriptionManager (android.telephony.SubscriptionManager)8 Dialog (android.app.Dialog)7 ListAdapter (android.widget.ListAdapter)7 Intent (android.content.Intent)6 Preference (android.support.v7.preference.Preference)6 ComponentName (android.content.ComponentName)4 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 RemoteException (android.os.RemoteException)4 IntArray (android.util.IntArray)4