blob: 64b3904428f1ae922bc504769ecd4def331f1ec4 [file] [log] [blame]
Anthony Chen54daefe2017-04-07 17:19:54 -07001/*
2 * Copyright (C) 2017 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
17package com.android.systemui.qs;
18
Charles Hece2a7c02017-10-11 20:25:20 +010019import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
20
Anthony Chen54daefe2017-04-07 17:19:54 -070021import android.content.Context;
22import android.content.Intent;
Amin Shaikh50c17892018-03-21 18:15:22 -040023import android.content.pm.UserInfo;
Amin Shaikh0e003312018-03-08 11:39:01 -050024import android.content.res.ColorStateList;
Anthony Chen54daefe2017-04-07 17:19:54 -070025import android.content.res.Configuration;
Anthony Chen54daefe2017-04-07 17:19:54 -070026import android.graphics.PorterDuff.Mode;
27import android.graphics.drawable.Drawable;
28import android.graphics.drawable.RippleDrawable;
Amin Shaikh8a3e23c2018-04-17 11:14:32 -040029import android.os.Bundle;
Anthony Chen54daefe2017-04-07 17:19:54 -070030import android.os.UserManager;
Aurimas Liutikasa14377a2018-04-17 09:50:46 -070031import androidx.annotation.Nullable;
32import androidx.annotation.VisibleForTesting;
Amin Shaikh0e003312018-03-08 11:39:01 -050033import android.text.TextUtils;
Anthony Chen54daefe2017-04-07 17:19:54 -070034import android.util.AttributeSet;
35import android.view.View;
36import android.view.View.OnClickListener;
Amin Shaikh8a3e23c2018-04-17 11:14:32 -040037import android.view.accessibility.AccessibilityNodeInfo;
Anthony Chen54daefe2017-04-07 17:19:54 -070038import android.widget.FrameLayout;
39import android.widget.ImageView;
Rohan Shah3090e792018-04-12 00:01:00 -040040import android.widget.LinearLayout;
Anthony Chen54daefe2017-04-07 17:19:54 -070041import android.widget.Toast;
42
43import com.android.internal.logging.MetricsLogger;
44import com.android.internal.logging.nano.MetricsProto;
Amin Shaikh0e003312018-03-08 11:39:01 -050045import com.android.keyguard.CarrierText;
Selim Cinek1a891a92017-12-04 17:41:27 +010046import com.android.keyguard.KeyguardUpdateMonitor;
Anthony Chen54daefe2017-04-07 17:19:54 -070047import com.android.settingslib.Utils;
Jason Monk826b6092017-08-29 11:30:52 -040048import com.android.settingslib.drawable.UserIconDrawable;
Amin Shaikh0e003312018-03-08 11:39:01 -050049import com.android.settingslib.graph.SignalDrawable;
Anthony Chen54daefe2017-04-07 17:19:54 -070050import com.android.systemui.Dependency;
Anthony Chen54daefe2017-04-07 17:19:54 -070051import com.android.systemui.R;
52import com.android.systemui.R.dimen;
Anthony Chen54daefe2017-04-07 17:19:54 -070053import com.android.systemui.plugins.ActivityStarter;
54import com.android.systemui.qs.TouchAnimator.Builder;
Anthony Chen54daefe2017-04-07 17:19:54 -070055import com.android.systemui.statusbar.phone.MultiUserSwitch;
56import com.android.systemui.statusbar.phone.SettingsButton;
57import com.android.systemui.statusbar.policy.DeviceProvisionedController;
58import com.android.systemui.statusbar.policy.NetworkController;
59import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
60import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
Anthony Chen54daefe2017-04-07 17:19:54 -070061import com.android.systemui.statusbar.policy.UserInfoController;
62import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
63import com.android.systemui.tuner.TunerService;
64
65public class QSFooterImpl extends FrameLayout implements QSFooter,
Amin Shaikhf09450b2018-04-06 17:32:45 -040066 OnClickListener, OnUserInfoChangedListener, EmergencyListener, SignalCallback {
Evan Lairdeb38aa72018-02-02 11:10:30 -050067
Anthony Chen54daefe2017-04-07 17:19:54 -070068 private ActivityStarter mActivityStarter;
Anthony Chen54daefe2017-04-07 17:19:54 -070069 private UserInfoController mUserInfoController;
70 private SettingsButton mSettingsButton;
71 protected View mSettingsContainer;
Rohan Shah3090e792018-04-12 00:01:00 -040072 private PageIndicator mPageIndicator;
Amin Shaikh0e003312018-03-08 11:39:01 -050073 private CarrierText mCarrierText;
Anthony Chen54daefe2017-04-07 17:19:54 -070074
Charles Hece2a7c02017-10-11 20:25:20 +010075 private boolean mQsDisabled;
Anthony Chen54daefe2017-04-07 17:19:54 -070076 private QSPanel mQsPanel;
77
78 private boolean mExpanded;
Anthony Chen54daefe2017-04-07 17:19:54 -070079
80 private boolean mListening;
Anthony Chen54daefe2017-04-07 17:19:54 -070081
82 private boolean mShowEmergencyCallsOnly;
Amin Shaikhacf322d2018-01-31 17:04:56 -050083 private View mDivider;
Anthony Chen54daefe2017-04-07 17:19:54 -070084 protected MultiUserSwitch mMultiUserSwitch;
85 private ImageView mMultiUserAvatar;
86
Evan Lairdeb38aa72018-02-02 11:10:30 -050087 protected TouchAnimator mFooterAnimator;
Anthony Chen54daefe2017-04-07 17:19:54 -070088 private float mExpansionAmount;
89
90 protected View mEdit;
Evan Lairdeb38aa72018-02-02 11:10:30 -050091 private TouchAnimator mSettingsCogAnimator;
Anthony Chen54daefe2017-04-07 17:19:54 -070092
Evan Laird00e43c42018-01-22 20:25:45 -050093 private View mActionsContainer;
Evan Lairdeb38aa72018-02-02 11:10:30 -050094 private View mDragHandle;
Amin Shaikh0e003312018-03-08 11:39:01 -050095 private View mMobileGroup;
96 private ImageView mMobileSignal;
97 private ImageView mMobileRoaming;
98 private final int mColorForeground;
99 private final CellSignalState mInfo = new CellSignalState();
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400100 private OnClickListener mExpandClickListener;
Evan Laird00e43c42018-01-22 20:25:45 -0500101
Anthony Chen54daefe2017-04-07 17:19:54 -0700102 public QSFooterImpl(Context context, AttributeSet attrs) {
103 super(context, attrs);
Amin Shaikh0e003312018-03-08 11:39:01 -0500104 mColorForeground = Utils.getColorAttr(context, android.R.attr.colorForeground);
Anthony Chen54daefe2017-04-07 17:19:54 -0700105 }
106
107 @Override
108 protected void onFinishInflate() {
109 super.onFinishInflate();
Amin Shaikhacf322d2018-01-31 17:04:56 -0500110 mDivider = findViewById(R.id.qs_footer_divider);
Anthony Chen54daefe2017-04-07 17:19:54 -0700111 mEdit = findViewById(android.R.id.edit);
112 mEdit.setOnClickListener(view ->
113 Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() ->
114 mQsPanel.showEdit(view)));
115
Rohan Shah3090e792018-04-12 00:01:00 -0400116 mPageIndicator = findViewById(R.id.footer_page_indicator);
117
Anthony Chen54daefe2017-04-07 17:19:54 -0700118 mSettingsButton = findViewById(R.id.settings_button);
119 mSettingsContainer = findViewById(R.id.settings_button_container);
120 mSettingsButton.setOnClickListener(this);
121
Amin Shaikh0e003312018-03-08 11:39:01 -0500122 mMobileGroup = findViewById(R.id.mobile_combo);
123 mMobileSignal = findViewById(R.id.mobile_signal);
124 mMobileRoaming = findViewById(R.id.mobile_roaming);
Evan Laird39254d42018-01-18 16:05:30 -0500125 mCarrierText = findViewById(R.id.qs_carrier_text);
Amin Shaikh0e003312018-03-08 11:39:01 -0500126 mCarrierText.setDisplayFlags(
127 CarrierText.FLAG_HIDE_AIRPLANE_MODE | CarrierText.FLAG_HIDE_MISSING_SIM);
Evan Laird39254d42018-01-18 16:05:30 -0500128
Anthony Chen54daefe2017-04-07 17:19:54 -0700129 mMultiUserSwitch = findViewById(R.id.multi_user_switch);
130 mMultiUserAvatar = mMultiUserSwitch.findViewById(R.id.multi_user_avatar);
131
Evan Lairdeb38aa72018-02-02 11:10:30 -0500132 mDragHandle = findViewById(R.id.qs_drag_handle_view);
Evan Laird00e43c42018-01-22 20:25:45 -0500133 mActionsContainer = findViewById(R.id.qs_footer_actions_container);
134
Anthony Chen54daefe2017-04-07 17:19:54 -0700135 // RenderThread is doing more harm than good when touching the header (to expand quick
136 // settings), so disable it for this view
137 ((RippleDrawable) mSettingsButton.getBackground()).setForceSoftware(true);
Anthony Chen54daefe2017-04-07 17:19:54 -0700138
139 updateResources();
140
Anthony Chen54daefe2017-04-07 17:19:54 -0700141 mUserInfoController = Dependency.get(UserInfoController.class);
142 mActivityStarter = Dependency.get(ActivityStarter.class);
143 addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight,
144 oldBottom) -> updateAnimator(right - left));
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400145 setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
Anthony Chen54daefe2017-04-07 17:19:54 -0700146 }
147
148 private void updateAnimator(int width) {
149 int numTiles = QuickQSPanel.getNumQuickTiles(mContext);
150 int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size)
151 - mContext.getResources().getDimensionPixelSize(dimen.qs_quick_tile_padding);
152 int remaining = (width - numTiles * size) / (numTiles - 1);
153 int defSpace = mContext.getResources().getDimensionPixelOffset(R.dimen.default_gear_space);
154
Evan Lairdeb38aa72018-02-02 11:10:30 -0500155 mSettingsCogAnimator = new Builder()
Jason Monk6dadd3e42017-09-01 09:36:19 -0400156 .addFloat(mSettingsContainer, "translationX",
157 isLayoutRtl() ? (remaining - defSpace) : -(remaining - defSpace), 0)
Anthony Chen54daefe2017-04-07 17:19:54 -0700158 .addFloat(mSettingsButton, "rotation", -120, 0)
159 .build();
Anthony Chen54daefe2017-04-07 17:19:54 -0700160
Anthony Chen54daefe2017-04-07 17:19:54 -0700161 setExpansion(mExpansionAmount);
162 }
163
164 @Override
165 protected void onConfigurationChanged(Configuration newConfig) {
166 super.onConfigurationChanged(newConfig);
167 updateResources();
168 }
169
170 @Override
171 public void onRtlPropertiesChanged(int layoutDirection) {
172 super.onRtlPropertiesChanged(layoutDirection);
173 updateResources();
174 }
175
176 private void updateResources() {
Evan Lairdeb38aa72018-02-02 11:10:30 -0500177 updateFooterAnimator();
Rohan Shah3090e792018-04-12 00:01:00 -0400178
179 // Update the width and weight of the actions container as the page indicator can sometimes
180 // show and the layout needs to center it between the carrier text and actions container.
181 LinearLayout.LayoutParams params =
182 (LinearLayout.LayoutParams) mActionsContainer.getLayoutParams();
183 params.width = mContext.getResources().getInteger(R.integer.qs_footer_actions_width);
184 params.weight = mContext.getResources().getInteger(R.integer.qs_footer_actions_weight);
185 mActionsContainer.setLayoutParams(params);
Anthony Chen54daefe2017-04-07 17:19:54 -0700186 }
187
Evan Lairdeb38aa72018-02-02 11:10:30 -0500188 private void updateFooterAnimator() {
189 mFooterAnimator = createFooterAnimator();
Anthony Chen54daefe2017-04-07 17:19:54 -0700190 }
191
192 @Nullable
Evan Lairdeb38aa72018-02-02 11:10:30 -0500193 private TouchAnimator createFooterAnimator() {
Anthony Chen54daefe2017-04-07 17:19:54 -0700194 return new TouchAnimator.Builder()
Amin Shaikhacf322d2018-01-31 17:04:56 -0500195 .addFloat(mDivider, "alpha", 0, 1)
Amin Shaikhd620def2018-02-27 16:52:53 -0500196 .addFloat(mCarrierText, "alpha", 0, 0, 1)
Amin Shaikh0e003312018-03-08 11:39:01 -0500197 .addFloat(mMobileGroup, "alpha", 0, 1)
Evan Laird00e43c42018-01-22 20:25:45 -0500198 .addFloat(mActionsContainer, "alpha", 0, 1)
Amin Shaikhd620def2018-02-27 16:52:53 -0500199 .addFloat(mDragHandle, "alpha", 1, 0, 0)
Rohan Shah3090e792018-04-12 00:01:00 -0400200 .addFloat(mPageIndicator, "alpha", 0, 1)
Amin Shaikh92fac562018-02-16 15:08:16 -0500201 .setStartDelay(0.15f)
Anthony Chen54daefe2017-04-07 17:19:54 -0700202 .build();
203 }
204
205 @Override
206 public void setKeyguardShowing(boolean keyguardShowing) {
Anthony Chen54daefe2017-04-07 17:19:54 -0700207 setExpansion(mExpansionAmount);
208 }
209
210 @Override
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400211 public void setExpandClickListener(OnClickListener onClickListener) {
212 mExpandClickListener = onClickListener;
213 }
214
215 @Override
Anthony Chen54daefe2017-04-07 17:19:54 -0700216 public void setExpanded(boolean expanded) {
217 if (mExpanded == expanded) return;
218 mExpanded = expanded;
219 updateEverything();
220 }
221
222 @Override
Anthony Chen54daefe2017-04-07 17:19:54 -0700223 public void setExpansion(float headerExpansionFraction) {
224 mExpansionAmount = headerExpansionFraction;
Evan Lairdeb38aa72018-02-02 11:10:30 -0500225 if (mSettingsCogAnimator != null) mSettingsCogAnimator.setPosition(headerExpansionFraction);
Anthony Chen54daefe2017-04-07 17:19:54 -0700226
Evan Lairdeb38aa72018-02-02 11:10:30 -0500227 if (mFooterAnimator != null) {
228 mFooterAnimator.setPosition(headerExpansionFraction);
Anthony Chen54daefe2017-04-07 17:19:54 -0700229 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700230 }
231
232 @Override
233 @VisibleForTesting
234 public void onDetachedFromWindow() {
235 setListening(false);
236 super.onDetachedFromWindow();
237 }
238
Anthony Chen54daefe2017-04-07 17:19:54 -0700239 @Override
240 public void setListening(boolean listening) {
241 if (listening == mListening) {
242 return;
243 }
244 mListening = listening;
245 updateListeners();
246 }
247
248 @Override
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400249 public boolean performAccessibilityAction(int action, Bundle arguments) {
250 if (action == AccessibilityNodeInfo.ACTION_EXPAND) {
251 if (mExpandClickListener != null) {
252 mExpandClickListener.onClick(null);
253 return true;
254 }
255 }
256 return super.performAccessibilityAction(action, arguments);
257 }
258
259 @Override
260 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
261 super.onInitializeAccessibilityNodeInfo(info);
262 info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
Anthony Chen54daefe2017-04-07 17:19:54 -0700263 }
264
Charles Hece2a7c02017-10-11 20:25:20 +0100265 @Override
266 public void disable(int state1, int state2, boolean animate) {
267 final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
268 if (disabled == mQsDisabled) return;
269 mQsDisabled = disabled;
270 updateEverything();
271 }
272
Anthony Chen54daefe2017-04-07 17:19:54 -0700273 public void updateEverything() {
274 post(() -> {
275 updateVisibilities();
276 setClickable(false);
277 });
278 }
279
280 private void updateVisibilities() {
Charles Hece2a7c02017-10-11 20:25:20 +0100281 mSettingsContainer.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
Anthony Chen54daefe2017-04-07 17:19:54 -0700282 mSettingsContainer.findViewById(R.id.tuner_icon).setVisibility(
283 TunerService.isTunerEnabled(mContext) ? View.VISIBLE : View.INVISIBLE);
284 final boolean isDemo = UserManager.isDeviceInDemoMode(mContext);
Amin Shaikh50c17892018-03-21 18:15:22 -0400285 mMultiUserSwitch.setVisibility(showUserSwitcher(isDemo) ? View.VISIBLE : View.INVISIBLE);
Anthony Chen54daefe2017-04-07 17:19:54 -0700286 mEdit.setVisibility(isDemo || !mExpanded ? View.INVISIBLE : View.VISIBLE);
Amin Shaikha59215a2018-04-23 08:52:38 -0400287 mSettingsButton.setVisibility(isDemo || !mExpanded ? View.INVISIBLE : View.VISIBLE);
Anthony Chen54daefe2017-04-07 17:19:54 -0700288 }
289
Amin Shaikh50c17892018-03-21 18:15:22 -0400290 private boolean showUserSwitcher(boolean isDemo) {
291 if (!mExpanded || isDemo || !UserManager.supportsMultipleUsers()) {
292 return false;
293 }
294 UserManager userManager = UserManager.get(mContext);
295 if (userManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)) {
296 return false;
297 }
298 int switchableUserCount = 0;
299 for (UserInfo user : userManager.getUsers(true)) {
300 if (user.supportsSwitchToByUser()) {
301 ++switchableUserCount;
302 if (switchableUserCount > 1) {
303 return true;
304 }
305 }
306 }
307 return getResources().getBoolean(R.bool.qs_show_user_switcher_for_single_user);
308 }
309
Anthony Chen54daefe2017-04-07 17:19:54 -0700310 private void updateListeners() {
311 if (mListening) {
Anthony Chen54daefe2017-04-07 17:19:54 -0700312 mUserInfoController.addCallback(this);
313 if (Dependency.get(NetworkController.class).hasVoiceCallingFeature()) {
314 Dependency.get(NetworkController.class).addEmergencyListener(this);
315 Dependency.get(NetworkController.class).addCallback(this);
316 }
317 } else {
Anthony Chen54daefe2017-04-07 17:19:54 -0700318 mUserInfoController.removeCallback(this);
319 Dependency.get(NetworkController.class).removeEmergencyListener(this);
320 Dependency.get(NetworkController.class).removeCallback(this);
321 }
322 }
323
324 @Override
325 public void setQSPanel(final QSPanel qsPanel) {
326 mQsPanel = qsPanel;
327 if (mQsPanel != null) {
328 mMultiUserSwitch.setQsPanel(qsPanel);
Rohan Shah3090e792018-04-12 00:01:00 -0400329 mQsPanel.setFooterPageIndicator(mPageIndicator);
Anthony Chen54daefe2017-04-07 17:19:54 -0700330 }
331 }
332
333 @Override
334 public void onClick(View v) {
Evan Laird00e43c42018-01-22 20:25:45 -0500335 // Don't do anything until view are unhidden
336 if (!mExpanded) {
337 return;
338 }
339
Anthony Chen54daefe2017-04-07 17:19:54 -0700340 if (v == mSettingsButton) {
341 if (!Dependency.get(DeviceProvisionedController.class).isCurrentUserSetup()) {
342 // If user isn't setup just unlock the device and dump them back at SUW.
343 mActivityStarter.postQSRunnableDismissingKeyguard(() -> { });
344 return;
345 }
346 MetricsLogger.action(mContext,
347 mExpanded ? MetricsProto.MetricsEvent.ACTION_QS_EXPANDED_SETTINGS_LAUNCH
348 : MetricsProto.MetricsEvent.ACTION_QS_COLLAPSED_SETTINGS_LAUNCH);
349 if (mSettingsButton.isTunerClick()) {
350 Dependency.get(ActivityStarter.class).postQSRunnableDismissingKeyguard(() -> {
351 if (TunerService.isTunerEnabled(mContext)) {
352 TunerService.showResetRequest(mContext, () -> {
353 // Relaunch settings so that the tuner disappears.
354 startSettingsActivity();
355 });
356 } else {
357 Toast.makeText(getContext(), R.string.tuner_toast,
358 Toast.LENGTH_LONG).show();
359 TunerService.setTunerEnabled(mContext, true);
360 }
361 startSettingsActivity();
362
363 });
364 } else {
365 startSettingsActivity();
366 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700367 }
368 }
369
370 private void startSettingsActivity() {
371 mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS),
372 true /* dismissShade */);
373 }
374
375 @Override
376 public void setEmergencyCallsOnly(boolean show) {
377 boolean changed = show != mShowEmergencyCallsOnly;
378 if (changed) {
379 mShowEmergencyCallsOnly = show;
380 if (mExpanded) {
381 updateEverything();
382 }
383 }
384 }
385
386 @Override
387 public void onUserInfoChanged(String name, Drawable picture, String userAccount) {
388 if (picture != null &&
Selim Cinek1a891a92017-12-04 17:41:27 +0100389 UserManager.get(mContext).isGuestUser(KeyguardUpdateMonitor.getCurrentUser()) &&
Jason Monk826b6092017-08-29 11:30:52 -0400390 !(picture instanceof UserIconDrawable)) {
391 picture = picture.getConstantState().newDrawable(mContext.getResources()).mutate();
Anthony Chen54daefe2017-04-07 17:19:54 -0700392 picture.setColorFilter(
393 Utils.getColorAttr(mContext, android.R.attr.colorForeground),
394 Mode.SRC_IN);
395 }
396 mMultiUserAvatar.setImageDrawable(picture);
397 }
Amin Shaikh0e003312018-03-08 11:39:01 -0500398
399 private void handleUpdateState() {
400 mMobileGroup.setVisibility(mInfo.visible ? View.VISIBLE : View.GONE);
401 if (mInfo.visible) {
402 mMobileRoaming.setVisibility(mInfo.roaming ? View.VISIBLE : View.GONE);
403 mMobileRoaming.setImageTintList(ColorStateList.valueOf(mColorForeground));
404 SignalDrawable d = new SignalDrawable(mContext);
405 d.setDarkIntensity(QuickStatusBarHeader.getColorIntensity(mColorForeground));
406 mMobileSignal.setImageDrawable(d);
407 mMobileSignal.setImageLevel(mInfo.mobileSignalIconId);
408
409 StringBuilder contentDescription = new StringBuilder();
410 if (mInfo.contentDescription != null) {
411 contentDescription.append(mInfo.contentDescription).append(", ");
412 }
413 if (mInfo.roaming) {
414 contentDescription
415 .append(mContext.getString(R.string.data_connection_roaming))
416 .append(", ");
417 }
418 // TODO: show mobile data off/no internet text for 5 seconds before carrier text
419 if (TextUtils.equals(mInfo.typeContentDescription,
420 mContext.getString(R.string.data_connection_no_internet))
421 || TextUtils.equals(mInfo.typeContentDescription,
Rohan Shah7bc37442018-04-10 00:34:50 -0400422 mContext.getString(R.string.cell_data_off_content_description))) {
Amin Shaikh0e003312018-03-08 11:39:01 -0500423 contentDescription.append(mInfo.typeContentDescription);
424 }
425 mMobileSignal.setContentDescription(contentDescription);
426 }
427 }
428
429 @Override
430 public void setMobileDataIndicators(NetworkController.IconState statusIcon,
431 NetworkController.IconState qsIcon, int statusType,
432 int qsType, boolean activityIn, boolean activityOut,
433 String typeContentDescription,
434 String description, boolean isWide, int subId, boolean roaming) {
435 mInfo.visible = statusIcon.visible;
436 mInfo.mobileSignalIconId = statusIcon.icon;
437 mInfo.contentDescription = statusIcon.contentDescription;
438 mInfo.typeContentDescription = typeContentDescription;
439 mInfo.roaming = roaming;
440 handleUpdateState();
441 }
442
443 @Override
444 public void setNoSims(boolean hasNoSims, boolean simDetected) {
445 if (hasNoSims) {
446 mInfo.visible = false;
447 }
448 handleUpdateState();
449 }
450
451 private final class CellSignalState {
452 boolean visible;
453 int mobileSignalIconId;
454 public String contentDescription;
455 String typeContentDescription;
456 boolean roaming;
457 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700458}