1 /* 2 * Copyright (C) 2019 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 package android.telephony.ims; 17 18 import android.annotation.WorkerThread; 19 20 /** 21 * This is a single instance of a message received over RCS. 22 * 23 * @hide 24 */ 25 public class RcsIncomingMessage extends RcsMessage { 26 /** 27 * @hide 28 */ RcsIncomingMessage(RcsControllerCall rcsControllerCall, int id)29 RcsIncomingMessage(RcsControllerCall rcsControllerCall, int id) { 30 super(rcsControllerCall, id); 31 } 32 33 /** 34 * Sets the timestamp of arrival for this message and persists into storage. The timestamp is 35 * defined as milliseconds passed after midnight, January 1, 1970 UTC 36 * 37 * @param arrivalTimestamp The timestamp to set to. 38 * @throws RcsMessageStoreException if the value could not be persisted into storage 39 */ 40 @WorkerThread setArrivalTimestamp(long arrivalTimestamp)41 public void setArrivalTimestamp(long arrivalTimestamp) throws RcsMessageStoreException { 42 mRcsControllerCall.callWithNoReturn( 43 (iRcs, callingPackage) -> iRcs.setMessageArrivalTimestamp(mId, true, 44 arrivalTimestamp, callingPackage)); 45 } 46 47 /** 48 * @return Returns the timestamp of arrival for this message. The timestamp is defined as 49 * milliseconds passed after midnight, January 1, 1970 UTC 50 * @throws RcsMessageStoreException if the value could not be read from the storage 51 */ 52 @WorkerThread getArrivalTimestamp()53 public long getArrivalTimestamp() throws RcsMessageStoreException { 54 return mRcsControllerCall.call( 55 (iRcs, callingPackage) -> iRcs.getMessageArrivalTimestamp(mId, true, 56 callingPackage)); 57 } 58 59 /** 60 * Sets the timestamp of when the user saw this message and persists into storage. The timestamp 61 * is defined as milliseconds passed after midnight, January 1, 1970 UTC 62 * 63 * @param notifiedTimestamp The timestamp to set to. 64 * @throws RcsMessageStoreException if the value could not be persisted into storage 65 */ 66 @WorkerThread setSeenTimestamp(long notifiedTimestamp)67 public void setSeenTimestamp(long notifiedTimestamp) throws RcsMessageStoreException { 68 mRcsControllerCall.callWithNoReturn( 69 (iRcs, callingPackage) -> iRcs.setMessageSeenTimestamp(mId, true, notifiedTimestamp, 70 callingPackage)); 71 } 72 73 /** 74 * @return Returns the timestamp of when the user saw this message. The timestamp is defined as 75 * milliseconds passed after midnight, January 1, 1970 UTC 76 * @throws RcsMessageStoreException if the value could not be read from the storage 77 */ 78 @WorkerThread getSeenTimestamp()79 public long getSeenTimestamp() throws RcsMessageStoreException { 80 return mRcsControllerCall.call( 81 (iRcs, callingPackage) -> iRcs.getMessageSeenTimestamp(mId, true, callingPackage)); 82 } 83 84 /** 85 * @return Returns the sender of this incoming message. 86 * @throws RcsMessageStoreException if the value could not be read from the storage 87 */ 88 @WorkerThread getSenderParticipant()89 public RcsParticipant getSenderParticipant() throws RcsMessageStoreException { 90 return new RcsParticipant( 91 mRcsControllerCall, 92 mRcsControllerCall.call( 93 (iRcs, callingPackage) -> iRcs.getSenderParticipant(mId, callingPackage))); 94 } 95 96 /** 97 * @return Returns {@code true} as this is an incoming message 98 */ 99 @Override isIncoming()100 public boolean isIncoming() { 101 return true; 102 } 103 } 104