Search in sources :

Example 91 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class TvInputManagerService method buildTvContentRatingSystemListLocked.

private void buildTvContentRatingSystemListLocked(int userId) {
    UserState userState = getOrCreateUserStateLocked(userId);
    userState.contentRatingSystemList.clear();
    final PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(TvInputManager.ACTION_QUERY_CONTENT_RATING_SYSTEMS);
    for (ResolveInfo resolveInfo : pm.queryBroadcastReceivers(intent, PackageManager.GET_META_DATA)) {
        ActivityInfo receiver = resolveInfo.activityInfo;
        Bundle metaData = receiver.metaData;
        if (metaData == null) {
            continue;
        }
        int xmlResId = metaData.getInt(TvInputManager.META_DATA_CONTENT_RATING_SYSTEMS);
        if (xmlResId == 0) {
            Slog.w(TAG, "Missing meta-data '" + TvInputManager.META_DATA_CONTENT_RATING_SYSTEMS + "' on receiver " + receiver.packageName + "/" + receiver.name);
            continue;
        }
        userState.contentRatingSystemList.add(TvContentRatingSystemInfo.createTvContentRatingSystemInfo(xmlResId, receiver.applicationInfo));
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) Bundle(android.os.Bundle) Intent(android.content.Intent)

Example 92 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class PhoneWindowManager method createHomeDockIntent.

/**
     * Return an Intent to launch the currently active dock app as home.  Returns
     * null if the standard home should be launched, which is the case if any of the following is
     * true:
     * <ul>
     *  <li>The device is not in either car mode or desk mode
     *  <li>The device is in car mode but mEnableCarDockHomeCapture is false
     *  <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false
     *  <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME
     *  <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME
     * </ul>
     * @return A dock intent.
     */
Intent createHomeDockIntent() {
    Intent intent = null;
    // of whether we are actually in a car dock.
    if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
        if (mEnableCarDockHomeCapture) {
            intent = mCarDockIntent;
        }
    } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
        if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
            intent = mDeskDockIntent;
        }
    } else if (mUiMode == Configuration.UI_MODE_TYPE_WATCH && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK)) {
        // Always launch dock home from home when watch is docked, if it exists.
        intent = mDeskDockIntent;
    }
    if (intent == null) {
        return null;
    }
    ActivityInfo ai = null;
    ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, mCurrentUserId);
    if (info != null) {
        ai = info.activityInfo;
    }
    if (ai != null && ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) {
        intent = new Intent(intent);
        intent.setClassName(ai.packageName, ai.name);
        return intent;
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent)

Example 93 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class MidiService method onUnlockUser.

private void onUnlockUser() {
    mPackageMonitor.register(mContext, null, true);
    Intent intent = new Intent(MidiDeviceService.SERVICE_INTERFACE);
    List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent, PackageManager.GET_META_DATA);
    if (resolveInfos != null) {
        int count = resolveInfos.size();
        for (int i = 0; i < count; i++) {
            ServiceInfo serviceInfo = resolveInfos.get(i).serviceInfo;
            if (serviceInfo != null) {
                addPackageDeviceServer(serviceInfo);
            }
        }
    }
    PackageInfo info;
    try {
        info = mPackageManager.getPackageInfo(MidiManager.BLUETOOTH_MIDI_SERVICE_PACKAGE, 0);
    } catch (PackageManager.NameNotFoundException e) {
        info = null;
    }
    if (info != null && info.applicationInfo != null) {
        mBluetoothServiceUid = info.applicationInfo.uid;
    } else {
        mBluetoothServiceUid = -1;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) Intent(android.content.Intent)

Example 94 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class RemotePrintServiceRecommendationService method getServiceIntent.

/**
     * @return The intent that is used to connect to the print service recommendation service.
     */
private Intent getServiceIntent(@NonNull UserHandle userHandle) throws Exception {
    List<ResolveInfo> installedServices = mContext.getPackageManager().queryIntentServicesAsUser(new Intent(android.printservice.recommendation.RecommendationService.SERVICE_INTERFACE), GET_SERVICES | GET_META_DATA | MATCH_DEBUG_TRIAGED_MISSING, userHandle.getIdentifier());
    if (installedServices.size() != 1) {
        throw new Exception(installedServices.size() + " instead of exactly one service found");
    }
    ResolveInfo installedService = installedServices.get(0);
    ComponentName serviceName = new ComponentName(installedService.serviceInfo.packageName, installedService.serviceInfo.name);
    ApplicationInfo appInfo = mContext.getPackageManager().getApplicationInfo(installedService.serviceInfo.packageName, 0);
    if (appInfo == null) {
        throw new Exception("Cannot read appInfo for service");
    }
    if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
        throw new Exception("Service is not part of the system");
    }
    if (!android.Manifest.permission.BIND_PRINT_RECOMMENDATION_SERVICE.equals(installedService.serviceInfo.permission)) {
        throw new Exception("Service " + serviceName.flattenToShortString() + " does not require permission " + android.Manifest.permission.BIND_PRINT_RECOMMENDATION_SERVICE);
    }
    Intent serviceIntent = new Intent();
    serviceIntent.setComponent(serviceName);
    return serviceIntent;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 95 with ResolveInfo

use of android.content.pm.ResolveInfo in project platform_frameworks_base by android.

the class UserState method dump.

public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String prefix) {
    pw.append(prefix).append("user state ").append(String.valueOf(mUserId)).append(":");
    pw.println();
    String tab = "  ";
    pw.append(prefix).append(tab).append("installed services:").println();
    final int installedServiceCount = mInstalledServices.size();
    for (int i = 0; i < installedServiceCount; i++) {
        PrintServiceInfo installedService = mInstalledServices.get(i);
        String installedServicePrefix = prefix + tab + tab;
        pw.append(installedServicePrefix).append("service:").println();
        ResolveInfo resolveInfo = installedService.getResolveInfo();
        ComponentName componentName = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name);
        pw.append(installedServicePrefix).append(tab).append("componentName=").append(componentName.flattenToString()).println();
        pw.append(installedServicePrefix).append(tab).append("settingsActivity=").append(installedService.getSettingsActivityName()).println();
        pw.append(installedServicePrefix).append(tab).append("addPrintersActivity=").append(installedService.getAddPrintersActivityName()).println();
        pw.append(installedServicePrefix).append(tab).append("avancedOptionsActivity=").append(installedService.getAdvancedOptionsActivityName()).println();
    }
    pw.append(prefix).append(tab).append("disabled services:").println();
    for (ComponentName disabledService : mDisabledServices) {
        String disabledServicePrefix = prefix + tab + tab;
        pw.append(disabledServicePrefix).append("service:").println();
        pw.append(disabledServicePrefix).append(tab).append("componentName=").append(disabledService.flattenToString());
        pw.println();
    }
    pw.append(prefix).append(tab).append("active services:").println();
    final int activeServiceCount = mActiveServices.size();
    for (int i = 0; i < activeServiceCount; i++) {
        RemotePrintService activeService = mActiveServices.valueAt(i);
        activeService.dump(pw, prefix + tab + tab);
        pw.println();
    }
    pw.append(prefix).append(tab).append("cached print jobs:").println();
    mPrintJobForAppCache.dump(pw, prefix + tab + tab);
    pw.append(prefix).append(tab).append("discovery mediator:").println();
    if (mPrinterDiscoverySession != null) {
        mPrinterDiscoverySession.dump(pw, prefix + tab + tab);
    }
    pw.append(prefix).append(tab).append("print spooler:").println();
    mSpooler.dump(fd, pw, prefix + tab + tab);
    pw.println();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)1211 Intent (android.content.Intent)760 PackageManager (android.content.pm.PackageManager)470 ComponentName (android.content.ComponentName)375 ActivityInfo (android.content.pm.ActivityInfo)209 ArrayList (java.util.ArrayList)205 PendingIntent (android.app.PendingIntent)159 RemoteException (android.os.RemoteException)137 ServiceInfo (android.content.pm.ServiceInfo)120 ApplicationInfo (android.content.pm.ApplicationInfo)73 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)53 Bundle (android.os.Bundle)47 HashMap (java.util.HashMap)46 IOException (java.io.IOException)43 HashSet (java.util.HashSet)43 Point (android.graphics.Point)42 ActivityNotFoundException (android.content.ActivityNotFoundException)38 PackageInfo (android.content.pm.PackageInfo)37 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)33