Search in sources :

Example 1 with CallAudioState

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

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) {
    LogUtil.v("VoicemailAudioManager.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) {
        LogUtil.w("VoicemailAudioManager.setAudioRoute", "Asking to set to a route that is unsupported: " + newRoute);
        return;
    }
    // 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 2 with CallAudioState

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

the class VoicemailAudioManager method onWiredHeadsetPluggedInChanged.

@Override
public void onWiredHeadsetPluggedInChanged(boolean oldIsPluggedIn, boolean newIsPluggedIn) {
    LogUtil.i("VoicemailAudioManager.onWiredHeadsetPluggedInChanged", "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 3 with CallAudioState

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

the class ReturnToCallActionReceiver method toggleSpeaker.

private void toggleSpeaker(Context context) {
    CallAudioState audioState = AudioModeProvider.getInstance().getAudioState();
    if ((audioState.getSupportedRouteMask() & CallAudioState.ROUTE_BLUETOOTH) == CallAudioState.ROUTE_BLUETOOTH) {
        LogUtil.w("ReturnToCallActionReceiver.toggleSpeaker", "toggleSpeaker() called when bluetooth available." + " Probably should have shown audio route selector");
    }
    DialerCall call = getCall();
    int newRoute;
    if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
        newRoute = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
        Logger.get(context).logCallImpression(DialerImpression.Type.BUBBLE_TURN_ON_WIRED_OR_EARPIECE, call != null ? call.getUniqueCallId() : "", call != null ? call.getTimeAddedMs() : 0);
    } else {
        newRoute = CallAudioState.ROUTE_SPEAKER;
        Logger.get(context).logCallImpression(DialerImpression.Type.BUBBLE_TURN_ON_SPEAKERPHONE, call != null ? call.getUniqueCallId() : "", call != null ? call.getTimeAddedMs() : 0);
    }
    TelecomAdapter.getInstance().setAudioRoute(newRoute);
}
Also used : CallAudioState(android.telecom.CallAudioState) DialerCall(com.android.incallui.call.DialerCall)

Example 4 with CallAudioState

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

the class DialerCall method onUpgradedToVideo.

@Override
public void onUpgradedToVideo(boolean switchToSpeaker) {
    LogUtil.enterBlock("DialerCall.onUpgradedToVideo");
    if (!switchToSpeaker) {
        return;
    }
    CallAudioState audioState = AudioModeProvider.getInstance().getAudioState();
    if (0 != (CallAudioState.ROUTE_BLUETOOTH & audioState.getSupportedRouteMask())) {
        LogUtil.e("DialerCall.onUpgradedToVideo", "toggling speakerphone not allowed when bluetooth supported.");
        return;
    }
    if (audioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
        return;
    }
    TelecomAdapter.getInstance().setAudioRoute(CallAudioState.ROUTE_SPEAKER);
}
Also used : CallAudioState(android.telecom.CallAudioState)

Example 5 with CallAudioState

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

the class AudioRouteSelectorDialogFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
    View view = layoutInflater.inflate(R.layout.audioroute_selector, viewGroup, false);
    CallAudioState audioState = getArguments().getParcelable(ARG_AUDIO_STATE);
    initItem((TextView) view.findViewById(R.id.audioroute_bluetooth), CallAudioState.ROUTE_BLUETOOTH, audioState);
    initItem((TextView) view.findViewById(R.id.audioroute_speaker), CallAudioState.ROUTE_SPEAKER, audioState);
    initItem((TextView) view.findViewById(R.id.audioroute_headset), CallAudioState.ROUTE_WIRED_HEADSET, audioState);
    initItem((TextView) view.findViewById(R.id.audioroute_earpiece), CallAudioState.ROUTE_EARPIECE, audioState);
    return view;
}
Also used : CallAudioState(android.telecom.CallAudioState) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

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