Search in sources :

Example 21 with ServiceInfo

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

the class ZenModeHelper method addAutomaticZenRule.

public String addAutomaticZenRule(AutomaticZenRule automaticZenRule, String reason) {
    if (!isSystemRule(automaticZenRule)) {
        ServiceInfo owner = getServiceInfo(automaticZenRule.getOwner());
        if (owner == null) {
            throw new IllegalArgumentException("Owner is not a condition provider service");
        }
        int ruleInstanceLimit = -1;
        if (owner.metaData != null) {
            ruleInstanceLimit = owner.metaData.getInt(ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
        }
        if (ruleInstanceLimit > 0 && ruleInstanceLimit < (getCurrentInstanceCount(automaticZenRule.getOwner()) + 1)) {
            throw new IllegalArgumentException("Rule instance limit exceeded");
        }
    }
    ZenModeConfig newConfig;
    synchronized (mConfig) {
        if (mConfig == null) {
            throw new AndroidRuntimeException("Could not create rule");
        }
        if (DEBUG) {
            Log.d(TAG, "addAutomaticZenRule rule= " + automaticZenRule + " reason=" + reason);
        }
        newConfig = mConfig.copy();
        ZenRule rule = new ZenRule();
        populateZenRule(automaticZenRule, rule, true);
        newConfig.automaticRules.put(rule.id, rule);
        if (setConfigLocked(newConfig, reason, true)) {
            return rule.id;
        } else {
            throw new AndroidRuntimeException("Could not create rule");
        }
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) AutomaticZenRule(android.app.AutomaticZenRule) ZenRule(android.service.notification.ZenModeConfig.ZenRule) AndroidRuntimeException(android.util.AndroidRuntimeException) ZenModeConfig(android.service.notification.ZenModeConfig)

Example 22 with ServiceInfo

use of android.content.pm.ServiceInfo 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 23 with ServiceInfo

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

the class WallpaperManagerService method switchWallpaper.

void switchWallpaper(WallpaperData wallpaper, IRemoteCallback reply) {
    synchronized (mLock) {
        mWaitingForUnlock = false;
        final ComponentName cname = wallpaper.wallpaperComponent != null ? wallpaper.wallpaperComponent : wallpaper.nextWallpaperComponent;
        if (!bindWallpaperComponentLocked(cname, true, false, wallpaper, reply)) {
            // We failed to bind the desired wallpaper, but that might
            // happen if the wallpaper isn't direct-boot aware
            ServiceInfo si = null;
            try {
                si = mIPackageManager.getServiceInfo(cname, PackageManager.MATCH_DIRECT_BOOT_UNAWARE, wallpaper.userId);
            } catch (RemoteException ignored) {
            }
            if (si == null) {
                Slog.w(TAG, "Failure starting previous wallpaper; clearing");
                clearWallpaperLocked(false, FLAG_SYSTEM, wallpaper.userId, reply);
            } else {
                Slog.w(TAG, "Wallpaper isn't direct boot aware; using fallback until unlocked");
                // We might end up persisting the current wallpaper data
                // while locked, so pretend like the component was actually
                // bound into place
                wallpaper.wallpaperComponent = wallpaper.nextWallpaperComponent;
                final WallpaperData fallback = new WallpaperData(wallpaper.userId, WALLPAPER_LOCK_ORIG, WALLPAPER_LOCK_CROP);
                ensureSaneWallpaperData(fallback);
                bindWallpaperComponentLocked(mImageWallpaper, true, false, fallback, reply);
                mWaitingForUnlock = true;
            }
        }
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 24 with ServiceInfo

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

the class TtsEngines method getSettingsIntent.

/**
     * @return an intent that can launch the settings activity for a given tts engine.
     */
public Intent getSettingsIntent(String engine) {
    PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
    intent.setPackage(engine);
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent, PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA);
    // the package name.
    if (resolveInfos != null && resolveInfos.size() == 1) {
        ServiceInfo service = resolveInfos.get(0).serviceInfo;
        if (service != null) {
            final String settings = settingsActivityFromServiceInfo(service, pm);
            if (settings != null) {
                Intent i = new Intent();
                i.setClassName(engine, settings);
                return i;
            }
        }
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) Secure.getString(android.provider.Settings.Secure.getString)

Example 25 with ServiceInfo

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

the class TtsEngines method getEngineInfo.

private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
    ServiceInfo service = resolve.serviceInfo;
    if (service != null) {
        EngineInfo engine = new EngineInfo();
        // Using just the package name isn't great, since it disallows having
        // multiple engines in the same package, but that's what the existing API does.
        engine.name = service.packageName;
        CharSequence label = service.loadLabel(pm);
        engine.label = TextUtils.isEmpty(label) ? engine.name : label.toString();
        engine.icon = service.getIconResource();
        engine.priority = resolve.priority;
        engine.system = isSystemEngine(service);
        return engine;
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo)

Aggregations

ServiceInfo (android.content.pm.ServiceInfo)236 ResolveInfo (android.content.pm.ResolveInfo)120 Intent (android.content.Intent)99 ComponentName (android.content.ComponentName)95 PackageManager (android.content.pm.PackageManager)60 RemoteException (android.os.RemoteException)48 PendingIntent (android.app.PendingIntent)37 ApplicationInfo (android.content.pm.ApplicationInfo)35 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)32 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)29 IOException (java.io.IOException)28 ArrayList (java.util.ArrayList)27 InputMethodInfo (android.view.inputmethod.InputMethodInfo)21 PackageInfo (android.content.pm.PackageInfo)16 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)14 Service (android.app.Service)13 Point (android.graphics.Point)11 SpellCheckerInfo (android.view.textservice.SpellCheckerInfo)11 ArraySet (android.util.ArraySet)10 ActivityInfo (android.content.pm.ActivityInfo)9