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

Commit 37bd361c authored by Suchand Ghosh's avatar Suchand Ghosh Committed by Gerrit - the friendly Code Review server
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 ae3da19a
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()) {