use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class CameraBinderTestUtils method isFeatureAvailable.
public static final boolean isFeatureAvailable(Context context, String feature) {
final PackageManager packageManager = context.getPackageManager();
final FeatureInfo[] featuresList = packageManager.getSystemAvailableFeatures();
for (FeatureInfo f : featuresList) {
if (f.name != null && f.name.equals(feature)) {
return true;
}
}
return false;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class CarNavigationBarController method facetHasMultiplePackages.
/**
* Helper method to check if a given facet has multiple packages associated with it.
* This can be resource defined package names or package names filtered by facet category.
*/
private boolean facetHasMultiplePackages(int index) {
PackageManager pm = mContext.getPackageManager();
// Check if the packages defined for the filter actually exists on the device
String[] packages = mFacetPackages.get(index);
if (packages.length > 1) {
int count = 0;
for (int i = 0; i < packages.length; i++) {
count += pm.getLaunchIntentForPackage(packages[i]) != null ? 1 : 0;
if (count > 1) {
return true;
}
}
}
// If there weren't multiple packages defined for the facet, check the categories
// and see if they resolve to multiple package names
String[] categories = mFacetCategories.get(index);
int count = 0;
for (int i = 0; i < categories.length; i++) {
String category = categories[i];
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(category);
count += pm.queryIntentActivities(intent, 0).size();
if (count > 1) {
return true;
}
}
return false;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class MediaSessions method getControllerName.
protected String getControllerName(MediaController controller) {
final PackageManager pm = mContext.getPackageManager();
final String pkg = controller.getPackageName();
try {
if (USE_SERVICE_LABEL) {
final List<ResolveInfo> ris = pm.queryIntentServices(new Intent("android.media.MediaRouteProviderService").setPackage(pkg), 0);
if (ris != null) {
for (ResolveInfo ri : ris) {
if (ri.serviceInfo == null)
continue;
if (pkg.equals(ri.serviceInfo.packageName)) {
final String serviceLabel = Objects.toString(ri.serviceInfo.loadLabel(pm), "").trim();
if (serviceLabel.length() > 0) {
return serviceLabel;
}
}
}
}
}
final ApplicationInfo ai = pm.getApplicationInfo(pkg, 0);
final String appLabel = Objects.toString(ai.loadLabel(pm), "").trim();
if (appLabel.length() > 0) {
return appLabel;
}
} catch (NameNotFoundException e) {
}
return pkg;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class PipUI method start.
@Override
public void start() {
PackageManager pm = mContext.getPackageManager();
mSupportPip = pm.hasSystemFeature(FEATURE_PICTURE_IN_PICTURE) && pm.hasSystemFeature(FEATURE_LEANBACK);
if (!mSupportPip) {
return;
}
PipManager pipManager = PipManager.getInstance();
pipManager.initialize(mContext);
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class UsbConfirmActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Intent intent = getIntent();
mDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
mAccessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
mResolveInfo = (ResolveInfo) intent.getParcelableExtra("rinfo");
PackageManager packageManager = getPackageManager();
String appName = mResolveInfo.loadLabel(packageManager).toString();
final AlertController.AlertParams ap = mAlertParams;
ap.mIcon = mResolveInfo.loadIcon(packageManager);
ap.mTitle = appName;
if (mDevice == null) {
ap.mMessage = getString(R.string.usb_accessory_confirm_prompt, appName);
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mAccessory);
} else {
ap.mMessage = getString(R.string.usb_device_confirm_prompt, appName);
mDisconnectedReceiver = new UsbDisconnectedReceiver(this, mDevice);
}
ap.mPositiveButtonText = getString(android.R.string.ok);
ap.mNegativeButtonText = getString(android.R.string.cancel);
ap.mPositiveButtonListener = this;
ap.mNegativeButtonListener = this;
// add "always use" checkbox
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ap.mView = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null);
mAlwaysUse = (CheckBox) ap.mView.findViewById(com.android.internal.R.id.alwaysUse);
if (mDevice == null) {
mAlwaysUse.setText(R.string.always_use_accessory);
} else {
mAlwaysUse.setText(R.string.always_use_device);
}
mAlwaysUse.setOnCheckedChangeListener(this);
mClearDefaultHint = (TextView) ap.mView.findViewById(com.android.internal.R.id.clearDefaultHint);
mClearDefaultHint.setVisibility(View.GONE);
setupAlert();
}
Aggregations