Search in sources :

Example 1 with ResolvedComponentInfo

use of com.android.internal.app.ResolverActivity.ResolvedComponentInfo in project android_frameworks_base by DirtyUnicorns.

the class ResolverComparator method compute.

public void compute(List<ResolvedComponentInfo> targets) {
    mScoredTargets.clear();
    final long recentSinceTime = mCurrentTime - RECENCY_TIME_PERIOD;
    long mostRecentlyUsedTime = recentSinceTime + 1;
    long mostTimeSpent = 1;
    int mostLaunched = 1;
    for (ResolvedComponentInfo target : targets) {
        final ScoredTarget scoredTarget = new ScoredTarget(target.getResolveInfoAt(0).activityInfo);
        mScoredTargets.put(target.name, scoredTarget);
        final UsageStats pkStats = mStats.get(target.name.getPackageName());
        if (pkStats != null) {
            // Persistent processes muck this up, so omit them too.
            if (!target.name.getPackageName().equals(mReferrerPackage) && !isPersistentProcess(target)) {
                final long lastTimeUsed = pkStats.getLastTimeUsed();
                scoredTarget.lastTimeUsed = lastTimeUsed;
                if (lastTimeUsed > mostRecentlyUsedTime) {
                    mostRecentlyUsedTime = lastTimeUsed;
                }
            }
            final long timeSpent = pkStats.getTotalTimeInForeground();
            scoredTarget.timeSpent = timeSpent;
            if (timeSpent > mostTimeSpent) {
                mostTimeSpent = timeSpent;
            }
            final int launched = pkStats.mLaunchCount;
            scoredTarget.launchCount = launched;
            if (launched > mostLaunched) {
                mostLaunched = launched;
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "compute - mostRecentlyUsedTime: " + mostRecentlyUsedTime + " mostTimeSpent: " + mostTimeSpent + " recentSinceTime: " + recentSinceTime + " mostLaunched: " + mostLaunched);
    }
    for (ScoredTarget target : mScoredTargets.values()) {
        final float recency = (float) Math.max(target.lastTimeUsed - recentSinceTime, 0) / (mostRecentlyUsedTime - recentSinceTime);
        final float recencyScore = recency * recency * RECENCY_MULTIPLIER;
        final float usageTimeScore = (float) target.timeSpent / mostTimeSpent;
        final float launchCountScore = (float) target.launchCount / mostLaunched;
        target.score = recencyScore + usageTimeScore + launchCountScore;
        if (DEBUG) {
            Log.d(TAG, "Scores: recencyScore: " + recencyScore + " usageTimeScore: " + usageTimeScore + " launchCountScore: " + launchCountScore + " - " + target);
        }
    }
}
Also used : UsageStats(android.app.usage.UsageStats) ResolvedComponentInfo(com.android.internal.app.ResolverActivity.ResolvedComponentInfo)

Example 2 with ResolvedComponentInfo

use of com.android.internal.app.ResolverActivity.ResolvedComponentInfo in project platform_frameworks_base by android.

the class ResolverComparator method compute.

public void compute(List<ResolvedComponentInfo> targets) {
    mScoredTargets.clear();
    final long recentSinceTime = mCurrentTime - RECENCY_TIME_PERIOD;
    long mostRecentlyUsedTime = recentSinceTime + 1;
    long mostTimeSpent = 1;
    int mostLaunched = 1;
    for (ResolvedComponentInfo target : targets) {
        final ScoredTarget scoredTarget = new ScoredTarget(target.getResolveInfoAt(0).activityInfo);
        mScoredTargets.put(target.name, scoredTarget);
        final UsageStats pkStats = mStats.get(target.name.getPackageName());
        if (pkStats != null) {
            // Persistent processes muck this up, so omit them too.
            if (!target.name.getPackageName().equals(mReferrerPackage) && !isPersistentProcess(target)) {
                final long lastTimeUsed = pkStats.getLastTimeUsed();
                scoredTarget.lastTimeUsed = lastTimeUsed;
                if (lastTimeUsed > mostRecentlyUsedTime) {
                    mostRecentlyUsedTime = lastTimeUsed;
                }
            }
            final long timeSpent = pkStats.getTotalTimeInForeground();
            scoredTarget.timeSpent = timeSpent;
            if (timeSpent > mostTimeSpent) {
                mostTimeSpent = timeSpent;
            }
            final int launched = pkStats.mLaunchCount;
            scoredTarget.launchCount = launched;
            if (launched > mostLaunched) {
                mostLaunched = launched;
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "compute - mostRecentlyUsedTime: " + mostRecentlyUsedTime + " mostTimeSpent: " + mostTimeSpent + " recentSinceTime: " + recentSinceTime + " mostLaunched: " + mostLaunched);
    }
    for (ScoredTarget target : mScoredTargets.values()) {
        final float recency = (float) Math.max(target.lastTimeUsed - recentSinceTime, 0) / (mostRecentlyUsedTime - recentSinceTime);
        final float recencyScore = recency * recency * RECENCY_MULTIPLIER;
        final float usageTimeScore = (float) target.timeSpent / mostTimeSpent;
        final float launchCountScore = (float) target.launchCount / mostLaunched;
        target.score = recencyScore + usageTimeScore + launchCountScore;
        if (DEBUG) {
            Log.d(TAG, "Scores: recencyScore: " + recencyScore + " usageTimeScore: " + usageTimeScore + " launchCountScore: " + launchCountScore + " - " + target);
        }
    }
}
Also used : UsageStats(android.app.usage.UsageStats) ResolvedComponentInfo(com.android.internal.app.ResolverActivity.ResolvedComponentInfo)

Example 3 with ResolvedComponentInfo

use of com.android.internal.app.ResolverActivity.ResolvedComponentInfo in project android_frameworks_base by AOSPA.

the class ResolverComparator method compute.

public void compute(List<ResolvedComponentInfo> targets) {
    mScoredTargets.clear();
    final long recentSinceTime = mCurrentTime - RECENCY_TIME_PERIOD;
    long mostRecentlyUsedTime = recentSinceTime + 1;
    long mostTimeSpent = 1;
    int mostLaunched = 1;
    for (ResolvedComponentInfo target : targets) {
        final ScoredTarget scoredTarget = new ScoredTarget(target.getResolveInfoAt(0).activityInfo);
        mScoredTargets.put(target.name, scoredTarget);
        final UsageStats pkStats = mStats.get(target.name.getPackageName());
        if (pkStats != null) {
            // Persistent processes muck this up, so omit them too.
            if (!target.name.getPackageName().equals(mReferrerPackage) && !isPersistentProcess(target)) {
                final long lastTimeUsed = pkStats.getLastTimeUsed();
                scoredTarget.lastTimeUsed = lastTimeUsed;
                if (lastTimeUsed > mostRecentlyUsedTime) {
                    mostRecentlyUsedTime = lastTimeUsed;
                }
            }
            final long timeSpent = pkStats.getTotalTimeInForeground();
            scoredTarget.timeSpent = timeSpent;
            if (timeSpent > mostTimeSpent) {
                mostTimeSpent = timeSpent;
            }
            final int launched = pkStats.mLaunchCount;
            scoredTarget.launchCount = launched;
            if (launched > mostLaunched) {
                mostLaunched = launched;
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "compute - mostRecentlyUsedTime: " + mostRecentlyUsedTime + " mostTimeSpent: " + mostTimeSpent + " recentSinceTime: " + recentSinceTime + " mostLaunched: " + mostLaunched);
    }
    for (ScoredTarget target : mScoredTargets.values()) {
        final float recency = (float) Math.max(target.lastTimeUsed - recentSinceTime, 0) / (mostRecentlyUsedTime - recentSinceTime);
        final float recencyScore = recency * recency * RECENCY_MULTIPLIER;
        final float usageTimeScore = (float) target.timeSpent / mostTimeSpent;
        final float launchCountScore = (float) target.launchCount / mostLaunched;
        target.score = recencyScore + usageTimeScore + launchCountScore;
        if (DEBUG) {
            Log.d(TAG, "Scores: recencyScore: " + recencyScore + " usageTimeScore: " + usageTimeScore + " launchCountScore: " + launchCountScore + " - " + target);
        }
    }
}
Also used : UsageStats(android.app.usage.UsageStats) ResolvedComponentInfo(com.android.internal.app.ResolverActivity.ResolvedComponentInfo)

Example 4 with ResolvedComponentInfo

use of com.android.internal.app.ResolverActivity.ResolvedComponentInfo in project android_frameworks_base by ResurrectionRemix.

the class ResolverComparator method compute.

public void compute(List<ResolvedComponentInfo> targets) {
    mScoredTargets.clear();
    final long recentSinceTime = mCurrentTime - RECENCY_TIME_PERIOD;
    long mostRecentlyUsedTime = recentSinceTime + 1;
    long mostTimeSpent = 1;
    int mostLaunched = 1;
    for (ResolvedComponentInfo target : targets) {
        final ScoredTarget scoredTarget = new ScoredTarget(target.getResolveInfoAt(0).activityInfo);
        mScoredTargets.put(target.name, scoredTarget);
        final UsageStats pkStats = mStats.get(target.name.getPackageName());
        if (pkStats != null) {
            // Persistent processes muck this up, so omit them too.
            if (!target.name.getPackageName().equals(mReferrerPackage) && !isPersistentProcess(target)) {
                final long lastTimeUsed = pkStats.getLastTimeUsed();
                scoredTarget.lastTimeUsed = lastTimeUsed;
                if (lastTimeUsed > mostRecentlyUsedTime) {
                    mostRecentlyUsedTime = lastTimeUsed;
                }
            }
            final long timeSpent = pkStats.getTotalTimeInForeground();
            scoredTarget.timeSpent = timeSpent;
            if (timeSpent > mostTimeSpent) {
                mostTimeSpent = timeSpent;
            }
            final int launched = pkStats.mLaunchCount;
            scoredTarget.launchCount = launched;
            if (launched > mostLaunched) {
                mostLaunched = launched;
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "compute - mostRecentlyUsedTime: " + mostRecentlyUsedTime + " mostTimeSpent: " + mostTimeSpent + " recentSinceTime: " + recentSinceTime + " mostLaunched: " + mostLaunched);
    }
    for (ScoredTarget target : mScoredTargets.values()) {
        final float recency = (float) Math.max(target.lastTimeUsed - recentSinceTime, 0) / (mostRecentlyUsedTime - recentSinceTime);
        final float recencyScore = recency * recency * RECENCY_MULTIPLIER;
        final float usageTimeScore = (float) target.timeSpent / mostTimeSpent;
        final float launchCountScore = (float) target.launchCount / mostLaunched;
        target.score = recencyScore + usageTimeScore + launchCountScore;
        if (DEBUG) {
            Log.d(TAG, "Scores: recencyScore: " + recencyScore + " usageTimeScore: " + usageTimeScore + " launchCountScore: " + launchCountScore + " - " + target);
        }
    }
}
Also used : UsageStats(android.app.usage.UsageStats) ResolvedComponentInfo(com.android.internal.app.ResolverActivity.ResolvedComponentInfo)

Example 5 with ResolvedComponentInfo

use of com.android.internal.app.ResolverActivity.ResolvedComponentInfo in project android_frameworks_base by crdroidandroid.

the class ResolverComparator method compute.

public void compute(List<ResolvedComponentInfo> targets) {
    mScoredTargets.clear();
    final long recentSinceTime = mCurrentTime - RECENCY_TIME_PERIOD;
    long mostRecentlyUsedTime = recentSinceTime + 1;
    long mostTimeSpent = 1;
    int mostLaunched = 1;
    for (ResolvedComponentInfo target : targets) {
        final ScoredTarget scoredTarget = new ScoredTarget(target.getResolveInfoAt(0).activityInfo);
        mScoredTargets.put(target.name, scoredTarget);
        final UsageStats pkStats = mStats.get(target.name.getPackageName());
        if (pkStats != null) {
            // Persistent processes muck this up, so omit them too.
            if (!target.name.getPackageName().equals(mReferrerPackage) && !isPersistentProcess(target)) {
                final long lastTimeUsed = pkStats.getLastTimeUsed();
                scoredTarget.lastTimeUsed = lastTimeUsed;
                if (lastTimeUsed > mostRecentlyUsedTime) {
                    mostRecentlyUsedTime = lastTimeUsed;
                }
            }
            final long timeSpent = pkStats.getTotalTimeInForeground();
            scoredTarget.timeSpent = timeSpent;
            if (timeSpent > mostTimeSpent) {
                mostTimeSpent = timeSpent;
            }
            final int launched = pkStats.mLaunchCount;
            scoredTarget.launchCount = launched;
            if (launched > mostLaunched) {
                mostLaunched = launched;
            }
        }
    }
    if (DEBUG) {
        Log.d(TAG, "compute - mostRecentlyUsedTime: " + mostRecentlyUsedTime + " mostTimeSpent: " + mostTimeSpent + " recentSinceTime: " + recentSinceTime + " mostLaunched: " + mostLaunched);
    }
    for (ScoredTarget target : mScoredTargets.values()) {
        final float recency = (float) Math.max(target.lastTimeUsed - recentSinceTime, 0) / (mostRecentlyUsedTime - recentSinceTime);
        final float recencyScore = recency * recency * RECENCY_MULTIPLIER;
        final float usageTimeScore = (float) target.timeSpent / mostTimeSpent;
        final float launchCountScore = (float) target.launchCount / mostLaunched;
        target.score = recencyScore + usageTimeScore + launchCountScore;
        if (DEBUG) {
            Log.d(TAG, "Scores: recencyScore: " + recencyScore + " usageTimeScore: " + usageTimeScore + " launchCountScore: " + launchCountScore + " - " + target);
        }
    }
}
Also used : UsageStats(android.app.usage.UsageStats) ResolvedComponentInfo(com.android.internal.app.ResolverActivity.ResolvedComponentInfo)

Aggregations

UsageStats (android.app.usage.UsageStats)5 ResolvedComponentInfo (com.android.internal.app.ResolverActivity.ResolvedComponentInfo)5