Search in sources :

Example 6 with CallAudioState

use of android.telecom.CallAudioState in project android_packages_apps_Dialer by MoKee.

the class VoicemailAudioManager method setAudioRoute.

/**
 * Change the audio route, for example from earpiece to speakerphone.
 *
 * @param route The new audio route to use. See {@link CallAudioState}.
 */
void setAudioRoute(int route) {
    Log.v(TAG, "setAudioRoute, route: " + CallAudioState.audioRouteToString(route));
    // Change ROUTE_WIRED_OR_EARPIECE to a single entry.
    int newRoute = selectWiredOrEarpiece(route, mCallAudioState.getSupportedRouteMask());
    // If route is unsupported, do nothing.
    if ((mCallAudioState.getSupportedRouteMask() | newRoute) == 0) {
        Log.w(TAG, "Asking to set to a route that is unsupported: " + newRoute);
        return;
    }
    if (mCallAudioState.getRoute() != newRoute) {
        // Remember the new speaker state so it can be restored when the user plugs and unplugs
        // a headset.
        mWasSpeakerOn = newRoute == CallAudioState.ROUTE_SPEAKER;
        setSystemAudioState(new CallAudioState(false, /* muted */
        newRoute, mCallAudioState.getSupportedRouteMask()));
    }
}
Also used : CallAudioState(android.telecom.CallAudioState)

Example 7 with CallAudioState

use of android.telecom.CallAudioState in project android_packages_apps_Dialer by LineageOS.

the class CallButtonPresenter method toggleSpeakerphone.

/**
 * Function assumes that bluetooth is not supported.
 */
@Override
public void toggleSpeakerphone() {
    // This function should not be called if bluetooth is available.
    CallAudioState audioState = getCurrentAudioState();
    if (0 != (CallAudioState.ROUTE_BLUETOOTH & audioState.getSupportedRouteMask())) {
        // It's clear the UI is wrong, so update the supported mode once again.
        LogUtil.e("CallButtonPresenter", "toggling speakerphone not allowed when bluetooth supported.");
        mInCallButtonUi.setAudioState(audioState);
        return;
    }
    int newRoute;
    if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
        newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
        Logger.get(mContext).logCallImpression(DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_WIRED_OR_EARPIECE, mCall.getUniqueCallId(), mCall.getTimeAddedMs());
    } else {
        newRoute = CallAudioState.ROUTE_SPEAKER;
        Logger.get(mContext).logCallImpression(DialerImpression.Type.IN_CALL_SCREEN_TURN_ON_SPEAKERPHONE, mCall.getUniqueCallId(), mCall.getTimeAddedMs());
    }
    setAudioRoute(newRoute);
}
Also used : CallAudioState(android.telecom.CallAudioState)

Example 8 with CallAudioState

use of android.telecom.CallAudioState in project android_packages_apps_Dialer by LineageOS.

the class VoicemailAudioManager method setSystemAudioState.

private void setSystemAudioState(CallAudioState callAudioState) {
    CallAudioState oldAudioState = mCallAudioState;
    mCallAudioState = callAudioState;
    LogUtil.i("VoicemailAudioManager.setSystemAudioState", "changing from " + oldAudioState + " to " + mCallAudioState);
    // Audio route.
    if (mCallAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
        turnOnSpeaker(true);
    } else if (mCallAudioState.getRoute() == CallAudioState.ROUTE_EARPIECE || mCallAudioState.getRoute() == CallAudioState.ROUTE_WIRED_HEADSET) {
        // Just handle turning off the speaker, the system will handle switching between wired
        // headset and earpiece.
        turnOnSpeaker(false);
        // BluetoothSco is not handled by the system so it has to be reset.
        applyBluetoothScoState();
    }
}
Also used : CallAudioState(android.telecom.CallAudioState)

Example 9 with CallAudioState

use of android.telecom.CallAudioState in project android_packages_apps_Dialer by MoKee.

the class VoicemailAudioManager method onWiredHeadsetPluggedInChanged.

@Override
public void onWiredHeadsetPluggedInChanged(boolean oldIsPluggedIn, boolean newIsPluggedIn) {
    Log.i(TAG, "wired headset was plugged in changed: " + oldIsPluggedIn + " -> " + newIsPluggedIn);
    if (oldIsPluggedIn == newIsPluggedIn) {
        return;
    }
    // start out with existing route
    int newRoute = mCallAudioState.getRoute();
    if (newIsPluggedIn) {
        newRoute = CallAudioState.ROUTE_WIRED_HEADSET;
    } else {
        if (mWasSpeakerOn) {
            newRoute = CallAudioState.ROUTE_SPEAKER;
        } else {
            newRoute = CallAudioState.ROUTE_EARPIECE;
        }
    }
    mVoicemailPlaybackPresenter.setSpeakerphoneOn(newRoute == CallAudioState.ROUTE_SPEAKER);
    // We need to call this every time even if we do not change the route because the supported
    // routes changed either to include or not include WIRED_HEADSET.
    setSystemAudioState(new CallAudioState(false, /* muted */
    newRoute, calculateSupportedRoutes()));
}
Also used : CallAudioState(android.telecom.CallAudioState)

Example 10 with CallAudioState

use of android.telecom.CallAudioState in project android_packages_apps_Dialer by MoKee.

the class VoicemailAudioManager method setSystemAudioState.

private void setSystemAudioState(CallAudioState callAudioState) {
    CallAudioState oldAudioState = mCallAudioState;
    mCallAudioState = callAudioState;
    Log.i(TAG, "setSystemAudioState: changing from " + oldAudioState + " to " + mCallAudioState);
    // Audio route.
    if (mCallAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
        turnOnSpeaker(true);
    } else if (mCallAudioState.getRoute() == CallAudioState.ROUTE_EARPIECE || mCallAudioState.getRoute() == CallAudioState.ROUTE_WIRED_HEADSET) {
        // Just handle turning off the speaker, the system will handle switching between wired
        // headset and earpiece.
        turnOnSpeaker(false);
    }
}
Also used : CallAudioState(android.telecom.CallAudioState)

Aggregations

CallAudioState (android.telecom.CallAudioState)10 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 TextView (android.widget.TextView)1 DialerCall (com.android.incallui.call.DialerCall)1