1 /* 2 * Copyright (C) 2022 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.nearby; 18 19 import android.annotation.IntDef; 20 import android.annotation.SystemApi; 21 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 25 /** 26 * Callback when broadcasting request using nearby specification. 27 * 28 * @hide 29 */ 30 @SystemApi 31 public interface BroadcastCallback { 32 /** Broadcast was successful. */ 33 int STATUS_OK = 0; 34 35 /** General status code when broadcast failed. */ 36 int STATUS_FAILURE = 1; 37 38 /** 39 * Broadcast failed as the callback was already registered. 40 */ 41 int STATUS_FAILURE_ALREADY_REGISTERED = 2; 42 43 /** 44 * Broadcast failed as the request contains excessive data. 45 */ 46 int STATUS_FAILURE_SIZE_EXCEED_LIMIT = 3; 47 48 /** 49 * Broadcast failed as the client doesn't hold required permissions. 50 */ 51 int STATUS_FAILURE_MISSING_PERMISSIONS = 4; 52 53 /** @hide **/ 54 @Retention(RetentionPolicy.SOURCE) 55 @IntDef({STATUS_OK, STATUS_FAILURE, STATUS_FAILURE_ALREADY_REGISTERED, 56 STATUS_FAILURE_SIZE_EXCEED_LIMIT, STATUS_FAILURE_MISSING_PERMISSIONS}) 57 @interface BroadcastStatus { 58 } 59 60 /** 61 * Called when broadcast status changes. 62 */ onStatusChanged(@roadcastStatus int status)63 void onStatusChanged(@BroadcastStatus int status); 64 } 65