1 /* 2 * Copyright (C) 2020 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 com.android.ims.rcs.uce.eab; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.net.Uri; 23 import android.telephony.ims.RcsContactUceCapability; 24 25 import java.lang.annotation.Retention; 26 import java.lang.annotation.RetentionPolicy; 27 28 /** 29 * The result class of retrieving capabilities from cache. 30 */ 31 public class EabCapabilityResult { 32 33 /** 34 * Query successful. 35 */ 36 public static final int EAB_QUERY_SUCCESSFUL = 0; 37 38 /** 39 * The {@link EabControllerImpl} has been destroyed. 40 */ 41 public static final int EAB_CONTROLLER_DESTROYED_FAILURE = 1; 42 43 /** 44 * The contact's capabilities expired. 45 */ 46 public static final int EAB_CONTACT_EXPIRED_FAILURE = 2; 47 48 /** 49 * The contact cannot be found in the contact provider. 50 */ 51 public static final int EAB_CONTACT_NOT_FOUND_FAILURE = 3; 52 53 /** @hide */ 54 @Retention(RetentionPolicy.SOURCE) 55 @IntDef(prefix = "EAB_", value = { 56 EAB_QUERY_SUCCESSFUL, 57 EAB_CONTROLLER_DESTROYED_FAILURE, 58 EAB_CONTACT_EXPIRED_FAILURE, 59 EAB_CONTACT_NOT_FOUND_FAILURE 60 }) 61 public @interface QueryResult {} 62 63 private final @QueryResult int mStatus; 64 private final Uri mContactUri; 65 private final RcsContactUceCapability mContactCapabilities; 66 EabCapabilityResult(@ueryResult Uri contactUri, int status, RcsContactUceCapability capabilities)67 public EabCapabilityResult(@QueryResult Uri contactUri, int status, 68 RcsContactUceCapability capabilities) { 69 mStatus = status; 70 mContactUri = contactUri; 71 mContactCapabilities = capabilities; 72 } 73 74 /** 75 * Return the status of query. The possible values are 76 * {@link EabCapabilityResult#EAB_QUERY_SUCCESSFUL}, 77 * {@link EabCapabilityResult#EAB_CONTROLLER_DESTROYED_FAILURE}, 78 * {@link EabCapabilityResult#EAB_CONTACT_EXPIRED_FAILURE}, 79 * {@link EabCapabilityResult#EAB_CONTACT_NOT_FOUND_FAILURE}. 80 * 81 */ getStatus()82 public @NonNull int getStatus() { 83 return mStatus; 84 } 85 86 /** 87 * Return the contact uri. 88 */ getContact()89 public @NonNull Uri getContact() { 90 return mContactUri; 91 } 92 93 /** 94 * Return the contacts capabilities which are cached in the EAB database and 95 * are not expired. 96 */ getContactCapabilities()97 public @Nullable RcsContactUceCapability getContactCapabilities() { 98 return mContactCapabilities; 99 } 100 } 101