Search in sources :

Example 76 with ActivityInfo

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);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

Example 77 with ActivityInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) ArrayList(java.util.ArrayList)

Example 78 with ActivityInfo

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();
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) XmlResourceParser(android.content.res.XmlResourceParser) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Example 79 with ActivityInfo

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);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ActivityInfo(android.content.pm.ActivityInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 80 with ActivityInfo

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);
            }
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) UserHandle(android.os.UserHandle) Intent(android.content.Intent)

Aggregations

ActivityInfo (android.content.pm.ActivityInfo)886 ResolveInfo (android.content.pm.ResolveInfo)360 Intent (android.content.Intent)339 ComponentName (android.content.ComponentName)324 PackageManager (android.content.pm.PackageManager)215 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)141 ArrayList (java.util.ArrayList)139 ApplicationInfo (android.content.pm.ApplicationInfo)115 Test (org.junit.Test)113 RemoteException (android.os.RemoteException)82 Bundle (android.os.Bundle)68 PendingIntent (android.app.PendingIntent)62 Drawable (android.graphics.drawable.Drawable)61 IOException (java.io.IOException)60 PackageInfo (android.content.pm.PackageInfo)59 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)54 XmlResourceParser (android.content.res.XmlResourceParser)43 Point (android.graphics.Point)35 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)34 Context (android.content.Context)33