Search in sources :

Example 56 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class TaskViewHeader method showAppOverlay.

/**
     * Shows the application overlay.
     */
private void showAppOverlay() {
    // Skip early if the task is invalid
    SystemServicesProxy ssp = Recents.getSystemServices();
    ComponentName cn = mTask.key.getComponent();
    int userId = mTask.key.userId;
    ActivityInfo activityInfo = ssp.getActivityInfo(cn, userId);
    if (activityInfo == null) {
        return;
    }
    // Inflate the overlay if necessary
    if (mAppOverlayView == null) {
        mAppOverlayView = (FrameLayout) Utilities.findViewStubById(this, R.id.app_overlay_stub).inflate();
        mAppOverlayView.setBackground(mOverlayBackground);
        mAppIconView = (ImageView) mAppOverlayView.findViewById(R.id.app_icon);
        mAppIconView.setOnClickListener(this);
        mAppIconView.setOnLongClickListener(this);
        mAppInfoView = (ImageView) mAppOverlayView.findViewById(R.id.app_info);
        mAppInfoView.setOnClickListener(this);
        mAppTitleView = (TextView) mAppOverlayView.findViewById(R.id.app_title);
        updateLayoutParams(mAppIconView, mAppTitleView, null, mAppInfoView);
    }
    // Update the overlay contents for the current app
    mAppTitleView.setText(ssp.getBadgedApplicationLabel(activityInfo.applicationInfo, userId));
    mAppTitleView.setTextColor(mTask.useLightOnPrimaryColor ? mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor);
    mAppIconView.setImageDrawable(ssp.getBadgedApplicationIcon(activityInfo.applicationInfo, userId));
    mAppInfoView.setImageDrawable(mTask.useLightOnPrimaryColor ? mLightInfoIcon : mDarkInfoIcon);
    mAppOverlayView.setVisibility(View.VISIBLE);
    int x = mIconView.getLeft() + mIconView.getWidth() / 2;
    int y = mIconView.getTop() + mIconView.getHeight() / 2;
    Animator revealAnim = ViewAnimationUtils.createCircularReveal(mAppOverlayView, x, y, 0, getWidth());
    revealAnim.setDuration(OVERLAY_REVEAL_DURATION);
    revealAnim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN);
    revealAnim.start();
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo) Animator(android.animation.Animator) ComponentName(android.content.ComponentName) Paint(android.graphics.Paint)

Example 57 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class PipManager method isSettingsShown.

private boolean isSettingsShown() {
    List<RunningTaskInfo> runningTasks;
    try {
        runningTasks = mActivityManager.getTasks(1, 0);
        if (runningTasks == null || runningTasks.size() == 0) {
            return false;
        }
    } catch (RemoteException e) {
        Log.d(TAG, "Failed to detect top activity", e);
        return false;
    }
    ComponentName topActivity = runningTasks.get(0).topActivity;
    for (Pair<String, String> componentName : sSettingsPackageAndClassNamePairList) {
        String packageName = componentName.first;
        if (topActivity.getPackageName().equals(packageName)) {
            String className = componentName.second;
            if (className == null || topActivity.getClassName().equals(className)) {
                return true;
            }
        }
    }
    return false;
}
Also used : ComponentName(android.content.ComponentName) RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo) RemoteException(android.os.RemoteException)

Example 58 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class WallpaperBackupAgent method parseWallpaperComponent.

private ComponentName parseWallpaperComponent(File wallpaperInfo, String sectionTag) {
    ComponentName name = null;
    try (FileInputStream stream = new FileInputStream(wallpaperInfo)) {
        final XmlPullParser parser = Xml.newPullParser();
        parser.setInput(stream, StandardCharsets.UTF_8.name());
        int type;
        do {
            type = parser.next();
            if (type == XmlPullParser.START_TAG) {
                String tag = parser.getName();
                if (sectionTag.equals(tag)) {
                    final String parsedName = parser.getAttributeValue(null, "component");
                    name = (parsedName != null) ? ComponentName.unflattenFromString(parsedName) : null;
                    break;
                }
            }
        } while (type != XmlPullParser.END_DOCUMENT);
    } catch (Exception e) {
        // Whoops; can't process the info file at all.  Report failure.
        Slog.w(TAG, "Failed to parse restored component: " + e.getMessage());
        return null;
    }
    return name;
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser) ComponentName(android.content.ComponentName) FileInputStream(java.io.FileInputStream) RemoteException(android.os.RemoteException) IOException(java.io.IOException)

Example 59 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class WallpaperBackupAgent method onRestoreFinished.

// We use the default onRestoreFile() implementation that will recreate our stage files,
// then post-process in onRestoreFinished() to apply the new wallpaper.
@Override
public void onRestoreFinished() {
    if (DEBUG) {
        Slog.v(TAG, "onRestoreFinished()");
    }
    final File filesDir = getFilesDir();
    final File infoStage = new File(filesDir, INFO_STAGE);
    final File imageStage = new File(filesDir, IMAGE_STAGE);
    final File lockImageStage = new File(filesDir, LOCK_IMAGE_STAGE);
    // If we restored separate lock imagery, the system wallpaper should be
    // applied as system-only; but if there's no separate lock image, make
    // sure to apply the restored system wallpaper as both.
    final int sysWhich = FLAG_SYSTEM | (lockImageStage.exists() ? 0 : FLAG_LOCK);
    try {
        // First off, revert to the factory state
        mWm.clear(FLAG_SYSTEM | FLAG_LOCK);
        // It is valid for the imagery to be absent; it means that we were not permitted
        // to back up the original image on the source device, or there was no user-supplied
        // wallpaper image present.
        restoreFromStage(imageStage, infoStage, "wp", sysWhich);
        restoreFromStage(lockImageStage, infoStage, "kwp", FLAG_LOCK);
        // And reset to the wallpaper service we should be using
        ComponentName wpService = parseWallpaperComponent(infoStage, "wp");
        if (servicePackageExists(wpService)) {
            if (DEBUG) {
                Slog.i(TAG, "Using wallpaper service " + wpService);
            }
            mWm.setWallpaperComponent(wpService, UserHandle.USER_SYSTEM);
        } else {
            if (DEBUG) {
                Slog.v(TAG, "Can't use wallpaper service " + wpService);
            }
        }
    } catch (Exception e) {
        Slog.e(TAG, "Unable to restore wallpaper: " + e.getMessage());
    } finally {
        if (DEBUG) {
            Slog.v(TAG, "Restore finished; clearing backup bookkeeping");
        }
        infoStage.delete();
        imageStage.delete();
        lockImageStage.delete();
        SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        prefs.edit().putInt(SYSTEM_GENERATION, -1).putInt(LOCK_GENERATION, -1).commit();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ComponentName(android.content.ComponentName) File(java.io.File) RemoteException(android.os.RemoteException) IOException(java.io.IOException)

Example 60 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class ActivityManagerService method dumpProcessOomList.

private static final boolean dumpProcessOomList(PrintWriter pw, ActivityManagerService service, List<ProcessRecord> origList, String prefix, String normalLabel, String persistentLabel, boolean inclDetails, String dumpPackage) {
    ArrayList<Pair<ProcessRecord, Integer>> list = new ArrayList<Pair<ProcessRecord, Integer>>(origList.size());
    for (int i = 0; i < origList.size(); i++) {
        ProcessRecord r = origList.get(i);
        if (dumpPackage != null && !r.pkgList.containsKey(dumpPackage)) {
            continue;
        }
        list.add(new Pair<ProcessRecord, Integer>(origList.get(i), i));
    }
    if (list.size() <= 0) {
        return false;
    }
    Comparator<Pair<ProcessRecord, Integer>> comparator = new Comparator<Pair<ProcessRecord, Integer>>() {

        @Override
        public int compare(Pair<ProcessRecord, Integer> object1, Pair<ProcessRecord, Integer> object2) {
            if (object1.first.setAdj != object2.first.setAdj) {
                return object1.first.setAdj > object2.first.setAdj ? -1 : 1;
            }
            if (object1.first.setProcState != object2.first.setProcState) {
                return object1.first.setProcState > object2.first.setProcState ? -1 : 1;
            }
            if (object1.second.intValue() != object2.second.intValue()) {
                return object1.second.intValue() > object2.second.intValue() ? -1 : 1;
            }
            return 0;
        }
    };
    Collections.sort(list, comparator);
    final long curRealtime = SystemClock.elapsedRealtime();
    final long realtimeSince = curRealtime - service.mLastPowerCheckRealtime;
    final long curUptime = SystemClock.uptimeMillis();
    final long uptimeSince = curUptime - service.mLastPowerCheckUptime;
    for (int i = list.size() - 1; i >= 0; i--) {
        ProcessRecord r = list.get(i).first;
        String oomAdj = ProcessList.makeOomAdjString(r.setAdj);
        char schedGroup;
        switch(r.setSchedGroup) {
            case ProcessList.SCHED_GROUP_BACKGROUND:
                schedGroup = 'B';
                break;
            case ProcessList.SCHED_GROUP_DEFAULT:
                schedGroup = 'F';
                break;
            case ProcessList.SCHED_GROUP_TOP_APP:
                schedGroup = 'T';
                break;
            default:
                schedGroup = '?';
                break;
        }
        char foreground;
        if (r.foregroundActivities) {
            foreground = 'A';
        } else if (r.foregroundServices) {
            foreground = 'S';
        } else {
            foreground = ' ';
        }
        String procState = ProcessList.makeProcStateString(r.curProcState);
        pw.print(prefix);
        pw.print(r.persistent ? persistentLabel : normalLabel);
        pw.print(" #");
        int num = (origList.size() - 1) - list.get(i).second;
        if (num < 10)
            pw.print(' ');
        pw.print(num);
        pw.print(": ");
        pw.print(oomAdj);
        pw.print(' ');
        pw.print(schedGroup);
        pw.print('/');
        pw.print(foreground);
        pw.print('/');
        pw.print(procState);
        pw.print(" trm:");
        if (r.trimMemoryLevel < 10)
            pw.print(' ');
        pw.print(r.trimMemoryLevel);
        pw.print(' ');
        pw.print(r.toShortString());
        pw.print(" (");
        pw.print(r.adjType);
        pw.println(')');
        if (r.adjSource != null || r.adjTarget != null) {
            pw.print(prefix);
            pw.print("    ");
            if (r.adjTarget instanceof ComponentName) {
                pw.print(((ComponentName) r.adjTarget).flattenToShortString());
            } else if (r.adjTarget != null) {
                pw.print(r.adjTarget.toString());
            } else {
                pw.print("{null}");
            }
            pw.print("<=");
            if (r.adjSource instanceof ProcessRecord) {
                pw.print("Proc{");
                pw.print(((ProcessRecord) r.adjSource).toShortString());
                pw.println("}");
            } else if (r.adjSource != null) {
                pw.println(r.adjSource.toString());
            } else {
                pw.println("{null}");
            }
        }
        if (inclDetails) {
            pw.print(prefix);
            pw.print("    ");
            pw.print("oom: max=");
            pw.print(r.maxAdj);
            pw.print(" curRaw=");
            pw.print(r.curRawAdj);
            pw.print(" setRaw=");
            pw.print(r.setRawAdj);
            pw.print(" cur=");
            pw.print(r.curAdj);
            pw.print(" set=");
            pw.println(r.setAdj);
            pw.print(prefix);
            pw.print("    ");
            pw.print("state: cur=");
            pw.print(ProcessList.makeProcStateString(r.curProcState));
            pw.print(" set=");
            pw.print(ProcessList.makeProcStateString(r.setProcState));
            pw.print(" lastPss=");
            DebugUtils.printSizeValue(pw, r.lastPss * 1024);
            pw.print(" lastSwapPss=");
            DebugUtils.printSizeValue(pw, r.lastSwapPss * 1024);
            pw.print(" lastCachedPss=");
            DebugUtils.printSizeValue(pw, r.lastCachedPss * 1024);
            pw.println();
            pw.print(prefix);
            pw.print("    ");
            pw.print("cached=");
            pw.print(r.cached);
            pw.print(" empty=");
            pw.print(r.empty);
            pw.print(" hasAboveClient=");
            pw.println(r.hasAboveClient);
            if (r.setProcState >= ActivityManager.PROCESS_STATE_SERVICE) {
                if (r.lastWakeTime != 0) {
                    long wtime;
                    BatteryStatsImpl stats = service.mBatteryStatsService.getActiveStatistics();
                    synchronized (stats) {
                        wtime = stats.getProcessWakeTime(r.info.uid, r.pid, curRealtime);
                    }
                    long timeUsed = wtime - r.lastWakeTime;
                    pw.print(prefix);
                    pw.print("    ");
                    pw.print("keep awake over ");
                    TimeUtils.formatDuration(realtimeSince, pw);
                    pw.print(" used ");
                    TimeUtils.formatDuration(timeUsed, pw);
                    pw.print(" (");
                    pw.print((timeUsed * 100) / realtimeSince);
                    pw.println("%)");
                }
                if (r.lastCpuTime != 0) {
                    long timeUsed = r.curCpuTime - r.lastCpuTime;
                    pw.print(prefix);
                    pw.print("    ");
                    pw.print("run cpu over ");
                    TimeUtils.formatDuration(uptimeSince, pw);
                    pw.print(" used ");
                    TimeUtils.formatDuration(timeUsed, pw);
                    pw.print(" (");
                    pw.print((timeUsed * 100) / uptimeSince);
                    pw.println("%)");
                }
            }
        }
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) BatteryStatsImpl(com.android.internal.os.BatteryStatsImpl) Point(android.graphics.Point) Comparator(java.util.Comparator) ComponentName(android.content.ComponentName) Pair(android.util.Pair)

Aggregations

ComponentName (android.content.ComponentName)2548 Intent (android.content.Intent)959 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)269 PendingIntent (android.app.PendingIntent)252 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)242 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)139 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)132 IBinder (android.os.IBinder)128 IOException (java.io.IOException)125 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)96 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)68