blob: 61911abd00c5f642136295969fdbe7ebee82cdc8 [file] [log] [blame]
Sahin Caliskanec851b12018-11-30 17:03:34 -08001/*
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 */
16package android.telephony.ims;
17
Sahin Caliskanf00a8762019-01-24 14:32:12 -080018import android.annotation.WorkerThread;
Sahin Caliskanec851b12018-11-30 17:03:34 -080019
20/**
21 * This is a single instance of a message received over RCS.
Sahin Caliskanec851b12018-11-30 17:03:34 -080022 */
23public class RcsIncomingMessage extends RcsMessage {
Sahin Caliskanf00a8762019-01-24 14:32:12 -080024 /**
25 * @hide
26 */
27 RcsIncomingMessage(int id) {
28 super(id);
Sahin Caliskanec851b12018-11-30 17:03:34 -080029 }
30
Sahin Caliskanf00a8762019-01-24 14:32:12 -080031 /**
32 * Sets the timestamp of arrival for this message and persists into storage. The timestamp is
33 * defined as milliseconds passed after midnight, January 1, 1970 UTC
34 *
35 * @param arrivalTimestamp The timestamp to set to.
36 * @throws RcsMessageStoreException if the value could not be persisted into storage
37 */
38 @WorkerThread
39 public void setArrivalTimestamp(long arrivalTimestamp) throws RcsMessageStoreException {
40 RcsControllerCall.callWithNoReturn(
41 iRcs -> iRcs.setMessageArrivalTimestamp(mId, true, arrivalTimestamp));
Sahin Caliskanec851b12018-11-30 17:03:34 -080042 }
43
Sahin Caliskanf00a8762019-01-24 14:32:12 -080044 /**
45 * @return Returns the timestamp of arrival for this message. The timestamp is defined as
46 * milliseconds passed after midnight, January 1, 1970 UTC
47 * @throws RcsMessageStoreException if the value could not be read from the storage
48 */
49 @WorkerThread
50 public long getArrivalTimestamp() throws RcsMessageStoreException {
51 return RcsControllerCall.call(iRcs -> iRcs.getMessageArrivalTimestamp(mId, true));
52 }
53
54 /**
55 * Sets the timestamp of when the user saw this message and persists into storage. The timestamp
56 * is defined as milliseconds passed after midnight, January 1, 1970 UTC
57 *
58 * @param notifiedTimestamp The timestamp to set to.
59 * @throws RcsMessageStoreException if the value could not be persisted into storage
60 */
61 @WorkerThread
62 public void setSeenTimestamp(long notifiedTimestamp) throws RcsMessageStoreException {
63 RcsControllerCall.callWithNoReturn(
64 iRcs -> iRcs.setMessageSeenTimestamp(mId, true, notifiedTimestamp));
65 }
66
67 /**
68 * @return Returns the timestamp of when the user saw this message. The timestamp is defined as
69 * milliseconds passed after midnight, January 1, 1970 UTC
70 * @throws RcsMessageStoreException if the value could not be read from the storage
71 */
72 @WorkerThread
73 public long getSeenTimestamp() throws RcsMessageStoreException {
74 return RcsControllerCall.call(iRcs -> iRcs.getMessageSeenTimestamp(mId, true));
75 }
76
77 /**
78 * @return Returns the sender of this incoming message.
79 * @throws RcsMessageStoreException if the value could not be read from the storage
80 */
81 @WorkerThread
82 public RcsParticipant getSenderParticipant() throws RcsMessageStoreException {
83 return new RcsParticipant(
84 RcsControllerCall.call(iRcs -> iRcs.getSenderParticipant(mId)));
85 }
86
87 /**
88 * @return Returns {@code true} as this is an incoming message
89 */
Sahin Caliskanec851b12018-11-30 17:03:34 -080090 @Override
Sahin Caliskanf00a8762019-01-24 14:32:12 -080091 public boolean isIncoming() {
92 return true;
Sahin Caliskanec851b12018-11-30 17:03:34 -080093 }
94}