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

Commit f202c697 authored by David Ng's avatar David Ng
Browse files

Merge tag 'android-6.0.1_r3' into 601r3

Android 6.0.1 release 3

* tag 'android-6.0.1_r3':
  Show CONNECTING and SELECT_PHONE_ACCOUNT states as bluetooth-dialing.
  DO NOT MERGE Don't show "Respond via SMS" for missed SIP calls.
  DO NOT MERGE Fix getAllPhoneAccounts() api method
  Specify user when setting MUTE for a call.

Change-Id: Ibe237bf69dcaa411b10e72cd7cdc48b806b6c22d
parents 26219fb8 d9f9006e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1208,13 +1208,13 @@ public final class BluetoothPhoneServiceImpl {
            case CallState.NEW:
            case CallState.ABORTED:
            case CallState.DISCONNECTED:
            case CallState.CONNECTING:
            case CallState.SELECT_PHONE_ACCOUNT:
                return CALL_STATE_IDLE;

            case CallState.ACTIVE:
                return CALL_STATE_ACTIVE;

            case CallState.CONNECTING:
            case CallState.SELECT_PHONE_ACCOUNT:
            case CallState.DIALING:
                // Yes, this is correctly returning ALERTING.
                // "Dialing" for BT means that we have sent information to the service provider
+45 −2
Original line number Diff line number Diff line
@@ -16,11 +16,19 @@

package com.android.server.telecom;

import android.app.ActivityManagerNative;
import android.content.Context;
import android.content.pm.UserInfo;
import android.media.AudioManager;
import android.media.IAudioService;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.telecom.CallAudioState;

import com.android.internal.util.IndentingPrintWriter;
@@ -86,9 +94,27 @@ final class CallAudioManager extends CallsManagerListenerBase
                case MSG_AUDIO_MANAGER_SET_MICROPHONE_MUTE: {
                    boolean mute = (msg.arg1 != 0);
                    if (mute != mAudioManager.isMicrophoneMute()) {
                        Log.i(this, "changing microphone mute state to: %b", mute);
                        mAudioManager.setMicrophoneMute(mute);
                        IAudioService audio = getAudioService();
                        Log.i(this, "changing microphone mute state to: %b [serviceIsNull=%b]",
                                mute, audio == null);
                        if (audio != null) {
                            try {
                                // We use the audio service directly here so that we can specify
                                // the current user. Telecom runs in the system_server process which
                                // may run as a separate user from the foreground user. If we
                                // used AudioManager directly, we would change mute for the system's
                                // user and not the current foreground, which we want to avoid.
                                audio.setMicrophoneMute(
                                        mute, mContext.getOpPackageName(), getCurrentUserId());

                            } catch (RemoteException e) {
                                Log.e(this, e, "Remote exception while toggling mute.");
                            }
                            // TODO: Check microphone state after attempting to set to ensure that
                            // our state corroborates AudioManager's state.
                        }
                    }

                    break;
                }
                case MSG_AUDIO_MANAGER_REQUEST_AUDIO_FOCUS_FOR_CALL: {
@@ -694,6 +720,23 @@ final class CallAudioManager extends CallsManagerListenerBase
        return mAudioFocusStreamType != STREAM_NONE;
    }

    private IAudioService getAudioService() {
        return IAudioService.Stub.asInterface(ServiceManager.getService(Context.AUDIO_SERVICE));
    }

    private int getCurrentUserId() {
        final long ident = Binder.clearCallingIdentity();
        try {
            UserInfo currentUser = ActivityManagerNative.getDefault().getCurrentUser();
            return currentUser.id;
        } catch (RemoteException e) {
            // Activity manager not running, nothing we can do assume user 0.
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        return UserHandle.USER_OWNER;
    }

    /**
     * Translates an {@link AudioManager} stream type to a human-readable string description.
     *
+1 −1
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public class TelecomServiceImpl {
                            .getAllPhoneAccounts();
                    List<PhoneAccount> profilePhoneAccounts = new ArrayList<>(
                            allPhoneAccounts.size());
                    for (PhoneAccount phoneAccount : profilePhoneAccounts) {
                    for (PhoneAccount phoneAccount : allPhoneAccounts) {
                        if (isVisibleToCaller(phoneAccount)) {
                            profilePhoneAccounts.add(phoneAccount);
                        }
+11 −3
Original line number Diff line number Diff line
@@ -204,10 +204,12 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
                        mContext.getString(R.string.notification_missedCall_call_back),
                        createCallBackPendingIntent(handleUri));

                if (canRespondViaSms(call)) {
                    builder.addAction(R.drawable.ic_message_24dp,
                            mContext.getString(R.string.notification_missedCall_message),
                            createSendSmsFromNotificationPendingIntent(handleUri));
                }
            }

            Bitmap photoIcon = call.getPhotoIcon();
            if (photoIcon != null) {
@@ -366,6 +368,12 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
        notification.defaults |= Notification.DEFAULT_LIGHTS;
    }

    private boolean canRespondViaSms(Call call) {
        // Only allow respond-via-sms for "tel:" calls.
        return call.getHandle() != null &&
                PhoneAccount.SCHEME_TEL.equals(call.getHandle().getScheme());
    }

    /**
     * Adds the missed call notification on startup if there are unread missed calls.
     */