1 /* 2 * Copyright (C) 2016 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.telephony.mbms; 18 19 import android.annotation.IntDef; 20 import android.annotation.Nullable; 21 import android.content.Context; 22 import android.telephony.MbmsStreamingSession; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 import java.util.List; 27 import java.util.concurrent.Executor; 28 29 /** 30 * A callback class that is used to receive information from the middleware on MBMS streaming 31 * services. An instance of this object should be passed into 32 * {@link MbmsStreamingSession#create(Context, Executor, int, MbmsStreamingSessionCallback)}. 33 */ 34 public class MbmsStreamingSessionCallback { 35 /** @hide */ 36 @Retention(RetentionPolicy.SOURCE) 37 @IntDef(value = { 38 MbmsErrors.ERROR_NO_UNIQUE_MIDDLEWARE, 39 MbmsErrors.ERROR_MIDDLEWARE_LOST, 40 MbmsErrors.ERROR_MIDDLEWARE_NOT_BOUND, 41 MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED, 42 MbmsErrors.InitializationErrors.ERROR_DUPLICATE_INITIALIZE, 43 MbmsErrors.InitializationErrors.ERROR_UNABLE_TO_INITIALIZE, 44 MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_NOT_YET_READY, 45 MbmsErrors.GeneralErrors.ERROR_OUT_OF_MEMORY, 46 MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE, 47 MbmsErrors.GeneralErrors.ERROR_IN_E911, 48 MbmsErrors.GeneralErrors.ERROR_NOT_CONNECTED_TO_HOME_CARRIER_LTE, 49 MbmsErrors.GeneralErrors.ERROR_UNABLE_TO_READ_SIM, 50 MbmsErrors.GeneralErrors.ERROR_CARRIER_CHANGE_NOT_ALLOWED, 51 MbmsErrors.StreamingErrors.ERROR_CONCURRENT_SERVICE_LIMIT_REACHED, 52 MbmsErrors.StreamingErrors.ERROR_UNABLE_TO_START_SERVICE, 53 MbmsErrors.StreamingErrors.ERROR_DUPLICATE_START_STREAM}, prefix = { "ERROR_" }) 54 private @interface StreamingError{} 55 56 /** 57 * Called by the middleware when it has detected an error condition. The possible error codes 58 * are listed in {@link MbmsErrors}. 59 * @param errorCode The error code. 60 * @param message A human-readable message generated by the middleware for debugging purposes. 61 */ 62 public void onError(@StreamingError int errorCode, @Nullable String message) { 63 // default implementation empty 64 } 65 66 /** 67 * Called to indicate published Streaming Services have changed. 68 * 69 * This will only be called after the application has requested 70 * a list of streaming services and specified a service class list 71 * of interest AND the results of a subsequent getStreamServices 72 * call with the same service class list would return different 73 * results. 74 * 75 * @param services The list of available services. 76 */ 77 public void onStreamingServicesUpdated(List<StreamingServiceInfo> services) { 78 // default implementation empty 79 } 80 81 /** 82 * Called to indicate that the middleware has been initialized and is ready. 83 * 84 * Before this method is called, calling any method on an instance of 85 * {@link MbmsStreamingSession} will result in an {@link IllegalStateException} or an error 86 * delivered via {@link #onError(int, String)} with error code 87 * {@link MbmsErrors.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY}. 88 */ 89 public void onMiddlewareReady() { 90 // default implementation empty 91 } 92 } 93