Search in sources :

Example 11 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodInfo method buildDummyResolveInfo.

private static ResolveInfo buildDummyResolveInfo(String packageName, String className, CharSequence label) {
    ResolveInfo ri = new ResolveInfo();
    ServiceInfo si = new ServiceInfo();
    ApplicationInfo ai = new ApplicationInfo();
    ai.packageName = packageName;
    ai.enabled = true;
    si.applicationInfo = ai;
    si.enabled = true;
    si.packageName = packageName;
    si.name = className;
    si.exported = true;
    si.nonLocalizedLabel = label;
    ri.serviceInfo = si;
    return ri;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 12 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodUtils method setNonSelectedSystemImesDisabledUntilUsed.

public static void setNonSelectedSystemImesDisabledUntilUsed(PackageManager packageManager, List<InputMethodInfo> enabledImis) {
    if (DEBUG) {
        Slog.d(TAG, "setNonSelectedSystemImesDisabledUntilUsed");
    }
    final String[] systemImesDisabledUntilUsed = Resources.getSystem().getStringArray(com.android.internal.R.array.config_disabledUntilUsedPreinstalledImes);
    if (systemImesDisabledUntilUsed == null || systemImesDisabledUntilUsed.length == 0) {
        return;
    }
    // Only the current spell checker should be treated as an enabled one.
    final SpellCheckerInfo currentSpellChecker = TextServicesManager.getInstance().getCurrentSpellChecker();
    for (final String packageName : systemImesDisabledUntilUsed) {
        if (DEBUG) {
            Slog.d(TAG, "check " + packageName);
        }
        boolean enabledIme = false;
        for (int j = 0; j < enabledImis.size(); ++j) {
            final InputMethodInfo imi = enabledImis.get(j);
            if (packageName.equals(imi.getPackageName())) {
                enabledIme = true;
                break;
            }
        }
        if (enabledIme) {
            // enabled ime. skip
            continue;
        }
        if (currentSpellChecker != null && packageName.equals(currentSpellChecker.getPackageName())) {
            // enabled spell checker. skip
            if (DEBUG) {
                Slog.d(TAG, packageName + " is the current spell checker. skip");
            }
            continue;
        }
        ApplicationInfo ai = null;
        try {
            ai = packageManager.getApplicationInfo(packageName, PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
        } catch (NameNotFoundException e) {
            Slog.w(TAG, "NameNotFoundException: " + packageName, e);
        }
        if (ai == null) {
            // No app found for packageName
            continue;
        }
        final boolean isSystemPackage = (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
        if (!isSystemPackage) {
            continue;
        }
        setDisabledUntilUsed(packageManager, packageName);
    }
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) InputMethodInfo(android.view.inputmethod.InputMethodInfo) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 13 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.

the class HeavyWeightSwitcherActivity method setIconAndText.

void setIconAndText(int iconId, int actionId, int descriptionId, String packageName, int actionStr, int descriptionStr) {
    CharSequence appName = "";
    Drawable appIcon = null;
    if (mCurApp != null) {
        try {
            ApplicationInfo info = getPackageManager().getApplicationInfo(packageName, 0);
            appName = info.loadLabel(getPackageManager());
            appIcon = info.loadIcon(getPackageManager());
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
    setDrawable(iconId, appIcon);
    setText(actionId, getString(actionStr, appName));
    setText(descriptionId, getText(descriptionStr));
}
Also used : PackageManager(android.content.pm.PackageManager) Drawable(android.graphics.drawable.Drawable) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 14 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.

the class AppSecurityPermissions method setPermissions.

private void setPermissions(List<MyPermissionInfo> permList) {
    if (permList != null) {
        // First pass to group permissions
        for (MyPermissionInfo pInfo : permList) {
            if (localLOGV)
                Log.i(TAG, "Processing permission:" + pInfo.name);
            if (!isDisplayablePermission(pInfo, pInfo.mNewReqFlags, pInfo.mExistingReqFlags)) {
                if (localLOGV)
                    Log.i(TAG, "Permission:" + pInfo.name + " is not displayable");
                continue;
            }
            MyPermissionGroupInfo group = mPermGroups.get(pInfo.group);
            if (group != null) {
                pInfo.mLabel = pInfo.loadLabel(mPm);
                addPermToList(group.mAllPermissions, pInfo);
                if (pInfo.mNew) {
                    addPermToList(group.mNewPermissions, pInfo);
                }
                if ((group.flags & PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) {
                    addPermToList(group.mPersonalPermissions, pInfo);
                } else {
                    addPermToList(group.mDevicePermissions, pInfo);
                }
            }
        }
    }
    for (MyPermissionGroupInfo pgrp : mPermGroups.values()) {
        if (pgrp.labelRes != 0 || pgrp.nonLocalizedLabel != null) {
            pgrp.mLabel = pgrp.loadLabel(mPm);
        } else {
            ApplicationInfo app;
            try {
                app = mPm.getApplicationInfo(pgrp.packageName, 0);
                pgrp.mLabel = app.loadLabel(mPm);
            } catch (NameNotFoundException e) {
                pgrp.mLabel = pgrp.loadLabel(mPm);
            }
        }
        mPermGroupsList.add(pgrp);
    }
    Collections.sort(mPermGroupsList, mPermGroupComparator);
    if (localLOGV) {
        for (MyPermissionGroupInfo grp : mPermGroupsList) {
            Log.i(TAG, "Group " + grp.name + " personal=" + ((grp.flags & PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) + " priority=" + grp.priority);
        }
    }
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 15 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodTest method createDummyInputMethodInfo.

private static InputMethodInfo createDummyInputMethodInfo(String packageName, String name, CharSequence label, boolean isAuxIme, boolean isDefault, List<InputMethodSubtype> subtypes) {
    final ResolveInfo ri = new ResolveInfo();
    final ServiceInfo si = new ServiceInfo();
    final ApplicationInfo ai = new ApplicationInfo();
    ai.packageName = packageName;
    ai.enabled = true;
    ai.flags |= ApplicationInfo.FLAG_SYSTEM;
    si.applicationInfo = ai;
    si.enabled = true;
    si.packageName = packageName;
    si.name = name;
    si.exported = true;
    si.nonLocalizedLabel = label;
    ri.serviceInfo = si;
    return new InputMethodInfo(ri, isAuxIme, "", subtypes, 1, isDefault);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ApplicationInfo(android.content.pm.ApplicationInfo) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Aggregations

ApplicationInfo (android.content.pm.ApplicationInfo)908 PackageManager (android.content.pm.PackageManager)339 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)272 RemoteException (android.os.RemoteException)204 Intent (android.content.Intent)100 ArrayList (java.util.ArrayList)98 IPackageManager (android.content.pm.IPackageManager)96 IOException (java.io.IOException)80 PackageInfo (android.content.pm.PackageInfo)78 ResolveInfo (android.content.pm.ResolveInfo)72 File (java.io.File)64 ComponentName (android.content.ComponentName)52 Bundle (android.os.Bundle)48 Context (android.content.Context)47 PendingIntent (android.app.PendingIntent)43 Drawable (android.graphics.drawable.Drawable)43 UserInfo (android.content.pm.UserInfo)40 ActivityInfo (android.content.pm.ActivityInfo)35 ServiceInfo (android.content.pm.ServiceInfo)35 Resources (android.content.res.Resources)32