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.telephony.MbmsDownloadSession; 21 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 import java.util.List; 25 26 /** 27 * A callback class that apps should use to receive information on file downloads over 28 * cell-broadcast. 29 */ 30 public class MbmsDownloadSessionCallback { 31 /** @hide */ 32 @Retention(RetentionPolicy.SOURCE) 33 @IntDef(value = { 34 MbmsErrors.ERROR_NO_UNIQUE_MIDDLEWARE, 35 MbmsErrors.ERROR_MIDDLEWARE_LOST, 36 MbmsErrors.ERROR_MIDDLEWARE_NOT_BOUND, 37 MbmsErrors.InitializationErrors.ERROR_APP_PERMISSIONS_NOT_GRANTED, 38 MbmsErrors.InitializationErrors.ERROR_DUPLICATE_INITIALIZE, 39 MbmsErrors.InitializationErrors.ERROR_UNABLE_TO_INITIALIZE, 40 MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_NOT_YET_READY, 41 MbmsErrors.GeneralErrors.ERROR_OUT_OF_MEMORY, 42 MbmsErrors.GeneralErrors.ERROR_MIDDLEWARE_TEMPORARILY_UNAVAILABLE, 43 MbmsErrors.GeneralErrors.ERROR_IN_E911, 44 MbmsErrors.GeneralErrors.ERROR_NOT_CONNECTED_TO_HOME_CARRIER_LTE, 45 MbmsErrors.GeneralErrors.ERROR_UNABLE_TO_READ_SIM, 46 MbmsErrors.GeneralErrors.ERROR_CARRIER_CHANGE_NOT_ALLOWED, 47 MbmsErrors.DownloadErrors.ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT, 48 MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST, 49 MbmsErrors.DownloadErrors.ERROR_UNKNOWN_FILE_INFO}, prefix = { "ERROR_" }) 50 private @interface DownloadError{} 51 52 /** 53 * Indicates that the middleware has encountered an asynchronous error. 54 * @param errorCode Any error code listed in {@link MbmsErrors} 55 * @param message A message, intended for debugging purposes, describing the error in further 56 * detail. 57 */ onError(@ownloadError int errorCode, String message)58 public void onError(@DownloadError int errorCode, String message) { 59 // default implementation empty 60 } 61 62 /** 63 * Called to indicate published File Services have changed. 64 * 65 * This will only be called after the application has requested a list of file services and 66 * specified a service class list of interest via 67 * {@link MbmsDownloadSession#requestUpdateFileServices(List)}. If there are subsequent calls to 68 * {@link MbmsDownloadSession#requestUpdateFileServices(List)}, 69 * this method may not be called again if 70 * the list of service classes would remain the same. 71 * 72 * @param services The most recently updated list of available file services. 73 */ onFileServicesUpdated(List<FileServiceInfo> services)74 public void onFileServicesUpdated(List<FileServiceInfo> services) { 75 // default implementation empty 76 } 77 78 /** 79 * Called to indicate that the middleware has been initialized and is ready. 80 * 81 * Before this method is called, calling any method on an instance of 82 * {@link MbmsDownloadSession} will result in an {@link IllegalStateException} 83 * being thrown or {@link #onError(int, String)} being called with error code 84 * {@link MbmsErrors.GeneralErrors#ERROR_MIDDLEWARE_NOT_YET_READY} 85 */ onMiddlewareReady()86 public void onMiddlewareReady() { 87 // default implementation empty 88 } 89 } 90