1/* 2 * Copyright (C) 2022 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 17export enum MessageType { 18 UNKNOWN = 0, 19 PING, 20 PONG, 21 BUGREPORT, 22 TIMESTAMP, 23 FILES, 24} 25 26export enum TimestampType { 27 UNKNOWN = 0, 28 CLOCK_BOOTTIME, 29 CLOCK_REALTIME, 30} 31 32export interface Message { 33 type: MessageType; 34} 35 36export class MessagePing implements Message { 37 type = MessageType.PING; 38} 39 40export class MessagePong implements Message { 41 type = MessageType.PONG; 42} 43 44export class MessageBugReport implements Message { 45 type = MessageType.BUGREPORT; 46 47 constructor( 48 public file: File, 49 public timestampNs?: bigint, 50 public timestampType?: TimestampType, 51 public issueId?: string, 52 ) {} 53} 54 55export class MessageTimestamp implements Message { 56 type = MessageType.TIMESTAMP; 57 58 constructor( 59 public timestampNs: bigint, 60 public timestampType?: TimestampType, 61 public sections?: string[], 62 ) {} 63} 64 65export class MessageFiles implements Message { 66 type = MessageType.FILES; 67 68 constructor( 69 public files: File[], 70 public timestampNs?: bigint, 71 public timestampType?: TimestampType, 72 ) {} 73} 74