Merge "Move config_isSafetyCenterLockScreenPendingIntentFixed"
diff --git a/res-export/drawable/ic_find_device_disabled.xml b/res-export/drawable/ic_find_device_disabled.xml
new file mode 100644
index 0000000..21e92c9
--- /dev/null
+++ b/res-export/drawable/ic_find_device_disabled.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FFF44336"
+ android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9zM11,13h2v2h-2V13zM13,6h-2v5h2V6z"/>
+</vector>
diff --git a/res-export/drawable/ic_find_device_enabled.xml b/res-export/drawable/ic_find_device_enabled.xml
new file mode 100644
index 0000000..614ac6d
--- /dev/null
+++ b/res-export/drawable/ic_find_device_enabled.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FF43A047"
+ android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9zM14.5,9c0,1.38 -1.12,2.5 -2.5,2.5S9.5,10.38 9.5,9s1.12,-2.5 2.5,-2.5S14.5,7.62 14.5,9z"/>
+</vector>
diff --git a/res-export/drawable/ic_package_verifier_disabled.xml b/res-export/drawable/ic_package_verifier_disabled.xml
new file mode 100644
index 0000000..49fe0d3
--- /dev/null
+++ b/res-export/drawable/ic_package_verifier_disabled.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FFEF6C00"
+ android:pathData="M12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2zM11,15h2v2h-2V15zM13,8h-2v5h2V8z"/>
+</vector>
diff --git a/res-export/drawable/ic_package_verifier_enabled.xml b/res-export/drawable/ic_package_verifier_enabled.xml
new file mode 100644
index 0000000..1e09eee
--- /dev/null
+++ b/res-export/drawable/ic_package_verifier_enabled.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="#FF43A047"
+ android:pathData="M11.14,16l-3.84,-3.84l1.41,-1.42l2.43,2.42l4.16,-4.16l1.42,1.41L11.14,16zM12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2z"/>
+</vector>
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index e48d745..691cbd6 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -51,6 +51,8 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
@SearchIndexable
public class MyDeviceInfoFragment extends DashboardFragment
@@ -105,14 +107,9 @@
Context context, MyDeviceInfoFragment fragment, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
- final SlotSimStatus slotSimStatus = new SlotSimStatus(context);
- for (int slotIndex = 0; slotIndex < slotSimStatus.size(); slotIndex ++) {
- SimStatusPreferenceController slotRecord =
- new SimStatusPreferenceController(context,
- slotSimStatus.getPreferenceKey(slotIndex));
- slotRecord.init(fragment, slotSimStatus);
- controllers.add(slotRecord);
- }
+ final ExecutorService executor = (fragment == null) ? null :
+ Executors.newSingleThreadExecutor();
+ final SlotSimStatus slotSimStatus = new SlotSimStatus(context, executor);
controllers.add(new IpAddressPreferenceController(context, lifecycle));
controllers.add(new WifiMacAddressPreferenceController(context, lifecycle));
@@ -123,6 +120,17 @@
controllers.add(new FeedbackPreferenceController(fragment, context));
controllers.add(new FccEquipmentIdPreferenceController(context));
controllers.add(new UptimePreferenceController(context, lifecycle));
+
+ for (int slotIndex = 0; slotIndex < slotSimStatus.size(); slotIndex ++) {
+ SimStatusPreferenceController slotRecord =
+ new SimStatusPreferenceController(context,
+ slotSimStatus.getPreferenceKey(slotIndex));
+ slotRecord.init(fragment, slotSimStatus);
+ controllers.add(slotRecord);
+ }
+ if (executor != null) {
+ executor.shutdown();
+ }
return controllers;
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java b/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java
index 7056181..033222a 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SlotSimStatus.java
@@ -21,6 +21,10 @@
import android.telephony.SubscriptionManager;
import android.util.Log;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Phaser;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* A class for showing a summary of status of sim slots.
*/
@@ -28,7 +32,8 @@
private static final String TAG = "SlotSimStatus";
- private int mNumberOfSlots;
+ private final AtomicInteger mNumberOfSlots = new AtomicInteger(0);
+ private final Phaser mBlocker = new Phaser(1);
private int mBasePreferenceOrdering;
private static final String KEY_SIM_STATUS = "sim_status";
@@ -38,11 +43,32 @@
* @param context Context
*/
public SlotSimStatus(Context context) {
- TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
- if (telMgr == null) {
- return;
+ this(context, null);
+ }
+
+ /**
+ * Construct of class.
+ * @param context Context
+ * @param executor executor for offload to thread
+ */
+ public SlotSimStatus(Context context, Executor executor) {
+ if (executor == null) {
+ queryRecords(context);
+ } else {
+ executor.execute(() -> queryRecords(context));
}
- mNumberOfSlots = telMgr.getPhoneCount();
+ }
+
+ protected void queryRecords(Context context) {
+ TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
+ if (telMgr != null) {
+ mNumberOfSlots.set(telMgr.getPhoneCount());
+ }
+ mBlocker.arrive();
+ }
+
+ protected void waitForResult() {
+ mBlocker.awaitAdvance(0);
}
/**
@@ -58,7 +84,8 @@
* @return number of slots
*/
public int size() {
- return mNumberOfSlots;
+ waitForResult();
+ return mNumberOfSlots.get();
}
/**
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
index 707c5b2..c2eab57 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
@@ -319,7 +319,8 @@
}
- if (mOnBatteryUsageUpdatedListener != null) {
+ if (mOnBatteryUsageUpdatedListener != null && mBatteryUsageMap != null
+ && mBatteryUsageMap.get(mDailyChartIndex) != null) {
final BatteryDiffData slotUsageData =
mBatteryUsageMap.get(mDailyChartIndex).get(mHourlyChartIndex);
mOnBatteryUsageUpdatedListener.onBatteryUsageUpdated(
@@ -359,6 +360,9 @@
mDailyChartIndex = 0;
} else {
mDailyChartView.setVisibility(View.VISIBLE);
+ if (mDailyChartIndex >= mDailyViewModel.size()) {
+ mDailyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
+ }
mDailyViewModel.setSelectedIndex(mDailyChartIndex);
mDailyChartView.setViewModel(mDailyViewModel);
}
@@ -370,6 +374,9 @@
animateBatteryHourlyChartView(/*visible=*/ true);
final BatteryChartViewModel hourlyViewModel =
mHourlyViewModels.get(mDailyChartIndex);
+ if (mHourlyChartIndex >= hourlyViewModel.size()) {
+ mHourlyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
+ }
hourlyViewModel.setSelectedIndex(mHourlyChartIndex);
mHourlyChartView.setViewModel(hourlyViewModel);
}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java b/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java
index 1a4e740..71f0faf 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/simstatus/SlotSimStatusTest.java
@@ -33,6 +33,9 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
@RunWith(AndroidJUnit4.class)
public class SlotSimStatusTest {
@@ -59,6 +62,16 @@
}
@Test
+ public void size_returnNumberOfPhone_whenQueryInBackgroundThread() {
+ doReturn(2).when(mTelephonyManager).getPhoneCount();
+
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ SlotSimStatus target = new SlotSimStatus(mContext, executor);
+
+ assertEquals(new Integer(target.size()), new Integer(2));
+ }
+
+ @Test
public void getPreferenceOrdering_returnOrdering_whenQuery() {
doReturn(2).when(mTelephonyManager).getPhoneCount();