import android.content.Context;
import android.content.Intent;
+import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
+import android.util.Log;
import java.util.List;
public class DefaultBrowserPreferenceController extends DefaultAppPreferenceController {
+ private static final String TAG = "BrowserPrefCtrl";
+
static final Intent BROWSE_PROBE = new Intent()
.setAction(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
@Override
protected DefaultAppInfo getDefaultAppInfo() {
try {
+ final String packageName = mPackageManager.getDefaultBrowserPackageNameAsUser(mUserId);
+ Log.d(TAG, "Get default browser package: " + packageName);
return new DefaultAppInfo(mPackageManager,
- mPackageManager.getPackageManager().getApplicationInfo(
- mPackageManager.getDefaultBrowserPackageNameAsUser(mUserId), 0));
+ mPackageManager.getPackageManager().getApplicationInfo(packageName, 0));
} catch (PackageManager.NameNotFoundException e) {
return null;
}
// Resolve that intent and check that the handleAllWebDataURI boolean is set
final List<ResolveInfo> list = getCandidates();
if (list != null && list.size() == 1) {
- return list.get(0).loadLabel(mPackageManager.getPackageManager()).toString();
+ final ResolveInfo info = list.get(0);
+ final String label = info.loadLabel(mPackageManager.getPackageManager()).toString();
+ final ComponentInfo cn = info.getComponentInfo();
+ final String packageName = cn == null ? null : cn.packageName;
+ Log.d(TAG, "Getting label for the only browser app: " + packageName + label);
+ return label;
}
return null;
}