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

Commit f36f22de authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Add constants "short service" foreground service

Aslo add the timeout callback.

All APIs are still hidden.

Bug: 257270313
Test: Build
Change-Id: I9868de22a343e97c83cc2524cf81aec159aa62ab
parent 890e92f4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1053,4 +1053,16 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
            return sStartForegroundServiceStackTraces.get(className);
        }
    }

    /**
     * Callback called on timeout for {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE}.
     *
     * TODO Implement it
     * TODO Javadoc
     *
     * @param startId
     * @hide
     */
    public void onTimeout(int startId) {
    }
}
+25 −0
Original line number Diff line number Diff line
@@ -363,6 +363,28 @@ public class ServiceInfo extends ComponentInfo
    )
    public static final int FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED = 1 << 10;

    /**
     * Foreground service type corresponding to {@code shortService} in
     * the {@link android.R.attr#foregroundServiceType} attribute.
     *
     * TODO Implement it
     *
     * TODO Expand the javadoc
     *
     * This type is not associated with specific use cases unlike other types, but this has
     * unique restrictions.
     * <ul>
     *     <li>Has a timeout
     *     <li>Cannot start other foreground services from this
     *     <li>
     * </ul>
     *
     * @see Service#onTimeout
     *
     * @hide
     */
    public static final int FOREGROUND_SERVICE_TYPE_SHORT_SERVICE = 1 << 11;

    /**
     * Constant corresponding to {@code specialUse} in
     * the {@link android.R.attr#foregroundServiceType} attribute.
@@ -446,6 +468,7 @@ public class ServiceInfo extends ComponentInfo
            FOREGROUND_SERVICE_TYPE_HEALTH,
            FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING,
            FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED,
            FOREGROUND_SERVICE_TYPE_SHORT_SERVICE,
            FOREGROUND_SERVICE_TYPE_SPECIAL_USE
    })
    @Retention(RetentionPolicy.SOURCE)
@@ -528,6 +551,8 @@ public class ServiceInfo extends ComponentInfo
                return "remoteMessaging";
            case FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED:
                return "systemExempted";
            case FOREGROUND_SERVICE_TYPE_SHORT_SERVICE:
                return "shortService";
            case FOREGROUND_SERVICE_TYPE_SPECIAL_USE:
                return "specialUse";
            default:
+6 −0
Original line number Diff line number Diff line
@@ -1704,6 +1704,12 @@
            {@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED}.
        -->
        <flag name="systemExempted" value="0x400" />
        <!-- "Short service" foreground service type. See
           TODO: Change it to a real link
           {@code android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE}.
           for more details.
        -->
        <flag name="shortService" value="0x800" />
        <!-- Use cases that can't be categorized into any other foreground service types, but also
            can't use @link android.app.job.JobInfo.Builder} APIs.
            See {@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE} for the