summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-08-30 23:35:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-08-30 23:35:07 +0000
commitdcadf1934a757cab2bde172bbf8033c21d3151a9 (patch)
tree9b2e0a8c21aaa515f0f082ec04c42d1155066cf7 /core/java
parent3eda5f4fe88705207ddde7bdf8393af090fd065c (diff)
parent0e3504c0fafb3506b1590f37b1633024384a6d28 (diff)
Merge "Add static lock in PowerProfile" into oc-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/os/PowerProfile.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/java/com/android/internal/os/PowerProfile.java b/core/java/com/android/internal/os/PowerProfile.java
index 51cf2eae851f..872b465a9ca5 100644
--- a/core/java/com/android/internal/os/PowerProfile.java
+++ b/core/java/com/android/internal/os/PowerProfile.java
@@ -205,13 +205,17 @@ public class PowerProfile {
private static final String TAG_ARRAYITEM = "value";
private static final String ATTR_NAME = "name";
+ private static final Object sLock = new Object();
+
public PowerProfile(Context context) {
// Read the XML file for the given profile (normally only one per
// device)
- if (sPowerMap.size() == 0) {
- readPowerValuesFromXml(context);
+ synchronized (sLock) {
+ if (sPowerMap.size() == 0) {
+ readPowerValuesFromXml(context);
+ }
+ initCpuClusters();
}
- initCpuClusters();
}
private void readPowerValuesFromXml(Context context) {