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 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 20 | import android.app.ActivityTaskManager; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [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; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 23 | import android.app.IActivityManager; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 24 | import android.app.SynchronousUserSwitchObserver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
| 26 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.content.Intent; |
| 28 | import android.content.IntentFilter; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 29 | import android.content.SharedPreferences; |
| 30 | import android.content.res.Resources; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.media.AudioManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.os.Handler; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 33 | import android.os.RemoteException; |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 34 | import android.os.UserHandle; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 35 | import android.os.UserManager; |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 36 | import android.provider.Settings.Global; |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 37 | import android.service.notification.ZenModeConfig; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 38 | import android.telecom.TelecomManager; |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 39 | import android.text.format.DateFormat; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 40 | import android.util.Log; |
Beth Thibodeau | a5af240 | 2020-06-15 23:16:09 -0400 | [diff] [blame] | 41 | import android.view.View; |
Beverly | ff2df9b | 2018-10-10 16:54:10 -0400 | [diff] [blame] | 42 | |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 43 | import androidx.lifecycle.Observer; |
| 44 | |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 45 | import com.android.systemui.R; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame] | 46 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 47 | import com.android.systemui.dagger.qualifiers.DisplayId; |
| 48 | import com.android.systemui.dagger.qualifiers.Main; |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 49 | import com.android.systemui.dagger.qualifiers.UiBackground; |
John Spurlock | 3c4076a | 2015-02-24 12:12:25 -0500 | [diff] [blame] | 50 | import com.android.systemui.qs.tiles.DndTile; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 51 | import com.android.systemui.qs.tiles.RotationLockTile; |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 52 | import com.android.systemui.screenrecord.RecordingController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 53 | import com.android.systemui.statusbar.CommandQueue; |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 54 | import com.android.systemui.statusbar.policy.BluetoothController; |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 55 | import com.android.systemui.statusbar.policy.CastController; |
| 56 | import com.android.systemui.statusbar.policy.CastController.CastDevice; |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 57 | import com.android.systemui.statusbar.policy.DataSaverController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 58 | import com.android.systemui.statusbar.policy.DataSaverController.Listener; |
| 59 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
| 60 | import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 61 | import com.android.systemui.statusbar.policy.HotspotController; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 62 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 63 | import com.android.systemui.statusbar.policy.LocationController; |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 64 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 65 | import com.android.systemui.statusbar.policy.RotationLockController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 66 | import com.android.systemui.statusbar.policy.RotationLockController.RotationLockControllerCallback; |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 67 | import com.android.systemui.statusbar.policy.SensorPrivacyController; |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 68 | import com.android.systemui.statusbar.policy.UserInfoController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 69 | import com.android.systemui.statusbar.policy.ZenModeController; |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 70 | import com.android.systemui.util.RingerModeTracker; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 71 | import com.android.systemui.util.time.DateFormatUtil; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 72 | |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 73 | import java.util.Locale; |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 74 | import java.util.concurrent.Executor; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 75 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 76 | import javax.inject.Inject; |
| 77 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | /** |
yoshiki iguchi | 69d6585 | 2019-02-13 18:07:41 +0900 | [diff] [blame] | 79 | * This class contains all of the policy about which icons are installed in the status bar at boot |
| 80 | * time. It goes through the normal API for icons, even though it probably strictly doesn't need to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | */ |
yoshiki iguchi | 69d6585 | 2019-02-13 18:07:41 +0900 | [diff] [blame] | 82 | public class PhoneStatusBarPolicy |
| 83 | implements BluetoothController.Callback, |
Lucas Dupin | 68857da0 | 2020-05-27 23:41:50 +0000 | [diff] [blame] | 84 | CommandQueue.Callbacks, |
| 85 | RotationLockControllerCallback, |
| 86 | Listener, |
| 87 | ZenModeController.Callback, |
| 88 | DeviceProvisionedListener, |
| 89 | KeyguardStateController.Callback, |
| 90 | LocationController.LocationChangeCallback, |
| 91 | RecordingController.RecordingStateChangeCallback { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 92 | private static final String TAG = "PhoneStatusBarPolicy"; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 93 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 94 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 95 | static final int LOCATION_STATUS_ICON_ID = |
Fabian Kozynski | 228e310 | 2019-11-25 11:04:34 -0500 | [diff] [blame] | 96 | com.android.internal.R.drawable.perm_group_location; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 97 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 98 | private final String mSlotCast; |
| 99 | private final String mSlotHotspot; |
| 100 | private final String mSlotBluetooth; |
| 101 | private final String mSlotTty; |
| 102 | private final String mSlotZen; |
| 103 | private final String mSlotVolume; |
| 104 | private final String mSlotAlarmClock; |
| 105 | private final String mSlotManagedProfile; |
| 106 | private final String mSlotRotate; |
| 107 | private final String mSlotHeadset; |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 108 | private final String mSlotDataSaver; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 109 | private final String mSlotLocation; |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 110 | private final String mSlotSensorsOff; |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 111 | private final String mSlotScreenRecord; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 112 | private final int mDisplayId; |
| 113 | private final SharedPreferences mSharedPreferences; |
| 114 | private final DateFormatUtil mDateFormatUtil; |
| 115 | private final TelecomManager mTelecomManager; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 116 | |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 117 | private final Handler mHandler = new Handler(); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 118 | private final CastController mCast; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 119 | private final HotspotController mHotspot; |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 120 | private final NextAlarmController mNextAlarmController; |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 121 | private final AlarmManager mAlarmManager; |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 122 | private final UserInfoController mUserInfoController; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 123 | private final IActivityManager mIActivityManager; |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 124 | private final UserManager mUserManager; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 125 | private final StatusBarIconController mIconController; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 126 | private final CommandQueue mCommandQueue; |
| 127 | private final BroadcastDispatcher mBroadcastDispatcher; |
| 128 | private final Resources mResources; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 129 | private final RotationLockController mRotationLockController; |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 130 | private final DataSaverController mDataSaver; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 131 | private final ZenModeController mZenController; |
| 132 | private final DeviceProvisionedController mProvisionedController; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 133 | private final KeyguardStateController mKeyguardStateController; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 134 | private final LocationController mLocationController; |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 135 | private final Executor mUiBgExecutor; |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 136 | private final SensorPrivacyController mSensorPrivacyController; |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 137 | private final RecordingController mRecordingController; |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 138 | private final RingerModeTracker mRingerModeTracker; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 140 | private boolean mZenVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | private boolean mVolumeVisible; |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 142 | private boolean mCurrentUserSetup; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 143 | |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 144 | private boolean mManagedProfileIconVisible = false; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 145 | |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 146 | private BluetoothController mBluetooth; |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 147 | private AlarmManager.AlarmClockInfo mNextAlarm; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 148 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 149 | @Inject |
| 150 | public PhoneStatusBarPolicy(StatusBarIconController iconController, |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 151 | CommandQueue commandQueue, BroadcastDispatcher broadcastDispatcher, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 152 | @UiBackground Executor uiBgExecutor, @Main Resources resources, |
| 153 | CastController castController, HotspotController hotspotController, |
| 154 | BluetoothController bluetoothController, NextAlarmController nextAlarmController, |
| 155 | UserInfoController userInfoController, RotationLockController rotationLockController, |
| 156 | DataSaverController dataSaverController, ZenModeController zenModeController, |
| 157 | DeviceProvisionedController deviceProvisionedController, |
| 158 | KeyguardStateController keyguardStateController, |
| 159 | LocationController locationController, |
| 160 | SensorPrivacyController sensorPrivacyController, IActivityManager iActivityManager, |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 161 | AlarmManager alarmManager, UserManager userManager, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 162 | RecordingController recordingController, |
| 163 | @Nullable TelecomManager telecomManager, @DisplayId int displayId, |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 164 | @Main SharedPreferences sharedPreferences, DateFormatUtil dateFormatUtil, |
| 165 | RingerModeTracker ringerModeTracker) { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 166 | mIconController = iconController; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 167 | mCommandQueue = commandQueue; |
| 168 | mBroadcastDispatcher = broadcastDispatcher; |
| 169 | mResources = resources; |
| 170 | mCast = castController; |
| 171 | mHotspot = hotspotController; |
| 172 | mBluetooth = bluetoothController; |
| 173 | mNextAlarmController = nextAlarmController; |
| 174 | mAlarmManager = alarmManager; |
| 175 | mUserInfoController = userInfoController; |
| 176 | mIActivityManager = iActivityManager; |
| 177 | mUserManager = userManager; |
| 178 | mRotationLockController = rotationLockController; |
| 179 | mDataSaver = dataSaverController; |
| 180 | mZenController = zenModeController; |
| 181 | mProvisionedController = deviceProvisionedController; |
| 182 | mKeyguardStateController = keyguardStateController; |
| 183 | mLocationController = locationController; |
| 184 | mSensorPrivacyController = sensorPrivacyController; |
| 185 | mRecordingController = recordingController; |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 186 | mUiBgExecutor = uiBgExecutor; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 187 | mTelecomManager = telecomManager; |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 188 | mRingerModeTracker = ringerModeTracker; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 189 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 190 | mSlotCast = resources.getString(com.android.internal.R.string.status_bar_cast); |
| 191 | mSlotHotspot = resources.getString(com.android.internal.R.string.status_bar_hotspot); |
| 192 | mSlotBluetooth = resources.getString(com.android.internal.R.string.status_bar_bluetooth); |
| 193 | mSlotTty = resources.getString(com.android.internal.R.string.status_bar_tty); |
| 194 | mSlotZen = resources.getString(com.android.internal.R.string.status_bar_zen); |
| 195 | mSlotVolume = resources.getString(com.android.internal.R.string.status_bar_volume); |
| 196 | mSlotAlarmClock = resources.getString(com.android.internal.R.string.status_bar_alarm_clock); |
| 197 | mSlotManagedProfile = resources.getString( |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 198 | com.android.internal.R.string.status_bar_managed_profile); |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 199 | mSlotRotate = resources.getString(com.android.internal.R.string.status_bar_rotate); |
| 200 | mSlotHeadset = resources.getString(com.android.internal.R.string.status_bar_headset); |
| 201 | mSlotDataSaver = resources.getString(com.android.internal.R.string.status_bar_data_saver); |
| 202 | mSlotLocation = resources.getString(com.android.internal.R.string.status_bar_location); |
| 203 | mSlotSensorsOff = resources.getString(com.android.internal.R.string.status_bar_sensors_off); |
| 204 | mSlotScreenRecord = resources.getString( |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 205 | com.android.internal.R.string.status_bar_screen_record); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 206 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 207 | mDisplayId = displayId; |
| 208 | mSharedPreferences = sharedPreferences; |
| 209 | mDateFormatUtil = dateFormatUtil; |
| 210 | } |
| 211 | |
| 212 | /** Initialize the object after construction. */ |
| 213 | public void init() { |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 214 | // listen for broadcasts |
| 215 | IntentFilter filter = new IntentFilter(); |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 216 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 217 | filter.addAction(AudioManager.ACTION_HEADSET_PLUG); |
Daniel Bright | 350f7f9 | 2020-01-22 14:24:11 -0800 | [diff] [blame] | 218 | filter.addAction(Intent.ACTION_SIM_STATE_CHANGED); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 219 | filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED); |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 220 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); |
| 221 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); |
Nicolas Prevot | 6c7b874 | 2016-04-13 10:28:58 +0100 | [diff] [blame] | 222 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 223 | mBroadcastDispatcher.registerReceiverWithHandler(mIntentReceiver, filter, mHandler); |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 224 | Observer<Integer> observer = ringer -> mHandler.post(this::updateVolumeZen); |
| 225 | |
| 226 | mRingerModeTracker.getRingerMode().observeForever(observer); |
| 227 | mRingerModeTracker.getRingerModeInternal().observeForever(observer); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 228 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 229 | // listen for user / profile change. |
| 230 | try { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 231 | mIActivityManager.registerUserSwitchObserver(mUserSwitchListener, TAG); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 232 | } catch (RemoteException e) { |
| 233 | // Ignore |
| 234 | } |
| 235 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 236 | // TTY status |
Hall Liu | 108ca20 | 2017-07-24 15:19:04 -0700 | [diff] [blame] | 237 | updateTTY(); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 238 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 239 | // bluetooth status |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 240 | updateBluetooth(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | // Alarm clock |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 243 | mIconController.setIcon(mSlotAlarmClock, R.drawable.stat_sys_alarm, null); |
| 244 | mIconController.setIconVisibility(mSlotAlarmClock, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 246 | // zen |
Amin Shaikh | 833bb0f | 2019-03-28 14:03:48 -0400 | [diff] [blame] | 247 | mIconController.setIcon(mSlotZen, R.drawable.stat_sys_dnd, null); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 248 | mIconController.setIconVisibility(mSlotZen, false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 249 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | // volume |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 251 | mIconController.setIcon(mSlotVolume, R.drawable.stat_sys_ringer_vibrate, null); |
| 252 | mIconController.setIconVisibility(mSlotVolume, false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 253 | updateVolumeZen(); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 254 | |
| 255 | // cast |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 256 | mIconController.setIcon(mSlotCast, R.drawable.stat_sys_cast, null); |
| 257 | mIconController.setIconVisibility(mSlotCast, false); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 258 | |
| 259 | // hotspot |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 260 | mIconController.setIcon(mSlotHotspot, R.drawable.stat_sys_hotspot, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 261 | mResources.getString(R.string.accessibility_status_bar_hotspot)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 262 | mIconController.setIconVisibility(mSlotHotspot, mHotspot.isHotspotEnabled()); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 263 | |
| 264 | // managed profile |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 265 | mIconController.setIcon(mSlotManagedProfile, R.drawable.stat_sys_managed_profile_status, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 266 | mResources.getString(R.string.accessibility_managed_profile)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 267 | mIconController.setIconVisibility(mSlotManagedProfile, mManagedProfileIconVisible); |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 268 | |
| 269 | // data saver |
| 270 | mIconController.setIcon(mSlotDataSaver, R.drawable.stat_sys_data_saver, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 271 | mResources.getString(R.string.accessibility_data_saver_on)); |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 272 | mIconController.setIconVisibility(mSlotDataSaver, false); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 273 | |
Fabian Kozynski | ed5dfd9 | 2018-12-20 15:00:48 -0500 | [diff] [blame] | 274 | mIconController.setIcon(mSlotLocation, LOCATION_STATUS_ICON_ID, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 275 | mResources.getString(R.string.accessibility_location_active)); |
Fabian Kozynski | ed5dfd9 | 2018-12-20 15:00:48 -0500 | [diff] [blame] | 276 | mIconController.setIconVisibility(mSlotLocation, false); |
Evan Laird | cf1a103 | 2018-11-14 13:46:08 -0500 | [diff] [blame] | 277 | |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 278 | // sensors off |
Michael Groover | 1ddabcc | 2019-04-19 18:35:24 -0700 | [diff] [blame] | 279 | mIconController.setIcon(mSlotSensorsOff, R.drawable.stat_sys_sensors_off, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 280 | mResources.getString(R.string.accessibility_sensors_off_active)); |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 281 | mIconController.setIconVisibility(mSlotSensorsOff, |
| 282 | mSensorPrivacyController.isSensorPrivacyEnabled()); |
| 283 | |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 284 | // screen record |
| 285 | mIconController.setIcon(mSlotScreenRecord, R.drawable.stat_sys_screen_record, null); |
| 286 | mIconController.setIconVisibility(mSlotScreenRecord, false); |
| 287 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 288 | mRotationLockController.addCallback(this); |
| 289 | mBluetooth.addCallback(this); |
| 290 | mProvisionedController.addCallback(this); |
| 291 | mZenController.addCallback(this); |
| 292 | mCast.addCallback(mCastCallback); |
| 293 | mHotspot.addCallback(mHotspotCallback); |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 294 | mNextAlarmController.addCallback(mNextAlarmCallback); |
Jason Monk | 8852905 | 2016-11-04 13:29:58 -0400 | [diff] [blame] | 295 | mDataSaver.addCallback(this); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 296 | mKeyguardStateController.addCallback(this); |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 297 | mSensorPrivacyController.addCallback(mSensorPrivacyListener); |
Fabian Kozynski | 16b2699 | 2019-05-06 10:18:41 -0400 | [diff] [blame] | 298 | mLocationController.addCallback(this); |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 299 | mRecordingController.addCallback(this); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 300 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 301 | mCommandQueue.addCallback(this); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | } |
| 303 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 304 | @Override |
| 305 | public void onZenChanged(int zen) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 306 | updateVolumeZen(); |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 307 | } |
| 308 | |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 309 | @Override |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 310 | public void onConfigChanged(ZenModeConfig config) { |
| 311 | updateVolumeZen(); |
| 312 | } |
| 313 | |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 314 | private void updateAlarm() { |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 315 | final AlarmClockInfo alarm = mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT); |
| 316 | final boolean hasAlarm = alarm != null && alarm.getTriggerTime() > 0; |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 317 | int zen = mZenController.getZen(); |
| 318 | final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 319 | mIconController.setIcon(mSlotAlarmClock, zenNone ? R.drawable.stat_sys_alarm_dim |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 320 | : R.drawable.stat_sys_alarm, buildAlarmContentDescription()); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 321 | mIconController.setIconVisibility(mSlotAlarmClock, mCurrentUserSetup && hasAlarm); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 322 | } |
| 323 | |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 324 | private String buildAlarmContentDescription() { |
| 325 | if (mNextAlarm == null) { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 326 | return mResources.getString(R.string.status_bar_alarm); |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 327 | } |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 328 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 329 | String skeleton = mDateFormatUtil.is24HourFormat() ? "EHm" : "Ehma"; |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 330 | String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 331 | String dateString = DateFormat.format(pattern, mNextAlarm.getTriggerTime()).toString(); |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 332 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 333 | return mResources.getString(R.string.accessibility_quick_settings_alarm, dateString); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | } |
| 335 | |
John Spurlock | bcc1087 | 2014-11-28 15:29:21 -0500 | [diff] [blame] | 336 | private final void updateVolumeZen() { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 337 | boolean zenVisible = false; |
| 338 | int zenIconId = 0; |
| 339 | String zenDescription = null; |
| 340 | |
| 341 | boolean volumeVisible = false; |
| 342 | int volumeIconId = 0; |
| 343 | String volumeDescription = null; |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 344 | int zen = mZenController.getZen(); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 345 | |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 346 | if (DndTile.isVisible(mSharedPreferences) || DndTile.isCombinedIcon(mSharedPreferences)) { |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 347 | zenVisible = zen != Global.ZEN_MODE_OFF; |
Evan Laird | a9adbd5 | 2018-05-16 11:32:08 -0400 | [diff] [blame] | 348 | zenIconId = R.drawable.stat_sys_dnd; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 349 | zenDescription = mResources.getString(R.string.quick_settings_dnd_label); |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 350 | } else if (zen == Global.ZEN_MODE_NO_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 351 | zenVisible = true; |
Amin Shaikh | 833bb0f | 2019-03-28 14:03:48 -0400 | [diff] [blame] | 352 | zenIconId = R.drawable.stat_sys_dnd; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 353 | zenDescription = mResources.getString(R.string.interruption_level_none); |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 354 | } else if (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 355 | zenVisible = true; |
Amin Shaikh | 833bb0f | 2019-03-28 14:03:48 -0400 | [diff] [blame] | 356 | zenIconId = R.drawable.stat_sys_dnd; |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 357 | zenDescription = mResources.getString(R.string.interruption_level_priority); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 358 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 359 | |
Beverly | ff2df9b | 2018-10-10 16:54:10 -0400 | [diff] [blame] | 360 | if (!ZenModeConfig.isZenOverridingRinger(zen, mZenController.getConsolidatedPolicy())) { |
Fabian Kozynski | b6a2037 | 2020-04-01 09:36:43 -0400 | [diff] [blame] | 361 | final Integer ringerModeInternal = |
| 362 | mRingerModeTracker.getRingerModeInternal().getValue(); |
| 363 | if (ringerModeInternal != null) { |
| 364 | if (ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE) { |
| 365 | volumeVisible = true; |
| 366 | volumeIconId = R.drawable.stat_sys_ringer_vibrate; |
| 367 | volumeDescription = mResources.getString(R.string.accessibility_ringer_vibrate); |
| 368 | } else if (ringerModeInternal == AudioManager.RINGER_MODE_SILENT) { |
| 369 | volumeVisible = true; |
| 370 | volumeIconId = R.drawable.stat_sys_ringer_silent; |
| 371 | volumeDescription = mResources.getString(R.string.accessibility_ringer_silent); |
| 372 | } |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 373 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | } |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 375 | |
| 376 | if (zenVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 377 | mIconController.setIcon(mSlotZen, zenIconId, zenDescription); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 378 | } |
| 379 | if (zenVisible != mZenVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 380 | mIconController.setIconVisibility(mSlotZen, zenVisible); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 381 | mZenVisible = zenVisible; |
| 382 | } |
| 383 | |
| 384 | if (volumeVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 385 | mIconController.setIcon(mSlotVolume, volumeIconId, volumeDescription); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 386 | } |
| 387 | if (volumeVisible != mVolumeVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 388 | mIconController.setIconVisibility(mSlotVolume, volumeVisible); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 389 | mVolumeVisible = volumeVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | } |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 391 | updateAlarm(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 392 | } |
| 393 | |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 394 | @Override |
| 395 | public void onBluetoothDevicesChanged() { |
| 396 | updateBluetooth(); |
| 397 | } |
| 398 | |
| 399 | @Override |
| 400 | public void onBluetoothStateChange(boolean enabled) { |
| 401 | updateBluetooth(); |
| 402 | } |
| 403 | |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 404 | private final void updateBluetooth() { |
Amin Shaikh | ad29e93 | 2019-03-08 11:26:12 -0500 | [diff] [blame] | 405 | int iconId = R.drawable.stat_sys_data_bluetooth_connected; |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 406 | String contentDescription = |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 407 | mResources.getString(R.string.accessibility_quick_settings_bluetooth_on); |
Evan Laird | 3cdf47e | 2018-01-29 16:01:41 -0500 | [diff] [blame] | 408 | boolean bluetoothVisible = false; |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 409 | if (mBluetooth != null) { |
Ugo Yu | 40f0880 | 2019-11-19 09:56:40 +0800 | [diff] [blame] | 410 | if (mBluetooth.isBluetoothConnected() |
| 411 | && (mBluetooth.isBluetoothAudioActive() |
| 412 | || !mBluetooth.isBluetoothAudioProfileOnly())) { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 413 | contentDescription = mResources.getString( |
Ugo Yu | 40f0880 | 2019-11-19 09:56:40 +0800 | [diff] [blame] | 414 | R.string.accessibility_bluetooth_connected); |
Evan Laird | 3cdf47e | 2018-01-29 16:01:41 -0500 | [diff] [blame] | 415 | bluetoothVisible = mBluetooth.isBluetoothEnabled(); |
Jaikumar Ganesh | 084c665 | 2009-12-07 10:58:18 -0800 | [diff] [blame] | 416 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 417 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 418 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 419 | mIconController.setIcon(mSlotBluetooth, iconId, contentDescription); |
Evan Laird | 3cdf47e | 2018-01-29 16:01:41 -0500 | [diff] [blame] | 420 | mIconController.setIconVisibility(mSlotBluetooth, bluetoothVisible); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 421 | } |
| 422 | |
Hall Liu | 108ca20 | 2017-07-24 15:19:04 -0700 | [diff] [blame] | 423 | private final void updateTTY() { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 424 | if (mTelecomManager == null) { |
Hall Liu | 108ca20 | 2017-07-24 15:19:04 -0700 | [diff] [blame] | 425 | updateTTY(TelecomManager.TTY_MODE_OFF); |
| 426 | } else { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 427 | updateTTY(mTelecomManager.getCurrentTtyMode()); |
Hall Liu | 108ca20 | 2017-07-24 15:19:04 -0700 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
| 431 | private final void updateTTY(int currentTtyMode) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 432 | boolean enabled = currentTtyMode != TelecomManager.TTY_MODE_OFF; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 433 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 434 | if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 435 | |
| 436 | if (enabled) { |
| 437 | // TTY is on |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 438 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY on"); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 439 | mIconController.setIcon(mSlotTty, R.drawable.stat_sys_tty_mode, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 440 | mResources.getString(R.string.accessibility_tty_enabled)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 441 | mIconController.setIconVisibility(mSlotTty, true); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 442 | } else { |
| 443 | // TTY is off |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 444 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY off"); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 445 | mIconController.setIconVisibility(mSlotTty, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 446 | } |
| 447 | } |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 448 | |
| 449 | private void updateCast() { |
| 450 | boolean isCasting = false; |
| 451 | for (CastDevice device : mCast.getCastDevices()) { |
| 452 | if (device.state == CastDevice.STATE_CONNECTING |
| 453 | || device.state == CastDevice.STATE_CONNECTED) { |
| 454 | isCasting = true; |
| 455 | break; |
| 456 | } |
| 457 | } |
| 458 | if (DEBUG) Log.v(TAG, "updateCast: isCasting: " + isCasting); |
Dan Sandler | 8fd25bf | 2015-10-20 16:01:27 -0700 | [diff] [blame] | 459 | mHandler.removeCallbacks(mRemoveCastIconRunnable); |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 460 | if (isCasting && !mRecordingController.isRecording()) { // screen record has its own icon |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 461 | mIconController.setIcon(mSlotCast, R.drawable.stat_sys_cast, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 462 | mResources.getString(R.string.accessibility_casting)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 463 | mIconController.setIconVisibility(mSlotCast, true); |
Dan Sandler | 8fd25bf | 2015-10-20 16:01:27 -0700 | [diff] [blame] | 464 | } else { |
| 465 | // don't turn off the screen-record icon for a few seconds, just to make sure the user |
| 466 | // has seen it |
| 467 | if (DEBUG) Log.v(TAG, "updateCast: hiding icon in 3 sec..."); |
| 468 | mHandler.postDelayed(mRemoveCastIconRunnable, 3000); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 469 | } |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 470 | } |
| 471 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 472 | private void updateManagedProfile() { |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 473 | // getLastResumedActivityUserId needds to acquire the AM lock, which may be contended in |
| 474 | // some cases. Since it doesn't really matter here whether it's updated in this frame |
| 475 | // or in the next one, we call this method from our UI offload thread. |
Dave Mankoff | c7cf9fc | 2019-12-19 15:43:20 -0500 | [diff] [blame] | 476 | mUiBgExecutor.execute(() -> { |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 477 | final int userId; |
| 478 | try { |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 479 | userId = ActivityTaskManager.getService().getLastResumedActivityUserId(); |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 480 | boolean isManagedProfile = mUserManager.isManagedProfile(userId); |
| 481 | mHandler.post(() -> { |
| 482 | final boolean showIcon; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 483 | if (isManagedProfile && (!mKeyguardStateController.isShowing() |
| 484 | || mKeyguardStateController.isOccluded())) { |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 485 | showIcon = true; |
| 486 | mIconController.setIcon(mSlotManagedProfile, |
| 487 | R.drawable.stat_sys_managed_profile_status, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 488 | mResources.getString(R.string.accessibility_managed_profile)); |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 489 | } else { |
| 490 | showIcon = false; |
| 491 | } |
| 492 | if (mManagedProfileIconVisible != showIcon) { |
| 493 | mIconController.setIconVisibility(mSlotManagedProfile, showIcon); |
| 494 | mManagedProfileIconVisible = showIcon; |
| 495 | } |
| 496 | }); |
| 497 | } catch (RemoteException e) { |
| 498 | Log.w(TAG, "updateManagedProfile: ", e); |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 499 | } |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 500 | }); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 501 | } |
| 502 | |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 503 | private final SynchronousUserSwitchObserver mUserSwitchListener = |
| 504 | new SynchronousUserSwitchObserver() { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 505 | @Override |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 506 | public void onUserSwitching(int newUserId) throws RemoteException { |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 507 | mHandler.post(() -> mUserInfoController.reloadUserInfo()); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | @Override |
| 511 | public void onUserSwitchComplete(int newUserId) throws RemoteException { |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 512 | mHandler.post(() -> { |
| 513 | updateAlarm(); |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 514 | updateManagedProfile(); |
Toni Barzic | e97f923 | 2016-04-27 18:10:58 -0700 | [diff] [blame] | 515 | }); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 516 | } |
| 517 | }; |
| 518 | |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 519 | private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { |
| 520 | @Override |
Rohan Shah | e407112 | 2018-01-22 15:16:09 -0800 | [diff] [blame] | 521 | public void onHotspotChanged(boolean enabled, int numDevices) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 522 | mIconController.setIconVisibility(mSlotHotspot, enabled); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 523 | } |
| 524 | }; |
| 525 | |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 526 | private final CastController.Callback mCastCallback = new CastController.Callback() { |
| 527 | @Override |
| 528 | public void onCastDevicesChanged() { |
| 529 | updateCast(); |
| 530 | } |
| 531 | }; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 532 | |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 533 | private final NextAlarmController.NextAlarmChangeCallback mNextAlarmCallback = |
| 534 | new NextAlarmController.NextAlarmChangeCallback() { |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 535 | @Override |
| 536 | public void onNextAlarmChanged(AlarmManager.AlarmClockInfo nextAlarm) { |
Evan Laird | bee3eb8 | 2018-05-16 15:58:49 -0400 | [diff] [blame] | 537 | mNextAlarm = nextAlarm; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 538 | updateAlarm(); |
| 539 | } |
| 540 | }; |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 541 | |
Michael Groover | a51ea81 | 2019-03-19 18:56:36 -0700 | [diff] [blame] | 542 | private final SensorPrivacyController.OnSensorPrivacyChangedListener mSensorPrivacyListener = |
| 543 | new SensorPrivacyController.OnSensorPrivacyChangedListener() { |
| 544 | @Override |
| 545 | public void onSensorPrivacyChanged(boolean enabled) { |
| 546 | mHandler.post(() -> { |
| 547 | mIconController.setIconVisibility(mSlotSensorsOff, enabled); |
| 548 | }); |
| 549 | } |
| 550 | }; |
| 551 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 552 | @Override |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 553 | public void appTransitionStarting(int displayId, long startTime, long duration, |
| 554 | boolean forced) { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 555 | if (mDisplayId == displayId) { |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 556 | updateManagedProfile(); |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 557 | } |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 558 | } |
| 559 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 560 | @Override |
| 561 | public void onKeyguardShowingChanged() { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 562 | updateManagedProfile(); |
| 563 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 564 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 565 | @Override |
| 566 | public void onUserSetupChanged() { |
| 567 | boolean userSetup = mProvisionedController.isUserSetup( |
| 568 | mProvisionedController.getCurrentUser()); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 569 | if (mCurrentUserSetup == userSetup) return; |
| 570 | mCurrentUserSetup = userSetup; |
| 571 | updateAlarm(); |
| 572 | } |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 573 | |
| 574 | @Override |
| 575 | public void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible) { |
| 576 | boolean portrait = RotationLockTile.isCurrentOrientationLockPortrait( |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 577 | mRotationLockController, mResources); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 578 | if (rotationLocked) { |
| 579 | if (portrait) { |
| 580 | mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_portrait, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 581 | mResources.getString(R.string.accessibility_rotation_lock_on_portrait)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 582 | } else { |
| 583 | mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_landscape, |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 584 | mResources.getString(R.string.accessibility_rotation_lock_on_landscape)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 585 | } |
Jason Monk | 8816dff | 2016-02-09 21:50:36 -0500 | [diff] [blame] | 586 | mIconController.setIconVisibility(mSlotRotate, true); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 587 | } else { |
Jason Monk | 8816dff | 2016-02-09 21:50:36 -0500 | [diff] [blame] | 588 | mIconController.setIconVisibility(mSlotRotate, false); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 589 | } |
| 590 | } |
| 591 | |
| 592 | private void updateHeadsetPlug(Intent intent) { |
| 593 | boolean connected = intent.getIntExtra("state", 0) != 0; |
| 594 | boolean hasMic = intent.getIntExtra("microphone", 0) != 0; |
| 595 | if (connected) { |
Dave Mankoff | 3c6aaab | 2020-01-10 17:50:34 -0500 | [diff] [blame] | 596 | String contentDescription = mResources.getString(hasMic |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 597 | ? R.string.accessibility_status_bar_headset |
| 598 | : R.string.accessibility_status_bar_headphones); |
Amin Shaikh | ad29e93 | 2019-03-08 11:26:12 -0500 | [diff] [blame] | 599 | mIconController.setIcon(mSlotHeadset, hasMic ? R.drawable.stat_sys_headset_mic |
| 600 | : R.drawable.stat_sys_headset, contentDescription); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 601 | mIconController.setIconVisibility(mSlotHeadset, true); |
| 602 | } else { |
| 603 | mIconController.setIconVisibility(mSlotHeadset, false); |
| 604 | } |
| 605 | } |
| 606 | |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 607 | @Override |
| 608 | public void onDataSaverChanged(boolean isDataSaving) { |
| 609 | mIconController.setIconVisibility(mSlotDataSaver, isDataSaving); |
| 610 | } |
| 611 | |
Fabian Kozynski | 16b2699 | 2019-05-06 10:18:41 -0400 | [diff] [blame] | 612 | @Override |
| 613 | public void onLocationActiveChanged(boolean active) { |
Fabian Kozynski | 228e310 | 2019-11-25 11:04:34 -0500 | [diff] [blame] | 614 | updateLocation(); |
Fabian Kozynski | 16b2699 | 2019-05-06 10:18:41 -0400 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | // Updates the status view based on the current state of location requests. |
| 618 | private void updateLocation() { |
| 619 | if (mLocationController.isLocationActive()) { |
| 620 | mIconController.setIconVisibility(mSlotLocation, true); |
| 621 | } else { |
| 622 | mIconController.setIconVisibility(mSlotLocation, false); |
| 623 | } |
| 624 | } |
| 625 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 626 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { |
| 627 | @Override |
| 628 | public void onReceive(Context context, Intent intent) { |
| 629 | String action = intent.getAction(); |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 630 | switch (action) { |
Daniel Bright | 350f7f9 | 2020-01-22 14:24:11 -0800 | [diff] [blame] | 631 | case Intent.ACTION_SIM_STATE_CHANGED: |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 632 | // Avoid rebroadcast because SysUI is direct boot aware. |
Meng Wang | 0e8d91a | 2020-01-17 14:58:01 -0800 | [diff] [blame] | 633 | if (intent.getBooleanExtra(Intent.EXTRA_REBROADCAST_ON_UNLOCK, false)) { |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 634 | break; |
| 635 | } |
Lucas Dupin | 5e0f0d2 | 2018-02-26 13:32:16 -0800 | [diff] [blame] | 636 | break; |
| 637 | case TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED: |
| 638 | updateTTY(intent.getIntExtra(TelecomManager.EXTRA_CURRENT_TTY_MODE, |
| 639 | TelecomManager.TTY_MODE_OFF)); |
| 640 | break; |
| 641 | case Intent.ACTION_MANAGED_PROFILE_AVAILABLE: |
| 642 | case Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE: |
| 643 | case Intent.ACTION_MANAGED_PROFILE_REMOVED: |
| 644 | updateManagedProfile(); |
| 645 | break; |
| 646 | case AudioManager.ACTION_HEADSET_PLUG: |
| 647 | updateHeadsetPlug(intent); |
| 648 | break; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 649 | } |
| 650 | } |
| 651 | }; |
| 652 | |
| 653 | private Runnable mRemoveCastIconRunnable = new Runnable() { |
| 654 | @Override |
| 655 | public void run() { |
| 656 | if (DEBUG) Log.v(TAG, "updateCast: hiding icon NOW"); |
| 657 | mIconController.setIconVisibility(mSlotCast, false); |
| 658 | } |
| 659 | }; |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 660 | |
| 661 | // Screen Recording |
| 662 | @Override |
| 663 | public void onCountdown(long millisUntilFinished) { |
| 664 | if (DEBUG) Log.d(TAG, "screenrecord: countdown " + millisUntilFinished); |
| 665 | int countdown = (int) Math.floorDiv(millisUntilFinished + 500, 1000); |
| 666 | int resourceId = R.drawable.stat_sys_screen_record; |
Beth Thibodeau | 47811b4 | 2020-04-22 01:22:39 -0400 | [diff] [blame] | 667 | String description = Integer.toString(countdown); |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 668 | switch (countdown) { |
| 669 | case 1: |
| 670 | resourceId = R.drawable.stat_sys_screen_record_1; |
| 671 | break; |
| 672 | case 2: |
| 673 | resourceId = R.drawable.stat_sys_screen_record_2; |
| 674 | break; |
| 675 | case 3: |
| 676 | resourceId = R.drawable.stat_sys_screen_record_3; |
| 677 | break; |
| 678 | } |
Beth Thibodeau | 47811b4 | 2020-04-22 01:22:39 -0400 | [diff] [blame] | 679 | mIconController.setIcon(mSlotScreenRecord, resourceId, description); |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 680 | mIconController.setIconVisibility(mSlotScreenRecord, true); |
Beth Thibodeau | a5af240 | 2020-06-15 23:16:09 -0400 | [diff] [blame] | 681 | // Set as assertive so talkback will announce the countdown |
| 682 | mIconController.setIconAccessibilityLiveRegion(mSlotScreenRecord, |
| 683 | View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE); |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | @Override |
Beth Thibodeau | 5877278 | 2020-02-18 20:55:38 -0500 | [diff] [blame] | 687 | public void onCountdownEnd() { |
| 688 | if (DEBUG) Log.d(TAG, "screenrecord: hiding icon during countdown"); |
| 689 | mHandler.post(() -> mIconController.setIconVisibility(mSlotScreenRecord, false)); |
Beth Thibodeau | a5af240 | 2020-06-15 23:16:09 -0400 | [diff] [blame] | 690 | // Reset talkback priority |
| 691 | mIconController.setIconAccessibilityLiveRegion(mSlotScreenRecord, |
| 692 | View.ACCESSIBILITY_LIVE_REGION_NONE); |
Beth Thibodeau | 5877278 | 2020-02-18 20:55:38 -0500 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | @Override |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 696 | public void onRecordingStart() { |
| 697 | if (DEBUG) Log.d(TAG, "screenrecord: showing icon"); |
| 698 | mIconController.setIcon(mSlotScreenRecord, |
Beth Thibodeau | 47811b4 | 2020-04-22 01:22:39 -0400 | [diff] [blame] | 699 | R.drawable.stat_sys_screen_record, |
| 700 | mResources.getString(R.string.screenrecord_ongoing_screen_only)); |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 701 | mIconController.setIconVisibility(mSlotScreenRecord, true); |
| 702 | } |
| 703 | |
| 704 | @Override |
| 705 | public void onRecordingEnd() { |
Beth Thibodeau | 5877278 | 2020-02-18 20:55:38 -0500 | [diff] [blame] | 706 | // Ensure this is on the main thread |
Beth Thibodeau | 8bfbf1f | 2020-02-13 13:55:37 -0500 | [diff] [blame] | 707 | if (DEBUG) Log.d(TAG, "screenrecord: hiding icon"); |
| 708 | mHandler.post(() -> mIconController.setIconVisibility(mSlotScreenRecord, false)); |
| 709 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 710 | } |