diff options
-rw-r--r-- | src/com/android/launcher3/AppInfo.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsGridAdapter.java | 25 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java index ca8ae255c..515f8b586 100644 --- a/src/com/android/launcher3/AppInfo.java +++ b/src/com/android/launcher3/AppInfo.java @@ -102,7 +102,10 @@ public class AppInfo extends ItemInfo { } public static int initFlags(LauncherActivityInfoCompat info) { - int appFlags = info.getApplicationInfo().flags; + return initFlags(info.getApplicationInfo().flags); + } + + public static int initFlags(int appFlags) { int flags = 0; if ((appFlags & android.content.pm.ApplicationInfo.FLAG_SYSTEM) == 0) { flags |= DOWNLOADED_FLAG; diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 643182588..12cda2571 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -41,6 +41,7 @@ import com.android.launcher3.BaseRecyclerViewFastScrollBar.FastScrollFocusApplic 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; @@ -350,6 +351,12 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. // 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; @@ -417,7 +424,15 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. 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(); @@ -614,7 +629,7 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. 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 : @@ -713,4 +728,10 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. marketSearchIntent.setData(marketSearchUri); return marketSearchIntent; } + + private boolean showMarketLink() { + return mMarketAppPackageName != null && + !ProtectedComponentsHelper.isProtectedPackage(mMarketAppFlags, + mMarketAppPackageName); + } } |