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

Commit 54d729b7 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #21572679: API Review: ActivityOptions, usage time report" into mnc-dev

parents 383ce580 67ba2c7f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3762,8 +3762,8 @@ package android.app {
    method public void requestUsageTimeReport(android.app.PendingIntent);
    method public android.os.Bundle toBundle();
    method public void update(android.app.ActivityOptions);
    field public static final java.lang.String EXTRA_USAGE_REPORT_PACKAGES = "android.package";
    field public static final java.lang.String EXTRA_USAGE_REPORT_TIME = "android.time";
    field public static final java.lang.String EXTRA_USAGE_TIME_REPORT = "android.usage_time";
    field public static final java.lang.String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages";
  }
  public class AlarmManager {
+2 −2
Original line number Diff line number Diff line
@@ -3855,8 +3855,8 @@ package android.app {
    method public void requestUsageTimeReport(android.app.PendingIntent);
    method public android.os.Bundle toBundle();
    method public void update(android.app.ActivityOptions);
    field public static final java.lang.String EXTRA_USAGE_REPORT_PACKAGES = "android.package";
    field public static final java.lang.String EXTRA_USAGE_REPORT_TIME = "android.time";
    field public static final java.lang.String EXTRA_USAGE_TIME_REPORT = "android.usage_time";
    field public static final java.lang.String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages";
  }
  public class AlarmManager {
+4 −4
Original line number Diff line number Diff line
@@ -41,16 +41,16 @@ public class ActivityOptions {

    /**
     * A long in the extras delivered by {@link #requestUsageTimeReport} that contains
     * the total time (in ms) the user spent in the app.
     * the total time (in ms) the user spent in the app flow.
     */
    public static final String EXTRA_USAGE_REPORT_TIME = "android.time";
    public static final String EXTRA_USAGE_TIME_REPORT = "android.usage_time";

    /**
     * A Bundle in the extras delivered by {@link #requestUsageTimeReport} that contains
     * detailed information about the time spent in each package associated with the app;
     * each key is a package name, whose value is a long containing the time (in ms).
     */
    public static final String EXTRA_USAGE_REPORT_PACKAGES = "android.package";
    public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages";

    /**
     * The package name that created the options.
@@ -915,7 +915,7 @@ public class ActivityOptions {
    /**
     * Ask the the system track that time the user spends in the app being launched, and
     * report it back once done.  The report will be sent to the given receiver, with
     * the extras {@link #EXTRA_USAGE_REPORT_TIME} and {@link #EXTRA_USAGE_REPORT_PACKAGES}
     * the extras {@link #EXTRA_USAGE_TIME_REPORT} and {@link #EXTRA_USAGE_TIME_REPORT_PACKAGES}
     * filled in.
     *
     * <p>The time interval tracked is from launching this activity until the user leaves
+2 −2
Original line number Diff line number Diff line
@@ -80,12 +80,12 @@ public class AppTimeTracker {
    public void deliverResult(Context context) {
        stop();
        Bundle extras = new Bundle();
        extras.putLong(ActivityOptions.EXTRA_USAGE_REPORT_TIME, mTotalTime);
        extras.putLong(ActivityOptions.EXTRA_USAGE_TIME_REPORT, mTotalTime);
        Bundle pkgs = new Bundle();
        for (int i=mPackageTimes.size()-1; i>=0; i--) {
            pkgs.putLong(mPackageTimes.keyAt(i), mPackageTimes.valueAt(i).value);
        }
        extras.putBundle(ActivityOptions.EXTRA_USAGE_REPORT_PACKAGES, pkgs);
        extras.putBundle(ActivityOptions.EXTRA_USAGE_TIME_REPORT_PACKAGES, pkgs);
        Intent fillinIntent = new Intent();
        fillinIntent.putExtras(extras);
        try {
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ public class TrackTimeReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle data = intent.getExtras();
        data.getLong(ActivityOptions.EXTRA_USAGE_REPORT_TIME);
        data.getLong(ActivityOptions.EXTRA_USAGE_TIME_REPORT);
        Log.i("ActivityTest", "Received time: " + data);
    }
}