Fix searching work app in settings
Test: m -j RunSettingsRoboTests
Test: Observe search result with badged icon and showing work app info
when tapping on it.
Test: personal app search result is still working
Test: Non app search result is working
Fix: 62366873
Merged-in: I333372699b263d02cc4083289dc746c7aacd414d
Change-Id: I333372699b263d02cc4083289dc746c7aacd414d
(cherry picked from commit 3bef8ce30a)
This commit is contained in:
@@ -16,9 +16,11 @@
|
||||
*/
|
||||
package com.android.settings.search;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
/**
|
||||
* ViewHolder for intent based search results.
|
||||
@@ -32,7 +34,7 @@ public class IntentSearchViewHolder extends SearchViewHolder {
|
||||
|
||||
@Override
|
||||
public int getClickActionMetricName() {
|
||||
return MetricsEvent.ACTION_CLICK_SETTINGS_SEARCH_RESULT;
|
||||
return MetricsProto.MetricsEvent.ACTION_CLICK_SETTINGS_SEARCH_RESULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +43,15 @@ public class IntentSearchViewHolder extends SearchViewHolder {
|
||||
|
||||
itemView.setOnClickListener(v -> {
|
||||
fragment.onSearchResultClicked(this, result);
|
||||
fragment.startActivity(result.payload.getIntent());
|
||||
final Intent intent = result.payload.getIntent();
|
||||
// Use app user id to support work profile use case.
|
||||
if (result instanceof AppSearchResult) {
|
||||
AppSearchResult appResult = (AppSearchResult) result;
|
||||
UserHandle userHandle = appResult.getAppUserHandle();
|
||||
fragment.getActivity().startActivityAsUser(intent, userHandle);
|
||||
} else {
|
||||
fragment.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user