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

Commit 7ffd9936 authored by Suchand Ghosh's avatar Suchand Ghosh Committed by Steve Kondik
Browse files

StatusBar: Update TTY icon on status bar at boot

When device reboot with TTY on, sometimes PhoneStatusBarPolicy
did not receive TTY event broadcast because PhoneStatusBarPolicy
is not started by the time Telecom broadcasted it. This ignore to
show TTY icon in status bar.
Add code to update TTY icon after PhoneStatusBarPolicy create.

Change-Id: I2b4f072147749d7b93e664adcb9f34884e8ad4fc
CRs-Fixed: 953066
parent 8c78865c
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -182,6 +182,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);
@@ -391,6 +394,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()) {