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

Commit 255ed845 authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Move BackgroundActivityStartMode to ActivityOptions

The ComponentOptions class is not publicly accessible, which causes
broken links in the documentation and in general confusion with
automatic imports in the IDE.
This is technically an API change, but practically the @IndDef is only
retained in the source and developers cannot access the definitions in
the hidden ComponentOptions class.

Test: atest ActivityStarterTests
Bug: 326324768
Flag: NONE
Change-Id: I6101c0582474dd8ec9b0fcdd81fc1183c6a3ddb0
parent d389c0f3
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -316,9 +316,6 @@ package android.app {
  }
  }


  public class ComponentOptions {
  public class ComponentOptions {
    field public static final int MODE_BACKGROUND_ACTIVITY_START_ALLOWED = 1; // 0x1
    field public static final int MODE_BACKGROUND_ACTIVITY_START_DENIED = 2; // 0x2
    field public static final int MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED = 0; // 0x0
  }
  }


  public class DownloadManager {
  public class DownloadManager {
+24 −9
Original line number Original line Diff line number Diff line
@@ -93,15 +93,30 @@ public class ActivityOptions extends ComponentOptions {
     */
     */
    public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages";
    public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages";


    /** No explicit value chosen. The system will decide whether to grant privileges. */
    /** Enumeration of background activity start modes.
    public static final int MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED =
     *
            ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED;
     * These define if an app wants to grant it's background activity start privileges to a
    /** Allow the {@link PendingIntent} to use the background activity start privileges. */
     * {@link PendingIntent}.
    public static final int MODE_BACKGROUND_ACTIVITY_START_ALLOWED =
     * @hide
            ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
     */
    /** Deny the {@link PendingIntent} to use the background activity start privileges. */
    @Retention(RetentionPolicy.SOURCE)
    public static final int MODE_BACKGROUND_ACTIVITY_START_DENIED =
    @IntDef(prefix = {"MODE_BACKGROUND_ACTIVITY_START_"}, value = {
            ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED;
            MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED,
            MODE_BACKGROUND_ACTIVITY_START_ALLOWED,
            MODE_BACKGROUND_ACTIVITY_START_DENIED})
    public @interface BackgroundActivityStartMode {}
    /**
     * No explicit value chosen. The system will decide whether to grant privileges.
     */
    public static final int MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED = 0;
    /**
     * Allow the {@link PendingIntent} to use the background activity start privileges.
     */
    public static final int MODE_BACKGROUND_ACTIVITY_START_ALLOWED = 1;
    /**
     * Deny the {@link PendingIntent} to use the background activity start privileges.
     */
    public static final int MODE_BACKGROUND_ACTIVITY_START_DENIED = 2;


    /**
    /**
     * The package name that created the options.
     * The package name that created the options.
+4 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.app;
package android.app;


import static android.app.ActivityOptions.BackgroundActivityStartMode;

import android.annotation.CurrentTimeMillisLong;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.FlaggedApi;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntDef;
@@ -1132,7 +1134,8 @@ public class BroadcastOptions extends ComponentOptions {
    @SystemApi
    @SystemApi
    @NonNull
    @NonNull
    @Override // to narrow down the return type
    @Override // to narrow down the return type
    public BroadcastOptions setPendingIntentBackgroundActivityStartMode(int state) {
    public BroadcastOptions setPendingIntentBackgroundActivityStartMode(
            @BackgroundActivityStartMode int state) {
        super.setPendingIntentBackgroundActivityStartMode(state);
        super.setPendingIntentBackgroundActivityStartMode(state);
        return this;
        return this;
    }
    }
+5 −30
Original line number Original line Diff line number Diff line
@@ -16,16 +16,17 @@


package android.app;
package android.app;


import android.annotation.IntDef;
import static android.app.ActivityOptions.BackgroundActivityStartMode;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED;

import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.annotation.TestApi;
import android.os.Bundle;
import android.os.Bundle;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
/**
 * Base class for {@link ActivityOptions} and {@link BroadcastOptions}.
 * Base class for {@link ActivityOptions} and {@link BroadcastOptions}.
 * @hide
 * @hide
@@ -56,32 +57,6 @@ public class ComponentOptions {
    private @Nullable Boolean mPendingIntentBalAllowed = null;
    private @Nullable Boolean mPendingIntentBalAllowed = null;
    private boolean mPendingIntentBalAllowedByPermission = false;
    private boolean mPendingIntentBalAllowedByPermission = false;


    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"MODE_BACKGROUND_ACTIVITY_START_"}, value = {
            MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED,
            MODE_BACKGROUND_ACTIVITY_START_ALLOWED,
            MODE_BACKGROUND_ACTIVITY_START_DENIED})
    public @interface BackgroundActivityStartMode {}
    /**
     * No explicit value chosen. The system will decide whether to grant privileges.
     * @hide
     */
    @TestApi
    public static final int MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED = 0;
    /**
     * Allow the {@link PendingIntent} to use the background activity start privileges.
     * @hide
     */
    @TestApi
    public static final int MODE_BACKGROUND_ACTIVITY_START_ALLOWED = 1;
    /**
     * Deny the {@link PendingIntent} to use the background activity start privileges.
     * @hide
     */
    @TestApi
    public static final int MODE_BACKGROUND_ACTIVITY_START_DENIED = 2;

    ComponentOptions() {
    ComponentOptions() {
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.systemui.controls.ui


import android.app.Activity
import android.app.Activity
import android.app.ActivityOptions
import android.app.ActivityOptions
import android.app.ComponentOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
import android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
import android.app.Dialog
import android.app.Dialog
import android.app.PendingIntent
import android.app.PendingIntent
import android.content.ComponentName
import android.content.ComponentName
Loading