1616
1717package com .android .systemui ;
1818
19- import android .animation .Animator ;
2019import android .animation .LayoutTransition ;
21- import android .app .ActivityManagerNative ;
2220import android .app .ActivityOptions ;
2321import android .app .SearchManager ;
2422import android .content .ActivityNotFoundException ;
2523import android .content .ComponentName ;
2624import android .content .Context ;
2725import android .content .Intent ;
2826import android .content .pm .PackageManager ;
27+ import android .content .res .Resources ;
28+ import android .os .Vibrator ;
29+ import android .provider .Settings ;
2930import android .util .AttributeSet ;
3031import android .util .Slog ;
3132import android .view .MotionEvent ;
3435import android .view .ViewTreeObserver ;
3536import android .view .ViewTreeObserver .OnPreDrawListener ;
3637import android .widget .FrameLayout ;
37-
3838import com .android .internal .widget .multiwaveview .MultiWaveView ;
3939import com .android .internal .widget .multiwaveview .MultiWaveView .OnTriggerListener ;
4040import com .android .systemui .R ;
@@ -77,7 +77,7 @@ public boolean isAssistantAvailable() {
7777 Intent intent = getAssistIntent ();
7878 return intent == null ? false
7979 : mContext .getPackageManager ().queryIntentActivities (intent ,
80- PackageManager .MATCH_DEFAULT_ONLY ).size () > 0 ;
80+ PackageManager .MATCH_DEFAULT_ONLY ).size () > 0 ;
8181 }
8282
8383 private Intent getAssistIntent () {
@@ -142,13 +142,14 @@ public void onTrigger(View v, final int target) {
142142 case com .android .internal .R .drawable .ic_lockscreen_search :
143143 mWaitingForLaunch = true ;
144144 startAssistActivity ();
145+ vibrate ();
145146 postDelayed (new Runnable () {
146147 public void run () {
147148 mWaitingForLaunch = false ;
148149 mBar .hideSearchPanel ();
149150 }
150151 }, SEARCH_PANEL_HOLD_DURATION );
151- break ;
152+ break ;
152153 }
153154 }
154155
@@ -194,10 +195,20 @@ public boolean onPreDraw() {
194195 }
195196 };
196197
198+ private void vibrate () {
199+ Context context = getContext ();
200+ if (Settings .System .getInt (context .getContentResolver (),
201+ Settings .System .HAPTIC_FEEDBACK_ENABLED , 1 ) != 0 ) {
202+ Resources res = context .getResources ();
203+ Vibrator vibrator = (Vibrator ) context .getSystemService (Context .VIBRATOR_SERVICE );
204+ vibrator .vibrate (res .getInteger (R .integer .config_search_panel_view_vibration_duration ));
205+ }
206+ }
207+
197208 public void show (final boolean show , boolean animate ) {
198209 if (!show ) {
199210 final LayoutTransition transitioner = animate ? createLayoutTransitioner () : null ;
200- ((ViewGroup )mSearchTargetsContainer ).setLayoutTransition (transitioner );
211+ ((ViewGroup ) mSearchTargetsContainer ).setLayoutTransition (transitioner );
201212 }
202213 mShowing = show ;
203214 if (show ) {
@@ -207,6 +218,7 @@ public void show(final boolean show, boolean animate) {
207218 // right before we are drawn
208219 mMultiWaveView .suspendAnimations ();
209220 getViewTreeObserver ().addOnPreDrawListener (mPreDrawListener );
221+ vibrate ();
210222 }
211223 setFocusable (true );
212224 setFocusableInTouchMode (true );
0 commit comments