diff --git a/api/current.txt b/api/current.txt index a2f2c060428d8..43c082b7cebc8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -43426,11 +43426,10 @@ package android.service.controls { public abstract class ControlsProviderService extends android.app.Service { ctor public ControlsProviderService(); - method @Deprecated public void loadAvailableControls(@NonNull java.util.function.Consumer>); method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void performControlAction(@NonNull String, @NonNull android.service.controls.actions.ControlAction, @NonNull java.util.function.Consumer); method @NonNull public abstract java.util.concurrent.Flow.Publisher publisherFor(@NonNull java.util.List); - method @Nullable public java.util.concurrent.Flow.Publisher publisherForAllAvailable(); + method @NonNull public abstract java.util.concurrent.Flow.Publisher publisherForAllAvailable(); method @Nullable public java.util.concurrent.Flow.Publisher publisherForSuggested(); method public static void requestAddControl(@NonNull android.content.Context, @NonNull android.content.ComponentName, @NonNull android.service.controls.Control); field public static final String SERVICE_CONTROLS = "android.service.controls.ControlsProviderService"; diff --git a/core/java/android/service/controls/Control.java b/core/java/android/service/controls/Control.java index 0cffe7180923a..ad93995b210aa 100644 --- a/core/java/android/service/controls/Control.java +++ b/core/java/android/service/controls/Control.java @@ -334,7 +334,7 @@ public final class Control implements Parcelable { *
  • Subtitle: {@code ""} * * This fixes the values relating to state of the {@link Control} as required by - * {@link ControlsProviderService#loadAvailableControls}: + * {@link ControlsProviderService#publisherForAllAvailable}: *
      *
    • Status: {@link Status#STATUS_UNKNOWN} *
    • Control template: {@link ControlTemplate#NO_TEMPLATE} diff --git a/core/java/android/service/controls/ControlsProviderService.java b/core/java/android/service/controls/ControlsProviderService.java index b23d0cd4bd939..44414884af84d 100644 --- a/core/java/android/service/controls/ControlsProviderService.java +++ b/core/java/android/service/controls/ControlsProviderService.java @@ -38,7 +38,6 @@ import android.util.Log; import com.android.internal.util.Preconditions; -import java.util.Collections; import java.util.List; import java.util.concurrent.Flow.Publisher; import java.util.concurrent.Flow.Subscriber; @@ -83,19 +82,6 @@ public abstract class ControlsProviderService extends Service { private IBinder mToken; private RequestHandler mHandler; - /** - * Retrieve all available controls, using the stateless builder - * {@link Control.StatelessBuilder} to build each Control, then use the - * provided consumer to callback to the call originator. - * - * @deprecated Removing consumer-based load apis. Use publisherForAllAvailable() instead - */ - @Deprecated - public void loadAvailableControls(@NonNull Consumer> consumer) { - // pending removal - consumer.accept(Collections.emptyList()); - } - /** * Publisher for all available controls * @@ -104,11 +90,8 @@ public abstract class ControlsProviderService extends Service { * controls, or {@link Subscriber#onError} for error scenarios. Duplicate Controls will * replace the original. */ - @Nullable - public Publisher publisherForAllAvailable() { - // will be abstract and @nonnull when consumers are removed - return null; - } + @NonNull + public abstract Publisher publisherForAllAvailable(); /** * (Optional) Publisher for suggested controls @@ -198,13 +181,7 @@ public abstract class ControlsProviderService extends Service { final IControlsSubscriber cs = (IControlsSubscriber) msg.obj; final SubscriberProxy proxy = new SubscriberProxy(true, mToken, cs); - Publisher publisher = - ControlsProviderService.this.publisherForAllAvailable(); - if (publisher == null) { - ControlsProviderService.this.loadAvailableControls(consumerFor(proxy)); - } else { - publisher.subscribe(proxy); - } + ControlsProviderService.this.publisherForAllAvailable().subscribe(proxy); break; } @@ -256,37 +233,6 @@ public abstract class ControlsProviderService extends Service { } }; } - - /** - * Method will be removed during migration to publisher - */ - private Consumer> consumerFor(final Subscriber subscriber) { - return (@NonNull final List controls) -> { - Preconditions.checkNotNull(controls); - - subscriber.onSubscribe(new Subscription() { - public void request(long n) { - for (Control control: controls) { - Control c; - if (control == null) { - Log.e(TAG, "onLoad: null control."); - } - if (isStatelessControl(control)) { - c = control; - } else { - Log.w(TAG, "onLoad: control is not stateless."); - c = new Control.StatelessBuilder(control).build(); - } - - subscriber.onNext(c); - } - subscriber.onComplete(); - } - - public void cancel() {} - }); - }; - } } private static boolean isStatelessControl(Control control) { diff --git a/core/tests/coretests/src/android/service/controls/ControlProviderServiceTest.java b/core/tests/coretests/src/android/service/controls/ControlProviderServiceTest.java index 4c2ca7eefcc16..c980ccb9423d1 100644 --- a/core/tests/coretests/src/android/service/controls/ControlProviderServiceTest.java +++ b/core/tests/coretests/src/android/service/controls/ControlProviderServiceTest.java @@ -284,8 +284,12 @@ public class ControlProviderServiceTest { } @Override - public void loadAvailableControls(Consumer> cb) { - cb.accept(mControls); + public Publisher publisherForAllAvailable() { + return new Publisher() { + public void subscribe(final Subscriber s) { + s.onSubscribe(createSubscription(s, mControls)); + } + }; } @Override