Search in sources :

Example 61 with ActivityInfo

use of android.content.pm.ActivityInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ShortcutPickHelper method getFriendlyActivityName.

private String getFriendlyActivityName(Intent intent, boolean labelOnly) {
    ActivityInfo ai = intent.resolveActivityInfo(mPackageManager, PackageManager.GET_ACTIVITIES);
    String friendlyName = null;
    if (ai != null) {
        friendlyName = ai.loadLabel(mPackageManager).toString();
        if (friendlyName == null && !labelOnly) {
            friendlyName = ai.name;
        }
    }
    return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo)

Example 62 with ActivityInfo

use of android.content.pm.ActivityInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppListPreference method setComponentNames.

public void setComponentNames(ComponentName[] componentNames, ComponentName defaultCN, CharSequence[] summaries) {
    mSummaries = summaries;
    mType = TYPE_COMPONENT;
    // Look up all package names in PackageManager. Skip ones we can't find.
    PackageManager pm = getContext().getPackageManager();
    final int entryCount = componentNames.length + (mShowItemNone ? 1 : 0);
    List<CharSequence> applicationNames = new ArrayList<>(entryCount);
    List<CharSequence> validatedComponentNames = new ArrayList<>(entryCount);
    List<Drawable> entryDrawables = new ArrayList<>(entryCount);
    int selectedIndex = -1;
    for (int i = 0; i < componentNames.length; i++) {
        try {
            ActivityInfo activityInfo = AppGlobals.getPackageManager().getActivityInfo(componentNames[i], 0, mUserId);
            if (activityInfo == null)
                continue;
            applicationNames.add(activityInfo.loadLabel(pm));
            validatedComponentNames.add(componentNames[i].flattenToString());
            entryDrawables.add(activityInfo.loadIcon(pm));
            if (defaultCN != null && componentNames[i].equals(defaultCN)) {
                selectedIndex = i;
            }
        } catch (RemoteException e) {
        // Skip unknown packages.
        }
    }
    if (mShowItemNone) {
        applicationNames.add(getContext().getResources().getText(R.string.app_list_preference_none));
        validatedComponentNames.add(ITEM_NONE_VALUE);
        entryDrawables.add(getContext().getDrawable(R.drawable.ic_remove_circle));
    }
    setEntries(applicationNames.toArray(new CharSequence[applicationNames.size()]));
    setEntryValues(validatedComponentNames.toArray(new CharSequence[validatedComponentNames.size()]));
    mEntryDrawables = entryDrawables.toArray(new Drawable[entryDrawables.size()]);
    if (selectedIndex != -1) {
        setValueIndex(selectedIndex);
    } else {
        setValue(null);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) RemoteException(android.os.RemoteException)

Example 63 with ActivityInfo

use of android.content.pm.ActivityInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DefaultHomePreference method refreshHomeOptions.

public void refreshHomeOptions() {
    ArrayList<ResolveInfo> homeActivities = new ArrayList<>();
    PackageManager pm = getContext().getPackageManager();
    ComponentName currentDefaultHome = pm.getHomeActivities(homeActivities);
    ArrayList<ComponentName> components = new ArrayList<>();
    mAllHomeComponents.clear();
    List<CharSequence> summaries = new ArrayList<>();
    boolean mustSupportManagedProfile = hasManagedProfile();
    for (ResolveInfo candidate : homeActivities) {
        final ActivityInfo info = candidate.activityInfo;
        ComponentName activityName = new ComponentName(info.packageName, info.name);
        mAllHomeComponents.add(activityName);
        if (info.packageName.equals(mPackageName)) {
            continue;
        }
        components.add(activityName);
        if (mustSupportManagedProfile && !launcherHasManagedProfilesFeature(candidate, pm)) {
            summaries.add(getContext().getString(R.string.home_work_profile_not_supported));
        } else {
            summaries.add(null);
        }
    }
    setComponentNames(components.toArray(new ComponentName[0]), currentDefaultHome, summaries.toArray(new CharSequence[0]));
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName)

Example 64 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class NativeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    String libname = "main";
    String funcname = "ANativeActivity_onCreate";
    ActivityInfo ai;
    mIMM = getSystemService(InputMethodManager.class);
    getWindow().takeSurface(this);
    getWindow().takeInputQueue(this);
    getWindow().setFormat(PixelFormat.RGB_565);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mNativeContentView = new NativeContentView(this);
    mNativeContentView.mActivity = this;
    setContentView(mNativeContentView);
    mNativeContentView.requestFocus();
    mNativeContentView.getViewTreeObserver().addOnGlobalLayoutListener(this);
    try {
        ai = getPackageManager().getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA);
        if (ai.metaData != null) {
            String ln = ai.metaData.getString(META_DATA_LIB_NAME);
            if (ln != null)
                libname = ln;
            ln = ai.metaData.getString(META_DATA_FUNC_NAME);
            if (ln != null)
                funcname = ln;
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Error getting activity info", e);
    }
    BaseDexClassLoader classLoader = (BaseDexClassLoader) getClassLoader();
    String path = classLoader.findLibrary(libname);
    if (path == null) {
        throw new IllegalArgumentException("Unable to find native library " + libname + " using classloader: " + classLoader.toString());
    }
    byte[] nativeSavedState = savedInstanceState != null ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
    mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(), getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()), getAbsolutePath(getExternalFilesDir(null)), Build.VERSION.SDK_INT, getAssets(), nativeSavedState, classLoader, classLoader.getLdLibraryPath());
    if (mNativeHandle == 0) {
        throw new UnsatisfiedLinkError("Unable to load native library \"" + path + "\": " + getDlError());
    }
    super.onCreate(savedInstanceState);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) BaseDexClassLoader(dalvik.system.BaseDexClassLoader) PackageManager(android.content.pm.PackageManager) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 65 with ActivityInfo

use of android.content.pm.ActivityInfo in project DroidPlugin by DroidPluginTeam.

the class StaticProcessList method onCreate.

void onCreate(Context mHostContext) throws NameNotFoundException {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(CATEGORY_ACTIVITY_PROXY_STUB);
    intent.setPackage(mHostContext.getPackageName());
    PackageManager pm = mHostContext.getPackageManager();
    List<ResolveInfo> activities = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
    for (ResolveInfo activity : activities) {
        addActivityInfo(activity.activityInfo);
    }
    List<ResolveInfo> services = pm.queryIntentServices(intent, 0);
    for (ResolveInfo service : services) {
        addServiceInfo(service.serviceInfo);
    }
    PackageInfo packageInfo = pm.getPackageInfo(mHostContext.getPackageName(), PackageManager.GET_PROVIDERS);
    if (packageInfo.providers != null && packageInfo.providers.length > 0) {
        for (ProviderInfo providerInfo : packageInfo.providers) {
            if (providerInfo.name != null && providerInfo.name.startsWith(ContentProviderStub.class.getName())) {
                addProviderInfo(providerInfo);
            }
        }
    }
    mOtherProcessNames.clear();
    PackageInfo packageInfo1 = pm.getPackageInfo(mHostContext.getPackageName(), PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS | PackageManager.GET_SERVICES);
    if (packageInfo1.activities != null) {
        for (ActivityInfo info : packageInfo1.activities) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
    if (packageInfo1.receivers != null) {
        for (ActivityInfo info : packageInfo1.receivers) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
    if (packageInfo1.providers != null) {
        for (ProviderInfo info : packageInfo1.providers) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
    if (packageInfo1.services != null) {
        for (ServiceInfo info : packageInfo1.services) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo) PackageInfo(android.content.pm.PackageInfo) 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