OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.components.precache; | 5 package org.chromium.components.precache; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.content.IntentFilter; | 9 import android.content.IntentFilter; |
10 import android.os.BatteryManager; | 10 import android.os.BatteryManager; |
11 | 11 |
12 import org.chromium.base.VisibleForTesting; | 12 import org.chromium.base.VisibleForTesting; |
13 | 13 |
14 /** | 14 /** |
15 * Utility class that provides information about the current state of the device
. | 15 * Utility class that provides information about the current state of the device
. |
16 */ | 16 */ |
17 public class DeviceState { | 17 public class DeviceState { |
18 private static DeviceState sDeviceState = null; | 18 private static DeviceState sDeviceState; |
19 | 19 |
20 // Saved battery level percentage. | 20 // Saved battery level percentage. |
21 private int mSavedBatteryPercentage = 0; | 21 private int mSavedBatteryPercentage; |
22 | 22 |
23 /** Disallow Construction of DeviceState objects. Use {@link #getInstance()}
instead to create | 23 /** Disallow Construction of DeviceState objects. Use {@link #getInstance()}
instead to create |
24 * a singleton instance. | 24 * a singleton instance. |
25 */ | 25 */ |
26 protected DeviceState() {} | 26 protected DeviceState() {} |
27 | 27 |
28 public static DeviceState getInstance() { | 28 public static DeviceState getInstance() { |
29 if (sDeviceState == null) sDeviceState = new DeviceState(); | 29 if (sDeviceState == null) sDeviceState = new DeviceState(); |
30 return sDeviceState; | 30 return sDeviceState; |
31 } | 31 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 NetworkInfoDelegate networkInfo = | 97 NetworkInfoDelegate networkInfo = |
98 mNetworkInfoDelegateFactory.getNetworkInfoDelegate(context); | 98 mNetworkInfoDelegateFactory.getNetworkInfoDelegate(context); |
99 return (networkInfo.isValid() | 99 return (networkInfo.isValid() |
100 && networkInfo.isAvailable() | 100 && networkInfo.isAvailable() |
101 && networkInfo.isConnected() | 101 && networkInfo.isConnected() |
102 && !networkInfo.isRoaming() | 102 && !networkInfo.isRoaming() |
103 && !networkInfo.isActiveNetworkMetered()); | 103 && !networkInfo.isActiveNetworkMetered()); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
OLD | NEW |