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

Commit 0d186240 authored by Rajeev Kumar's avatar Rajeev Kumar Committed by Automerger Merge Worker
Browse files

Merge changes I0bd9becd,I1f2967dc into sc-dev am: 2c293a43

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13604966

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I626d62a5775a0d69fed5fab99b5986f2a5f28037
parents 98d55d20 2c293a43
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -273,10 +273,12 @@ public final class JobServiceContext implements ServiceConnection {
                    // another binding flag for that.
                    bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
                            | Context.BIND_ALMOST_PERCEPTIBLE
                            | Context.BIND_ALLOW_NETWORK_ACCESS;
                            | Context.BIND_ALLOW_NETWORK_ACCESS
                            | Context.BIND_NOT_APP_COMPONENT_USAGE;
                } else {
                    bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
                            | Context.BIND_NOT_PERCEPTIBLE;
                            | Context.BIND_NOT_PERCEPTIBLE
                            | Context.BIND_NOT_APP_COMPONENT_USAGE;
                }
                binding = mContext.bindServiceAsUser(intent, this, bindFlags,
                        UserHandle.of(job.getUserId()));
+10 −1
Original line number Diff line number Diff line
@@ -333,11 +333,20 @@ public final class UsageEvents implements Parcelable {
         */
        public static final int LOCUS_ID_SET = 30;

        /**
         * An event type denoting that a component in the package has been used (e.g. broadcast
         * receiver, service, content provider). This generally matches up with usage that would
         * cause an app to leave force stop. The component itself is not provided as we are only
         * interested in whether the package is used, not the component itself.
         * @hide
         */
        public static final int APP_COMPONENT_USED = 31;

        /**
         * Keep in sync with the greatest event type value.
         * @hide
         */
        public static final int MAX_EVENT_TYPE = 30;
        public static final int MAX_EVENT_TYPE = 31;

        /** @hide */
        public static final int FLAG_IS_PACKAGE_INSTANT_APP = 1 << 0;
+9 −0
Original line number Diff line number Diff line
@@ -369,6 +369,15 @@ public abstract class Context {
    /***********    Public flags above this line ***********/
    /***********    Hidden flags below this line ***********/

    /**
     * Flag for {@link #bindService}: This flag is only intended to be used by the system to
     * indicate that a service binding is not considered as real package component usage and should
     * not generate a {@link android.app.usage.UsageEvents.Event#APP_COMPONENT_USED} event in usage
     * stats.
     * @hide
     */
    public static final int BIND_NOT_APP_COMPONENT_USAGE = 0x00008000;

    /**
     * Flag for {@link #bindService}: allow the process hosting the target service to be treated
     * as if it's as important as a perceptible app to the user and avoid the oom killer killing
+9 −9
Original line number Diff line number Diff line
@@ -78,15 +78,15 @@ public class UsageStatsPersistenceTest {
            "VALID_FLAG_BITS", "UNASSIGNED_TOKEN", "MAX_EVENT_TYPE"};
    // All fields in this list are final constants defining event types and not persisted
    private static final String[] EVENT_TYPES = {"NONE", "ACTIVITY_DESTROYED", "ACTIVITY_PAUSED",
            "ACTIVITY_RESUMED", "ACTIVITY_STOPPED", "CHOOSER_ACTION", "CONFIGURATION_CHANGE",
            "CONTINUE_PREVIOUS_DAY", "CONTINUING_FOREGROUND_SERVICE", "DEVICE_SHUTDOWN",
            "DEVICE_STARTUP", "END_OF_DAY", "FLUSH_TO_DISK", "FOREGROUND_SERVICE_START",
            "FOREGROUND_SERVICE_STOP", "KEYGUARD_HIDDEN", "KEYGUARD_SHOWN", "LOCUS_ID_SET",
            "MOVE_TO_BACKGROUND", "MOVE_TO_FOREGROUND", "NOTIFICATION_INTERRUPTION",
            "NOTIFICATION_SEEN", "ROLLOVER_FOREGROUND_SERVICE", "SCREEN_INTERACTIVE",
            "SCREEN_NON_INTERACTIVE", "SHORTCUT_INVOCATION", "SLICE_PINNED", "SLICE_PINNED_PRIV",
            "STANDBY_BUCKET_CHANGED", "SYSTEM_INTERACTION", "USER_INTERACTION", "USER_STOPPED",
            "USER_UNLOCKED"};
            "ACTIVITY_RESUMED", "ACTIVITY_STOPPED", "APP_COMPONENT_USED", "CHOOSER_ACTION",
            "CONFIGURATION_CHANGE", "CONTINUE_PREVIOUS_DAY", "CONTINUING_FOREGROUND_SERVICE",
            "DEVICE_SHUTDOWN", "DEVICE_STARTUP", "END_OF_DAY", "FLUSH_TO_DISK",
            "FOREGROUND_SERVICE_START", "FOREGROUND_SERVICE_STOP", "KEYGUARD_HIDDEN",
            "KEYGUARD_SHOWN", "LOCUS_ID_SET", "MOVE_TO_BACKGROUND", "MOVE_TO_FOREGROUND",
            "NOTIFICATION_INTERRUPTION", "NOTIFICATION_SEEN", "ROLLOVER_FOREGROUND_SERVICE",
            "SCREEN_INTERACTIVE", "SCREEN_NON_INTERACTIVE", "SHORTCUT_INVOCATION", "SLICE_PINNED",
            "SLICE_PINNED_PRIV", "STANDBY_BUCKET_CHANGED", "SYSTEM_INTERACTION", "USER_INTERACTION",
            "USER_STOPPED", "USER_UNLOCKED"};

    @Test
    public void testUsageEventsFields() {
+13 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import android.app.Service;
import android.app.ServiceStartArgs;
import android.app.admin.DevicePolicyEventLogger;
import android.app.compat.CompatChanges;
import android.app.usage.UsageEvents;
import android.appwidget.AppWidgetManagerInternal;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
@@ -2504,6 +2505,10 @@ public final class ActiveServices {
                s.setAllowedBgFgsStartsByBinding(true);
            }

            if ((flags & Context.BIND_NOT_APP_COMPONENT_USAGE) != 0) {
                s.isNotAppComponentUsage = true;
            }

            if (s.app != null) {
                updateServiceClientActivitiesLocked(s.app.mServices, c, true);
            }
@@ -3372,6 +3377,14 @@ public final class ActiveServices {
            return msg;
        }

        // Report usage if binding is from a different package except for explicitly exempted
        // bindings
        if (!r.appInfo.packageName.equals(r.mRecentCallingPackage)
                && !r.isNotAppComponentUsage) {
            mAm.mUsageStatsService.reportEvent(
                    r.packageName, r.userId, UsageEvents.Event.APP_COMPONENT_USED);
        }

        // Service is now being launched, its package can't be stopped.
        try {
            AppGlobals.getPackageManager().setPackageStoppedState(
Loading