Sahin Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 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 | |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 18 | import android.annotation.WorkerThread; |
Sahin Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * This is a single instance of a message received over RCS. |
Sahin Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 22 | */ |
| 23 | public class RcsIncomingMessage extends RcsMessage { |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 24 | /** |
| 25 | * @hide |
| 26 | */ |
| 27 | RcsIncomingMessage(int id) { |
| 28 | super(id); |
Sahin Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 29 | } |
| 30 | |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 31 | /** |
| 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 Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 42 | } |
| 43 | |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 44 | /** |
| 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 Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 90 | @Override |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 91 | public boolean isIncoming() { |
| 92 | return true; |
Sahin Caliskan | ec851b1 | 2018-11-30 17:03:34 -0800 | [diff] [blame] | 93 | } |
| 94 | } |