1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.service.wearable; 18 19 import android.annotation.FlaggedApi; 20 import android.annotation.IntDef; 21 import android.annotation.NonNull; 22 import android.annotation.SystemApi; 23 import android.app.wearable.Flags; 24 import android.app.wearable.WearableSensingDataRequest; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 import java.util.function.Consumer; 29 30 /** 31 * An interface to request wearable sensing data. 32 * 33 * @hide 34 */ 35 @FlaggedApi(Flags.FLAG_ENABLE_DATA_REQUEST_OBSERVER_API) 36 @SystemApi 37 public interface WearableSensingDataRequester { 38 39 /** An unknown status. */ 40 int STATUS_UNKNOWN = 0; 41 42 /** The value of the status code that indicates success. */ 43 int STATUS_SUCCESS = 1; 44 45 /** 46 * The value of the status code that indicates the request is rejected because the data request 47 * observer PendingIntent has been cancelled. 48 */ 49 int STATUS_OBSERVER_CANCELLED = 2; 50 51 /** 52 * The value of the status code that indicates the request is rejected because it is larger than 53 * {@link WearableSensingDataRequest#getMaxRequestSize()}. 54 */ 55 int STATUS_TOO_LARGE = 3; 56 57 /** 58 * The value of the status code that indicates the request is rejected because it exceeds the 59 * rate limit. See {@link WearableSensingDataRequest#getRateLimit()}. 60 */ 61 int STATUS_TOO_FREQUENT = 4; 62 63 /** @hide */ 64 @IntDef( 65 prefix = {"STATUS_"}, 66 value = { 67 STATUS_UNKNOWN, 68 STATUS_SUCCESS, 69 STATUS_OBSERVER_CANCELLED, 70 STATUS_TOO_LARGE, 71 STATUS_TOO_FREQUENT 72 }) 73 @Retention(RetentionPolicy.SOURCE) 74 @interface StatusCode {} 75 76 /** 77 * Sends a data request. See {@link WearableSensingService#onDataRequestObserverRegistered(int, 78 * String, WearableSensingDataRequester, Consumer)} for size and rate restrictions on data 79 * requests. 80 * 81 * @param dataRequest The data request to send. 82 * @param statusConsumer A consumer that handles the status code for the data request. 83 */ requestData( @onNull WearableSensingDataRequest dataRequest, @NonNull @StatusCode Consumer<Integer> statusConsumer)84 void requestData( 85 @NonNull WearableSensingDataRequest dataRequest, 86 @NonNull @StatusCode Consumer<Integer> statusConsumer); 87 } 88