Skip to content

Commit 43d8451

Browse files
author
John Spurlock
committed
Disable navbar searchlight if search assist not available.
Bug:7506441 Change-Id: I55c740d4c3a45b9f7fdfa38346d1bc3fb1299153
1 parent c1ae43a commit 43d8451

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

core/java/android/app/SearchManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,9 @@ public Intent getAssistIntent(Context context) {
858858
*/
859859
public Intent getAssistIntent(Context context, int userHandle) {
860860
try {
861+
if (mService == null) {
862+
return null;
863+
}
861864
ComponentName comp = mService.getAssistIntent(userHandle);
862865
if (comp == null) {
863866
return null;

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.app.ActivityManagerNative;
2323
import android.app.AlarmManager;
2424
import android.app.PendingIntent;
25+
import android.app.SearchManager;
2526
import android.app.StatusBarManager;
2627
import android.content.BroadcastReceiver;
2728
import android.content.ContentResolver;
@@ -166,6 +167,9 @@ public class KeyguardViewMediator {
166167
/** UserManager for querying number of users */
167168
private UserManager mUserManager;
168169

170+
/** SearchManager for determining whether or not search assistant is available */
171+
private SearchManager mSearchManager;
172+
169173
/**
170174
* Used to keep the device awake while to ensure the keyguard finishes opening before
171175
* we sleep.
@@ -527,6 +531,7 @@ public KeyguardViewMediator(Context context, LockPatternUtils lockPatternUtils)
527531
* Let us know that the system is ready after startup.
528532
*/
529533
public void onSystemReady() {
534+
mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
530535
synchronized (this) {
531536
if (DEBUG) Log.d(TAG, "onSystemReady");
532537
mSystemReady = true;
@@ -1313,6 +1318,9 @@ private void adjustStatusBarLocked() {
13131318
// showing secure lockscreen; disable ticker.
13141319
flags |= StatusBarManager.DISABLE_NOTIFICATION_TICKER;
13151320
}
1321+
if (!isAssistantAvailable()) {
1322+
flags |= StatusBarManager.DISABLE_SEARCH;
1323+
}
13161324
}
13171325

13181326
if (DEBUG) {
@@ -1410,4 +1418,8 @@ public void handleShowAssistant() {
14101418
mKeyguardViewManager.showAssistant();
14111419
}
14121420

1421+
private boolean isAssistantAvailable() {
1422+
return mSearchManager != null
1423+
&& mSearchManager.getAssistIntent(mContext, UserHandle.USER_CURRENT) != null;
1424+
}
14131425
}

0 commit comments

Comments
 (0)