blob: 237b78272b47aacb229ffe13a4206dd460426b27 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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 Onoratofd52b182010-11-10 18:00:52 -080017package com.android.systemui.statusbar.phone;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018
Adrian Roosc42a1e12014-07-07 23:35:53 +020019import android.app.AlarmManager;
Joe Onorato798ac4c2010-05-27 16:39:00 -040020import android.app.StatusBarManager;
Nick Pellybd022f42009-08-14 18:33:38 -070021import android.bluetooth.BluetoothAdapter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.content.BroadcastReceiver;
23import android.content.Context;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.content.Intent;
25import android.content.IntentFilter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.media.AudioManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.os.Handler;
Adrian Roosc42a1e12014-07-07 23:35:53 +020028import android.os.UserHandle;
John Spurlockae641c92014-06-30 18:11:40 -040029import android.provider.Settings.Global;
Sailesh Nepal001bbbb2014-07-15 14:40:39 -070030import android.telecomm.TelecommManager;
John Spurlockcd686b52013-06-05 10:13:46 -040031import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032
Wink Savillea639b312012-07-10 12:37:54 -070033import com.android.internal.telephony.IccCardConstants;
Wink Saville04e71b32009-04-02 11:00:54 -070034import com.android.internal.telephony.TelephonyIntents;
Joe Onorato798ac4c2010-05-27 16:39:00 -040035import com.android.systemui.R;
John Spurlock96fe98d2014-08-27 09:36:02 -040036import com.android.systemui.statusbar.policy.CastController;
37import com.android.systemui.statusbar.policy.CastController.CastDevice;
Joe Onorato798ac4c2010-05-27 16:39:00 -040038
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039/**
40 * This class contains all of the policy about which icons are installed in the status
Joe Onorato798ac4c2010-05-27 16:39:00 -040041 * bar at boot time. It goes through the normal API for icons, even though it probably
42 * strictly doesn't need to.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 */
Joe Onoratofd52b182010-11-10 18:00:52 -080044public class PhoneStatusBarPolicy {
45 private static final String TAG = "PhoneStatusBarPolicy";
John Spurlocka37e9c82014-07-08 09:40:31 -040046 private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
Robert Greenwaltd7085fc2010-09-08 15:24:47 -070047
Daniel Sandlerb1e8dab2011-09-26 20:06:19 -040048 private static final boolean SHOW_SYNC_ICON = false;
49
John Spurlocka37e9c82014-07-08 09:40:31 -040050 private static final String SLOT_SYNC_ACTIVE = "sync_active";
John Spurlock96fe98d2014-08-27 09:36:02 -040051 private static final String SLOT_CAST = "cast";
John Spurlocka37e9c82014-07-08 09:40:31 -040052 private static final String SLOT_BLUETOOTH = "bluetooth";
53 private static final String SLOT_TTY = "tty";
54 private static final String SLOT_ZEN = "zen";
55 private static final String SLOT_VOLUME = "volume";
56 private static final String SLOT_CDMA_ERI = "cdma_eri";
57 private static final String SLOT_ALARM_CLOCK = "alarm_clock";
58
Dianne Hackborn4840e142009-03-24 22:40:29 -070059 private final Context mContext;
Joe Onorato798ac4c2010-05-27 16:39:00 -040060 private final StatusBarManager mService;
Joe Onorato10523b4d2010-10-25 10:42:46 -070061 private final Handler mHandler = new Handler();
John Spurlock96fe98d2014-08-27 09:36:02 -040062 private final CastController mCast;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064 // Assume it's all good unless we hear otherwise. We don't always seem
65 // to get broadcasts that it *is* there.
Wink Savillea639b312012-07-10 12:37:54 -070066 IccCardConstants.State mSimState = IccCardConstants.State.READY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067
John Spurlocka37e9c82014-07-08 09:40:31 -040068 private boolean mZenVisible;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 private boolean mVolumeVisible;
Wink Saville04e71b32009-04-02 11:00:54 -070070
John Spurlockae641c92014-06-30 18:11:40 -040071 private int mZen;
John Spurlockba2c6a02014-05-19 09:44:06 -040072
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -040073 private boolean mBluetoothEnabled = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074
Wink Savillee9b06d72009-05-18 21:47:50 -070075
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
77 @Override
78 public void onReceive(Context context, Intent intent) {
79 String action = intent.getAction();
Adrian Roosc42a1e12014-07-07 23:35:53 +020080 if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
81 updateAlarm();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 }
83 else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) {
84 updateSyncState(intent);
85 }
Nick Pellyde893f52009-09-08 13:15:33 -070086 else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
Jaikumar Ganeshd9bb6882010-09-27 17:05:24 -070087 action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 updateBluetooth(intent);
89 }
Eric Laurentbffc3d12012-05-07 17:43:49 -070090 else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
John Spurlocka37e9c82014-07-08 09:40:31 -040091 updateVolumeZen();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 }
93 else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
94 updateSimState(intent);
95 }
Evan Charlton10197192014-07-19 15:00:29 -070096 else if (action.equals(TelecommManager.ACTION_CURRENT_TTY_MODE_CHANGED)) {
Wink Saville04e71b32009-04-02 11:00:54 -070097 updateTTY(intent);
98 }
Adrian Roosc42a1e12014-07-07 23:35:53 +020099 else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
100 updateAlarm();
101 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 }
103 };
104
John Spurlock96fe98d2014-08-27 09:36:02 -0400105 public PhoneStatusBarPolicy(Context context, CastController cast) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 mContext = context;
John Spurlock96fe98d2014-08-27 09:36:02 -0400107 mCast = cast;
Joe Onorato798ac4c2010-05-27 16:39:00 -0400108 mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -0400110 // listen for broadcasts
111 IntentFilter filter = new IntentFilter();
Adrian Roosc42a1e12014-07-07 23:35:53 +0200112 filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -0400113 filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
114 filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -0400115 filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
116 filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
117 filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
Evan Charlton10197192014-07-19 15:00:29 -0700118 filter.addAction(TelecommManager.ACTION_CURRENT_TTY_MODE_CHANGED);
Adrian Roosc42a1e12014-07-07 23:35:53 +0200119 filter.addAction(Intent.ACTION_USER_SWITCHED);
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -0400120 mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
121
Wink Saville04e71b32009-04-02 11:00:54 -0700122 // TTY status
John Spurlocka37e9c82014-07-08 09:40:31 -0400123 mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, null);
124 mService.setIconVisibility(SLOT_TTY, false);
Wink Saville04e71b32009-04-02 11:00:54 -0700125
Wink Savillee9b06d72009-05-18 21:47:50 -0700126 // Cdma Roaming Indicator, ERI
John Spurlocka37e9c82014-07-08 09:40:31 -0400127 mService.setIcon(SLOT_CDMA_ERI, R.drawable.stat_sys_roaming_cdma_0, 0, null);
128 mService.setIconVisibility(SLOT_CDMA_ERI, false);
Wink Savillee9b06d72009-05-18 21:47:50 -0700129
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800130 // bluetooth status
Nick Pellyf242b7b2009-10-08 00:12:45 +0200131 BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -0400132 int bluetoothIcon = R.drawable.stat_sys_data_bluetooth;
Nick Pellybd022f42009-08-14 18:33:38 -0700133 if (adapter != null) {
Daniel Sandlere3b7a2d2011-10-27 16:16:15 -0400134 mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON);
135 if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
136 bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected;
137 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138 }
John Spurlocka37e9c82014-07-08 09:40:31 -0400139 mService.setIcon(SLOT_BLUETOOTH, bluetoothIcon, 0, null);
140 mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800142 // Alarm clock
John Spurlocka37e9c82014-07-08 09:40:31 -0400143 mService.setIcon(SLOT_ALARM_CLOCK, R.drawable.stat_sys_alarm, 0, null);
144 mService.setIconVisibility(SLOT_ALARM_CLOCK, false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145
146 // Sync state
John Spurlocka37e9c82014-07-08 09:40:31 -0400147 mService.setIcon(SLOT_SYNC_ACTIVE, R.drawable.stat_sys_sync, 0, null);
148 mService.setIconVisibility(SLOT_SYNC_ACTIVE, false);
John Spurlock3c875662013-08-31 15:07:25 -0400149 // "sync_failing" is obsolete: b/1297963
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150
John Spurlocka37e9c82014-07-08 09:40:31 -0400151 // zen
152 mService.setIcon(SLOT_ZEN, R.drawable.stat_sys_zen_important, 0, null);
153 mService.setIconVisibility(SLOT_ZEN, false);
154
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800155 // volume
John Spurlockad494bc2014-07-19 15:56:19 -0400156 mService.setIcon(SLOT_VOLUME, R.drawable.stat_sys_ringer_vibrate, 0, null);
John Spurlocka37e9c82014-07-08 09:40:31 -0400157 mService.setIconVisibility(SLOT_VOLUME, false);
158 updateVolumeZen();
John Spurlock96fe98d2014-08-27 09:36:02 -0400159
160 // cast
161 mService.setIcon(SLOT_CAST, R.drawable.stat_sys_cast, 0, null);
162 mService.setIconVisibility(SLOT_CAST, false);
163 mCast.addCallback(mCastCallback);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164 }
165
John Spurlockae641c92014-06-30 18:11:40 -0400166 public void setZenMode(int zen) {
John Spurlockba2c6a02014-05-19 09:44:06 -0400167 mZen = zen;
John Spurlocka37e9c82014-07-08 09:40:31 -0400168 updateVolumeZen();
John Spurlockba2c6a02014-05-19 09:44:06 -0400169 }
170
Adrian Roosc42a1e12014-07-07 23:35:53 +0200171 private void updateAlarm() {
172 AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
173 boolean alarmSet = alarmManager.getNextAlarmClock(UserHandle.USER_CURRENT) != null;
John Spurlocka37e9c82014-07-08 09:40:31 -0400174 mService.setIconVisibility(SLOT_ALARM_CLOCK, alarmSet);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 }
176
177 private final void updateSyncState(Intent intent) {
Daniel Sandlerb1e8dab2011-09-26 20:06:19 -0400178 if (!SHOW_SYNC_ICON) return;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 boolean isActive = intent.getBooleanExtra("active", false);
John Spurlocka37e9c82014-07-08 09:40:31 -0400180 mService.setIconVisibility(SLOT_SYNC_ACTIVE, isActive);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800181 }
182
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800183 private final void updateSimState(Intent intent) {
Wink Savillea639b312012-07-10 12:37:54 -0700184 String stateExtra = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
185 if (IccCardConstants.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
186 mSimState = IccCardConstants.State.ABSENT;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 }
Rakesh Pallerlaf099a5f2013-02-06 11:44:23 +0530188 else if (IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR.equals(stateExtra)) {
189 mSimState = IccCardConstants.State.CARD_IO_ERROR;
190 }
Wink Savillea639b312012-07-10 12:37:54 -0700191 else if (IccCardConstants.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
192 mSimState = IccCardConstants.State.READY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 }
Wink Savillea639b312012-07-10 12:37:54 -0700194 else if (IccCardConstants.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
195 final String lockedReason =
196 intent.getStringExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON);
197 if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
198 mSimState = IccCardConstants.State.PIN_REQUIRED;
johnwang347c5a22009-08-24 22:11:11 -0700199 }
Wink Savillea639b312012-07-10 12:37:54 -0700200 else if (IccCardConstants.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
201 mSimState = IccCardConstants.State.PUK_REQUIRED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 }
203 else {
Wink Savillea639b312012-07-10 12:37:54 -0700204 mSimState = IccCardConstants.State.NETWORK_LOCKED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 }
206 } else {
Wink Savillea639b312012-07-10 12:37:54 -0700207 mSimState = IccCardConstants.State.UNKNOWN;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800208 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800209 }
210
John Spurlocka37e9c82014-07-08 09:40:31 -0400211 private final void updateVolumeZen() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212 AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
John Spurlocka37e9c82014-07-08 09:40:31 -0400213
214 boolean zenVisible = false;
215 int zenIconId = 0;
216 String zenDescription = null;
217
218 boolean volumeVisible = false;
219 int volumeIconId = 0;
220 String volumeDescription = null;
221
222 if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) {
223 zenVisible = true;
224 zenIconId = R.drawable.stat_sys_zen_none;
225 zenDescription = mContext.getString(R.string.zen_no_interruptions);
John Spurlockae641c92014-06-30 18:11:40 -0400226 } else if (mZen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
John Spurlocka37e9c82014-07-08 09:40:31 -0400227 zenVisible = true;
228 zenIconId = R.drawable.stat_sys_zen_important;
229 zenDescription = mContext.getString(R.string.zen_important_interruptions);
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700230 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231
John Spurlocka37e9c82014-07-08 09:40:31 -0400232 if (mZen != Global.ZEN_MODE_NO_INTERRUPTIONS &&
233 audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
234 volumeVisible = true;
235 volumeIconId = R.drawable.stat_sys_ringer_vibrate;
236 volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800237 }
John Spurlocka37e9c82014-07-08 09:40:31 -0400238
239 if (zenVisible) {
240 mService.setIcon(SLOT_ZEN, zenIconId, 0, zenDescription);
241 }
242 if (zenVisible != mZenVisible) {
243 mService.setIconVisibility(SLOT_ZEN, zenVisible);
244 mZenVisible = zenVisible;
245 }
246
247 if (volumeVisible) {
248 mService.setIcon(SLOT_VOLUME, volumeIconId, 0, volumeDescription);
249 }
250 if (volumeVisible != mVolumeVisible) {
251 mService.setIconVisibility(SLOT_VOLUME, volumeVisible);
252 mVolumeVisible = volumeVisible;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800253 }
254 }
255
256 private final void updateBluetooth(Intent intent) {
Joe Onorato798ac4c2010-05-27 16:39:00 -0400257 int iconId = R.drawable.stat_sys_data_bluetooth;
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700258 String contentDescription = null;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 String action = intent.getAction();
Nick Pellyde893f52009-09-08 13:15:33 -0700260 if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
Nick Pellyb24e11b2009-09-08 17:40:43 -0700261 int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
Nick Pellyde893f52009-09-08 13:15:33 -0700262 mBluetoothEnabled = state == BluetoothAdapter.STATE_ON;
Jaikumar Ganeshd9bb6882010-09-27 17:05:24 -0700263 } else if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
Jaikumar Ganesh0b63a6a2011-07-11 14:34:34 -0700264 int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
Jaikumar Ganeshd9bb6882010-09-27 17:05:24 -0700265 BluetoothAdapter.STATE_DISCONNECTED);
266 if (state == BluetoothAdapter.STATE_CONNECTED) {
267 iconId = R.drawable.stat_sys_data_bluetooth_connected;
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700268 contentDescription = mContext.getString(R.string.accessibility_bluetooth_connected);
269 } else {
270 contentDescription = mContext.getString(
271 R.string.accessibility_bluetooth_disconnected);
Jaikumar Ganesh084c6652009-12-07 10:58:18 -0800272 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 } else {
274 return;
275 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700276
John Spurlocka37e9c82014-07-08 09:40:31 -0400277 mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
278 mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800279 }
280
Wink Savillee9b06d72009-05-18 21:47:50 -0700281 private final void updateTTY(Intent intent) {
Evan Charlton10197192014-07-19 15:00:29 -0700282 int currentTtyMode = intent.getIntExtra(TelecommManager.EXTRA_CURRENT_TTY_MODE,
283 TelecommManager.TTY_MODE_OFF);
284 boolean enabled = currentTtyMode != TelecommManager.TTY_MODE_OFF;
Wink Saville04e71b32009-04-02 11:00:54 -0700285
John Spurlocka37e9c82014-07-08 09:40:31 -0400286 if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled);
Wink Saville04e71b32009-04-02 11:00:54 -0700287
288 if (enabled) {
289 // TTY is on
John Spurlocka37e9c82014-07-08 09:40:31 -0400290 if (DEBUG) Log.v(TAG, "updateTTY: set TTY on");
291 mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0,
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700292 mContext.getString(R.string.accessibility_tty_enabled));
John Spurlocka37e9c82014-07-08 09:40:31 -0400293 mService.setIconVisibility(SLOT_TTY, true);
Wink Saville04e71b32009-04-02 11:00:54 -0700294 } else {
295 // TTY is off
John Spurlocka37e9c82014-07-08 09:40:31 -0400296 if (DEBUG) Log.v(TAG, "updateTTY: set TTY off");
297 mService.setIconVisibility(SLOT_TTY, false);
Wink Saville04e71b32009-04-02 11:00:54 -0700298 }
299 }
John Spurlock96fe98d2014-08-27 09:36:02 -0400300
301 private void updateCast() {
302 boolean isCasting = false;
303 for (CastDevice device : mCast.getCastDevices()) {
304 if (device.state == CastDevice.STATE_CONNECTING
305 || device.state == CastDevice.STATE_CONNECTED) {
306 isCasting = true;
307 break;
308 }
309 }
310 if (DEBUG) Log.v(TAG, "updateCast: isCasting: " + isCasting);
311 if (isCasting) {
312 mService.setIcon(SLOT_CAST, R.drawable.stat_sys_cast, 0,
313 mContext.getString(R.string.accessibility_casting));
314 }
315 mService.setIconVisibility(SLOT_CAST, isCasting);
316 }
317
318 private final CastController.Callback mCastCallback = new CastController.Callback() {
319 @Override
320 public void onCastDevicesChanged() {
321 updateCast();
322 }
323 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324}