Merge "Fix issue #21572679: API Review: ActivityOptions, usage time report" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
54d729b73f
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user