|
22 | 22 | import android.app.ActivityManagerNative; |
23 | 23 | import android.app.AlarmManager; |
24 | 24 | import android.app.PendingIntent; |
| 25 | +import android.app.SearchManager; |
25 | 26 | import android.app.StatusBarManager; |
26 | 27 | import android.content.BroadcastReceiver; |
27 | 28 | import android.content.ContentResolver; |
@@ -166,6 +167,9 @@ public class KeyguardViewMediator { |
166 | 167 | /** UserManager for querying number of users */ |
167 | 168 | private UserManager mUserManager; |
168 | 169 |
|
| 170 | + /** SearchManager for determining whether or not search assistant is available */ |
| 171 | + private SearchManager mSearchManager; |
| 172 | + |
169 | 173 | /** |
170 | 174 | * Used to keep the device awake while to ensure the keyguard finishes opening before |
171 | 175 | * we sleep. |
@@ -527,6 +531,7 @@ public KeyguardViewMediator(Context context, LockPatternUtils lockPatternUtils) |
527 | 531 | * Let us know that the system is ready after startup. |
528 | 532 | */ |
529 | 533 | public void onSystemReady() { |
| 534 | + mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
530 | 535 | synchronized (this) { |
531 | 536 | if (DEBUG) Log.d(TAG, "onSystemReady"); |
532 | 537 | mSystemReady = true; |
@@ -1313,6 +1318,9 @@ private void adjustStatusBarLocked() { |
1313 | 1318 | // showing secure lockscreen; disable ticker. |
1314 | 1319 | flags |= StatusBarManager.DISABLE_NOTIFICATION_TICKER; |
1315 | 1320 | } |
| 1321 | + if (!isAssistantAvailable()) { |
| 1322 | + flags |= StatusBarManager.DISABLE_SEARCH; |
| 1323 | + } |
1316 | 1324 | } |
1317 | 1325 |
|
1318 | 1326 | if (DEBUG) { |
@@ -1410,4 +1418,8 @@ public void handleShowAssistant() { |
1410 | 1418 | mKeyguardViewManager.showAssistant(); |
1411 | 1419 | } |
1412 | 1420 |
|
| 1421 | + private boolean isAssistantAvailable() { |
| 1422 | + return mSearchManager != null |
| 1423 | + && mSearchManager.getAssistIntent(mContext, UserHandle.USER_CURRENT) != null; |
| 1424 | + } |
1413 | 1425 | } |
0 commit comments