-
Notifications
You must be signed in to change notification settings - Fork 2
/
.merge_file_a03560
3689 lines (3199 loc) · 147 KB
/
.merge_file_a03560
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
* Not a Contribution.
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.phone;
import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.app.StatusBarManager.windowStateToString;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.ThemeConfig;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
import android.os.Bundle;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.IPowerManager;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.telephony.MSimTelephonyManager;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
import android.util.Pair;
import android.view.Display;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewPropertyAnimator;
import android.view.ViewStub;
import android.view.WindowManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.BatteryMeterView.BatteryMeterMode;
import com.android.systemui.DemoMode;
import com.android.systemui.DockBatteryMeterView;
import com.android.systemui.EventLogTags;
import com.android.systemui.R;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.MSimSignalClusterView;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.SignalClusterTextView;
import com.android.systemui.statusbar.SignalClusterView;
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.DateView;
import com.android.systemui.statusbar.policy.DockBatteryController;
import com.android.systemui.statusbar.policy.HeadsUpNotificationView;
import com.android.systemui.statusbar.policy.LocationController;
import com.android.systemui.statusbar.policy.MSimNetworkController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NotificationRowLayout;
import com.android.systemui.statusbar.policy.OnSizeChangedListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
NetworkController.UpdateUIListener {
static final String TAG = "PhoneStatusBar";
public static final boolean DEBUG = BaseStatusBar.DEBUG;
public static final boolean SPEW = false;
public static final boolean DUMPTRUCK = true; // extra dumpsys info
public static final boolean DEBUG_GESTURES = false;
public static final boolean DEBUG_WINDOW_STATE = false;
public static final boolean SETTINGS_DRAG_SHORTCUT = true;
// additional instrumentation for testing purposes; intended to be left on during development
public static final boolean CHATTY = DEBUG;
public static final String ACTION_STATUSBAR_START
= "com.android.internal.policy.statusbar.START";
public static final String CUSTOM_LOCKSCREEN_STATE
= "com.android.keyguard.custom.STATE";
private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000;
private static final int MSG_CLOSE_PANELS = 1001;
private static final int MSG_OPEN_SETTINGS_PANEL = 1002;
// 1020-1030 reserved for BaseStatusBar
private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true;
// will likely move to a resource or other tunable param at some point
private static final int INTRUDER_ALERT_DECAY_MS = 0; // disabled, was 10000;
private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; // see NotificationManagerService
private static final int HIDE_ICONS_BELOW_SCORE = Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER;
private static final int STATUS_OR_NAV_TRANSIENT =
View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT;
private static final long AUTOHIDE_TIMEOUT_MS = 3000;
private static final float BRIGHTNESS_CONTROL_PADDING = 0.15f;
private static final int BRIGHTNESS_CONTROL_LONG_PRESS_TIMEOUT = 750; // ms
private static final int BRIGHTNESS_CONTROL_LINGER_THRESHOLD = 20;
// fling gesture tuning parameters, scaled to display density
private float mSelfExpandVelocityPx; // classic value: 2000px/s
private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up")
private float mFlingExpandMinVelocityPx; // classic value: 200px/s
private float mFlingCollapseMinVelocityPx; // classic value: 200px/s
private float mCollapseMinDisplayFraction; // classic value: 0.08 (25px/min(320px,480px) on G1)
private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand)
private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s
private float mExpandAccelPx; // classic value: 2000px/s/s
private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up")
private float mFlingGestureMaxOutputVelocityPx; // how fast can it really go? (should be a little
// faster than mSelfCollapseVelocityPx)
PhoneStatusBarPolicy mIconPolicy;
// These are no longer handled by the policy, because we need custom strategies for them
BluetoothController mBluetoothController;
BatteryController mBatteryController;
DockBatteryController mDockBatteryController;
LocationController mLocationController;
NetworkController mNetworkController;
MSimNetworkController mMSimNetworkController;
int mNaturalBarHeight = -1;
int mIconSize = -1;
int mIconHPadding = -1;
Display mDisplay;
Point mCurrentDisplaySize = new Point();
private float mHeadsUpVerticalOffset;
private int[] mPilePosition = new int[2];
StatusBarWindowView mStatusBarWindow;
PhoneStatusBarView mStatusBarView;
private int mStatusBarWindowState = WINDOW_STATE_SHOWING;
int mPixelFormat;
Object mQueueLock = new Object();
// viewgroup containing the normal contents of the statusbar
LinearLayout mStatusBarContents;
// right-hand icons
LinearLayout mSystemIconArea;
// left-hand icons
LinearLayout mStatusIcons;
// the icons themselves
IconMerger mNotificationIcons;
// [+>
View mMoreIcon;
// expanded notifications
NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
ScrollView mScrollView;
View mExpandedContents;
int mNotificationPanelGravity;
int mNotificationPanelMarginBottomPx, mNotificationPanelMarginPx;
float mNotificationPanelMinHeightFrac;
boolean mNotificationPanelIsFullScreenWidth;
TextView mNotificationPanelDebugText;
// settings
QuickSettingsController mQS;
boolean mHasSettingsPanel, mHasFlipSettings;
SettingsPanelView mSettingsPanel;
View mFlipSettingsView;
QuickSettingsContainerView mSettingsContainer;
int mSettingsPanelGravity;
private TilesChangedObserver mTilesChangedObserver;
private SettingsObserver mSettingsObserver;
private DevForceNavbarObserver mDevForceNavbarObserver;
// Ribbon settings
private boolean mHasQuickAccessSettings;
private boolean mQuickAccessLayoutLinked = true;
private QuickSettingsHorizontalScrollView mRibbonView;
private QuickSettingsController mRibbonQS;
// top bar
View mNotificationPanelHeader;
View mDateTimeView;
View mClearButton;
ImageView mAddTileButton;
ImageView mSettingsButton, mNotificationButton;
// carrier/wifi label
private TextView mCarrierLabel;
private TextView mSubsLabel;
private boolean mCarrierLabelVisible = false;
private int mCarrierLabelHeight;
private TextView mEmergencyCallLabel;
private int mNotificationHeaderHeight;
private boolean mShowCarrierInPanel = false;
private SignalClusterView mSignalClusterView;
private MSimSignalClusterView mMSimSignalClusterView;
private SignalClusterTextView mSignalTextView;
private BatteryMeterView mBatteryView;
private DockBatteryMeterView mDockBatteryView;
// clock
private boolean mShowClock = true;
private boolean mClockEnabled;
// position
int[] mPositionTmp = new int[2];
boolean mExpandedVisible;
// the date view
DateView mDateView;
// for heads up notifications
private HeadsUpNotificationView mHeadsUpNotificationView;
private int mHeadsUpNotificationDecay;
// on-screen navigation buttons
private NavigationBarView mNavigationBarView = null;
private int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
// the tracker view
int mTrackingPosition; // the position of the top of the tracking view.
// ticker
private Ticker mTicker;
private View mTickerView;
private boolean mTicking;
// Tracking finger for opening/closing.
int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore
boolean mTracking;
VelocityTracker mVelocityTracker;
int[] mAbsPos = new int[2];
// last theme that was applied in order to detect theme change (as opposed
// to some other configuration change).
ThemeConfig mCurrentTheme;
private boolean mRecreating = false;
private boolean mBrightnessControl;
private boolean mAnimatingFlip = false;
private float mScreenWidth;
private int mMinBrightness;
private int mPeekHeight;
private boolean mJustPeeked;
int mLinger;
int mInitialTouchX;
int mInitialTouchY;
// for disabling the status bar
int mDisabled = 0;
// tracking calls to View.setSystemUiVisibility()
int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
DisplayMetrics mDisplayMetrics = new DisplayMetrics();
boolean mTransparentNav = false;
// XXX: gesture research
private final GestureRecorder mGestureRec = DEBUG_GESTURES
? new GestureRecorder("/sdcard/statusbar_gestures.dat")
: null;
private int mNavigationIconHints = 0;
private final Animator.AnimatorListener mMakeIconsInvisible = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// double-check to avoid races
if (mStatusBarContents.getAlpha() == 0) {
if (DEBUG) Log.d(TAG, "makeIconsInvisible");
mStatusBarContents.setVisibility(View.INVISIBLE);
}
}
};
private final Runnable mLongPressBrightnessChange = new Runnable() {
@Override
public void run() {
mStatusBarView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
adjustBrightness(mInitialTouchX);
mLinger = BRIGHTNESS_CONTROL_LINGER_THRESHOLD + 1;
}
};
private final Runnable mNotifyClearAll = new Runnable() {
@Override
public void run() {
if (DEBUG) {
Log.v(TAG, "Notifying status bar of notification clear");
}
try {
mPile.setViewRemoval(true);
mBarService.onClearAllNotifications();
} catch (RemoteException ex) { }
}
};
private int mInitialHeadsUpDecay;
class SettingsObserver extends ContentObserver {
SettingsObserver(Handler handler) {
super(handler);
}
void observe() {
ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.SCREEN_BRIGHTNESS_MODE), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_BATTERY), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_BATTERY_SHOW_PERCENT), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_CLOCK), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.STATUS_BAR_SIGNAL_TEXT), false, this);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.NAVBAR_LEFT_IN_LANDSCAPE), false, this);
updateSettings();
}
@Override
public void onChange(boolean selfChange) {
updateSettings();
}
}
class DevForceNavbarObserver extends ContentObserver {
DevForceNavbarObserver(Handler handler) {
super(handler);
}
void observe() {
ContentResolver resolver = mContext.getContentResolver();
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.DEV_FORCE_SHOW_NAVBAR), false, this);
}
@Override
public void onChange(boolean selfChange) {
boolean visible = Settings.System.getIntForUser(mContext.getContentResolver(),
Settings.System.DEV_FORCE_SHOW_NAVBAR, 0, UserHandle.USER_CURRENT) == 1;
if (visible) {
forceAddNavigationBar();
} else {
removeNavigationBar();
}
}
}
private void forceAddNavigationBar() {
// If we have no Navbar view and we should have one, create it
if (mNavigationBarView != null) {
return;
}
mNavigationBarView =
(NavigationBarView) View.inflate(mContext, R.layout.navigation_bar, null);
mNavigationBarView.setDisabledFlags(mDisabled);
mNavigationBarView.setBar(this);
mNavigationBarView.updateResources(getNavbarThemedResources());
addNavigationBar();
}
// ensure quick settings is disabled until the current user makes it through the setup wizard
private boolean mUserSetup = false;
private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
final boolean userSetup = 0 != Settings.Secure.getIntForUser(
mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE,
0 /*default */,
mCurrentUserId);
if (MULTIUSER_DEBUG) Log.d(TAG, String.format("User setup changed: " +
"selfChange=%s userSetup=%s mUserSetup=%s",
selfChange, userSetup, mUserSetup));
if (mSettingsButton != null && mHasFlipSettings) {
mSettingsButton.setVisibility(userSetup ? View.VISIBLE : View.INVISIBLE);
}
if (mSettingsPanel != null) {
mSettingsPanel.setEnabled(userSetup);
}
if (userSetup != mUserSetup) {
mUserSetup = userSetup;
if (!mUserSetup && mStatusBarView != null)
animateCollapseQuickSettings();
}
}
};
final private ContentObserver mHeadsUpObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
boolean wasUsing = mUseHeadsUp;
mUseHeadsUp = ENABLE_HEADS_UP && Settings.System.getIntForUser(
mContext.getContentResolver(),
Settings.System.HEADS_UP_NOTIFICATION, 0, UserHandle.USER_CURRENT) == 1;
Log.d(TAG, "heads up is " + (mUseHeadsUp ? "enabled" : "disabled"));
if (wasUsing != mUseHeadsUp) {
if (!mUseHeadsUp) {
Log.d(TAG, "dismissing any existing heads up notification on disable event");
mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
removeHeadsUpView();
} else {
addHeadsUpView();
}
}
}
};
private int mInteractingWindows;
private boolean mAutohideSuspended;
private int mStatusBarMode;
private int mNavigationBarMode;
private Boolean mScreenOn;
private final Runnable mAutohide = new Runnable() {
@Override
public void run() {
doAutoHide();
}};
private final Runnable mUserAutohide = new Runnable() {
@Override
public void run() {
doAutoHide();
}};
private void doAutoHide() {
int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT;
if (mSystemUiVisibility != requested) {
notifyUiVisibilityChanged(requested);
}
}
@Override
public void start() {
mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
updateDisplaySize();
ThemeConfig currentTheme = mContext.getResources().getConfiguration().themeConfig;
if (currentTheme != null) {
mCurrentTheme = (ThemeConfig)currentTheme.clone();
}
mLocationController = new LocationController(mContext);
mBatteryController = new BatteryController(mContext);
mDockBatteryController = new DockBatteryController(mContext);
mBluetoothController = new BluetoothController(mContext);
super.start(); // calls createAndAddWindows()
addNavigationBar();
SettingsObserver observer = new SettingsObserver(mHandler);
observer.observe();
// Developer options - Force Navigation bar
try {
boolean needsNav = mWindowManagerService.needsNavigationBar();
if (!needsNav) {
mDevForceNavbarObserver = new DevForceNavbarObserver(mHandler);
mDevForceNavbarObserver.observe();
}
} catch (RemoteException ex) {
// no window manager? good luck with that
}
// Lastly, call to the icon policy to install/update all the icons.
mIconPolicy = new PhoneStatusBarPolicy(mContext);
mHeadsUpObserver.onChange(true); // set up
if (ENABLE_HEADS_UP) {
mContext.getContentResolver().registerContentObserver(
Settings.System.getUriFor(Settings.System.HEADS_UP_NOTIFICATION), true,
mHeadsUpObserver, mCurrentUserId);
}
}
private void cleanupRibbon() {
if (mRibbonView == null) {
return;
}
mRibbonView.setVisibility(View.GONE);
mRibbonQS.shutdown();
mRibbonQS = null;
}
private void inflateRibbon() {
if (mRibbonView == null) {
ViewStub ribbon_stub = (ViewStub) mStatusBarWindow.findViewById(R.id.ribbon_settings_stub);
if (ribbon_stub != null) {
mRibbonView = (QuickSettingsHorizontalScrollView) ((ViewStub)ribbon_stub).inflate();
mRibbonView.setVisibility(View.VISIBLE);
}
}
if (mRibbonQS == null) {
QuickSettingsContainerView mRibbonContainer = (QuickSettingsContainerView)
mStatusBarWindow.findViewById(R.id.quick_settings_ribbon_container);
if (mRibbonContainer != null) {
String settingsKey = mQuickAccessLayoutLinked
? Settings.System.QUICK_SETTINGS_TILES
: Settings.System.QUICK_SETTINGS_RIBBON_TILES;
mRibbonQS = new QuickSettingsController(mContext, mRibbonContainer, this,
settingsKey, true);
mRibbonQS.setService(this);
mRibbonQS.setBar(mStatusBarView);
mRibbonQS.setupQuickSettings();
}
}
}
// ================================================================================
// Constructing the view
// ================================================================================
protected PhoneStatusBarView makeStatusBarView() {
final Context context = mContext;
Resources res = context.getResources();
mScreenWidth = (float) context.getResources().getDisplayMetrics().widthPixels;
mMinBrightness = context.getResources().getInteger(
com.android.internal.R.integer.config_screenBrightnessDim);
mInitialHeadsUpDecay = mContext.getResources().getInteger(R.integer.heads_up_sensitivity_delay);
updateDisplaySize(); // populates mDisplayMetrics
loadDimens();
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
R.layout.msim_super_status_bar, null);
} else {
mStatusBarWindow = (StatusBarWindowView) View.inflate(context,
R.layout.super_status_bar, null);
}
mStatusBarWindow.mService = this;
mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
checkUserAutohide(v, event);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (mExpandedVisible) {
animateCollapsePanels();
}
}
return mStatusBarWindow.onTouchEvent(event);
}});
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(
R.id.msim_status_bar);
} else {
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
}
mStatusBarView.setBar(this);
PanelHolder holder;
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.msim_panel_holder);
} else {
holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder);
}
mStatusBarView.setPanelHolder(holder);
mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById(R.id.notification_panel);
mNotificationPanel.setStatusBar(this);
mNotificationPanelIsFullScreenWidth =
(mNotificationPanel.getLayoutParams().width == ViewGroup.LayoutParams.MATCH_PARENT);
// make the header non-responsive to clicks
mNotificationPanel.findViewById(R.id.header).setOnTouchListener(
new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true; // e eats everything
}
});
if (!ActivityManager.isHighEndGfx()) {
mStatusBarWindow.setBackground(null);
mNotificationPanel.setBackground(new FastColorDrawable(context.getResources().getColor(
R.color.notification_panel_solid_background)));
}
if (ENABLE_HEADS_UP) {
mHeadsUpNotificationView =
(HeadsUpNotificationView) View.inflate(context, R.layout.heads_up, null);
mHeadsUpNotificationView.setVisibility(View.GONE);
mHeadsUpNotificationView.setBar(this);
}
if (MULTIUSER_DEBUG) {
mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(R.id.header_debug_info);
mNotificationPanelDebugText.setVisibility(View.VISIBLE);
}
updateShowSearchHoldoff();
try {
boolean showNav = mWindowManagerService.hasNavigationBar();
if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
if (showNav && !mRecreating) {
mNavigationBarView =
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
mNavigationBarView.updateResources(getNavbarThemedResources());
mNavigationBarView.setDisabledFlags(mDisabled);
mNavigationBarView.setBar(this);
mNavigationBarView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
checkUserAutohide(v, event);
return false;
}});
}
} catch (RemoteException ex) {
// no window manager? good luck with that
}
// figure out which pixel-format to use for the status bar.
mPixelFormat = PixelFormat.OPAQUE;
mSystemIconArea = (LinearLayout) mStatusBarView.findViewById(R.id.system_icon_area);
mStatusIcons = (LinearLayout)mStatusBarView.findViewById(R.id.statusIcons);
mNotificationIcons = (IconMerger)mStatusBarView.findViewById(R.id.notificationIcons);
mMoreIcon = mStatusBarView.findViewById(R.id.moreIcon);
mNotificationIcons.setOverflowIndicator(mMoreIcon);
mStatusBarContents = (LinearLayout)mStatusBarView.findViewById(R.id.status_bar_contents);
mTickerView = mStatusBarView.findViewById(R.id.ticker);
mPile = (NotificationRowLayout)mStatusBarWindow.findViewById(R.id.latestItems);
mPile.setLayoutTransitionsEnabled(false);
mPile.setLongPressListener(getNotificationLongClicker());
mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout);
mNotificationPanelHeader = mStatusBarWindow.findViewById(R.id.header);
mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button);
mClearButton.setOnClickListener(mClearButtonListener);
mClearButton.setAlpha(0f);
mClearButton.setVisibility(View.INVISIBLE);
mClearButton.setEnabled(false);
mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date);
mHasSettingsPanel = res.getBoolean(R.bool.config_hasSettingsPanel);
mHasFlipSettings = res.getBoolean(R.bool.config_hasFlipSettingsPanel);
mDateTimeView = mNotificationPanelHeader.findViewById(R.id.datetime);
mSettingsButton = (ImageView) mStatusBarWindow.findViewById(R.id.settings_button);
if (mSettingsButton != null) {
mSettingsButton.setOnClickListener(mSettingsButtonListener);
if (mHasSettingsPanel) {
if (mStatusBarView.hasFullWidthNotifications()) {
// the settings panel is hiding behind this button
mSettingsButton.setImageResource(R.drawable.ic_notify_quicksettings);
mSettingsButton.setVisibility(View.VISIBLE);
} else {
// there is a settings panel, but it's on the other side of the (large) screen
final View buttonHolder = mStatusBarWindow.findViewById(
R.id.settings_button_holder);
if (buttonHolder != null) {
buttonHolder.setVisibility(View.GONE);
}
}
} else {
// no settings panel, go straight to settings
mSettingsButton.setVisibility(View.VISIBLE);
mSettingsButton.setImageResource(R.drawable.ic_notify_settings);
}
}
if (mHasFlipSettings) {
mNotificationButton = (ImageView) mStatusBarWindow.findViewById(R.id.notification_button);
mAddTileButton = (ImageView) mStatusBarWindow.findViewById(R.id.add_tile_button);
if (mNotificationButton != null) {
mNotificationButton.setOnClickListener(mNotificationButtonListener);
}
if (mAddTileButton != null) {
mAddTileButton.setOnClickListener(mAddTileButtonListener);
}
}
mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll);
mScrollView.setVerticalScrollBarEnabled(false); // less drawing during pulldowns
if (!mNotificationPanelIsFullScreenWidth) {
mScrollView.setSystemUiVisibility(
View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER |
View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS |
View.STATUS_BAR_DISABLE_CLOCK);
}
mTicker = new MyTicker(context, mStatusBarView);
TickerView tickerView = (TickerView)mStatusBarView.findViewById(R.id.tickerText);
tickerView.mTicker = mTicker;
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
// set the inital view visibility
setAreThereNotifications();
// Other icons
mBatteryView = (BatteryMeterView) mStatusBarView.findViewById(R.id.battery);
mDockBatteryView = (DockBatteryMeterView) mStatusBarView.findViewById(R.id.dock_battery);
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
mMSimNetworkController = new MSimNetworkController(mContext);
mMSimSignalClusterView = (MSimSignalClusterView)
mStatusBarView.findViewById(R.id.msim_signal_cluster);
for (int i=0; i < MSimTelephonyManager.getDefault().getPhoneCount(); i++) {
mMSimNetworkController.addSignalCluster(mMSimSignalClusterView, i);
}
mMSimSignalClusterView.setNetworkController(mMSimNetworkController);
mEmergencyCallLabel = (TextView)mStatusBarWindow.findViewById(
R.id.emergency_calls_only);
if (mEmergencyCallLabel != null) {
mMSimNetworkController.addEmergencyLabelView(mEmergencyCallLabel);
mEmergencyCallLabel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { }});
mEmergencyCallLabel.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
updateCarrierLabelVisibility(false);
}});
}
mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
mSubsLabel = (TextView)mStatusBarWindow.findViewById(R.id.subs_label);
mShowCarrierInPanel = (mCarrierLabel != null);
if (DEBUG) Log.v(TAG, "carrierlabel=" + mCarrierLabel + " show=" +
mShowCarrierInPanel + "operator label=" + mSubsLabel);
if (mShowCarrierInPanel) {
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
// for mobile devices, we always show mobile connection info here (SPN/PLMN)
// for other devices, we show whatever network is connected
if (mMSimNetworkController.hasMobileDataFeature()) {
mMSimNetworkController.addMobileLabelView(mCarrierLabel);
} else {
mMSimNetworkController.addCombinedLabelView(mCarrierLabel);
}
mSubsLabel.setVisibility(View.VISIBLE);
mMSimNetworkController.addSubsLabelView(mSubsLabel);
// set up the dynamic hide/show of the label
mPile.setOnSizeChangedListener(new OnSizeChangedListener() {
@Override
public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
updateCarrierLabelVisibility(false);
}
});
}
} else {
mNetworkController = new NetworkController(mContext);
mSignalClusterView = (SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster);
mNetworkController.addSignalCluster(mSignalClusterView);
mSignalClusterView.setNetworkController(mNetworkController);
mSignalTextView = (SignalClusterTextView)
mStatusBarView.findViewById(R.id.signal_cluster_text);
if (mSignalTextView != null) {
mNetworkController.addNetworkSignalChangedCallback(mSignalTextView);
mNetworkController.addSignalStrengthChangedCallback(mSignalTextView);
}
final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
if (isAPhone) {
mEmergencyCallLabel = (TextView)mStatusBarWindow.findViewById(
R.id.emergency_calls_only);
if (mEmergencyCallLabel != null) {
mNetworkController.addEmergencyLabelView(mEmergencyCallLabel);
mEmergencyCallLabel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { }});
mEmergencyCallLabel.addOnLayoutChangeListener(
new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
updateCarrierLabelVisibility(false);
}});
}
}
mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
mShowCarrierInPanel = (mCarrierLabel != null);
if (DEBUG) Log.v(TAG, "carrierlabel=" + mCarrierLabel + " show=" +
mShowCarrierInPanel);
if (mShowCarrierInPanel) {
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
// for mobile devices, we always show mobile connection info here (SPN/PLMN)
// for other devices, we show whatever network is connected
if (mNetworkController.hasMobileDataFeature()) {
mNetworkController.addMobileLabelView(mCarrierLabel);
} else {
mNetworkController.addCombinedLabelView(mCarrierLabel);
}
// set up the dynamic hide/show of the label
mPile.setOnSizeChangedListener(new OnSizeChangedListener() {
@Override
public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
updateCarrierLabelVisibility(false);
}
});
}
}
// Quick Settings (where available, some restrictions apply)
if (mHasSettingsPanel) {
// first, figure out where quick settings should be inflated
final View settings_stub;
if (mHasFlipSettings) {
// a version of quick settings that flips around behind the notifications
settings_stub = mStatusBarWindow.findViewById(R.id.flip_settings_stub);
if (settings_stub != null) {
mFlipSettingsView = ((ViewStub)settings_stub).inflate();
mFlipSettingsView.setVisibility(View.GONE);
mFlipSettingsView.setVerticalScrollBarEnabled(false);
}
} else {
// full quick settings panel
settings_stub = mStatusBarWindow.findViewById(R.id.quick_settings_stub);
if (settings_stub != null) {
mSettingsPanel = (SettingsPanelView) ((ViewStub)settings_stub).inflate();
} else {
mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel);
}
if (mSettingsPanel != null) {
if (!ActivityManager.isHighEndGfx()) {
mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor(
R.color.notification_panel_solid_background)));
}
}
}
if (mQS != null) {
mQS.shutdown();
mQS = null;
}
// wherever you find it, Quick Settings needs a container to survive
mSettingsContainer = (QuickSettingsContainerView)
mStatusBarWindow.findViewById(R.id.quick_settings_container);
if (mSettingsContainer != null) {
mQS = new QuickSettingsController(mContext, mSettingsContainer, this,
Settings.System.QUICK_SETTINGS_TILES, false);
if (!mNotificationPanelIsFullScreenWidth) {
mSettingsContainer.setSystemUiVisibility(
View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER
| View.STATUS_BAR_DISABLE_SYSTEM_INFO);
}
if (mSettingsPanel != null) {
mSettingsPanel.setQuickSettings(mQS);
}
mQS.setService(this);
mQS.setBar(mStatusBarView);
mQS.setupQuickSettings();
// Start observing for changes
if (mTilesChangedObserver == null) {
mTilesChangedObserver = new TilesChangedObserver(mHandler);
mTilesChangedObserver.startObserving();
}
} else {
mQS = null; // fly away, be free
}
final ContentResolver resolver = mContext.getContentResolver();
mHasQuickAccessSettings = Settings.System.getIntForUser(resolver,
Settings.System.QS_QUICK_ACCESS, 0, UserHandle.USER_CURRENT) == 1;
mQuickAccessLayoutLinked = Settings.System.getIntForUser(resolver,
Settings.System.QS_QUICK_ACCESS_LINKED, 1, UserHandle.USER_CURRENT) == 1;
if (mHasQuickAccessSettings) {
cleanupRibbon();
mRibbonView = null;
inflateRibbon();
}
}
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mBroadcastReceiver.onReceive(mContext,
new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF));
// receive broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(ACTION_DEMO);
filter.addAction(CUSTOM_LOCKSCREEN_STATE);
context.registerReceiver(mBroadcastReceiver, filter);
// listen for USER_SETUP_COMPLETE setting (per-user)
resetUserSetupObserver();
if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) {
mMSimNetworkController.setListener(this);
} else {
mNetworkController.setListener(this);
}
return mStatusBarView;
}
@Override
protected void onShowSearchPanel() {
if (mNavigationBarView != null) {
mNavigationBarView.getBarTransitions().setContentVisible(false);
}
}
@Override
protected void onHideSearchPanel() {
if (mNavigationBarView != null) {
mNavigationBarView.getBarTransitions().setContentVisible(true);
}
}