Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59f028d4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Create an API for browser app checking." into rvc-dev am: 38e3d616...

Merge "Create an API for browser app checking." into rvc-dev am: 38e3d616 am: 709540b2 am: 14f55ea3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11716084

Change-Id: I5ca7c967ee49ba3d6941364e6ac4d82a1f5e6b35
parents 6fc36910 14f55ea3
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -19,10 +19,13 @@ package com.android.settingslib.applications;
import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.hardware.usb.IUsbManager;
import android.net.Uri;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
@@ -44,6 +47,15 @@ public class AppUtils {
     */
    private static InstantAppDataProvider sInstantAppDataProvider = null;

    private static final Intent sBrowserIntent;

    static {
        sBrowserIntent = new Intent()
                .setAction(Intent.ACTION_VIEW)
                .addCategory(Intent.CATEGORY_BROWSABLE)
                .setData(Uri.parse("http:"));
    }

    public static CharSequence getLaunchByDefaultSummary(ApplicationsState.AppEntry appEntry,
            IUsbManager usbManager, PackageManager pm, Context context) {
        String packageName = appEntry.info.packageName;
@@ -153,4 +165,22 @@ public class AppUtils {
        return com.android.settingslib.utils.applications.AppUtils.getAppContentDescription(context,
                packageName, userId);
    }

    /**
     * Returns a boolean indicating whether a given package is a browser app.
     *
     * An app is a "browser" if it has an activity resolution that wound up
     * marked with the 'handleAllWebDataURI' flag.
     */
    public static boolean isBrowserApp(Context context, String packageName, int userId) {
        sBrowserIntent.setPackage(packageName);
        final List<ResolveInfo> list = context.getPackageManager().queryIntentActivitiesAsUser(
                sBrowserIntent, PackageManager.MATCH_ALL, userId);
        for (ResolveInfo info : list) {
            if (info.activityInfo != null && info.handleAllWebDataURI) {
                return true;
            }
        }
        return false;
    }
}