Add default app prefs to app info

This makes them easier to discover and to know the state of them.

Bug: 27276982
Change-Id: I24a9d34d7e189b19df39cc0b9028b6412f76aa05
This commit is contained in:
Jason Monk
2016-02-23 17:28:29 -05:00
parent 91e2f89b0f
commit 2108d361bb
11 changed files with 270 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Handler;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -172,4 +173,21 @@ public class DefaultBrowserPreference extends AppListPreference {
mHandler.postDelayed(mUpdateRunnable, DELAY_UPDATE_BROWSER_MILLIS);
}
};
public static boolean hasBrowserPreference(String pkg, Context context) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http:"));
intent.setPackage(pkg);
final List<ResolveInfo> resolveInfos =
context.getPackageManager().queryIntentActivities(intent, 0);
return resolveInfos != null && resolveInfos.size() != 0;
}
public static boolean isBrowserDefault(String pkg, Context context) {
String defaultPackage = context.getPackageManager()
.getDefaultBrowserPackageNameAsUser(UserHandle.myUserId());
return defaultPackage != null && defaultPackage.equals(pkg);
}
}