use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.
the class DefaultDialerManager method getInstalledDialerApplications.
/**
* Returns a list of installed and available dialer applications.
*
* In order to appear in the list, a dialer application must implement an intent-filter with
* the DIAL intent for the following schemes:
*
* 1) Empty scheme
* 2) tel Uri scheme
*
* @hide
**/
public static List<String> getInstalledDialerApplications(Context context, int userId) {
PackageManager packageManager = context.getPackageManager();
// Get the list of apps registered for the DIAL intent with empty scheme
Intent intent = new Intent(Intent.ACTION_DIAL);
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivitiesAsUser(intent, 0, userId);
List<String> packageNames = new ArrayList<>();
for (ResolveInfo resolveInfo : resolveInfoList) {
final ActivityInfo activityInfo = resolveInfo.activityInfo;
if (activityInfo != null && !packageNames.contains(activityInfo.packageName)) {
packageNames.add(activityInfo.packageName);
}
}
final Intent dialIntentWithTelScheme = new Intent(Intent.ACTION_DIAL);
dialIntentWithTelScheme.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, "", null));
return filterByIntent(context, packageNames, dialIntentWithTelScheme);
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.
the class DefaultDialerManager method filterByIntent.
/**
* Filter a given list of package names for those packages that contain an activity that has
* an intent filter for a given intent.
*
* @param context A valid context
* @param packageNames List of package names to filter.
* @return The filtered list.
*/
private static List<String> filterByIntent(Context context, List<String> packageNames, Intent intent) {
if (packageNames == null || packageNames.isEmpty()) {
return new ArrayList<>();
}
final List<String> result = new ArrayList<>();
final List<ResolveInfo> resolveInfoList = context.getPackageManager().queryIntentActivities(intent, 0);
final int length = resolveInfoList.size();
for (int i = 0; i < length; i++) {
final ActivityInfo info = resolveInfoList.get(i).activityInfo;
if (info != null && packageNames.contains(info.packageName) && !result.contains(info.packageName)) {
result.add(info.packageName);
}
}
return result;
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.
the class AliasActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
XmlResourceParser parser = null;
try {
ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
parser = ai.loadXmlMetaData(getPackageManager(), ALIAS_META_DATA);
if (parser == null) {
throw new RuntimeException("Alias requires a meta-data field " + ALIAS_META_DATA);
}
Intent intent = parseAlias(parser);
if (intent == null) {
throw new RuntimeException("No <intent> tag found in alias description");
}
startActivity(intent);
finish();
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("Error parsing alias", e);
} catch (XmlPullParserException e) {
throw new RuntimeException("Error parsing alias", e);
} catch (IOException e) {
throw new RuntimeException("Error parsing alias", e);
} finally {
if (parser != null)
parser.close();
}
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.
the class NetworkScorerAppManagerTest method buildResolveInfo.
private ResolveInfoHolder buildResolveInfo(String packageName, int packageUid, boolean hasReceiverPermission, boolean hasScorePermission, boolean hasConfigActivity, boolean hasServiceInfo) throws Exception {
Mockito.when(mMockPm.checkPermission(permission.SCORE_NETWORKS, packageName)).thenReturn(hasScorePermission ? PackageManager.PERMISSION_GRANTED : PackageManager.PERMISSION_DENIED);
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.activityInfo = new ActivityInfo();
resolveInfo.activityInfo.packageName = packageName;
resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
resolveInfo.activityInfo.applicationInfo.uid = packageUid;
if (hasReceiverPermission) {
resolveInfo.activityInfo.permission = permission.BROADCAST_NETWORK_PRIVILEGED;
}
ResolveInfo configActivityInfo = null;
if (hasConfigActivity) {
configActivityInfo = new ResolveInfo();
configActivityInfo.activityInfo = new ActivityInfo();
configActivityInfo.activityInfo.name = ".ConfigActivity";
}
ResolveInfo serviceInfo = null;
if (hasServiceInfo) {
serviceInfo = new ResolveInfo();
serviceInfo.serviceInfo = new ServiceInfo();
serviceInfo.serviceInfo.name = ".ScoringService";
}
return new ResolveInfoHolder(resolveInfo, configActivityInfo, serviceInfo);
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by DirtyUnicorns.
the class KeyguardBottomAreaView method bindCameraPrewarmService.
public void bindCameraPrewarmService() {
Intent intent = getCameraIntent();
ActivityInfo targetInfo = PreviewInflater.getTargetActivityInfo(mContext, intent, KeyguardUpdateMonitor.getCurrentUser(), true);
if (targetInfo != null && targetInfo.metaData != null) {
String clazz = targetInfo.metaData.getString(MediaStore.META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE);
if (clazz != null) {
Intent serviceIntent = new Intent();
serviceIntent.setClassName(targetInfo.packageName, clazz);
serviceIntent.setAction(CameraPrewarmService.ACTION_PREWARM);
try {
if (getContext().bindServiceAsUser(serviceIntent, mPrewarmConnection, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, new UserHandle(UserHandle.USER_CURRENT))) {
mPrewarmBound = true;
}
} catch (SecurityException e) {
Log.w(TAG, "Unable to bind to prewarm service package=" + targetInfo.packageName + " class=" + clazz, e);
}
}
}
}
Aggregations