The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 17 | package com.android.systemui.statusbar.phone; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 19 | import android.app.ActivityManager; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 20 | import android.app.ActivityManagerNative; |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 21 | import android.app.AlarmManager; |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 22 | import android.app.AlarmManager.AlarmClockInfo; |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 23 | import android.app.SynchronousUserSwitchObserver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.content.BroadcastReceiver; |
| 25 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.Intent; |
| 27 | import android.content.IntentFilter; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 28 | import android.content.pm.UserInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | import android.media.AudioManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.os.Handler; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 31 | import android.os.RemoteException; |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 32 | import android.os.UserHandle; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 33 | import android.os.UserManager; |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 34 | import android.provider.Settings.Global; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 35 | import android.telecom.TelecomManager; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 36 | import android.util.Log; |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 37 | import com.android.internal.telephony.IccCardConstants; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 38 | import com.android.internal.telephony.TelephonyIntents; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 39 | import com.android.systemui.R; |
John Spurlock | 3c4076a | 2015-02-24 12:12:25 -0500 | [diff] [blame] | 40 | import com.android.systemui.qs.tiles.DndTile; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 41 | import com.android.systemui.qs.tiles.RotationLockTile; |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 42 | import com.android.systemui.statusbar.policy.BluetoothController; |
| 43 | import com.android.systemui.statusbar.policy.BluetoothController.Callback; |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 44 | import com.android.systemui.statusbar.policy.CastController; |
| 45 | import com.android.systemui.statusbar.policy.CastController.CastDevice; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 46 | import com.android.systemui.statusbar.policy.HotspotController; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 47 | import com.android.systemui.statusbar.policy.RotationLockController; |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 48 | import com.android.systemui.statusbar.policy.UserInfoController; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 49 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | /** |
| 51 | * This class contains all of the policy about which icons are installed in the status |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 52 | * bar at boot time. It goes through the normal API for icons, even though it probably |
| 53 | * strictly doesn't need to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | */ |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 55 | public class PhoneStatusBarPolicy implements Callback, RotationLockController.RotationLockControllerCallback { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 56 | private static final String TAG = "PhoneStatusBarPolicy"; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 57 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 58 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 59 | private final String mSlotCast; |
| 60 | private final String mSlotHotspot; |
| 61 | private final String mSlotBluetooth; |
| 62 | private final String mSlotTty; |
| 63 | private final String mSlotZen; |
| 64 | private final String mSlotVolume; |
| 65 | private final String mSlotAlarmClock; |
| 66 | private final String mSlotManagedProfile; |
| 67 | private final String mSlotRotate; |
| 68 | private final String mSlotHeadset; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 69 | |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 70 | private final Context mContext; |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 71 | private final Handler mHandler = new Handler(); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 72 | private final CastController mCast; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 73 | private final HotspotController mHotspot; |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 74 | private final AlarmManager mAlarmManager; |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 75 | private final UserInfoController mUserInfoController; |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 76 | private final UserManager mUserManager; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 77 | private final StatusBarIconController mIconController; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 78 | private final RotationLockController mRotationLockController; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | // Assume it's all good unless we hear otherwise. We don't always seem |
| 81 | // to get broadcasts that it *is* there. |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 82 | IccCardConstants.State mSimState = IccCardConstants.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 84 | private boolean mZenVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 85 | private boolean mVolumeVisible; |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 86 | private boolean mCurrentUserSetup; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 87 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 88 | private int mZen; |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 89 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 90 | private boolean mManagedProfileFocused = false; |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 91 | private boolean mManagedProfileIconVisible = false; |
| 92 | private boolean mManagedProfileInQuietMode = false; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 93 | |
| 94 | private boolean mKeyguardVisible = true; |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 95 | private BluetoothController mBluetooth; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 96 | |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 97 | public PhoneStatusBarPolicy(Context context, StatusBarIconController iconController, |
| 98 | CastController cast, HotspotController hotspot, UserInfoController userInfoController, |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 99 | BluetoothController bluetooth, RotationLockController rotationLockController) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | mContext = context; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 101 | mIconController = iconController; |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 102 | mCast = cast; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 103 | mHotspot = hotspot; |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 104 | mBluetooth = bluetooth; |
| 105 | mBluetooth.addStateChangedCallback(this); |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 106 | mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 107 | mUserInfoController = userInfoController; |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 108 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 109 | mRotationLockController = rotationLockController; |
| 110 | |
| 111 | mSlotCast = context.getString(com.android.internal.R.string.status_bar_cast); |
| 112 | mSlotHotspot = context.getString(com.android.internal.R.string.status_bar_hotspot); |
| 113 | mSlotBluetooth = context.getString(com.android.internal.R.string.status_bar_bluetooth); |
| 114 | mSlotTty = context.getString(com.android.internal.R.string.status_bar_tty); |
| 115 | mSlotZen = context.getString(com.android.internal.R.string.status_bar_zen); |
| 116 | mSlotVolume = context.getString(com.android.internal.R.string.status_bar_volume); |
| 117 | mSlotAlarmClock = context.getString(com.android.internal.R.string.status_bar_alarm_clock); |
| 118 | mSlotManagedProfile = context.getString( |
| 119 | com.android.internal.R.string.status_bar_managed_profile); |
| 120 | mSlotRotate = context.getString(com.android.internal.R.string.status_bar_rotate); |
| 121 | mSlotHeadset = context.getString(com.android.internal.R.string.status_bar_headset); |
| 122 | |
| 123 | mRotationLockController.addRotationLockControllerCallback(this); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 124 | |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 125 | // listen for broadcasts |
| 126 | IntentFilter filter = new IntentFilter(); |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 127 | filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 128 | filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); |
John Spurlock | bcc1087 | 2014-11-28 15:29:21 -0500 | [diff] [blame] | 129 | filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 130 | filter.addAction(AudioManager.ACTION_HEADSET_PLUG); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 131 | filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 132 | filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED); |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 133 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 134 | mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); |
| 135 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 136 | // listen for user / profile change. |
| 137 | try { |
| 138 | ActivityManagerNative.getDefault().registerUserSwitchObserver(mUserSwitchListener); |
| 139 | } catch (RemoteException e) { |
| 140 | // Ignore |
| 141 | } |
| 142 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 143 | // TTY status |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 144 | mIconController.setIcon(mSlotTty, R.drawable.stat_sys_tty_mode, null); |
| 145 | mIconController.setIconVisibility(mSlotTty, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 146 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | // bluetooth status |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 148 | updateBluetooth(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | // Alarm clock |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 151 | mIconController.setIcon(mSlotAlarmClock, R.drawable.stat_sys_alarm, null); |
| 152 | mIconController.setIconVisibility(mSlotAlarmClock, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 154 | // zen |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 155 | mIconController.setIcon(mSlotZen, R.drawable.stat_sys_zen_important, null); |
| 156 | mIconController.setIconVisibility(mSlotZen, false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 157 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | // volume |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 159 | mIconController.setIcon(mSlotVolume, R.drawable.stat_sys_ringer_vibrate, null); |
| 160 | mIconController.setIconVisibility(mSlotVolume, false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 161 | updateVolumeZen(); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 162 | |
| 163 | // cast |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 164 | mIconController.setIcon(mSlotCast, R.drawable.stat_sys_cast, null); |
| 165 | mIconController.setIconVisibility(mSlotCast, false); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 166 | mCast.addCallback(mCastCallback); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 167 | |
| 168 | // hotspot |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 169 | mIconController.setIcon(mSlotHotspot, R.drawable.stat_sys_hotspot, |
Jason Monk | 08187a4 | 2015-06-09 14:33:51 -0400 | [diff] [blame] | 170 | mContext.getString(R.string.accessibility_status_bar_hotspot)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 171 | mIconController.setIconVisibility(mSlotHotspot, mHotspot.isHotspotEnabled()); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 172 | mHotspot.addCallback(mHotspotCallback); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 173 | |
| 174 | // managed profile |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 175 | mIconController.setIcon(mSlotManagedProfile, R.drawable.stat_sys_managed_profile_status, |
Adrian Roos | 1b5eb97 | 2015-06-11 18:22:52 -0700 | [diff] [blame] | 176 | mContext.getString(R.string.accessibility_managed_profile)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 177 | mIconController.setIconVisibility(mSlotManagedProfile, mManagedProfileIconVisible); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | } |
| 179 | |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 180 | public void setZenMode(int zen) { |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 181 | mZen = zen; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 182 | updateVolumeZen(); |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 183 | } |
| 184 | |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 185 | private void updateAlarm() { |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 186 | final AlarmClockInfo alarm = mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT); |
| 187 | final boolean hasAlarm = alarm != null && alarm.getTriggerTime() > 0; |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 188 | final boolean zenNone = mZen == Global.ZEN_MODE_NO_INTERRUPTIONS; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 189 | mIconController.setIcon(mSlotAlarmClock, zenNone ? R.drawable.stat_sys_alarm_dim |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 190 | : R.drawable.stat_sys_alarm, null); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 191 | mIconController.setIconVisibility(mSlotAlarmClock, mCurrentUserSetup && hasAlarm); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | } |
| 193 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | private final void updateSimState(Intent intent) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 195 | String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); |
| 196 | if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { |
| 197 | mSimState = IccCardConstants.State.ABSENT; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 198 | } else if (IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR.equals(stateExtra)) { |
Rakesh Pallerla | f099a5f | 2013-02-06 11:44:23 +0530 | [diff] [blame] | 199 | mSimState = IccCardConstants.State.CARD_IO_ERROR; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 200 | } else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 201 | mSimState = IccCardConstants.State.READY; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 202 | } else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 203 | final String lockedReason = |
| 204 | intent.getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON); |
| 205 | if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { |
| 206 | mSimState = IccCardConstants.State.PIN_REQUIRED; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 207 | } else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 208 | mSimState = IccCardConstants.State.PUK_REQUIRED; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 209 | } else { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 210 | mSimState = IccCardConstants.State.NETWORK_LOCKED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | } |
| 212 | } else { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 213 | mSimState = IccCardConstants.State.UNKNOWN; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 215 | } |
| 216 | |
John Spurlock | bcc1087 | 2014-11-28 15:29:21 -0500 | [diff] [blame] | 217 | private final void updateVolumeZen() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 219 | |
| 220 | boolean zenVisible = false; |
| 221 | int zenIconId = 0; |
| 222 | String zenDescription = null; |
| 223 | |
| 224 | boolean volumeVisible = false; |
| 225 | int volumeIconId = 0; |
| 226 | String volumeDescription = null; |
| 227 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 228 | if (DndTile.isVisible(mContext) || DndTile.isCombinedIcon(mContext)) { |
John Spurlock | 3c4076a | 2015-02-24 12:12:25 -0500 | [diff] [blame] | 229 | zenVisible = mZen != Global.ZEN_MODE_OFF; |
John Spurlock | 4ec8b60 | 2015-05-11 17:46:28 -0400 | [diff] [blame] | 230 | zenIconId = mZen == Global.ZEN_MODE_NO_INTERRUPTIONS |
| 231 | ? R.drawable.stat_sys_dnd_total_silence : R.drawable.stat_sys_dnd; |
John Spurlock | 3c4076a | 2015-02-24 12:12:25 -0500 | [diff] [blame] | 232 | zenDescription = mContext.getString(R.string.quick_settings_dnd_label); |
| 233 | } else if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 234 | zenVisible = true; |
| 235 | zenIconId = R.drawable.stat_sys_zen_none; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 236 | zenDescription = mContext.getString(R.string.interruption_level_none); |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 237 | } else if (mZen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 238 | zenVisible = true; |
| 239 | zenIconId = R.drawable.stat_sys_zen_important; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 240 | zenDescription = mContext.getString(R.string.interruption_level_priority); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 241 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 243 | if (DndTile.isVisible(mContext) && !DndTile.isCombinedIcon(mContext) |
John Spurlock | a48d779 | 2015-03-03 17:35:57 -0500 | [diff] [blame] | 244 | && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) { |
| 245 | volumeVisible = true; |
| 246 | volumeIconId = R.drawable.stat_sys_ringer_silent; |
| 247 | volumeDescription = mContext.getString(R.string.accessibility_ringer_silent); |
John Spurlock | 4f1163c | 2015-04-02 17:41:21 -0400 | [diff] [blame] | 248 | } else if (mZen != Global.ZEN_MODE_NO_INTERRUPTIONS && mZen != Global.ZEN_MODE_ALARMS && |
John Spurlock | 661f2cf | 2014-11-17 10:29:10 -0500 | [diff] [blame] | 249 | audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_VIBRATE) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 250 | volumeVisible = true; |
| 251 | volumeIconId = R.drawable.stat_sys_ringer_vibrate; |
| 252 | volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | } |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 254 | |
| 255 | if (zenVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 256 | mIconController.setIcon(mSlotZen, zenIconId, zenDescription); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 257 | } |
| 258 | if (zenVisible != mZenVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 259 | mIconController.setIconVisibility(mSlotZen, zenVisible); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 260 | mZenVisible = zenVisible; |
| 261 | } |
| 262 | |
| 263 | if (volumeVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 264 | mIconController.setIcon(mSlotVolume, volumeIconId, volumeDescription); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 265 | } |
| 266 | if (volumeVisible != mVolumeVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 267 | mIconController.setIconVisibility(mSlotVolume, volumeVisible); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 268 | mVolumeVisible = volumeVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 269 | } |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 270 | updateAlarm(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | } |
| 272 | |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 273 | @Override |
| 274 | public void onBluetoothDevicesChanged() { |
| 275 | updateBluetooth(); |
| 276 | } |
| 277 | |
| 278 | @Override |
| 279 | public void onBluetoothStateChange(boolean enabled) { |
| 280 | updateBluetooth(); |
| 281 | } |
| 282 | |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 283 | private final void updateBluetooth() { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 284 | int iconId = R.drawable.stat_sys_data_bluetooth; |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 285 | String contentDescription = |
Jason Monk | 1aa3282 | 2015-07-14 16:10:32 -0400 | [diff] [blame] | 286 | mContext.getString(R.string.accessibility_quick_settings_bluetooth_on); |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 287 | boolean bluetoothEnabled = false; |
| 288 | if (mBluetooth != null) { |
| 289 | bluetoothEnabled = mBluetooth.isBluetoothEnabled(); |
| 290 | if (mBluetooth.isBluetoothConnected()) { |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 291 | iconId = R.drawable.stat_sys_data_bluetooth_connected; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 292 | contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected); |
Jaikumar Ganesh | 084c665 | 2009-12-07 10:58:18 -0800 | [diff] [blame] | 293 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 295 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 296 | mIconController.setIcon(mSlotBluetooth, iconId, contentDescription); |
| 297 | mIconController.setIconVisibility(mSlotBluetooth, bluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | } |
| 299 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 300 | private final void updateTTY(Intent intent) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 301 | int currentTtyMode = intent.getIntExtra(TelecomManager.EXTRA_CURRENT_TTY_MODE, |
| 302 | TelecomManager.TTY_MODE_OFF); |
| 303 | boolean enabled = currentTtyMode != TelecomManager.TTY_MODE_OFF; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 304 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 305 | if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 306 | |
| 307 | if (enabled) { |
| 308 | // TTY is on |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 309 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY on"); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 310 | mIconController.setIcon(mSlotTty, R.drawable.stat_sys_tty_mode, |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 311 | mContext.getString(R.string.accessibility_tty_enabled)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 312 | mIconController.setIconVisibility(mSlotTty, true); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 313 | } else { |
| 314 | // TTY is off |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 315 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY off"); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 316 | mIconController.setIconVisibility(mSlotTty, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 317 | } |
| 318 | } |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 319 | |
| 320 | private void updateCast() { |
| 321 | boolean isCasting = false; |
| 322 | for (CastDevice device : mCast.getCastDevices()) { |
| 323 | if (device.state == CastDevice.STATE_CONNECTING |
| 324 | || device.state == CastDevice.STATE_CONNECTED) { |
| 325 | isCasting = true; |
| 326 | break; |
| 327 | } |
| 328 | } |
| 329 | if (DEBUG) Log.v(TAG, "updateCast: isCasting: " + isCasting); |
Dan Sandler | 8fd25bf | 2015-10-20 16:01:27 -0700 | [diff] [blame] | 330 | mHandler.removeCallbacks(mRemoveCastIconRunnable); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 331 | if (isCasting) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 332 | mIconController.setIcon(mSlotCast, R.drawable.stat_sys_cast, |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 333 | mContext.getString(R.string.accessibility_casting)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 334 | mIconController.setIconVisibility(mSlotCast, true); |
Dan Sandler | 8fd25bf | 2015-10-20 16:01:27 -0700 | [diff] [blame] | 335 | } else { |
| 336 | // don't turn off the screen-record icon for a few seconds, just to make sure the user |
| 337 | // has seen it |
| 338 | if (DEBUG) Log.v(TAG, "updateCast: hiding icon in 3 sec..."); |
| 339 | mHandler.postDelayed(mRemoveCastIconRunnable, 3000); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 340 | } |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 341 | } |
| 342 | |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 343 | private void updateQuietState() { |
| 344 | mManagedProfileInQuietMode = false; |
| 345 | int currentUserId = ActivityManager.getCurrentUser(); |
| 346 | for (UserInfo ui : mUserManager.getEnabledProfiles(currentUserId)) { |
| 347 | if (ui.isManagedProfile() && ui.isQuietModeEnabled()) { |
| 348 | mManagedProfileInQuietMode = true; |
| 349 | return; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 354 | private void profileChanged(int userId) { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 355 | UserInfo user = null; |
| 356 | if (userId == UserHandle.USER_CURRENT) { |
| 357 | try { |
| 358 | user = ActivityManagerNative.getDefault().getCurrentUser(); |
| 359 | } catch (RemoteException e) { |
| 360 | // Ignore |
| 361 | } |
| 362 | } else { |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 363 | user = mUserManager.getUserInfo(userId); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | mManagedProfileFocused = user != null && user.isManagedProfile(); |
| 367 | if (DEBUG) Log.v(TAG, "profileChanged: mManagedProfileFocused: " + mManagedProfileFocused); |
| 368 | // Actually update the icon later when transition starts. |
| 369 | } |
| 370 | |
| 371 | private void updateManagedProfile() { |
| 372 | if (DEBUG) Log.v(TAG, "updateManagedProfile: mManagedProfileFocused: " |
| 373 | + mManagedProfileFocused |
| 374 | + " mKeyguardVisible: " + mKeyguardVisible); |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 375 | final boolean showIcon; |
| 376 | if (mManagedProfileFocused && !mKeyguardVisible) { |
| 377 | showIcon = true; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 378 | mIconController.setIcon(mSlotManagedProfile, |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 379 | R.drawable.stat_sys_managed_profile_status, |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 380 | mContext.getString(R.string.accessibility_managed_profile)); |
| 381 | } else if (mManagedProfileInQuietMode) { |
| 382 | showIcon = true; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 383 | mIconController.setIcon(mSlotManagedProfile, |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 384 | R.drawable.stat_sys_managed_profile_status_off, |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 385 | mContext.getString(R.string.accessibility_managed_profile)); |
| 386 | } else { |
| 387 | showIcon = false; |
| 388 | } |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 389 | if (mManagedProfileIconVisible != showIcon) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 390 | mIconController.setIconVisibility(mSlotManagedProfile, showIcon); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 391 | mManagedProfileIconVisible = showIcon; |
| 392 | } |
| 393 | } |
| 394 | |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 395 | private final SynchronousUserSwitchObserver mUserSwitchListener = |
| 396 | new SynchronousUserSwitchObserver() { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 397 | @Override |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 398 | public void onUserSwitching(int newUserId) throws RemoteException { |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 399 | mUserInfoController.reloadUserInfo(); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public void onUserSwitchComplete(int newUserId) throws RemoteException { |
| 404 | updateAlarm(); |
| 405 | profileChanged(newUserId); |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 406 | updateQuietState(); |
| 407 | updateManagedProfile(); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | @Override |
| 411 | public void onForegroundProfileSwitch(int newProfileId) { |
| 412 | profileChanged(newProfileId); |
| 413 | } |
| 414 | }; |
| 415 | |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 416 | private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { |
| 417 | @Override |
| 418 | public void onHotspotChanged(boolean enabled) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 419 | mIconController.setIconVisibility(mSlotHotspot, enabled); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 420 | } |
| 421 | }; |
| 422 | |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 423 | private final CastController.Callback mCastCallback = new CastController.Callback() { |
| 424 | @Override |
| 425 | public void onCastDevicesChanged() { |
| 426 | updateCast(); |
| 427 | } |
| 428 | }; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 429 | |
| 430 | public void appTransitionStarting(long startTime, long duration) { |
| 431 | updateManagedProfile(); |
| 432 | } |
| 433 | |
| 434 | public void setKeyguardShowing(boolean visible) { |
| 435 | mKeyguardVisible = visible; |
| 436 | updateManagedProfile(); |
| 437 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 438 | |
| 439 | public void setCurrentUserSetup(boolean userSetup) { |
| 440 | if (mCurrentUserSetup == userSetup) return; |
| 441 | mCurrentUserSetup = userSetup; |
| 442 | updateAlarm(); |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 443 | updateQuietState(); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 444 | } |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame^] | 445 | |
| 446 | @Override |
| 447 | public void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible) { |
| 448 | boolean portrait = RotationLockTile.isCurrentOrientationLockPortrait( |
| 449 | mRotationLockController, mContext); |
| 450 | if (rotationLocked) { |
| 451 | if (portrait) { |
| 452 | mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_portrait, |
| 453 | mContext.getString(R.string.accessibility_rotation_lock_on_portrait)); |
| 454 | } else { |
| 455 | mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_landscape, |
| 456 | mContext.getString(R.string.accessibility_rotation_lock_on_landscape)); |
| 457 | } |
| 458 | } else { |
| 459 | mIconController.setIcon(mSlotRotate, portrait |
| 460 | ? R.drawable.stat_sys_auto_rotate_portrait |
| 461 | : R.drawable.stat_sys_auto_rotate_landscape, |
| 462 | mContext.getString(R.string.accessibility_rotation_lock_off)); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | private void updateHeadsetPlug(Intent intent) { |
| 467 | boolean connected = intent.getIntExtra("state", 0) != 0; |
| 468 | boolean hasMic = intent.getIntExtra("microphone", 0) != 0; |
| 469 | if (connected) { |
| 470 | String contentDescription = mContext.getString(hasMic |
| 471 | ? R.string.accessibility_status_bar_headset |
| 472 | : R.string.accessibility_status_bar_headphones); |
| 473 | mIconController.setIcon(mSlotHeadset, hasMic ? R.drawable.ic_headset_mic |
| 474 | : R.drawable.ic_headset, contentDescription); |
| 475 | mIconController.setIconVisibility(mSlotHeadset, true); |
| 476 | } else { |
| 477 | mIconController.setIconVisibility(mSlotHeadset, false); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { |
| 482 | @Override |
| 483 | public void onReceive(Context context, Intent intent) { |
| 484 | String action = intent.getAction(); |
| 485 | if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) { |
| 486 | updateAlarm(); |
| 487 | } else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) || |
| 488 | action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) { |
| 489 | updateVolumeZen(); |
| 490 | } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { |
| 491 | updateSimState(intent); |
| 492 | } else if (action.equals(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED)) { |
| 493 | updateTTY(intent); |
| 494 | } else if (action.equals(Intent.ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED)) { |
| 495 | updateQuietState(); |
| 496 | updateManagedProfile(); |
| 497 | } else if (action.equals(AudioManager.ACTION_HEADSET_PLUG)) { |
| 498 | updateHeadsetPlug(intent); |
| 499 | } |
| 500 | } |
| 501 | }; |
| 502 | |
| 503 | private Runnable mRemoveCastIconRunnable = new Runnable() { |
| 504 | @Override |
| 505 | public void run() { |
| 506 | if (DEBUG) Log.v(TAG, "updateCast: hiding icon NOW"); |
| 507 | mIconController.setIconVisibility(mSlotCast, false); |
| 508 | } |
| 509 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | } |