Stop using persist.sys.time.offset

Seems like it's not always accurate
e.g. in bug below, sys.time.offset is 8 hours but sys.timezone gives offset of 7 hours for timestamps in trace.

This means we have no need to include utcOffsetMs in the TimezoneInfo interface, as we're never going to be receiving it alongside the timezone string.

Fixes: 340198224
Test: npm run test:unit:ci
Change-Id: I020b2f4b189ae6e51bf1b636faec1161ffb13b91
diff --git a/tools/winscope/src/app/mediator_test.ts b/tools/winscope/src/app/mediator_test.ts
index 49ba964..03c2f99 100644
--- a/tools/winscope/src/app/mediator_test.ts
+++ b/tools/winscope/src/app/mediator_test.ts
@@ -273,7 +273,6 @@
     const timezoneInfo: TimezoneInfo = {
       timezone: 'Asia/Kolkata',
       locale: 'en-US',
-      utcOffsetMs: 19800000,
     };
     const converter = new TimestampConverter(timezoneInfo, 0n);
     spyOn(tracePipeline, 'getTimestampConverter').and.returnValue(converter);
diff --git a/tools/winscope/src/app/trace_file_filter.ts b/tools/winscope/src/app/trace_file_filter.ts
index 0d59979..9d07158 100644
--- a/tools/winscope/src/app/trace_file_filter.ts
+++ b/tools/winscope/src/app/trace_file_filter.ts
@@ -99,15 +99,7 @@
       timezoneStartIndex,
     );
 
-    let utcOffsetMs = undefined;
-    const timeOffsetIndex = fileData.indexOf('[persist.sys.time.offset]');
-    if (timeOffsetIndex !== -1) {
-      utcOffsetMs = Number(
-        this.extractValueFromRawBugReport(fileData, timeOffsetIndex),
-      );
-    }
-
-    return {timezone, locale: 'en-US', utcOffsetMs};
+    return {timezone, locale: 'en-US'};
   }
 
   private extractValueFromRawBugReport(
diff --git a/tools/winscope/src/app/trace_file_filter_test.ts b/tools/winscope/src/app/trace_file_filter_test.ts
index d259844..5645ee7 100644
--- a/tools/winscope/src/app/trace_file_filter_test.ts
+++ b/tools/winscope/src/app/trace_file_filter_test.ts
@@ -148,28 +148,6 @@
       expect(result.timezoneInfo).toEqual({
         timezone: 'Asia/Kolkata',
         locale: 'en-US',
-        utcOffsetMs: 19800000,
-      });
-      expect(warnings).toEqual([]);
-    });
-
-    it('identifies timezone information from bugreport codename file without time offset', async () => {
-      const legacyFile = makeTraceFile(
-        'proto/window_CRITICAL.proto',
-        bugreportArchive,
-      );
-      const bugreportFiles = [
-        await makeBugreportMainEntryTraceFile(),
-        await makeBugreportCodenameNoTimeOffsetTraceFile(),
-        legacyFile,
-      ];
-      const result = await filter.filter(bugreportFiles, notificationListener);
-      expect(result.legacy).toEqual([legacyFile]);
-      expect(result.perfetto).toBeUndefined();
-      expect(result.timezoneInfo).toEqual({
-        timezone: 'Asia/Kolkata',
-        locale: 'en-US',
-        utcOffsetMs: undefined,
       });
       expect(warnings).toEqual([]);
     });
@@ -283,12 +261,4 @@
     );
     return new TraceFile(file, bugreportArchive);
   }
-
-  async function makeBugreportCodenameNoTimeOffsetTraceFile(): Promise<TraceFile> {
-    const file = await UnitTestUtils.getFixtureFile(
-      'bugreports/bugreport-codename_beta-no-time-offset-UPB2.230407.019-2023-05-30-14-33-48.txt',
-      'bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt',
-    );
-    return new TraceFile(file, bugreportArchive);
-  }
 });
diff --git a/tools/winscope/src/app/trace_pipeline_test.ts b/tools/winscope/src/app/trace_pipeline_test.ts
index 2f179fc..518cc62 100644
--- a/tools/winscope/src/app/trace_pipeline_test.ts
+++ b/tools/winscope/src/app/trace_pipeline_test.ts
@@ -172,16 +172,40 @@
     expect(traces.getTrace(TraceType.INPUT_METHOD_CLIENTS)).toBeDefined();
   });
 
-  it('detects bugreports and extracts utc offset directly', async () => {
-    await testTimezoneOffsetExtraction(
-      'bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt',
-    );
-  });
-
   it('detects bugreports and extracts timezone info, then calculates utc offset', async () => {
-    await testTimezoneOffsetExtraction(
-      'bugreports/bugreport-codename_beta-no-time-offset-UPB2.230407.019-2023-05-30-14-33-48.txt',
+    const bugreportFiles = [
+      await UnitTestUtils.getFixtureFile(
+        'bugreports/main_entry.txt',
+        'main_entry.txt',
+      ),
+      await UnitTestUtils.getFixtureFile(
+        'bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt',
+        'bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt',
+      ),
+      await UnitTestUtils.getFixtureFile(
+        'traces/elapsed_and_real_timestamp/SurfaceFlinger.pb',
+        'FS/data/misc/wmtrace/surface_flinger.bp',
+      ),
+    ];
+    const bugreportArchive = new File(
+      [await FileUtils.createZipArchive(bugreportFiles)],
+      'bugreport.zip',
     );
+
+    await loadFiles([bugreportArchive]);
+    await expectLoadResult(1, []);
+
+    const timestampConverter = tracePipeline.getTimestampConverter();
+    expect(timestampConverter);
+    expect(timestampConverter.getUTCOffset()).toEqual('UTC+05:30');
+
+    const expectedTimestamp =
+      TimestampConverterUtils.makeRealTimestampWithUTCOffset(
+        1659107089102062832n,
+      );
+    expect(
+      timestampConverter.makeTimestampFromMonotonicNs(14500282843n),
+    ).toEqual(expectedTimestamp);
   });
 
   it('is robust to corrupted archive', async () => {
@@ -408,40 +432,4 @@
     expect(warnings).toEqual(expectedWarnings);
     expect(tracePipeline.getTraces().getSize()).toEqual(numberOfTraces);
   }
-
-  async function testTimezoneOffsetExtraction(codenameFileName: string) {
-    const bugreportFiles = [
-      await UnitTestUtils.getFixtureFile(
-        'bugreports/main_entry.txt',
-        'main_entry.txt',
-      ),
-      await UnitTestUtils.getFixtureFile(
-        codenameFileName,
-        'bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt',
-      ),
-      await UnitTestUtils.getFixtureFile(
-        'traces/elapsed_and_real_timestamp/SurfaceFlinger.pb',
-        'FS/data/misc/wmtrace/surface_flinger.bp',
-      ),
-    ];
-    const bugreportArchive = new File(
-      [await FileUtils.createZipArchive(bugreportFiles)],
-      'bugreport.zip',
-    );
-
-    await loadFiles([bugreportArchive]);
-    await expectLoadResult(1, []);
-
-    const timestampConverter = tracePipeline.getTimestampConverter();
-    expect(timestampConverter);
-    expect(timestampConverter.getUTCOffset()).toEqual('UTC+05:30');
-
-    const expectedTimestamp =
-      TimestampConverterUtils.makeRealTimestampWithUTCOffset(
-        1659107089102062832n,
-      );
-    expect(
-      timestampConverter.makeTimestampFromMonotonicNs(14500282843n),
-    ).toEqual(expectedTimestamp);
-  }
 });
diff --git a/tools/winscope/src/common/time.ts b/tools/winscope/src/common/time.ts
index f66326a..cbf0477 100644
--- a/tools/winscope/src/common/time.ts
+++ b/tools/winscope/src/common/time.ts
@@ -29,7 +29,6 @@
 export interface TimezoneInfo {
   timezone: string;
   locale: string;
-  utcOffsetMs: number | undefined;
 }
 
 export interface TimestampFormatter {
diff --git a/tools/winscope/src/common/timestamp_converter.ts b/tools/winscope/src/common/timestamp_converter.ts
index 70d05e1..97b6956 100644
--- a/tools/winscope/src/common/timestamp_converter.ts
+++ b/tools/winscope/src/common/timestamp_converter.ts
@@ -101,13 +101,7 @@
     private timezoneInfo: TimezoneInfo,
     private realToMonotonicTimeOffsetNs?: bigint,
     private realToBootTimeOffsetNs?: bigint,
-  ) {
-    if (timezoneInfo.utcOffsetMs !== undefined) {
-      this.utcOffset.initialize(
-        BigInt(timezoneInfo.utcOffsetMs * TIME_UNIT_TO_NANO.ms),
-      );
-    }
-  }
+  ) {}
 
   initializeUTCOffset(timestamp: Timestamp) {
     if (
@@ -324,5 +318,4 @@
 export const UTC_TIMEZONE_INFO = {
   timezone: 'UTC',
   locale: 'en-US',
-  utcOffsetMs: 0,
 };
diff --git a/tools/winscope/src/common/timestamp_converter_test.ts b/tools/winscope/src/common/timestamp_converter_test.ts
index 67fc14b..d83240b 100644
--- a/tools/winscope/src/common/timestamp_converter_test.ts
+++ b/tools/winscope/src/common/timestamp_converter_test.ts
@@ -50,7 +50,7 @@
       testRealToBootTimeOffsetNs,
     );
 
-    it('can create real-formatted timestamp without offset set', () => {
+    it('can create real-formatted timestamp without real-time offset set', () => {
       const timestamp = new TimestampConverter(
         TimestampConverterUtils.UTC_TIMEZONE_INFO,
       ).makeTimestampFromRealNs(testRealNs);
@@ -105,6 +105,9 @@
     converterWithMonotonicOffset.setRealToMonotonicTimeOffsetNs(
       testMonotonicTimeOffsetNs,
     );
+    converterWithMonotonicOffset.initializeUTCOffset(
+      converterWithMonotonicOffset.makeTimestampFromRealNs(testRealNs),
+    );
 
     const converterWithBootTimeOffset = new TimestampConverter(
       TimestampConverterUtils.ASIA_TIMEZONE_INFO,
@@ -112,11 +115,19 @@
     converterWithBootTimeOffset.setRealToBootTimeOffsetNs(
       testRealToBootTimeOffsetNs,
     );
+    converterWithBootTimeOffset.initializeUTCOffset(
+      converterWithBootTimeOffset.makeTimestampFromRealNs(testRealNs),
+    );
 
-    it('can create real-formatted timestamp without offset set', () => {
-      const timestamp = new TimestampConverter(
+    it('can create real-formatted timestamp without real-time offset set', () => {
+      const converter = new TimestampConverter(
         TimestampConverterUtils.ASIA_TIMEZONE_INFO,
-      ).makeTimestampFromRealNs(testRealNs);
+      );
+      converter.initializeUTCOffset(
+        converter.makeTimestampFromRealNs(testRealNs),
+      );
+
+      const timestamp = converter.makeTimestampFromRealNs(testRealNs);
       expect(timestamp.getValueNs()).toBe(testRealNs);
       expect(timestamp.format()).toEqual('2022-07-31, 10:25:41.051');
     });
@@ -149,53 +160,60 @@
 
     describe('adds correct offset for different timezones', () => {
       it('creates correct real-formatted timestamps for different timezones', () => {
+        const londonConverter = new TimestampConverter(
+          {
+            timezone: 'Europe/London',
+            locale: 'en-US',
+          },
+          0n,
+        );
+        londonConverter.initializeUTCOffset(
+          londonConverter.makeTimestampFromRealNs(testRealNs),
+        );
         expect(
-          new TimestampConverter(
-            {
-              timezone: 'Europe/London',
-              locale: 'en-US',
-              utcOffsetMs: 3600000,
-            },
-            0n,
-          )
-            .makeTimestampFromRealNs(testRealNs)
-            .format(),
+          londonConverter.makeTimestampFromRealNs(testRealNs).format(),
         ).toEqual('2022-07-31, 05:55:41.051');
+
+        const zurichConverter = new TimestampConverter(
+          {
+            timezone: 'Europe/Zurich',
+            locale: 'en-US',
+          },
+          0n,
+        );
+        zurichConverter.initializeUTCOffset(
+          zurichConverter.makeTimestampFromRealNs(testRealNs),
+        );
         expect(
-          new TimestampConverter(
-            {
-              timezone: 'Europe/Zurich',
-              locale: 'en-US',
-              utcOffsetMs: 7200000,
-            },
-            0n,
-          )
-            .makeTimestampFromRealNs(testRealNs)
-            .format(),
+          zurichConverter.makeTimestampFromRealNs(testRealNs).format(),
         ).toEqual('2022-07-31, 06:55:41.051');
+
+        const westCoastConverter = new TimestampConverter(
+          {
+            timezone: 'America/Los_Angeles',
+            locale: 'en-US',
+          },
+          0n,
+        );
+        westCoastConverter.initializeUTCOffset(
+          westCoastConverter.makeTimestampFromRealNs(testRealNs),
+        );
         expect(
-          new TimestampConverter(
-            {
-              timezone: 'America/Los_Angeles',
-              locale: 'en-US',
-              utcOffsetMs: -25200000,
-            },
-            0n,
-          )
-            .makeTimestampFromRealNs(testRealNs)
-            .format(),
+          westCoastConverter.makeTimestampFromRealNs(testRealNs).format(),
         ).toEqual('2022-07-30, 21:55:41.051');
+
+        const indiaConverter = new TimestampConverter(
+          {
+            timezone: 'Asia/Kolkata',
+            locale: 'en-US',
+          },
+          0n,
+        );
+        indiaConverter.initializeUTCOffset(
+          indiaConverter.makeTimestampFromRealNs(testRealNs),
+        );
         expect(
-          new TimestampConverter(
-            {
-              timezone: 'Asia/Kolkata',
-              locale: 'en-US',
-              utcOffsetMs: 19800000,
-            },
-            0n,
-          )
-            .makeTimestampFromRealNs(testRealNs)
-            .format(),
+          indiaConverter.makeTimestampFromRealNs(testRealNs).format(),
         ).toEqual('2022-07-31, 10:25:41.051');
       });
     });
@@ -453,6 +471,9 @@
       TimestampConverterUtils.ASIA_TIMEZONE_INFO,
     );
     converter.setRealToMonotonicTimeOffsetNs(testMonotonicTimeOffsetNs);
+    converter.initializeUTCOffset(
+      converter.makeTimestampFromRealNs(testRealNs),
+    );
 
     it('makeTimestampFromHumanReal', () => {
       const NOV_10_2022 = 1668038400000n * MILLISECOND;
diff --git a/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt b/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt
index 95285e2..aaa239b 100644
--- a/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt
+++ b/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt
@@ -5,4 +5,3 @@
 # ORIGINAL CONTENTS REMOVED TO AVOID INFORMATION LEAKS
 [persist.sys.locale]: [en-US]
 [persist.sys.timezone]: [Asia/Kolkata]
-[persist.sys.time.offset]: [19800000]
diff --git a/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-no-time-offset-UPB2.230407.019-2023-05-30-14-33-48.txt b/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-no-time-offset-UPB2.230407.019-2023-05-30-14-33-48.txt
deleted file mode 100644
index aaa239b..0000000
--- a/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-no-time-offset-UPB2.230407.019-2023-05-30-14-33-48.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-========================================================
-== dumpstate: 2023-05-30 14:33:48
-========================================================
-
-# ORIGINAL CONTENTS REMOVED TO AVOID INFORMATION LEAKS
-[persist.sys.locale]: [en-US]
-[persist.sys.timezone]: [Asia/Kolkata]
diff --git a/tools/winscope/src/test/unit/timestamp_converter_utils.ts b/tools/winscope/src/test/unit/timestamp_converter_utils.ts
index 3b5c017..d7e0ce1 100644
--- a/tools/winscope/src/test/unit/timestamp_converter_utils.ts
+++ b/tools/winscope/src/test/unit/timestamp_converter_utils.ts
@@ -14,55 +14,57 @@
  * limitations under the License.
  */
 
-import {Timestamp} from 'common/time';
+import {Timestamp, TimezoneInfo} from 'common/time';
 import {TimestampConverter} from 'common/timestamp_converter';
 
-export class TimestampConverterUtils {
-  static readonly ASIA_TIMEZONE_INFO = {
+class TimestampConverterTestUtils {
+  readonly ASIA_TIMEZONE_INFO: TimezoneInfo = {
     timezone: 'Asia/Kolkata',
     locale: 'en-US',
-    utcOffsetMs: 19800000,
   };
-  static readonly UTC_TIMEZONE_INFO = {
+  readonly UTC_TIMEZONE_INFO: TimezoneInfo = {
     timezone: 'UTC',
     locale: 'en-US',
-    utcOffsetMs: 0,
   };
 
-  static readonly TIMESTAMP_CONVERTER_WITH_UTC_OFFSET = new TimestampConverter(
-    TimestampConverterUtils.ASIA_TIMEZONE_INFO,
+  readonly TIMESTAMP_CONVERTER = new TimestampConverter(
+    this.UTC_TIMEZONE_INFO,
     0n,
     0n,
   );
 
-  static readonly TIMESTAMP_CONVERTER = new TimestampConverter(
-    TimestampConverterUtils.UTC_TIMEZONE_INFO,
+  readonly TIMESTAMP_CONVERTER_WITH_UTC_OFFSET = new TimestampConverter(
+    this.ASIA_TIMEZONE_INFO,
     0n,
     0n,
   );
 
-  private static readonly TIMESTAMP_CONVERTER_NO_RTE_OFFSET =
-    new TimestampConverter({
-      timezone: 'UTC',
-      locale: 'en-US',
-      utcOffsetMs: 0,
-    });
+  private readonly TIMESTAMP_CONVERTER_NO_RTE_OFFSET = new TimestampConverter({
+    timezone: 'UTC',
+    locale: 'en-US',
+  });
 
-  static makeRealTimestamp(valueNs: bigint): Timestamp {
-    return TimestampConverterUtils.TIMESTAMP_CONVERTER.makeTimestampFromRealNs(
+  constructor() {
+    this.TIMESTAMP_CONVERTER_WITH_UTC_OFFSET.initializeUTCOffset(
+      this.TIMESTAMP_CONVERTER_WITH_UTC_OFFSET.makeTimestampFromRealNs(0n),
+    );
+  }
+
+  makeRealTimestamp(valueNs: bigint): Timestamp {
+    return this.TIMESTAMP_CONVERTER.makeTimestampFromRealNs(valueNs);
+  }
+
+  makeRealTimestampWithUTCOffset(valueNs: bigint): Timestamp {
+    return this.TIMESTAMP_CONVERTER_WITH_UTC_OFFSET.makeTimestampFromRealNs(
       valueNs,
     );
   }
 
-  static makeRealTimestampWithUTCOffset(valueNs: bigint): Timestamp {
-    return TimestampConverterUtils.TIMESTAMP_CONVERTER_WITH_UTC_OFFSET.makeTimestampFromRealNs(
-      valueNs,
-    );
-  }
-
-  static makeElapsedTimestamp(valueNs: bigint): Timestamp {
-    return TimestampConverterUtils.TIMESTAMP_CONVERTER_NO_RTE_OFFSET.makeTimestampFromMonotonicNs(
+  makeElapsedTimestamp(valueNs: bigint): Timestamp {
+    return this.TIMESTAMP_CONVERTER_NO_RTE_OFFSET.makeTimestampFromMonotonicNs(
       valueNs,
     );
   }
 }
+
+export const TimestampConverterUtils = new TimestampConverterTestUtils();