Search in sources :

Example 11 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.

the class MemoryUsageTest method getPss.

private int getPss(String processName) {
    ActivityManager am = (ActivityManager) getInstrumentation().getContext().getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> apps = am.getRunningAppProcesses();
    for (RunningAppProcessInfo proc : apps) {
        if (!proc.processName.equals(processName)) {
            continue;
        }
        int[] pids = { proc.pid };
        MemoryInfo meminfo = am.getProcessMemoryInfo(pids)[0];
        return meminfo.getTotalPss();
    }
    return -1;
}
Also used : MemoryInfo(android.os.Debug.MemoryInfo) RunningAppProcessInfo(android.app.ActivityManager.RunningAppProcessInfo) ActivityManager(android.app.ActivityManager) IActivityManager(android.app.IActivityManager)

Example 12 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.

the class ExtendedPropertiesUtils method getAppInfoFromPID.

/**
     * Returns an {@link ApplicationInfo}, with the given PID.
     *
     * @param  pid  the application PID
     * @return application info
     */
public static ApplicationInfo getAppInfoFromPID(int pid) {
    if (isInitialized()) {
        List mProcessList = ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses();
        Iterator mProcessListIt = mProcessList.iterator();
        while (mProcessListIt.hasNext()) {
            ActivityManager.RunningAppProcessInfo mAppInfo = (ActivityManager.RunningAppProcessInfo) (mProcessListIt.next());
            if (mAppInfo.pid == pid) {
                return getAppInfoFromPackageName(mAppInfo.processName);
            }
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ActivityManager(android.app.ActivityManager)

Example 13 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.

the class RecentTasksLoader method loadThumbnailAndIcon.

void loadThumbnailAndIcon(TaskDescription td) {
    final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    final PackageManager pm = mContext.getPackageManager();
    Bitmap thumbnail = am.getTaskTopThumbnail(td.persistentTaskId);
    Drawable icon = getFullResIcon(td.resolveInfo, pm);
    if (DEBUG)
        Log.v(TAG, "Loaded bitmap for task " + td + ": " + thumbnail);
    synchronized (td) {
        if (thumbnail != null) {
            td.setThumbnail(thumbnail);
        } else {
            td.setThumbnail(mDefaultThumbnailBackground);
        }
        if (icon != null) {
            td.setIcon(icon);
        }
        td.setLoaded(true);
    }
}
Also used : Bitmap(android.graphics.Bitmap) PackageManager(android.content.pm.PackageManager) Drawable(android.graphics.drawable.Drawable) ActivityManager(android.app.ActivityManager)

Example 14 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.

the class RecentsPanelView method handleSwipe.

public void handleSwipe(View view) {
    TaskDescription ad = ((ViewHolder) view.getTag()).taskDescription;
    if (ad == null) {
        Log.v(TAG, "Not able to find activity description for swiped task; view=" + view + " tag=" + view.getTag());
        return;
    }
    if (DEBUG)
        Log.v(TAG, "Jettison " + ad.getLabel());
    mRecentTaskDescriptions.remove(ad);
    mRecentTasksLoader.remove(ad);
    if (mRecentTaskDescriptions.size() == 0) {
        dismissAndGoBack();
    }
    // Currently, either direction means the same thing, so ignore direction and remove
    // the task.
    final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    if (am != null) {
        am.removeTask(ad.persistentTaskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
        // Accessibility feedback
        setContentDescription(mContext.getString(R.string.accessibility_recents_item_dismissed, ad.getLabel()));
        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
        setContentDescription(null);
    }
}
Also used : ActivityManager(android.app.ActivityManager)

Example 15 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ParanoidAndroid.

the class RecentsPanelView method handleOnClick.

public void handleOnClick(View view) {
    ViewHolder holder = (ViewHolder) view.getTag();
    TaskDescription ad = holder.taskDescription;
    final Context context = view.getContext();
    final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    Bitmap bm = holder.thumbnailViewImageBitmap;
    boolean usingDrawingCache;
    if (bm.getWidth() == holder.thumbnailViewImage.getWidth() && bm.getHeight() == holder.thumbnailViewImage.getHeight()) {
        usingDrawingCache = false;
    } else {
        holder.thumbnailViewImage.setDrawingCacheEnabled(true);
        bm = holder.thumbnailViewImage.getDrawingCache();
        usingDrawingCache = true;
    }
    Bundle opts = (bm == null) ? null : ActivityOptions.makeThumbnailScaleUpAnimation(holder.thumbnailViewImage, bm, 0, 0, null).toBundle();
    show(false);
    Intent intent = ad.intent;
    boolean floating = (intent.getFlags() & Intent.FLAG_FLOATING_WINDOW) == Intent.FLAG_FLOATING_WINDOW;
    if (ad.taskId >= 0 && !floating) {
        // This is an active task; it should just go to the foreground.
        am.moveTaskToFront(ad.taskId, ActivityManager.MOVE_TASK_WITH_HOME, opts);
    } else {
        boolean backPressed = mRecentsActivity != null && mRecentsActivity.mBackPressed;
        if (!floating || !backPressed) {
            intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME | Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        if (DEBUG)
            Log.v(TAG, "Starting activity " + intent);
        if (floating && mRecentsActivity != null) {
            mRecentsActivity.finish();
        }
        try {
            context.startActivityAsUser(intent, opts, new UserHandle(UserHandle.USER_CURRENT));
        } catch (SecurityException e) {
            Log.e(TAG, "Recents does not have the permission to launch " + intent, e);
        }
    }
    if (usingDrawingCache) {
        holder.thumbnailViewImage.setDrawingCacheEnabled(false);
    }
}
Also used : Context(android.content.Context) Bitmap(android.graphics.Bitmap) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager)

Aggregations

ActivityManager (android.app.ActivityManager)612 Intent (android.content.Intent)61 RunningAppProcessInfo (android.app.ActivityManager.RunningAppProcessInfo)55 PackageManager (android.content.pm.PackageManager)50 Context (android.content.Context)47 ComponentName (android.content.ComponentName)44 RunningServiceInfo (android.app.ActivityManager.RunningServiceInfo)36 ArrayList (java.util.ArrayList)31 View (android.view.View)29 IOException (java.io.IOException)29 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)27 SuppressLint (android.annotation.SuppressLint)26 ImageView (android.widget.ImageView)25 TextView (android.widget.TextView)25 IActivityManager (android.app.IActivityManager)19 Point (android.graphics.Point)19 RemoteException (android.os.RemoteException)19 MemoryInfo (android.app.ActivityManager.MemoryInfo)18 Bitmap (android.graphics.Bitmap)18 AdapterView (android.widget.AdapterView)18