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

Commit d29237be authored by Xin Li's avatar Xin Li
Browse files

Merge Android 13 QPR2

Bug: 273316506
Merged-In: I521ff72d82ddc023d28610ea664e79c84c43380e
Change-Id: I75ae4618e7e04e09129d8a2ad4836fdde8a4b8a7
parents f979b23c fa7057a3
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -50,6 +50,16 @@ import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.stream.Collectors;

import static android.provider.CallLog.Calls.AUTO_MISSED_EMERGENCY_CALL;
import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_DIALING;
import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_RINGING;
import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT;
import static android.provider.CallLog.Calls.USER_MISSED_CALL_SCREENING_SERVICE_SILENCED;
import static android.provider.CallLog.Calls.USER_MISSED_DND_MODE;
import static android.provider.CallLog.Calls.USER_MISSED_LOW_RING_VOLUME;
import static android.provider.CallLog.Calls.USER_MISSED_NEVER_RANG;
import static android.provider.CallLog.Calls.USER_MISSED_NO_VIBRATE;
import static android.provider.CallLog.Calls.USER_MISSED_SHORT_RING;
import static android.telecom.ParcelableCallAnalytics.AnalyticsEvent;
import static android.telecom.TelecomAnalytics.SessionTiming;

@@ -538,7 +548,30 @@ public class Analytics {

        private String getMissedReasonString() {
            //TODO: Implement this
            return null;
            StringBuilder s =  new StringBuilder();
            s.append('[');
            if ((missedReason & AUTO_MISSED_EMERGENCY_CALL) != 0) {
                s.append("emergency]");
                return s.toString();
            } else if ((missedReason & AUTO_MISSED_MAXIMUM_DIALING) != 0) {
                s.append("max_dialing]");
                return s.toString();
            } else if ((missedReason & AUTO_MISSED_MAXIMUM_RINGING) != 0) {
                s.append("max_ringing]");
                return s.toString();
            }

            // user missed
            if ((missedReason & USER_MISSED_SHORT_RING) != 0) s.append("short_ring ");
            if ((missedReason & USER_MISSED_DND_MODE) != 0) s.append("dnd ");
            if ((missedReason & USER_MISSED_LOW_RING_VOLUME) != 0) s.append("low_volume ");
            if ((missedReason & USER_MISSED_NO_VIBRATE) != 0) s.append("no_vibrate ");
            if ((missedReason & USER_MISSED_CALL_SCREENING_SERVICE_SILENCED) != 0)
                s.append("css_silenced ");
            if ((missedReason & USER_MISSED_CALL_FILTERS_TIMEOUT) != 0) s.append("filter_timeout ");
            if ((missedReason & USER_MISSED_NEVER_RANG) != 0) s.append("no_ring ");
            s.append("]");
            return s.toString();
        }

        private String getInCallServicesString() {
+25 −13
Original line number Diff line number Diff line
@@ -287,6 +287,12 @@ public class PhoneAccountRegistrar {
        if (account != null) {
            return defaultPhoneAccountHandle.phoneAccountHandle;
        }

        Log.v(this,
                "getUserSelectedOutgoingPhoneAccount: defaultPhoneAccountHandle"
                        + ".phoneAccountHandle=[%s] is not registered or owned by %s"
                , defaultPhoneAccountHandle.phoneAccountHandle, userHandle);

        return null;
    }

@@ -343,6 +349,15 @@ public class PhoneAccountRegistrar {
                mState.defaultOutgoingAccountHandles.get(userHandle);
        PhoneAccountHandle currentDefaultPhoneAccount = currentDefaultInfo == null ? null :
                currentDefaultInfo.phoneAccountHandle;

        Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s", accountHandle);

        if (Objects.equals(currentDefaultPhoneAccount, accountHandle)) {
            Log.i(this, "setUserSelectedOutgoingPhoneAccount: "
                    + "no change in default phoneAccountHandle.  current is same as new.");
            return;
        }

        boolean isSimAccount = false;
        if (accountHandle == null) {
            // Asking to clear the default outgoing is a valid request
@@ -371,10 +386,8 @@ public class PhoneAccountRegistrar {
                    .put(userHandle, new DefaultPhoneAccountHandle(userHandle, accountHandle,
                            account.getGroupId()));
        }
        Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s", accountHandle);

        // Potentially update the default voice subid in SubscriptionManager.
        if (!Objects.equals(currentDefaultPhoneAccount, accountHandle)) {
        int newSubId = accountHandle == null ? SubscriptionManager.INVALID_SUBSCRIPTION_ID :
                getSubscriptionIdForPhoneAccount(accountHandle);
        if (isSimAccount || accountHandle == null) {
@@ -383,12 +396,11 @@ public class PhoneAccountRegistrar {
                Log.i(this, "setUserSelectedOutgoingPhoneAccount: update voice sub; "
                        + "account=%s, subId=%d", accountHandle, newSubId);
                mSubscriptionManager.setDefaultVoiceSubscriptionId(newSubId);
                }
            } else {
                Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s is not a sub", accountHandle);
                Log.i(this, "setUserSelectedOutgoingPhoneAccount: no change to voice sub");
            }
        } else {
            Log.i(this, "setUserSelectedOutgoingPhoneAccount: no change to voice sub");
            Log.i(this, "setUserSelectedOutgoingPhoneAccount: %s is not a sub", accountHandle);
        }

        write();
+6 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.telecom;
import static android.provider.CallLog.Calls.USER_MISSED_DND_MODE;
import static android.provider.CallLog.Calls.USER_MISSED_LOW_RING_VOLUME;
import static android.provider.CallLog.Calls.USER_MISSED_NO_VIBRATE;
import static android.provider.Settings.Global.ZEN_MODE_OFF;

import android.app.Notification;
import android.app.NotificationManager;
@@ -507,10 +508,14 @@ public class Ringer {
        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        // Use AudioManager#getRingerMode for more accurate result, instead of
        // AudioManager#getRingerModeInternal which only useful for volume controllers
        NotificationManager notificationManager = context.getSystemService(
                NotificationManager.class);
        boolean zenModeOn = notificationManager != null
                && notificationManager.getZenMode() != ZEN_MODE_OFF;
        return mVibrator.hasVibrator()
                && mSystemSettingsUtil.isRingVibrationEnabled(context)
                && (audioManager.getRingerMode() != AudioManager.RINGER_MODE_SILENT
                || shouldRingForContact);
                || (zenModeOn && shouldRingForContact));
    }

    private RingerAttributes getRingerAttributes(Call call, boolean isHfpDeviceAttached) {
+28 −20
Original line number Diff line number Diff line
@@ -1520,6 +1520,7 @@ public class TelecomServiceImpl {
                enforceCallingPackage(callingPackage, "placeCall");

                PhoneAccountHandle phoneAccountHandle = null;
                boolean clearPhoneAccountHandleExtra = false;
                if (extras != null) {
                    phoneAccountHandle = extras.getParcelable(
                            TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
@@ -1528,29 +1529,33 @@ public class TelecomServiceImpl {
                        extras.remove(TelecomManager.EXTRA_IS_HANDOVER);
                    }
                }
                ComponentName componentName = phoneAccountHandle != null
                        ? phoneAccountHandle.getComponentName() : null;
                String packageName = componentName != null
                        ? componentName.getPackageName() : null;
                boolean isSelfManaged = phoneAccountHandle != null &&
                        isSelfManagedConnectionService(phoneAccountHandle);
                if (isSelfManaged) {
                    try {
                        mContext.enforceCallingOrSelfPermission(
                                Manifest.permission.MANAGE_OWN_CALLS,
                                "Self-managed ConnectionServices require "
                                        + "MANAGE_OWN_CALLS permission.");
                    } catch (SecurityException e) {
                        // Fallback to use mobile network to avoid disclosing phone account handle
                        // package information
                        clearPhoneAccountHandleExtra = true;
                    }

                // Two cases here: the app calling this API is trying to place a call on another
                // ConnectionService or the app calling this API implements a self-managed
                // ConnectionService and is trying to place a call on their own ConnectionService.
                // Case 1: If the app does not implement the ConnectionService they are requesting
                // the call be placed on, ensure they have the correct CALL_PHONE permissions.
                if (!callingPackage.equals(packageName) && !canCallPhone(callingPackage,
                        callingFeatureId, "CALL_PHONE permission required to place calls.")) {
                    throw new SecurityException("CALL_PHONE permission required to place calls.");
                    if (!clearPhoneAccountHandleExtra && !callingPackage.equals(
                            phoneAccountHandle.getComponentName().getPackageName())
                            && !canCallPhone(callingPackage, callingFeatureId,
                            "CALL_PHONE permission required to place calls.")) {
                        // The caller is not allowed to place calls, so fallback to use mobile
                        // network.
                        clearPhoneAccountHandleExtra = true;
                    }
                // Case 2: The package name of the caller matches the package name of the
                // PhoneAccountHandle, so ensure the app has MANAGE_OWN_CALLS permission.
                if (callingPackage.equals(packageName)) {
                    mContext.enforceCallingOrSelfPermission(Manifest.permission.MANAGE_OWN_CALLS,
                            "Self-managed ConnectionServices require MANAGE_OWN_CALLS permission.");
                } else if (!canCallPhone(callingPackage, callingFeatureId, "placeCall")) {
                    throw new SecurityException("Package " + callingPackage
                            + " is not allowed to place phone calls");
                }

                boolean isSelfManaged = isSelfManagedConnectionService(phoneAccountHandle);

                // Note: we can still get here for the default/system dialer, even if the Phone
                // permission is turned off. This is because the default/system dialer is always
                // allowed to attempt to place a call (regardless of permission state), in case
@@ -1579,6 +1584,9 @@ public class TelecomServiceImpl {
                        final Intent intent = new Intent(hasCallPrivilegedPermission ?
                                Intent.ACTION_CALL_PRIVILEGED : Intent.ACTION_CALL, handle);
                        if (extras != null) {
                            if (clearPhoneAccountHandleExtra) {
                                extras.remove(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
                            }
                            extras.setDefusable(true);
                            intent.putExtras(extras);
                        }
+9 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ public class BluetoothDeviceManager {
    private BluetoothLeAudio mBluetoothLeAudioService;
    private boolean mLeAudioSetAsCommunicationDevice = false;
    private String mLeAudioDevice;
    private String mHearingAidDevice;
    private boolean mHearingAidSetAsCommunicationDevice = false;
    private BluetoothDevice mBluetoothHearingAidActiveDeviceCache;
    private BluetoothAdapter mBluetoothAdapter;
@@ -444,10 +445,17 @@ public class BluetoothDeviceManager {
    }

    public void clearHearingAidCommunicationDevice() {
        Log.i(this, "clearHearingAidCommunicationDevice: mHearingAidSetAsCommunicationDevice = "
                + mHearingAidSetAsCommunicationDevice);
        if (!mHearingAidSetAsCommunicationDevice) {
            return;
        }
        mHearingAidSetAsCommunicationDevice = false;
        if (mHearingAidDevice != null) {
            mBluetoothRouteManager.onAudioLost(mHearingAidDevice);
            mHearingAidDevice = null;
        }

        if (mAudioManager == null) {
            Log.i(this, "clearHearingAidCommunicationDevice: mAudioManager is null");
            return;
@@ -551,6 +559,7 @@ public class BluetoothDeviceManager {
            Log.w(this, " Could not set hearingAid device");
        } else {
            Log.i(this, " hearingAid device set");
            mHearingAidDevice = hearingAid.getAddress();
            mHearingAidSetAsCommunicationDevice = true;
        }
        return result;
Loading