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 | |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 19 | import android.app.ActivityManager; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 20 | import android.app.ActivityManager.StackId; |
| 21 | import android.app.ActivityManager.StackInfo; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 22 | import android.app.AlarmManager; |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 23 | import android.app.AlarmManager.AlarmClockInfo; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 24 | import android.app.AppGlobals; |
| 25 | import android.app.Notification; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 26 | import android.app.Notification.Action; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 27 | import android.app.NotificationManager; |
| 28 | import android.app.PendingIntent; |
| 29 | import android.app.SynchronousUserSwitchObserver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.content.BroadcastReceiver; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 31 | import android.content.ComponentName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | import android.content.Intent; |
| 34 | import android.content.IntentFilter; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 35 | import android.content.pm.ApplicationInfo; |
| 36 | import android.content.pm.IPackageManager; |
| 37 | import android.content.pm.PackageManager; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 38 | import android.content.pm.UserInfo; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 39 | import android.graphics.drawable.Icon; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | import android.media.AudioManager; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 41 | import android.net.Uri; |
| 42 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import android.os.Handler; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 44 | import android.os.RemoteException; |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 45 | import android.os.UserHandle; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 46 | import android.os.UserManager; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 47 | import android.provider.Settings; |
John Spurlock | ae641c9 | 2014-06-30 18:11:40 -0400 | [diff] [blame] | 48 | import android.provider.Settings.Global; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 49 | import android.service.notification.StatusBarNotification; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 50 | import android.telecom.TelecomManager; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 51 | import android.util.ArraySet; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 52 | import android.util.Log; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 53 | import android.util.Pair; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 54 | import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 55 | import com.android.internal.telephony.IccCardConstants; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 56 | import com.android.internal.telephony.TelephonyIntents; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 57 | import com.android.systemui.Dependency; |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 58 | import com.android.systemui.DockedStackExistsListener; |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 59 | import com.android.systemui.R; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 60 | import com.android.systemui.SysUiServiceProvider; |
John Spurlock | 3c4076a | 2015-02-24 12:12:25 -0500 | [diff] [blame] | 61 | import com.android.systemui.qs.tiles.DndTile; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 62 | import com.android.systemui.qs.tiles.RotationLockTile; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 63 | import com.android.systemui.recents.misc.SystemServicesProxy; |
| 64 | import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 65 | import com.android.systemui.statusbar.CommandQueue; |
| 66 | import com.android.systemui.statusbar.CommandQueue.Callbacks; |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 67 | import com.android.systemui.statusbar.policy.BluetoothController; |
| 68 | import com.android.systemui.statusbar.policy.BluetoothController.Callback; |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 69 | import com.android.systemui.statusbar.policy.CastController; |
| 70 | import com.android.systemui.statusbar.policy.CastController.CastDevice; |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 71 | import com.android.systemui.statusbar.policy.DataSaverController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 72 | import com.android.systemui.statusbar.policy.DataSaverController.Listener; |
| 73 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
| 74 | import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 75 | import com.android.systemui.statusbar.policy.HotspotController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 76 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 77 | import com.android.systemui.statusbar.policy.LocationController; |
| 78 | import com.android.systemui.statusbar.policy.LocationController.LocationChangeCallback; |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 79 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 80 | import com.android.systemui.statusbar.policy.RotationLockController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 81 | import com.android.systemui.statusbar.policy.RotationLockController.RotationLockControllerCallback; |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 82 | import com.android.systemui.statusbar.policy.UserInfoController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 83 | import com.android.systemui.statusbar.policy.ZenModeController; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 84 | import com.android.systemui.util.NotificationChannels; |
| 85 | |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 86 | import java.util.List; |
| 87 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | /** |
| 89 | * 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] | 90 | * bar at boot time. It goes through the normal API for icons, even though it probably |
| 91 | * strictly doesn't need to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | */ |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 93 | public class PhoneStatusBarPolicy implements Callback, Callbacks, |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 94 | RotationLockControllerCallback, Listener, LocationChangeCallback, |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 95 | ZenModeController.Callback, DeviceProvisionedListener, KeyguardMonitor.Callback { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 96 | private static final String TAG = "PhoneStatusBarPolicy"; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 97 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 98 | |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 99 | public static final int LOCATION_STATUS_ICON_ID = R.drawable.stat_sys_location; |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 100 | public static final int NUM_TASKS_FOR_INSTANT_APP_INFO = 5; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 101 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 102 | private final String mSlotCast; |
| 103 | private final String mSlotHotspot; |
| 104 | private final String mSlotBluetooth; |
| 105 | private final String mSlotTty; |
| 106 | private final String mSlotZen; |
| 107 | private final String mSlotVolume; |
| 108 | private final String mSlotAlarmClock; |
| 109 | private final String mSlotManagedProfile; |
| 110 | private final String mSlotRotate; |
| 111 | private final String mSlotHeadset; |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 112 | private final String mSlotDataSaver; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 113 | private final String mSlotLocation; |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 114 | |
Dianne Hackborn | 4840e14 | 2009-03-24 22:40:29 -0700 | [diff] [blame] | 115 | private final Context mContext; |
Joe Onorato | 10523b4d | 2010-10-25 10:42:46 -0700 | [diff] [blame] | 116 | private final Handler mHandler = new Handler(); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 117 | private final CastController mCast; |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 118 | private final HotspotController mHotspot; |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 119 | private final NextAlarmController mNextAlarm; |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 120 | private final AlarmManager mAlarmManager; |
Adrian Roos | 88b1193 | 2015-07-22 14:59:48 -0700 | [diff] [blame] | 121 | private final UserInfoController mUserInfoController; |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 122 | private final UserManager mUserManager; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 123 | private final StatusBarIconController mIconController; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 124 | private final RotationLockController mRotationLockController; |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 125 | private final DataSaverController mDataSaver; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 126 | private final ZenModeController mZenController; |
| 127 | private final DeviceProvisionedController mProvisionedController; |
| 128 | private final KeyguardMonitor mKeyguardMonitor; |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 129 | private final LocationController mLocationController; |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 130 | private final ArraySet<Pair<String, Integer>> mCurrentNotifs = new ArraySet<>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 132 | // Assume it's all good unless we hear otherwise. We don't always seem |
| 133 | // to get broadcasts that it *is* there. |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 134 | IccCardConstants.State mSimState = IccCardConstants.State.READY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 136 | private boolean mZenVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | private boolean mVolumeVisible; |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 138 | private boolean mCurrentUserSetup; |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 139 | private boolean mDockedStackExists; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 140 | |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 141 | private boolean mManagedProfileIconVisible = false; |
| 142 | private boolean mManagedProfileInQuietMode = false; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 143 | |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 144 | private BluetoothController mBluetooth; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 145 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 146 | public PhoneStatusBarPolicy(Context context, StatusBarIconController iconController) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | mContext = context; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 148 | mIconController = iconController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 149 | mCast = Dependency.get(CastController.class); |
| 150 | mHotspot = Dependency.get(HotspotController.class); |
| 151 | mBluetooth = Dependency.get(BluetoothController.class); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 152 | mNextAlarm = Dependency.get(NextAlarmController.class); |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 153 | mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 154 | mUserInfoController = Dependency.get(UserInfoController.class); |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 155 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 156 | mRotationLockController = Dependency.get(RotationLockController.class); |
| 157 | mDataSaver = Dependency.get(DataSaverController.class); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 158 | mZenController = Dependency.get(ZenModeController.class); |
| 159 | mProvisionedController = Dependency.get(DeviceProvisionedController.class); |
| 160 | mKeyguardMonitor = Dependency.get(KeyguardMonitor.class); |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 161 | mLocationController = Dependency.get(LocationController.class); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 162 | |
| 163 | mSlotCast = context.getString(com.android.internal.R.string.status_bar_cast); |
| 164 | mSlotHotspot = context.getString(com.android.internal.R.string.status_bar_hotspot); |
| 165 | mSlotBluetooth = context.getString(com.android.internal.R.string.status_bar_bluetooth); |
| 166 | mSlotTty = context.getString(com.android.internal.R.string.status_bar_tty); |
| 167 | mSlotZen = context.getString(com.android.internal.R.string.status_bar_zen); |
| 168 | mSlotVolume = context.getString(com.android.internal.R.string.status_bar_volume); |
| 169 | mSlotAlarmClock = context.getString(com.android.internal.R.string.status_bar_alarm_clock); |
| 170 | mSlotManagedProfile = context.getString( |
| 171 | com.android.internal.R.string.status_bar_managed_profile); |
| 172 | mSlotRotate = context.getString(com.android.internal.R.string.status_bar_rotate); |
| 173 | mSlotHeadset = context.getString(com.android.internal.R.string.status_bar_headset); |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 174 | mSlotDataSaver = context.getString(com.android.internal.R.string.status_bar_data_saver); |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 175 | mSlotLocation = context.getString(com.android.internal.R.string.status_bar_location); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 177 | // listen for broadcasts |
| 178 | IntentFilter filter = new IntentFilter(); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 179 | filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); |
John Spurlock | bcc1087 | 2014-11-28 15:29:21 -0500 | [diff] [blame] | 180 | filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 181 | filter.addAction(AudioManager.ACTION_HEADSET_PLUG); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 182 | filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 183 | filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED); |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 184 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); |
| 185 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); |
Nicolas Prevot | 6c7b874 | 2016-04-13 10:28:58 +0100 | [diff] [blame] | 186 | filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); |
Daniel Sandler | e3b7a2d | 2011-10-27 16:16:15 -0400 | [diff] [blame] | 187 | mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); |
| 188 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 189 | // listen for user / profile change. |
| 190 | try { |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame] | 191 | ActivityManager.getService().registerUserSwitchObserver(mUserSwitchListener, TAG); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 192 | } catch (RemoteException e) { |
| 193 | // Ignore |
| 194 | } |
| 195 | |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 196 | // TTY status |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 197 | mIconController.setIcon(mSlotTty, R.drawable.stat_sys_tty_mode, null); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 198 | mIconController.setIconVisibility(mSlotTty, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 199 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | // bluetooth status |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 201 | updateBluetooth(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 202 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 203 | // Alarm clock |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 204 | mIconController.setIcon(mSlotAlarmClock, R.drawable.stat_sys_alarm, null); |
| 205 | mIconController.setIconVisibility(mSlotAlarmClock, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 206 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 207 | // zen |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 208 | mIconController.setIcon(mSlotZen, R.drawable.stat_sys_zen_important, null); |
| 209 | mIconController.setIconVisibility(mSlotZen, false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 210 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | // volume |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 212 | mIconController.setIcon(mSlotVolume, R.drawable.stat_sys_ringer_vibrate, null); |
| 213 | mIconController.setIconVisibility(mSlotVolume, false); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 214 | updateVolumeZen(); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 215 | |
| 216 | // cast |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 217 | mIconController.setIcon(mSlotCast, R.drawable.stat_sys_cast, null); |
| 218 | mIconController.setIconVisibility(mSlotCast, false); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 219 | |
| 220 | // hotspot |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 221 | mIconController.setIcon(mSlotHotspot, R.drawable.stat_sys_hotspot, |
Jason Monk | 08187a4 | 2015-06-09 14:33:51 -0400 | [diff] [blame] | 222 | mContext.getString(R.string.accessibility_status_bar_hotspot)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 223 | mIconController.setIconVisibility(mSlotHotspot, mHotspot.isHotspotEnabled()); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 224 | |
| 225 | // managed profile |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 226 | mIconController.setIcon(mSlotManagedProfile, R.drawable.stat_sys_managed_profile_status, |
Adrian Roos | 1b5eb97 | 2015-06-11 18:22:52 -0700 | [diff] [blame] | 227 | mContext.getString(R.string.accessibility_managed_profile)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 228 | mIconController.setIconVisibility(mSlotManagedProfile, mManagedProfileIconVisible); |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 229 | |
| 230 | // data saver |
| 231 | mIconController.setIcon(mSlotDataSaver, R.drawable.stat_sys_data_saver, |
| 232 | context.getString(R.string.accessibility_data_saver_on)); |
| 233 | mIconController.setIconVisibility(mSlotDataSaver, false); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 234 | |
| 235 | mRotationLockController.addCallback(this); |
| 236 | mBluetooth.addCallback(this); |
| 237 | mProvisionedController.addCallback(this); |
| 238 | mZenController.addCallback(this); |
| 239 | mCast.addCallback(mCastCallback); |
| 240 | mHotspot.addCallback(mHotspotCallback); |
| 241 | mNextAlarm.addCallback(mNextAlarmCallback); |
Jason Monk | 8852905 | 2016-11-04 13:29:58 -0400 | [diff] [blame] | 242 | mDataSaver.addCallback(this); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 243 | mKeyguardMonitor.addCallback(this); |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 244 | mLocationController.addCallback(this); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 245 | |
| 246 | SysUiServiceProvider.getComponent(mContext, CommandQueue.class).addCallbacks(this); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 247 | SystemServicesProxy.getInstance(mContext).registerTaskStackListener(mTaskListener); |
| 248 | |
| 249 | // Clear out all old notifications on startup (only present in the case where sysui dies) |
| 250 | NotificationManager noMan = mContext.getSystemService(NotificationManager.class); |
| 251 | for (StatusBarNotification notification : noMan.getActiveNotifications()) { |
| 252 | if (notification.getId() == SystemMessage.NOTE_INSTANT_APPS) { |
| 253 | noMan.cancel(notification.getTag(), notification.getId()); |
| 254 | } |
| 255 | } |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 256 | DockedStackExistsListener.register(exists -> { |
| 257 | mDockedStackExists = exists; |
| 258 | updateForegroundInstantApps(); |
| 259 | }); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | } |
| 261 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 262 | public void destroy() { |
| 263 | mRotationLockController.removeCallback(this); |
| 264 | mBluetooth.removeCallback(this); |
| 265 | mProvisionedController.removeCallback(this); |
| 266 | mZenController.removeCallback(this); |
| 267 | mCast.removeCallback(mCastCallback); |
| 268 | mHotspot.removeCallback(mHotspotCallback); |
| 269 | mNextAlarm.removeCallback(mNextAlarmCallback); |
| 270 | mDataSaver.removeCallback(this); |
| 271 | mKeyguardMonitor.removeCallback(this); |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 272 | mLocationController.removeCallback(this); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 273 | SysUiServiceProvider.getComponent(mContext, CommandQueue.class).removeCallbacks(this); |
| 274 | mContext.unregisterReceiver(mIntentReceiver); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 275 | |
| 276 | NotificationManager noMan = mContext.getSystemService(NotificationManager.class); |
| 277 | mCurrentNotifs.forEach(v -> noMan.cancelAsUser(v.first, SystemMessage.NOTE_INSTANT_APPS, |
| 278 | new UserHandle(v.second))); |
Nicolas Prevot | 1dbbe7d | 2016-05-17 12:52:54 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 281 | @Override |
| 282 | public void onZenChanged(int zen) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 283 | updateVolumeZen(); |
John Spurlock | ba2c6a0 | 2014-05-19 09:44:06 -0400 | [diff] [blame] | 284 | } |
| 285 | |
Jason Monk | 359bb74 | 2017-04-13 10:40:40 -0400 | [diff] [blame] | 286 | @Override |
| 287 | public void onLocationActiveChanged(boolean active) { |
| 288 | updateLocation(); |
| 289 | } |
| 290 | |
| 291 | // Updates the status view based on the current state of location requests. |
| 292 | private void updateLocation() { |
| 293 | if (mLocationController.isLocationActive()) { |
| 294 | mIconController.setIcon(mSlotLocation, LOCATION_STATUS_ICON_ID, |
| 295 | mContext.getString(R.string.accessibility_location_active)); |
| 296 | } else { |
| 297 | mIconController.removeIcon(mSlotLocation); |
| 298 | } |
| 299 | } |
| 300 | |
Adrian Roos | c42a1e1 | 2014-07-07 23:35:53 +0200 | [diff] [blame] | 301 | private void updateAlarm() { |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 302 | final AlarmClockInfo alarm = mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT); |
| 303 | final boolean hasAlarm = alarm != null && alarm.getTriggerTime() > 0; |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 304 | int zen = mZenController.getZen(); |
| 305 | final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS; |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 306 | mIconController.setIcon(mSlotAlarmClock, zenNone ? R.drawable.stat_sys_alarm_dim |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 307 | : R.drawable.stat_sys_alarm, null); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 308 | mIconController.setIconVisibility(mSlotAlarmClock, mCurrentUserSetup && hasAlarm); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 309 | } |
| 310 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | private final void updateSimState(Intent intent) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 312 | String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); |
| 313 | if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) { |
| 314 | mSimState = IccCardConstants.State.ABSENT; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 315 | } else if (IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR.equals(stateExtra)) { |
Rakesh Pallerla | f099a5f | 2013-02-06 11:44:23 +0530 | [diff] [blame] | 316 | mSimState = IccCardConstants.State.CARD_IO_ERROR; |
Junda Liu | a2f6a67 | 2016-05-24 10:07:40 -0700 | [diff] [blame] | 317 | } else if (IccCardConstants.INTENT_VALUE_ICC_CARD_RESTRICTED.equals(stateExtra)) { |
| 318 | mSimState = IccCardConstants.State.CARD_RESTRICTED; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 319 | } else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 320 | mSimState = IccCardConstants.State.READY; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 321 | } else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 322 | final String lockedReason = |
| 323 | intent.getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON); |
| 324 | if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) { |
| 325 | mSimState = IccCardConstants.State.PIN_REQUIRED; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 326 | } else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 327 | mSimState = IccCardConstants.State.PUK_REQUIRED; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 328 | } else { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 329 | mSimState = IccCardConstants.State.NETWORK_LOCKED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | } |
| 331 | } else { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 332 | mSimState = IccCardConstants.State.UNKNOWN; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 333 | } |
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() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 338 | |
| 339 | boolean zenVisible = false; |
| 340 | int zenIconId = 0; |
| 341 | String zenDescription = null; |
| 342 | |
| 343 | boolean volumeVisible = false; |
| 344 | int volumeIconId = 0; |
| 345 | String volumeDescription = null; |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 346 | int zen = mZenController.getZen(); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 347 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 348 | if (DndTile.isVisible(mContext) || DndTile.isCombinedIcon(mContext)) { |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 349 | zenVisible = zen != Global.ZEN_MODE_OFF; |
| 350 | zenIconId = zen == Global.ZEN_MODE_NO_INTERRUPTIONS |
John Spurlock | 4ec8b60 | 2015-05-11 17:46:28 -0400 | [diff] [blame] | 351 | ? R.drawable.stat_sys_dnd_total_silence : R.drawable.stat_sys_dnd; |
John Spurlock | 3c4076a | 2015-02-24 12:12:25 -0500 | [diff] [blame] | 352 | zenDescription = mContext.getString(R.string.quick_settings_dnd_label); |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 353 | } else if (zen == Global.ZEN_MODE_NO_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 354 | zenVisible = true; |
| 355 | zenIconId = R.drawable.stat_sys_zen_none; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 356 | zenDescription = mContext.getString(R.string.interruption_level_none); |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 357 | } else if (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 358 | zenVisible = true; |
| 359 | zenIconId = R.drawable.stat_sys_zen_important; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 360 | zenDescription = mContext.getString(R.string.interruption_level_priority); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 361 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 362 | |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 363 | if (DndTile.isVisible(mContext) && !DndTile.isCombinedIcon(mContext) |
John Spurlock | a48d779 | 2015-03-03 17:35:57 -0500 | [diff] [blame] | 364 | && audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT) { |
| 365 | volumeVisible = true; |
| 366 | volumeIconId = R.drawable.stat_sys_ringer_silent; |
| 367 | volumeDescription = mContext.getString(R.string.accessibility_ringer_silent); |
Jason Monk | 20c0eb4 | 2017-03-02 17:35:49 -0500 | [diff] [blame] | 368 | } else if (zen != Global.ZEN_MODE_NO_INTERRUPTIONS && zen != Global.ZEN_MODE_ALARMS && |
John Spurlock | 661f2cf | 2014-11-17 10:29:10 -0500 | [diff] [blame] | 369 | audioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_VIBRATE) { |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 370 | volumeVisible = true; |
| 371 | volumeIconId = R.drawable.stat_sys_ringer_vibrate; |
| 372 | volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 373 | } |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 374 | |
| 375 | if (zenVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 376 | mIconController.setIcon(mSlotZen, zenIconId, zenDescription); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 377 | } |
| 378 | if (zenVisible != mZenVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 379 | mIconController.setIconVisibility(mSlotZen, zenVisible); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 380 | mZenVisible = zenVisible; |
| 381 | } |
| 382 | |
| 383 | if (volumeVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 384 | mIconController.setIcon(mSlotVolume, volumeIconId, volumeDescription); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 385 | } |
| 386 | if (volumeVisible != mVolumeVisible) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 387 | mIconController.setIconVisibility(mSlotVolume, volumeVisible); |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 388 | mVolumeVisible = volumeVisible; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 389 | } |
John Spurlock | 1578226 | 2015-05-29 15:35:53 -0400 | [diff] [blame] | 390 | updateAlarm(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 393 | @Override |
| 394 | public void onBluetoothDevicesChanged() { |
| 395 | updateBluetooth(); |
| 396 | } |
| 397 | |
| 398 | @Override |
| 399 | public void onBluetoothStateChange(boolean enabled) { |
| 400 | updateBluetooth(); |
| 401 | } |
| 402 | |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 403 | private final void updateBluetooth() { |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 404 | int iconId = R.drawable.stat_sys_data_bluetooth; |
Jorim Jaggi | 2d75f9f | 2014-10-08 17:10:58 -0700 | [diff] [blame] | 405 | String contentDescription = |
Jason Monk | 1aa3282 | 2015-07-14 16:10:32 -0400 | [diff] [blame] | 406 | mContext.getString(R.string.accessibility_quick_settings_bluetooth_on); |
Jason Monk | 7036436 | 2015-08-06 16:32:18 -0400 | [diff] [blame] | 407 | boolean bluetoothEnabled = false; |
| 408 | if (mBluetooth != null) { |
| 409 | bluetoothEnabled = mBluetooth.isBluetoothEnabled(); |
| 410 | if (mBluetooth.isBluetoothConnected()) { |
Jaikumar Ganesh | d9bb688 | 2010-09-27 17:05:24 -0700 | [diff] [blame] | 411 | iconId = R.drawable.stat_sys_data_bluetooth_connected; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 412 | contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected); |
Jaikumar Ganesh | 084c665 | 2009-12-07 10:58:18 -0800 | [diff] [blame] | 413 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 415 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 416 | mIconController.setIcon(mSlotBluetooth, iconId, contentDescription); |
| 417 | mIconController.setIconVisibility(mSlotBluetooth, bluetoothEnabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 418 | } |
| 419 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 420 | private final void updateTTY(Intent intent) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 421 | int currentTtyMode = intent.getIntExtra(TelecomManager.EXTRA_CURRENT_TTY_MODE, |
| 422 | TelecomManager.TTY_MODE_OFF); |
| 423 | boolean enabled = currentTtyMode != TelecomManager.TTY_MODE_OFF; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 424 | |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 425 | if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 426 | |
| 427 | if (enabled) { |
| 428 | // TTY is on |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 429 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY on"); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 430 | mIconController.setIcon(mSlotTty, R.drawable.stat_sys_tty_mode, |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 431 | mContext.getString(R.string.accessibility_tty_enabled)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 432 | mIconController.setIconVisibility(mSlotTty, true); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 433 | } else { |
| 434 | // TTY is off |
John Spurlock | a37e9c8 | 2014-07-08 09:40:31 -0400 | [diff] [blame] | 435 | if (DEBUG) Log.v(TAG, "updateTTY: set TTY off"); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 436 | mIconController.setIconVisibility(mSlotTty, false); |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 437 | } |
| 438 | } |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 439 | |
| 440 | private void updateCast() { |
| 441 | boolean isCasting = false; |
| 442 | for (CastDevice device : mCast.getCastDevices()) { |
| 443 | if (device.state == CastDevice.STATE_CONNECTING |
| 444 | || device.state == CastDevice.STATE_CONNECTED) { |
| 445 | isCasting = true; |
| 446 | break; |
| 447 | } |
| 448 | } |
| 449 | if (DEBUG) Log.v(TAG, "updateCast: isCasting: " + isCasting); |
Dan Sandler | 8fd25bf | 2015-10-20 16:01:27 -0700 | [diff] [blame] | 450 | mHandler.removeCallbacks(mRemoveCastIconRunnable); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 451 | if (isCasting) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 452 | mIconController.setIcon(mSlotCast, R.drawable.stat_sys_cast, |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 453 | mContext.getString(R.string.accessibility_casting)); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 454 | mIconController.setIconVisibility(mSlotCast, true); |
Dan Sandler | 8fd25bf | 2015-10-20 16:01:27 -0700 | [diff] [blame] | 455 | } else { |
| 456 | // don't turn off the screen-record icon for a few seconds, just to make sure the user |
| 457 | // has seen it |
| 458 | if (DEBUG) Log.v(TAG, "updateCast: hiding icon in 3 sec..."); |
| 459 | mHandler.postDelayed(mRemoveCastIconRunnable, 3000); |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 460 | } |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 461 | } |
| 462 | |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 463 | private void updateQuietState() { |
| 464 | mManagedProfileInQuietMode = false; |
| 465 | int currentUserId = ActivityManager.getCurrentUser(); |
| 466 | for (UserInfo ui : mUserManager.getEnabledProfiles(currentUserId)) { |
| 467 | if (ui.isManagedProfile() && ui.isQuietModeEnabled()) { |
| 468 | mManagedProfileInQuietMode = true; |
| 469 | return; |
| 470 | } |
| 471 | } |
| 472 | } |
| 473 | |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 474 | private void updateManagedProfile() { |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 475 | try { |
| 476 | final boolean showIcon; |
| 477 | final int userId = ActivityManager.getService().getLastResumedActivityUserId(); |
| 478 | if (mUserManager.isManagedProfile(userId) && !mKeyguardMonitor.isShowing()) { |
| 479 | showIcon = true; |
| 480 | mIconController.setIcon(mSlotManagedProfile, |
| 481 | R.drawable.stat_sys_managed_profile_status, |
| 482 | mContext.getString(R.string.accessibility_managed_profile)); |
| 483 | } else if (mManagedProfileInQuietMode) { |
| 484 | showIcon = true; |
| 485 | mIconController.setIcon(mSlotManagedProfile, |
| 486 | R.drawable.stat_sys_managed_profile_status_off, |
| 487 | mContext.getString(R.string.accessibility_managed_profile)); |
| 488 | } else { |
| 489 | showIcon = false; |
| 490 | } |
| 491 | if (mManagedProfileIconVisible != showIcon) { |
| 492 | mIconController.setIconVisibility(mSlotManagedProfile, showIcon); |
| 493 | mManagedProfileIconVisible = showIcon; |
| 494 | } |
| 495 | } catch (RemoteException ex) { |
| 496 | Log.w(TAG, "updateManagedProfile: ", ex); |
| 497 | // ignore |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 501 | private void updateForegroundInstantApps() { |
| 502 | NotificationManager noMan = mContext.getSystemService(NotificationManager.class); |
| 503 | ArraySet<Pair<String, Integer>> notifs = new ArraySet<>(mCurrentNotifs); |
| 504 | IPackageManager pm = AppGlobals.getPackageManager(); |
| 505 | mCurrentNotifs.clear(); |
| 506 | try { |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 507 | ArraySet<Integer> stacksToCheck = new ArraySet<>(); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 508 | int[] STACKS_TO_CHECK = new int[]{ |
| 509 | StackId.FULLSCREEN_WORKSPACE_STACK_ID, |
| 510 | StackId.DOCKED_STACK_ID, |
| 511 | }; |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 512 | int focusedId = ActivityManager.getService().getFocusedStackId(); |
| 513 | if (focusedId == StackId.FULLSCREEN_WORKSPACE_STACK_ID |
| 514 | || focusedId == StackId.FULLSCREEN_WORKSPACE_STACK_ID) { |
| 515 | checkStack(StackId.FULLSCREEN_WORKSPACE_STACK_ID, notifs, noMan, pm); |
| 516 | } |
| 517 | if (mDockedStackExists) { |
| 518 | checkStack(StackId.DOCKED_STACK_ID, notifs, noMan, pm); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 519 | } |
| 520 | } catch (RemoteException e) { |
| 521 | e.rethrowFromSystemServer(); |
| 522 | } |
| 523 | // Cancel all the leftover notifications that don't have a foreground process anymore. |
| 524 | notifs.forEach(v -> noMan.cancelAsUser(v.first, SystemMessage.NOTE_INSTANT_APPS, |
| 525 | new UserHandle(v.second))); |
| 526 | } |
| 527 | |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 528 | private void checkStack(int stackId, ArraySet<Pair<String, Integer>> notifs, |
| 529 | NotificationManager noMan, IPackageManager pm) { |
| 530 | try { |
| 531 | StackInfo info = ActivityManager.getService().getStackInfo(stackId); |
| 532 | if (info == null || info.topActivity == null) return; |
| 533 | String pkg = info.topActivity.getPackageName(); |
| 534 | if (!hasNotif(notifs, pkg, info.userId)) { |
| 535 | // TODO: Optimize by not always needing to get application info. |
| 536 | // Maybe cache non-ephemeral packages? |
| 537 | ApplicationInfo appInfo = pm.getApplicationInfo(pkg, |
| 538 | PackageManager.MATCH_UNINSTALLED_PACKAGES, info.userId); |
| 539 | if (appInfo.isInstantApp()) { |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 540 | postEphemeralNotif(pkg, info.userId, appInfo, noMan, info.taskIds[info.taskIds.length - 1]); |
Jason Monk | f85fc96 | 2017-04-19 17:13:41 -0400 | [diff] [blame] | 541 | } |
| 542 | } |
| 543 | } catch (RemoteException e) { |
| 544 | e.rethrowFromSystemServer(); |
| 545 | } |
| 546 | } |
| 547 | |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 548 | private void postEphemeralNotif(String pkg, int userId, ApplicationInfo appInfo, |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 549 | NotificationManager noMan, int taskId) { |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 550 | final Bundle extras = new Bundle(); |
| 551 | extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, |
| 552 | mContext.getString(R.string.instant_apps)); |
| 553 | mCurrentNotifs.add(new Pair<>(pkg, userId)); |
| 554 | String message = mContext.getString(R.string.instant_apps_message); |
| 555 | PendingIntent appInfoAction = PendingIntent.getActivity(mContext, 0, |
| 556 | new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) |
| 557 | .setData(Uri.fromParts("package", pkg, null)), 0); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 558 | Action action = new Notification.Action.Builder(null, mContext.getString(R.string.app_info), |
| 559 | appInfoAction).build(); |
| 560 | |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 561 | Intent browserIntent = getTaskIntent(taskId, userId); |
| 562 | Notification.Builder builder = new Notification.Builder(mContext, NotificationChannels.GENERAL); |
| 563 | if (browserIntent != null) { |
Jesse Evans | a2024a2 | 2017-04-20 14:44:49 -0700 | [diff] [blame] | 564 | // Make sure that this doesn't resolve back to an instant app |
| 565 | browserIntent.setComponent(null) |
| 566 | .setPackage(null) |
| 567 | .addFlags(Intent.FLAG_IGNORE_EPHEMERAL) |
| 568 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 569 | |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 570 | PendingIntent pendingIntent = PendingIntent.getActivity(mContext, |
| 571 | 0 /* requestCode */, browserIntent, 0 /* flags */); |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 572 | ComponentName aiaComponent = null; |
| 573 | try { |
| 574 | aiaComponent = AppGlobals.getPackageManager().getInstantAppInstallerComponent(); |
| 575 | } catch (RemoteException e) { |
| 576 | e.rethrowFromSystemServer(); |
| 577 | } |
| 578 | Intent goToWebIntent = new Intent() |
| 579 | .setComponent(aiaComponent) |
| 580 | .setAction(Intent.ACTION_VIEW) |
| 581 | .addCategory(Intent.CATEGORY_BROWSABLE) |
Jason Monk | 83c0051 | 2017-05-08 11:23:14 -0400 | [diff] [blame] | 582 | .addCategory("unique:" + System.currentTimeMillis()) |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 583 | .putExtra(Intent.EXTRA_PACKAGE_NAME, appInfo.packageName) |
| 584 | .putExtra(Intent.EXTRA_VERSION_CODE, appInfo.versionCode) |
| 585 | .putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, pendingIntent); |
| 586 | |
| 587 | PendingIntent webPendingIntent = PendingIntent.getActivity(mContext, 0, goToWebIntent, 0); |
| 588 | Action webAction = new Notification.Action.Builder(null, mContext.getString(R.string.go_to_web), |
| 589 | webPendingIntent).build(); |
| 590 | builder.addAction(webAction); |
| 591 | } |
| 592 | |
| 593 | noMan.notifyAsUser(pkg, SystemMessage.NOTE_INSTANT_APPS, builder |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 594 | .addExtras(extras) |
| 595 | .addAction(action) |
| 596 | .setContentIntent(appInfoAction) |
| 597 | .setColor(mContext.getColor(R.color.instant_apps_color)) |
| 598 | .setContentTitle(appInfo.loadLabel(mContext.getPackageManager())) |
| 599 | .setLargeIcon(Icon.createWithResource(pkg, appInfo.icon)) |
| 600 | .setSmallIcon(Icon.createWithResource(mContext.getPackageName(), |
| 601 | R.drawable.instant_icon)) |
| 602 | .setContentText(message) |
| 603 | .setOngoing(true) |
| 604 | .build(), |
| 605 | new UserHandle(userId)); |
| 606 | } |
| 607 | |
Jason Monk | 697b82a | 2017-04-19 18:41:06 -0400 | [diff] [blame] | 608 | private Intent getTaskIntent(int taskId, int userId) { |
| 609 | List<ActivityManager.RecentTaskInfo> tasks = mContext.getSystemService(ActivityManager.class) |
| 610 | .getRecentTasksForUser(NUM_TASKS_FOR_INSTANT_APP_INFO, 0, userId); |
| 611 | for (int i = 0; i < tasks.size(); i++) { |
| 612 | if (tasks.get(i).id == taskId) { |
| 613 | return tasks.get(i).baseIntent; |
| 614 | } |
| 615 | } |
| 616 | return null; |
| 617 | } |
| 618 | |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 619 | private boolean hasNotif(ArraySet<Pair<String, Integer>> notifs, String pkg, int userId) { |
| 620 | Pair<String, Integer> key = new Pair<>(pkg, userId); |
| 621 | if (notifs.remove(key)) { |
| 622 | mCurrentNotifs.add(key); |
| 623 | return true; |
| 624 | } |
| 625 | return false; |
| 626 | } |
| 627 | |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 628 | private final SynchronousUserSwitchObserver mUserSwitchListener = |
| 629 | new SynchronousUserSwitchObserver() { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 630 | @Override |
Fyodor Kupolov | 6005b3f | 2015-11-23 17:41:50 -0800 | [diff] [blame] | 631 | public void onUserSwitching(int newUserId) throws RemoteException { |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 632 | mHandler.post(() -> mUserInfoController.reloadUserInfo()); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | @Override |
| 636 | public void onUserSwitchComplete(int newUserId) throws RemoteException { |
Tony Mak | ec319ab | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 637 | mHandler.post(() -> { |
| 638 | updateAlarm(); |
| 639 | updateQuietState(); |
| 640 | updateManagedProfile(); |
| 641 | updateForegroundInstantApps(); |
Toni Barzic | e97f923 | 2016-04-27 18:10:58 -0700 | [diff] [blame] | 642 | }); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 643 | } |
| 644 | }; |
| 645 | |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 646 | private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { |
| 647 | @Override |
| 648 | public void onHotspotChanged(boolean enabled) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 649 | mIconController.setIconVisibility(mSlotHotspot, enabled); |
Jason Monk | 952d5d8 | 2014-10-27 15:28:22 -0400 | [diff] [blame] | 650 | } |
| 651 | }; |
| 652 | |
John Spurlock | 96fe98d | 2014-08-27 09:36:02 -0400 | [diff] [blame] | 653 | private final CastController.Callback mCastCallback = new CastController.Callback() { |
| 654 | @Override |
| 655 | public void onCastDevicesChanged() { |
| 656 | updateCast(); |
| 657 | } |
| 658 | }; |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 659 | |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 660 | private final NextAlarmController.NextAlarmChangeCallback mNextAlarmCallback = |
| 661 | new NextAlarmController.NextAlarmChangeCallback() { |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 662 | @Override |
| 663 | public void onNextAlarmChanged(AlarmManager.AlarmClockInfo nextAlarm) { |
| 664 | updateAlarm(); |
| 665 | } |
| 666 | }; |
Juan Flores | 2ff3720 | 2015-04-30 13:44:23 +0200 | [diff] [blame] | 667 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 668 | @Override |
| 669 | public void appTransitionStarting(long startTime, long duration, boolean forced) { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 670 | updateManagedProfile(); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 671 | updateForegroundInstantApps(); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 672 | } |
| 673 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 674 | @Override |
| 675 | public void onKeyguardShowingChanged() { |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 676 | updateManagedProfile(); |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 677 | updateForegroundInstantApps(); |
Kenny Guy | 3094d4a | 2015-04-01 19:14:10 +0100 | [diff] [blame] | 678 | } |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 679 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 680 | @Override |
| 681 | public void onUserSetupChanged() { |
| 682 | boolean userSetup = mProvisionedController.isUserSetup( |
| 683 | mProvisionedController.getCurrentUser()); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 684 | if (mCurrentUserSetup == userSetup) return; |
| 685 | mCurrentUserSetup = userSetup; |
| 686 | updateAlarm(); |
Rubin Xu | 1205fb1 | 2015-11-04 17:45:03 +0000 | [diff] [blame] | 687 | updateQuietState(); |
John Spurlock | 604a5ee | 2015-06-01 12:27:22 -0400 | [diff] [blame] | 688 | } |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 689 | |
| 690 | @Override |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 691 | public void preloadRecentApps() { |
| 692 | updateForegroundInstantApps(); |
| 693 | } |
| 694 | |
| 695 | @Override |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 696 | public void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible) { |
| 697 | boolean portrait = RotationLockTile.isCurrentOrientationLockPortrait( |
| 698 | mRotationLockController, mContext); |
| 699 | if (rotationLocked) { |
| 700 | if (portrait) { |
| 701 | mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_portrait, |
| 702 | mContext.getString(R.string.accessibility_rotation_lock_on_portrait)); |
| 703 | } else { |
| 704 | mIconController.setIcon(mSlotRotate, R.drawable.stat_sys_rotate_landscape, |
| 705 | mContext.getString(R.string.accessibility_rotation_lock_on_landscape)); |
| 706 | } |
Jason Monk | 8816dff | 2016-02-09 21:50:36 -0500 | [diff] [blame] | 707 | mIconController.setIconVisibility(mSlotRotate, true); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 708 | } else { |
Jason Monk | 8816dff | 2016-02-09 21:50:36 -0500 | [diff] [blame] | 709 | mIconController.setIconVisibility(mSlotRotate, false); |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 710 | } |
| 711 | } |
| 712 | |
| 713 | private void updateHeadsetPlug(Intent intent) { |
| 714 | boolean connected = intent.getIntExtra("state", 0) != 0; |
| 715 | boolean hasMic = intent.getIntExtra("microphone", 0) != 0; |
| 716 | if (connected) { |
| 717 | String contentDescription = mContext.getString(hasMic |
| 718 | ? R.string.accessibility_status_bar_headset |
| 719 | : R.string.accessibility_status_bar_headphones); |
| 720 | mIconController.setIcon(mSlotHeadset, hasMic ? R.drawable.ic_headset_mic |
| 721 | : R.drawable.ic_headset, contentDescription); |
| 722 | mIconController.setIconVisibility(mSlotHeadset, true); |
| 723 | } else { |
| 724 | mIconController.setIconVisibility(mSlotHeadset, false); |
| 725 | } |
| 726 | } |
| 727 | |
Jason Monk | f23aa99 | 2016-01-22 16:45:21 -0500 | [diff] [blame] | 728 | @Override |
| 729 | public void onDataSaverChanged(boolean isDataSaving) { |
| 730 | mIconController.setIconVisibility(mSlotDataSaver, isDataSaving); |
| 731 | } |
| 732 | |
Jason Monk | 324b886 | 2017-02-16 17:19:12 -0500 | [diff] [blame] | 733 | private final TaskStackListener mTaskListener = new TaskStackListener() { |
| 734 | @Override |
| 735 | public void onTaskStackChanged() { |
| 736 | // Listen for changes to stacks and then check which instant apps are foreground. |
| 737 | updateForegroundInstantApps(); |
| 738 | } |
| 739 | }; |
| 740 | |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 741 | private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { |
| 742 | @Override |
| 743 | public void onReceive(Context context, Intent intent) { |
| 744 | String action = intent.getAction(); |
Julia Reynolds | 4e6024b | 2016-04-26 16:12:26 -0400 | [diff] [blame] | 745 | if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) || |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 746 | action.equals(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)) { |
| 747 | updateVolumeZen(); |
| 748 | } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { |
| 749 | updateSimState(intent); |
| 750 | } else if (action.equals(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED)) { |
| 751 | updateTTY(intent); |
Rubin Xu | e95057a | 2016-04-01 16:49:25 +0100 | [diff] [blame] | 752 | } else if (action.equals(Intent.ACTION_MANAGED_PROFILE_AVAILABLE) || |
Nicolas Prevot | 6c7b874 | 2016-04-13 10:28:58 +0100 | [diff] [blame] | 753 | action.equals(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE) || |
| 754 | action.equals(Intent.ACTION_MANAGED_PROFILE_REMOVED)) { |
Jason Monk | 3e18987 | 2016-01-12 09:10:34 -0500 | [diff] [blame] | 755 | updateQuietState(); |
| 756 | updateManagedProfile(); |
| 757 | } else if (action.equals(AudioManager.ACTION_HEADSET_PLUG)) { |
| 758 | updateHeadsetPlug(intent); |
| 759 | } |
| 760 | } |
| 761 | }; |
| 762 | |
| 763 | private Runnable mRemoveCastIconRunnable = new Runnable() { |
| 764 | @Override |
| 765 | public void run() { |
| 766 | if (DEBUG) Log.v(TAG, "updateCast: hiding icon NOW"); |
| 767 | mIconController.setIconVisibility(mSlotCast, false); |
| 768 | } |
| 769 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 770 | } |