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

Commit 568a34f8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "StatusBar: Update TTY icon on status bar at boot"

parents 8a99ad1f 37bd361c
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.IRemoteCallback;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.telecom.TelecomManager;
import android.util.Log;
@@ -151,6 +152,9 @@ public class PhoneStatusBarPolicy implements Callback {
        // bluetooth status
        updateBluetooth();

        //Update initial tty mode
        updateTTYMode();

        // Alarm clock
        mService.setIcon(SLOT_ALARM_CLOCK, R.drawable.stat_sys_alarm, 0, null);
        mService.setIconVisibility(SLOT_ALARM_CLOCK, false);
@@ -326,6 +330,29 @@ public class PhoneStatusBarPolicy implements Callback {
        }
    }

    private boolean isWiredHeadsetOn() {
        AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        return audioManager.isWiredHeadsetOn();
    }

    private final void updateTTYMode() {
        int ttyMode = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.PREFERRED_TTY_MODE, TelecomManager.TTY_MODE_OFF);
        boolean enabled = ttyMode != TelecomManager.TTY_MODE_OFF;
        if (DEBUG) Log.v(TAG, "updateTTYMode: enabled: " + enabled);
        if (enabled && isWiredHeadsetOn()) {
            // TTY is on
            if (DEBUG) Log.v(TAG, "updateTTYMode: set TTY on");
            mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0,
                    mContext.getString(R.string.accessibility_tty_enabled));
            mService.setIconVisibility(SLOT_TTY, true);
        } else {
            // TTY is off
            if (DEBUG) Log.v(TAG, "updateTTYMode: set TTY off");
            mService.setIconVisibility(SLOT_TTY, false);
        }
    }

    private void updateCast() {
        boolean isCasting = false;
        for (CastDevice device : mCast.getCastDevices()) {