@@ -83,7 +83,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
8383 private View mUnlockWidget ;
8484 private boolean mCameraDisabled ;
8585 private boolean mSearchDisabled ;
86- private SearchManager mSearchManager ;
8786 // Is there a vibrator
8887 private final boolean mHasVibrator ;
8988
@@ -253,23 +252,6 @@ public void cleanUp() {
253252 }
254253 }
255254
256- private boolean isAssistantAvailable () {
257- SearchManager searchManager = getSearchManager ();
258- return searchManager != null && searchManager .isAssistantAvailable ();
259- }
260-
261- private Intent getAssistIntent () {
262- SearchManager searchManager = getSearchManager ();
263- return searchManager != null ? searchManager .getAssistIntent () : null ;
264- }
265-
266- private SearchManager getSearchManager () {
267- if (mSearchManager == null ) {
268- mSearchManager = (SearchManager ) mContext .getSystemService (Context .SEARCH_SERVICE );
269- }
270- return mSearchManager ;
271- }
272-
273255 class GlowPadViewMethods implements GlowPadView .OnTriggerListener ,
274256 UnlockWidgetCommonMethods {
275257 private final GlowPadView mGlowPadView ;
@@ -297,27 +279,21 @@ public void updateResources() {
297279
298280 // Update the search icon with drawable from the search .apk
299281 if (!mSearchDisabled ) {
300- SearchManager searchManager = getSearchManager ();
301- if (searchManager != null ) {
302- ComponentName component = searchManager .getGlobalSearchActivity ();
303- if (component != null ) {
304- // XXX Hack. We need to substitute the icon here but haven't formalized
305- // the public API. The "_google" metadata will be going away, so
306- // DON'T USE IT!
307- boolean replaced = mGlowPadView .replaceTargetDrawablesIfPresent (component ,
308- ASSIST_ICON_METADATA_NAME + "_google" ,
309- com .android .internal .R .drawable .ic_action_assist_generic );
310-
311- if (!replaced && !mGlowPadView .replaceTargetDrawablesIfPresent (component ,
312- ASSIST_ICON_METADATA_NAME ,
313- com .android .internal .R .drawable .ic_action_assist_generic )) {
314- Slog .w (TAG , "Couldn't grab icon from package " + component );
315- }
316- } else {
317- Slog .w (TAG , "No search icon specified in package " + component );
282+ Intent intent = SearchManager .getAssistIntent (mContext );
283+ if (intent != null ) {
284+ // XXX Hack. We need to substitute the icon here but haven't formalized
285+ // the public API. The "_google" metadata will be going away, so
286+ // DON'T USE IT!
287+ ComponentName component = intent .getComponent ();
288+ boolean replaced = mGlowPadView .replaceTargetDrawablesIfPresent (component ,
289+ ASSIST_ICON_METADATA_NAME + "_google" ,
290+ com .android .internal .R .drawable .ic_action_assist_generic );
291+
292+ if (!replaced && !mGlowPadView .replaceTargetDrawablesIfPresent (component ,
293+ ASSIST_ICON_METADATA_NAME ,
294+ com .android .internal .R .drawable .ic_action_assist_generic )) {
295+ Slog .w (TAG , "Couldn't grab icon from package " + component );
318296 }
319- } else {
320- Slog .w (TAG , "No SearchManager" );
321297 }
322298 }
323299
@@ -337,7 +313,7 @@ public void onTrigger(View v, int target) {
337313 final int resId = mGlowPadView .getResourceIdForTarget (target );
338314 switch (resId ) {
339315 case com .android .internal .R .drawable .ic_action_assist_generic :
340- Intent assistIntent = getAssistIntent ();
316+ Intent assistIntent = SearchManager . getAssistIntent (mContext );
341317 if (assistIntent != null ) {
342318 launchActivity (assistIntent );
343319 } else {
@@ -550,7 +526,7 @@ private void updateTargets() {
550526 } else if (disabledBySimState ) {
551527 Log .v (TAG , "Camera disabled by Sim State" );
552528 }
553- boolean searchActionAvailable = isAssistantAvailable () ;
529+ boolean searchActionAvailable = SearchManager . getAssistIntent ( mContext ) != null ;
554530 mCameraDisabled = disabledByAdmin || disabledBySimState || !cameraTargetPresent ;
555531 mSearchDisabled = disabledBySimState || !searchActionAvailable || !searchTargetPresent ;
556532 mUnlockWidgetMethods .updateResources ();
0 commit comments