Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38eac112 authored by Peter Visontay's avatar Peter Visontay
Browse files

"Increase launch counts" functionality added to Applications.

Dependent on change I4125b34a1923fe5866c52bf77218974ed14a38bc.

Change-Id: If04c67f04bb72d8c4853c1f2de0f0e8150bf00c8
parent f676466d
Loading
Loading
Loading
Loading
+38 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.provider;

import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

@@ -26,10 +27,12 @@ import java.util.List;
/**
 * The Applications provider gives information about installed applications.
 *
 * @hide Only used by ApplicationsProvider so far.
 * @hide Only used by ApplicationsProvider and Launchers so far.
 */
public class Applications {

    private static final String TAG = "ApplicationsProvider";

    /**
     * The content authority for this provider.
     */
@@ -64,6 +67,26 @@ public class Applications {
    public static final String APPLICATION_DIR_TYPE =
            ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + APPLICATION_SUB_TYPE;

    /**
     * The path that should be used when an application is launched. The aim is
     * to help ApplicationsProvider keep track of which applications the user
     * uses the most, and improve app ranking based on this.
     */
    public static final String INCREASE_LAUNCH_COUNT_PATH = "increase_launch_count";

    public static final Uri INCREASE_LAUNCH_COUNT_URI = CONTENT_URI.buildUpon()
            .appendPath(INCREASE_LAUNCH_COUNT_PATH).build();

    /**
     * The package name parameter for the "increase launch count" call.
     */
    public static final String INCREASE_LAUNCH_COUNT_PACKAGE = "packageName";

    /**
     * The classname parameter for the "increase launch count" call.
     */
    public static final String INCREASE_LAUNCH_COUNT_CLASS = "className";

    /**
     * no public constructor since this is a utility class
     */
@@ -78,6 +101,20 @@ public class Applications {
        return resolver.query(searchUri, null, null, null, null);
    }

    /**
     * Increases the launch count of an application. Launch counts are used
     * by the ApplicationsProvider to improve ranking.
     */
    public static void increaseLaunchCount(
            final ContentResolver resolver, final ComponentName componentName) {

        ContentValues parameters = new ContentValues();
        parameters.put(INCREASE_LAUNCH_COUNT_PACKAGE, componentName.getPackageName());
        parameters.put(INCREASE_LAUNCH_COUNT_CLASS, componentName.getClassName());

        resolver.insert(INCREASE_LAUNCH_COUNT_URI, parameters);
    }

    /**
     * Gets the application component name from an application URI.
     *