1 /* 2 * Copyright (c) 2015, Motorola Mobility LLC 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * - Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * - Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * - Neither the name of Motorola Mobility nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA MOBILITY LLC BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 * DAMAGE. 27 */ 28 29 package com.android.service.ims; 30 31 import java.lang.String; 32 import android.telephony.TelephonyManager; 33 import android.content.Context; 34 35 import com.android.ims.internal.uce.common.StatusCode; 36 37 import com.android.ims.RcsManager.ResultCode; 38 39 import com.android.ims.internal.Logger; 40 41 public class RcsUtils{ 42 /* 43 * The logger 44 */ 45 static private Logger logger = Logger.getLogger("RcsUtils"); 46 RcsUtils()47 public RcsUtils() { 48 } 49 statusCodeToResultCode(int sipStatusCode)50 static public int statusCodeToResultCode(int sipStatusCode){ 51 if(sipStatusCode == StatusCode.UCE_SUCCESS || 52 sipStatusCode == StatusCode.UCE_SUCCESS_ASYC_UPDATE){ 53 return ResultCode.SUCCESS; 54 } 55 56 if(sipStatusCode == StatusCode.UCE_INVALID_PARAM) { 57 return ResultCode.SUBSCRIBE_INVALID_PARAM; 58 } 59 60 if(sipStatusCode == StatusCode.UCE_FETCH_ERROR) { 61 return ResultCode.SUBSCRIBE_FETCH_ERROR; 62 } 63 64 if(sipStatusCode == StatusCode.UCE_REQUEST_TIMEOUT) { 65 return ResultCode.SUBSCRIBE_REQUEST_TIMEOUT; 66 } 67 68 if(sipStatusCode == StatusCode.UCE_INSUFFICIENT_MEMORY) { 69 return ResultCode.SUBSCRIBE_INSUFFICIENT_MEMORY; 70 } 71 72 if(sipStatusCode == StatusCode.UCE_LOST_NET) { 73 return ResultCode.SUBSCRIBE_LOST_NETWORK; 74 } 75 76 if(sipStatusCode == StatusCode.UCE_NOT_SUPPORTED){ 77 return ResultCode.SUBSCRIBE_NOT_SUPPORTED; 78 } 79 80 if(sipStatusCode == StatusCode.UCE_NOT_FOUND){ 81 return ResultCode.SUBSCRIBE_NOT_FOUND; 82 } 83 84 if(sipStatusCode == StatusCode.UCE_FAILURE || 85 sipStatusCode == StatusCode.UCE_INVALID_SERVICE_HANDLE || 86 sipStatusCode == StatusCode.UCE_INVALID_LISTENER_HANDLE){ 87 return ResultCode.SUBSCRIBE_GENERIC; 88 } 89 90 return ResultCode.SUBSCRIBE_GENERIC; 91 } 92 toContactString(String[] contacts)93 static public String toContactString(String[] contacts) { 94 if(contacts == null) { 95 return null; 96 } 97 98 String result = ""; 99 for(int i=0; i<contacts.length; i++) { 100 result += contacts[i]; 101 if(i != contacts.length -1) { 102 result += ";"; 103 } 104 } 105 106 return result; 107 } 108 } 109 110