import com.android.launcher3.BaseRecyclerViewFastScrollBar.FastScrollFocusable;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
+import com.android.launcher3.ProtectedComponentsHelper;
import com.android.launcher3.R;
import com.android.launcher3.RemoteFolderManager;
import com.android.launcher3.Utilities;
// The name of the market app which handles searches, to be used in the format str
// below when updating the search-market view. Only needs to be loaded once.
private String mMarketAppName;
+ // The package name of the market app which handles searches, to be used to
+ // check if the app is protected or not. Only needs to be loaded once.
+ private String mMarketAppPackageName;
+ // The flags of the market app which handles searches, to be used to check if the
+ // market app is protected or not. Only needs to be loaded once.
+ private int mMarketAppFlags;
// The text to show when there is a market app which can handle a specific query, updated
// each time the search query changes.
private String mMarketSearchMessage;
ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""),
PackageManager.MATCH_DEFAULT_ONLY);
if (marketInfo != null) {
- mMarketAppName = marketInfo.loadLabel(pm).toString();
+ try {
+ String packageName = marketInfo.activityInfo.packageName;
+ int flags = pm.getApplicationInfo(packageName, 0).flags;
+ mMarketAppFlags = AppInfo.initFlags(flags);
+ mMarketAppPackageName = packageName;
+ mMarketAppName = marketInfo.loadLabel(pm).toString();
+ } catch (PackageManager.NameNotFoundException e) {
+ // Don't do anything
+ }
}
mRemoteFolderManager = launcher.getRemoteFolderManager();
break;
case SEARCH_MARKET_VIEW_TYPE:
TextView searchView = (TextView) holder.mContent;
- if (mMarketSearchIntent != null) {
+ if (showMarketLink()) {
searchView.setVisibility(View.VISIBLE);
searchView.setContentDescription(mMarketSearchMessage);
searchView.setGravity(mApps.hasNoFilteredResults() ? Gravity.CENTER :
marketSearchIntent.setData(marketSearchUri);
return marketSearchIntent;
}
+
+ private boolean showMarketLink() {
+ return mMarketAppPackageName != null &&
+ !ProtectedComponentsHelper.isProtectedPackage(mMarketAppFlags,
+ mMarketAppPackageName);
+ }
}