• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.base;
6 
7 import android.os.StrictMode;
8 
9 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace;
11 import org.chromium.base.annotations.MainDex;
12 
13 import java.util.TimeZone;
14 
15 @JNINamespace("base::android")
16 @MainDex
17 class TimezoneUtils {
18     /**
19      * Guards this class from being instantiated.
20      */
21 
TimezoneUtils()22     private TimezoneUtils() {}
23 
24     /**
25      * @return the Olson timezone ID of the current system time zone.
26      */
27     @CalledByNative
getDefaultTimeZoneId()28     private static String getDefaultTimeZoneId() {
29         // On Android N or earlier, getting the default timezone requires the disk
30         // access when a device set up is skipped.
31         StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
32         String timezoneID = TimeZone.getDefault().getID();
33         StrictMode.setThreadPolicy(oldPolicy);
34         return timezoneID;
35     }
36 }
37