Snap for 10071751 from 2330c13289 to udc-qpr1-release
Change-Id: I4f3820151f3ffc018e6b8007653518374cc49ccc
This commit is contained in:
@@ -17,9 +17,9 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportWidth="24.0"
|
android:viewportWidth="960"
|
||||||
android:viewportHeight="24.0">
|
android:viewportHeight="960">
|
||||||
<path
|
<path
|
||||||
android:pathData="M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM12,15c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM14,6h-4L10,4h4v2z"
|
android:pathData="M140,840Q116,840 98,822Q80,804 80,780L80,300Q80,276 98,258Q116,240 140,240L320,240L320,140Q320,116 338,98Q356,80 380,80L580,80Q604,80 622,98Q640,116 640,140L640,240L820,240Q844,240 862,258Q880,276 880,300L880,780Q880,804 862,822Q844,840 820,840L140,840ZM380,240L580,240L580,140Q580,140 580,140Q580,140 580,140L380,140Q380,140 380,140Q380,140 380,140L380,240Z"
|
||||||
android:fillColor="?android:attr/colorPrimary"/>
|
android:fillColor="?android:attr/colorPrimary"/>
|
||||||
</vector>
|
</vector>
|
||||||
32
res/drawable/trackpad_bordered.xml
Normal file
32
res/drawable/trackpad_bordered.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2023 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<inset
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
|
<ripple
|
||||||
|
android:color="?android:attr/colorControlHighlight">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<corners android:radius="24dp" />
|
||||||
|
<solid android:color="@android:color/transparent"/>
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="?androidprv:attr/materialColorPrimary"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
|
</inset>
|
||||||
29
res/drawable/trackpad_button_done_colored.xml
Normal file
29
res/drawable/trackpad_button_done_colored.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2022 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<inset
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
|
<ripple
|
||||||
|
android:color="?android:attr/colorControlHighlight">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<corners android:radius="24dp"/>
|
||||||
|
<solid android:color="?androidprv:attr/materialColorPrimary"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
|
</inset>
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
android:textSize="@dimen/dream_item_title_text_size"
|
android:textSize="@dimen/dream_item_title_text_size"
|
||||||
android:textColor="@color/dream_card_text_color_state_list"
|
android:textColor="@color/dream_card_text_color_state_list"
|
||||||
android:drawablePadding="@dimen/dream_item_icon_padding"
|
android:drawablePadding="@dimen/dream_item_icon_padding"
|
||||||
|
android:drawableTint="@color/dream_card_icon_color_state_list"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/preview"
|
app:layout_constraintTop_toBottomOf="@+id/preview"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|||||||
@@ -29,11 +29,11 @@
|
|||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dip"
|
android:layout_marginStart="8dip"
|
||||||
android:layout_marginEnd="8dip"
|
android:layout_marginEnd="8dip"
|
||||||
android:layout_marginTop="6dip"
|
android:layout_marginTop="6dip"
|
||||||
android:layout_marginBottom="6dip"
|
android:layout_marginBottom="48dip"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonCancel"
|
style="@style/TrackpadButtonCancel"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:text="@string/gesture_button_skip"/>
|
android:text="@string/gesture_button_skip"/>
|
||||||
|
|
||||||
@@ -60,15 +60,16 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonCancel"
|
style="@style/TrackpadButtonCancel"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:text="@string/gesture_button_restart"/>
|
android:text="@string/gesture_button_restart"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/viewGroup"
|
android:id="@+id/viewGroup"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"/>
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_centerHorizontal="true"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_next"
|
android:id="@+id/button_next"
|
||||||
@@ -80,7 +81,7 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonDone"
|
style="@style/TrackpadButtonDone"
|
||||||
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
||||||
android:text="@string/gesture_button_next"/>
|
android:text="@string/gesture_button_next"/>
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:drawablePadding="9dp"
|
android:drawablePadding="9dp"
|
||||||
style="@style/ModifierKeyButtonDone"
|
style="@style/TrackpadButtonDone"
|
||||||
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
android:textColor="?androidprv:attr/materialColorOnPrimary"
|
||||||
android:text="@string/gesture_button_done"/>
|
android:text="@string/gesture_button_done"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -380,6 +380,20 @@
|
|||||||
<item name="android:padding">4dp</item>
|
<item name="android:padding">4dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TrackpadButtonDone" parent="@android:style/Widget.Material.Button">
|
||||||
|
<item name="android:background">@drawable/trackpad_button_done_colored</item>
|
||||||
|
<item name="android:stateListAnimator">@null</item>
|
||||||
|
<item name="android:textSize">16sp</item>
|
||||||
|
<item name="android:padding">4dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TrackpadButtonCancel" parent="@android:style/Widget.Material.Button">
|
||||||
|
<item name="android:background">@drawable/trackpad_bordered</item>
|
||||||
|
<item name="android:stateListAnimator">@null</item>
|
||||||
|
<item name="android:textSize">16sp</item>
|
||||||
|
<item name="android:padding">4dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="LockPatternContainerStyle">
|
<style name="LockPatternContainerStyle">
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:maxHeight">@dimen/biometric_auth_pattern_view_max_size</item>
|
<item name="android:maxHeight">@dimen/biometric_auth_pattern_view_max_size</item>
|
||||||
|
|||||||
@@ -562,6 +562,7 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
|
|||||||
|
|
||||||
List<String> enabledServices = getEnabledSettings();
|
List<String> enabledServices = getEnabledSettings();
|
||||||
mCredentialManager.setEnabledProviders(
|
mCredentialManager.setEnabledProviders(
|
||||||
|
new ArrayList<String>(), // TODO(240466271): pass down primary providers
|
||||||
enabledServices,
|
enabledServices,
|
||||||
getUser(),
|
getUser(),
|
||||||
mExecutor,
|
mExecutor,
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ public class DefaultCombinedPicker extends DefaultAppPickerFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
service.setEnabledProviders(
|
service.setEnabledProviders(
|
||||||
|
new ArrayList<String>(), // TODO(240466271): pass down primary providers.
|
||||||
credManProviders,
|
credManProviders,
|
||||||
mUserId,
|
mUserId,
|
||||||
ContextCompat.getMainExecutor(getContext()),
|
ContextCompat.getMainExecutor(getContext()),
|
||||||
|
|||||||
@@ -182,16 +182,11 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
|||||||
|
|
||||||
boolean isFaceStrong = sensors.get(0).sensorStrength
|
boolean isFaceStrong = sensors.get(0).sensorStrength
|
||||||
== SensorProperties.STRENGTH_STRONG;
|
== SensorProperties.STRENGTH_STRONG;
|
||||||
if (mIsFaceStrong == isFaceStrong) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mIsFaceStrong = isFaceStrong;
|
mIsFaceStrong = isFaceStrong;
|
||||||
onFaceStrengthChanged();
|
onFaceStrengthChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onFaceStrengthChanged();
|
|
||||||
|
|
||||||
// This path is an entry point for SetNewPasswordController, e.g.
|
// This path is an entry point for SetNewPasswordController, e.g.
|
||||||
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
|
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
|
||||||
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
|
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
|
||||||
|
|||||||
@@ -107,10 +107,9 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
new BluetoothAdapter.OnMetadataChangedListener() {
|
new BluetoothAdapter.OnMetadataChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMetadataChanged(BluetoothDevice device, int key, byte[] value) {
|
public void onMetadataChanged(BluetoothDevice device, int key, byte[] value) {
|
||||||
if (DEBUG) {
|
Log.d(TAG, String.format("Metadata updated in Device %s: %d = %s.",
|
||||||
Log.d(TAG, String.format("Metadata updated in Device %s: %d = %s.", device,
|
device.getAnonymizedAddress(),
|
||||||
key, value == null ? null : new String(value)));
|
key, value == null ? null : new String(value)));
|
||||||
}
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -276,11 +275,22 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
}
|
}
|
||||||
final int batteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, batteryMetaKey);
|
final int batteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, batteryMetaKey);
|
||||||
final boolean charging = BluetoothUtils.getBooleanMetaData(bluetoothDevice, chargeMetaKey);
|
final boolean charging = BluetoothUtils.getBooleanMetaData(bluetoothDevice, chargeMetaKey);
|
||||||
if (DEBUG) {
|
int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice,
|
||||||
Log.d(TAG, "updateSubLayout() icon : " + iconMetaKey + ", battery : " + batteryMetaKey
|
lowBatteryMetaKey);
|
||||||
+ ", charge : " + chargeMetaKey + ", batteryLevel : " + batteryLevel
|
if (lowBatteryLevel == BluetoothUtils.META_INT_ERROR) {
|
||||||
+ ", charging : " + charging + ", iconUri : " + iconUri);
|
if (batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY) {
|
||||||
|
lowBatteryLevel = CASE_LOW_BATTERY_LEVEL;
|
||||||
|
} else {
|
||||||
|
lowBatteryLevel = LOW_BATTERY_LEVEL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.d(TAG, "buletoothDevice: " + bluetoothDevice.getAnonymizedAddress()
|
||||||
|
+ ", updateSubLayout() icon : " + iconMetaKey + ", battery : " + batteryMetaKey
|
||||||
|
+ ", charge : " + chargeMetaKey + ", batteryLevel : " + batteryLevel
|
||||||
|
+ ", charging : " + charging + ", iconUri : " + iconUri
|
||||||
|
+ ", lowBatteryLevel : " + lowBatteryLevel);
|
||||||
|
|
||||||
if (deviceId == LEFT_DEVICE_ID || deviceId == RIGHT_DEVICE_ID) {
|
if (deviceId == LEFT_DEVICE_ID || deviceId == RIGHT_DEVICE_ID) {
|
||||||
showBatteryPredictionIfNecessary(linearLayout, deviceId, batteryLevel);
|
showBatteryPredictionIfNecessary(linearLayout, deviceId, batteryLevel);
|
||||||
}
|
}
|
||||||
@@ -291,15 +301,6 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
batterySummaryView.setText(
|
batterySummaryView.setText(
|
||||||
com.android.settings.Utils.formatPercentage(batteryLevel));
|
com.android.settings.Utils.formatPercentage(batteryLevel));
|
||||||
batterySummaryView.setVisibility(View.VISIBLE);
|
batterySummaryView.setVisibility(View.VISIBLE);
|
||||||
int lowBatteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice,
|
|
||||||
lowBatteryMetaKey);
|
|
||||||
if (lowBatteryLevel == BluetoothUtils.META_INT_ERROR) {
|
|
||||||
if (batteryMetaKey == BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY) {
|
|
||||||
lowBatteryLevel = CASE_LOW_BATTERY_LEVEL;
|
|
||||||
} else {
|
|
||||||
lowBatteryLevel = LOW_BATTERY_LEVEL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showBatteryIcon(linearLayout, batteryLevel, lowBatteryLevel, charging);
|
showBatteryIcon(linearLayout, batteryLevel, lowBatteryLevel, charging);
|
||||||
} else {
|
} else {
|
||||||
if (deviceId == MAIN_DEVICE_ID) {
|
if (deviceId == MAIN_DEVICE_ID) {
|
||||||
@@ -320,7 +321,15 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
batterySummaryView.setVisibility(View.GONE);
|
if (batteryLevel != BluetoothUtils.META_INT_ERROR) {
|
||||||
|
linearLayout.setVisibility(View.VISIBLE);
|
||||||
|
batterySummaryView.setText(
|
||||||
|
com.android.settings.Utils.formatPercentage(batteryLevel));
|
||||||
|
batterySummaryView.setVisibility(View.VISIBLE);
|
||||||
|
showBatteryIcon(linearLayout, batteryLevel, lowBatteryLevel, charging);
|
||||||
|
} else {
|
||||||
|
batterySummaryView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final TextView textView = linearLayout.findViewById(R.id.header_title);
|
final TextView textView = linearLayout.findViewById(R.id.header_title);
|
||||||
if (deviceId == MAIN_DEVICE_ID) {
|
if (deviceId == MAIN_DEVICE_ID) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import android.widget.TextView;
|
|||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
|
||||||
|
|
||||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||||
import com.google.android.setupcompat.template.FooterButton;
|
import com.google.android.setupcompat.template.FooterButton;
|
||||||
@@ -85,6 +85,7 @@ public abstract class StorageWizardBase extends FragmentActivity {
|
|||||||
this.setTheme(sudTheme);
|
this.setTheme(sudTheme);
|
||||||
ThemeHelper.trySetDynamicColor(this);
|
ThemeHelper.trySetDynamicColor(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||||
|
|
||||||
mStorage = getSystemService(StorageManager.class);
|
mStorage = getSystemService(StorageManager.class);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.settings.dream;
|
|||||||
import android.annotation.LayoutRes;
|
import android.annotation.LayoutRes;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.VectorDrawable;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -86,10 +85,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
final Drawable icon = item.isActive()
|
final Drawable icon = item.isActive()
|
||||||
? mContext.getDrawable(R.drawable.ic_dream_check_circle)
|
? mContext.getDrawable(R.drawable.ic_dream_check_circle)
|
||||||
: item.getIcon().mutate();
|
: item.getIcon().mutate();
|
||||||
if (icon instanceof VectorDrawable) {
|
|
||||||
icon.setTintList(
|
|
||||||
mContext.getColorStateList(R.color.dream_card_icon_color_state_list));
|
|
||||||
}
|
|
||||||
final int iconSize = mContext.getResources().getDimensionPixelSize(
|
final int iconSize = mContext.getResources().getDimensionPixelSize(
|
||||||
R.dimen.dream_item_icon_size);
|
R.dimen.dream_item_icon_size);
|
||||||
icon.setBounds(0, 0, iconSize, iconSize);
|
icon.setBounds(0, 0, iconSize, iconSize);
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.fuelgauge;
|
package com.android.settings.fuelgauge;
|
||||||
@@ -25,6 +23,7 @@ import android.icu.text.NumberFormat;
|
|||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
@@ -48,6 +47,8 @@ import com.android.settingslib.widget.UsageProgressBarPreference;
|
|||||||
public class BatteryHeaderPreferenceController extends BasePreferenceController
|
public class BatteryHeaderPreferenceController extends BasePreferenceController
|
||||||
implements PreferenceControllerMixin, LifecycleObserver, OnStart,
|
implements PreferenceControllerMixin, LifecycleObserver, OnStart,
|
||||||
BatteryPreferenceController {
|
BatteryPreferenceController {
|
||||||
|
private static final String TAG = "BatteryHeaderPreferenceController";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_BATTERY_HEADER = "battery_header";
|
static final String KEY_BATTERY_HEADER = "battery_header";
|
||||||
private static final int BATTERY_MAX_LEVEL = 100;
|
private static final int BATTERY_MAX_LEVEL = 100;
|
||||||
@@ -86,7 +87,7 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
|
mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
|
||||||
//Set up loading text first to prevent layout flaky before info loaded.
|
// Set up loading text first to prevent layout flaky before info loaded.
|
||||||
mBatteryUsageProgressBarPref.setBottomSummary(
|
mBatteryUsageProgressBarPref.setBottomSummary(
|
||||||
mContext.getString(R.string.settings_license_activity_loading));
|
mContext.getString(R.string.settings_license_activity_loading));
|
||||||
|
|
||||||
@@ -109,7 +110,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence generateLabel(BatteryInfo info) {
|
private CharSequence generateLabel(BatteryInfo info) {
|
||||||
if (BatteryUtils.isBatteryDefenderOn(info)) {
|
if (Utils.containsIncompatibleChargers(mContext, TAG)) {
|
||||||
|
return mContext.getString(R.string.battery_info_status_not_charging);
|
||||||
|
} else if (BatteryUtils.isBatteryDefenderOn(info)) {
|
||||||
return null;
|
return null;
|
||||||
} else if (info.remainingLabel == null
|
} else if (info.remainingLabel == null
|
||||||
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
||||||
@@ -151,12 +154,14 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||||||
* Callback which receives text for the summary line.
|
* Callback which receives text for the summary line.
|
||||||
*/
|
*/
|
||||||
public void updateBatteryStatus(String label, BatteryInfo info) {
|
public void updateBatteryStatus(String label, BatteryInfo info) {
|
||||||
mBatteryUsageProgressBarPref.setBottomSummary(label != null ? label : generateLabel(info));
|
final CharSequence summary = label != null ? label : generateLabel(info);
|
||||||
|
mBatteryUsageProgressBarPref.setBottomSummary(summary);
|
||||||
|
Log.d(TAG, "updateBatteryStatus: " + label + " summary: " + summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void quickUpdateHeaderPreference() {
|
public void quickUpdateHeaderPreference() {
|
||||||
Intent batteryBroadcast = mContext.registerReceiver(null,
|
Intent batteryBroadcast = com.android.settingslib.fuelgauge.BatteryUtils
|
||||||
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
.getBatteryIntent(mContext);
|
||||||
final int batteryLevel = Utils.getBatteryLevel(batteryBroadcast);
|
final int batteryLevel = Utils.getBatteryLevel(batteryBroadcast);
|
||||||
final boolean discharging =
|
final boolean discharging =
|
||||||
batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
|
batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
|||||||
if (summary != null) {
|
if (summary != null) {
|
||||||
mPreference.setSummary(summary);
|
mPreference.setSummary(summary);
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "updateBatteryStatus: " + label + " summary: " + summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -1754,7 +1754,7 @@ public final class DataProcessor {
|
|||||||
|
|
||||||
private static Set<String> getSystemAppsPackageNames(Context context) {
|
private static Set<String> getSystemAppsPackageNames(Context context) {
|
||||||
return sTestSystemAppsPackageNames != null ? sTestSystemAppsPackageNames
|
return sTestSystemAppsPackageNames != null ? sTestSystemAppsPackageNames
|
||||||
: AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId(), false);
|
: AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Integer> getSystemAppsUids(Context context) {
|
private static Set<Integer> getSystemAppsUids(Context context) {
|
||||||
|
|||||||
@@ -17,17 +17,21 @@
|
|||||||
package com.android.settings.inputmethod;
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@@ -87,21 +91,36 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
|
|||||||
if (window == null) {
|
if (window == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setLayoutEdgeToEdge(window);
|
||||||
final Point size = getScreenSize();
|
final Point size = getScreenSize();
|
||||||
final WindowManager.LayoutParams attributes = window.getAttributes();
|
final WindowManager.LayoutParams attributes = window.getAttributes();
|
||||||
attributes.width = (int) (size.x * 0.75);
|
attributes.width = (int) (size.x * 0.75);
|
||||||
window.setAttributes(attributes);
|
window.setAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLayoutEdgeToEdge(Window window) {
|
||||||
|
View windowDecorView = window.getDecorView();
|
||||||
|
windowDecorView.setSystemUiVisibility(
|
||||||
|
windowDecorView.getSystemUiVisibility()
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||||
|
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||||
|
|
||||||
mInflater = mContext.getSystemService(LayoutInflater.class);
|
mInflater = mContext.getSystemService(LayoutInflater.class);
|
||||||
|
View contentView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
|
||||||
View gestureEducationView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
|
addViewPager(contentView);
|
||||||
addViewPager(gestureEducationView);
|
dialog.setContentView(contentView);
|
||||||
dialog.setContentView(gestureEducationView);
|
|
||||||
|
|
||||||
Window gestureDialogWindow = dialog.getWindow();
|
Window gestureDialogWindow = dialog.getWindow();
|
||||||
gestureDialogWindow.setType(TYPE_SYSTEM_DIALOG);
|
gestureDialogWindow.setType(TYPE_SYSTEM_DIALOG);
|
||||||
|
|
||||||
@@ -109,8 +128,40 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
|
|||||||
FrameLayout bottomSheet = (FrameLayout)
|
FrameLayout bottomSheet = (FrameLayout)
|
||||||
dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
||||||
bottomSheet.setBackgroundResource(android.R.color.transparent);
|
bottomSheet.setBackgroundResource(android.R.color.transparent);
|
||||||
BottomSheetBehavior.from(bottomSheet)
|
BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
|
||||||
.setState(BottomSheetBehavior.STATE_EXPANDED);
|
if (!isGestureNavigationEnabled()) {
|
||||||
|
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
|
}
|
||||||
|
ViewTreeObserver observer = contentView.getViewTreeObserver();
|
||||||
|
observer.addOnGlobalLayoutListener(
|
||||||
|
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
int contentViewHeight = contentView.getMeasuredHeight();
|
||||||
|
int navigationBarHeight = getNavigationBarHeight();
|
||||||
|
behavior.setPeekHeight(contentViewHeight - navigationBarHeight);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// The gesture education view shouldn't be draggable."
|
||||||
|
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
||||||
|
@Override
|
||||||
|
public void onStateChanged(View bottomSheet, int newState) {
|
||||||
|
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
|
||||||
|
if (isGestureNavigationEnabled()) {
|
||||||
|
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
|
} else {
|
||||||
|
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSlide(View bottomSheet, float slideOffset) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
@@ -263,4 +314,16 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
|
|||||||
display.getSize(size);
|
display.getSize(size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getNavigationBarHeight() {
|
||||||
|
final Activity activity = (Activity) mContext;
|
||||||
|
WindowInsets insets =
|
||||||
|
activity.getWindowManager().getCurrentWindowMetrics().getWindowInsets();
|
||||||
|
return insets.getInsets(WindowInsets.Type.navigationBars()).bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isGestureNavigationEnabled() {
|
||||||
|
return NAV_BAR_MODE_GESTURAL == mContext.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ import android.telephony.TelephonyManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.LifecycleObserver;
|
import androidx.lifecycle.LifecycleObserver;
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
import androidx.lifecycle.OnLifecycleEvent;
|
import androidx.lifecycle.OnLifecycleEvent;
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
@@ -232,13 +232,12 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
|
|||||||
mSubscriptionInfoEntityList.forEach(entity -> {
|
mSubscriptionInfoEntityList.forEach(entity -> {
|
||||||
if (entity.getSubId() == mSubId) {
|
if (entity.getSubId() == mSubId) {
|
||||||
mSubscriptionInfoEntity = entity;
|
mSubscriptionInfoEntity = entity;
|
||||||
|
if (entity.getSubId() == SubscriptionManager.getDefaultDataSubscriptionId()) {
|
||||||
|
mDefaultSubId = entity.getSubId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
int subId = mSubscriptionInfoEntity.getSubId();
|
|
||||||
if (mSubscriptionInfoEntity != null
|
|
||||||
&& subId == SubscriptionManager.getDefaultDataSubscriptionId()) {
|
|
||||||
mDefaultSubId = subId;
|
|
||||||
}
|
|
||||||
update();
|
update();
|
||||||
refreshSummary(mPreference);
|
refreshSummary(mPreference);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -940,28 +940,11 @@ public class MobileNetworkUtils {
|
|||||||
* Copied from WifiCallingPreferenceController#isWifiCallingEnabled()
|
* Copied from WifiCallingPreferenceController#isWifiCallingEnabled()
|
||||||
*/
|
*/
|
||||||
public static boolean isWifiCallingEnabled(Context context, int subId,
|
public static boolean isWifiCallingEnabled(Context context, int subId,
|
||||||
@Nullable WifiCallingQueryImsState queryImsState,
|
@Nullable WifiCallingQueryImsState queryImsState) {
|
||||||
@Nullable PhoneAccountHandle phoneAccountHandle) {
|
if (queryImsState == null) {
|
||||||
if (phoneAccountHandle == null){
|
queryImsState = new WifiCallingQueryImsState(context, subId);
|
||||||
phoneAccountHandle = context.getSystemService(TelecomManager.class)
|
|
||||||
.getSimCallManagerForSubscription(subId);
|
|
||||||
}
|
}
|
||||||
boolean isWifiCallingEnabled;
|
return queryImsState.isReadyToWifiCalling();
|
||||||
if (phoneAccountHandle != null) {
|
|
||||||
final Intent intent = buildPhoneAccountConfigureIntent(context, phoneAccountHandle);
|
|
||||||
if (intent == null) {
|
|
||||||
Log.d(TAG, "Can not get phoneAccount configure intent.");
|
|
||||||
isWifiCallingEnabled = false;
|
|
||||||
} else {
|
|
||||||
isWifiCallingEnabled = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (queryImsState == null) {
|
|
||||||
queryImsState = new WifiCallingQueryImsState(context, subId);
|
|
||||||
}
|
|
||||||
isWifiCallingEnabled = queryImsState.isReadyToWifiCalling();
|
|
||||||
}
|
|
||||||
return isWifiCallingEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.PersistableBundle;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telecom.PhoneAccountHandle;
|
import android.telecom.PhoneAccountHandle;
|
||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
@@ -314,8 +313,7 @@ public class NetworkProviderWifiCallingGroup extends
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean shouldShowWifiCallingForSub(int subId) {
|
protected boolean shouldShowWifiCallingForSub(int subId) {
|
||||||
if (SubscriptionManager.isValidSubscriptionId(subId)
|
if (SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, queryImsState(subId),
|
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, queryImsState(subId))) {
|
||||||
null)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus(int subId) {
|
public int getAvailabilityStatus(int subId) {
|
||||||
return SubscriptionManager.isValidSubscriptionId(subId)
|
return SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, null, null)
|
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, null)
|
||||||
? AVAILABLE
|
? AVAILABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -853,6 +853,19 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
// hasCredential checks to see if user chooses a password for screen lock. If the
|
||||||
|
// screen lock is None or Swipe, we do not want to call getActivity().finish().
|
||||||
|
// Otherwise, bugs would be caused. (e.g. b/278488549, b/278530059)
|
||||||
|
final boolean hasCredential = mLockPatternUtils.isSecure(mUserId);
|
||||||
|
if (!getActivity().isChangingConfigurations()
|
||||||
|
&& !mWaitingForConfirmation && hasCredential) {
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|||||||
@@ -257,8 +257,10 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
|
|||||||
for (SubscriptionInfo subInfo : subInfoList) {
|
for (SubscriptionInfo subInfo : subInfoList) {
|
||||||
int subId = subInfo.getSubscriptionId();
|
int subId = subInfo.getSubscriptionId();
|
||||||
try {
|
try {
|
||||||
if (MobileNetworkUtils.isWifiCallingEnabled(getContext(), subId,
|
if (MobileNetworkUtils.isWifiCallingEnabled(
|
||||||
queryImsState(subId), null)) {
|
getContext(),
|
||||||
|
subId,
|
||||||
|
queryImsState(subId))) {
|
||||||
selectedList.add(subInfo);
|
selectedList.add(subInfo);
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {}
|
} catch (Exception exception) {}
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
|
import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -43,8 +41,8 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class SettingsDumpServiceTest {
|
public class SettingsDumpServiceTest {
|
||||||
@@ -102,15 +100,16 @@ public class SettingsDumpServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDump_ReturnJsonObject() throws JSONException {
|
public void testDump_printServiceAsKey() {
|
||||||
mResolveInfo.activityInfo = new ActivityInfo();
|
mResolveInfo.activityInfo = new ActivityInfo();
|
||||||
mResolveInfo.activityInfo.packageName = PACKAGE_BROWSER;
|
mResolveInfo.activityInfo.packageName = PACKAGE_BROWSER;
|
||||||
TestPrintWriter printWriter = new TestPrintWriter(System.out);
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||||
|
|
||||||
mTestService.dump(null, printWriter, null);
|
mTestService.dump(null, printWriter, null);
|
||||||
JSONObject object = (JSONObject) printWriter.getPrintObject();
|
|
||||||
|
|
||||||
assertThat(object.get(TestService.KEY_SERVICE)).isNotNull();
|
assertThat(stringWriter.toString())
|
||||||
|
.contains("{\"" + SettingsDumpService.KEY_SERVICE + "\":");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,24 +127,4 @@ public class SettingsDumpServiceTest {
|
|||||||
return mPm;
|
return mPm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test printWriter to store the object to be printed
|
|
||||||
*/
|
|
||||||
private class TestPrintWriter extends PrintWriter {
|
|
||||||
private Object mPrintObject;
|
|
||||||
|
|
||||||
private TestPrintWriter(@NonNull OutputStream out) {
|
|
||||||
super(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println(Object object) {
|
|
||||||
mPrintObject = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getPrintObject() {
|
|
||||||
return mPrintObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import static com.google.common.truth.Truth.assertWithMessage;
|
|||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -61,6 +60,7 @@ import com.android.settings.biometrics.BiometricEnrollBase;
|
|||||||
import com.android.settings.biometrics.BiometricUtils;
|
import com.android.settings.biometrics.BiometricUtils;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
|
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
|
||||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
||||||
import com.android.settings.testutils.shadow.ShadowSensorPrivacyManager;
|
import com.android.settings.testutils.shadow.ShadowSensorPrivacyManager;
|
||||||
@@ -98,7 +98,8 @@ import java.util.List;
|
|||||||
ShadowUserManager.class,
|
ShadowUserManager.class,
|
||||||
ShadowUtils.class,
|
ShadowUtils.class,
|
||||||
ShadowDevicePolicyManager.class,
|
ShadowDevicePolicyManager.class,
|
||||||
ShadowSensorPrivacyManager.class
|
ShadowSensorPrivacyManager.class,
|
||||||
|
SettingsShadowResources.class
|
||||||
})
|
})
|
||||||
public class FaceEnrollIntroductionTest {
|
public class FaceEnrollIntroductionTest {
|
||||||
|
|
||||||
@@ -188,7 +189,6 @@ public class FaceEnrollIntroductionTest {
|
|||||||
mController = Robolectric.buildActivity(
|
mController = Robolectric.buildActivity(
|
||||||
TestFaceEnrollIntroduction.class, testIntent);
|
TestFaceEnrollIntroduction.class, testIntent);
|
||||||
mActivity = (TestFaceEnrollIntroduction) spy(mController.get());
|
mActivity = (TestFaceEnrollIntroduction) spy(mController.get());
|
||||||
doReturn(mFaceManager).when(mActivity).getFaceManager();
|
|
||||||
when(mActivity.getPostureGuidanceIntent()).thenReturn(null);
|
when(mActivity.getPostureGuidanceIntent()).thenReturn(null);
|
||||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||||
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
|
||||||
@@ -313,11 +313,15 @@ public class FaceEnrollIntroductionTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFaceEnrollIntroduction_hasDescription_weakFace() throws Exception {
|
public void testFaceEnrollIntroduction_hasDescription_weakFace() throws Exception {
|
||||||
setupActivity();
|
setupActivity();
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
R.bool.config_face_intro_show_less_secure,
|
||||||
|
true);
|
||||||
verify(mFaceManager).addAuthenticatorsRegisteredCallback(mCaptor.capture());
|
verify(mFaceManager).addAuthenticatorsRegisteredCallback(mCaptor.capture());
|
||||||
CharSequence desc = getGlifLayout(mActivity).getDescriptionText();
|
|
||||||
|
|
||||||
assertThat(desc.toString()).isEqualTo(
|
assertThat(getGlifLayout(mActivity).getDescriptionText().toString()).isEqualTo(
|
||||||
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
|
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
|
||||||
|
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
|
||||||
|
View.GONE);
|
||||||
|
|
||||||
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
||||||
0 /* id */,
|
0 /* id */,
|
||||||
@@ -329,18 +333,27 @@ public class FaceEnrollIntroductionTest {
|
|||||||
true /* supportsSelfIllumination */,
|
true /* supportsSelfIllumination */,
|
||||||
false /* resetLockoutRequiresChallenge */));
|
false /* resetLockoutRequiresChallenge */));
|
||||||
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
|
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
|
||||||
desc = getGlifLayout(mActivity).getDescriptionText();
|
|
||||||
|
|
||||||
assertThat(desc.toString()).isEqualTo(
|
assertThat(getGlifLayout(mActivity).getDescriptionText().toString()).isEqualTo(
|
||||||
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
|
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
|
||||||
|
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
|
||||||
|
View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFaceEnrollIntroduction_hasDescriptionNoLessSecure_strongFace()
|
public void testFaceEnrollIntroduction_hasDescriptionNoLessSecure_strongFace()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
setupActivity();
|
setupActivity();
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
R.bool.config_face_intro_show_less_secure,
|
||||||
|
true);
|
||||||
verify(mFaceManager).addAuthenticatorsRegisteredCallback(mCaptor.capture());
|
verify(mFaceManager).addAuthenticatorsRegisteredCallback(mCaptor.capture());
|
||||||
|
|
||||||
|
assertThat(getGlifLayout(mActivity).getDescriptionText().toString()).isEqualTo(
|
||||||
|
mContext.getString(R.string.security_settings_face_enroll_introduction_message));
|
||||||
|
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
|
||||||
|
View.GONE);
|
||||||
|
|
||||||
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
|
||||||
0 /* id */,
|
0 /* id */,
|
||||||
FaceSensorProperties.STRENGTH_STRONG,
|
FaceSensorProperties.STRENGTH_STRONG,
|
||||||
@@ -351,11 +364,12 @@ public class FaceEnrollIntroductionTest {
|
|||||||
true /* supportsSelfIllumination */,
|
true /* supportsSelfIllumination */,
|
||||||
false /* resetLockoutRequiresChallenge */));
|
false /* resetLockoutRequiresChallenge */));
|
||||||
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
|
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
|
||||||
CharSequence desc = getGlifLayout(mActivity).getDescriptionText();
|
|
||||||
|
|
||||||
assertThat(desc.toString()).isEqualTo(
|
assertThat(getGlifLayout(mActivity).getDescriptionText().toString()).isEqualTo(
|
||||||
mContext.getString(
|
mContext.getString(
|
||||||
R.string.security_settings_face_enroll_introduction_message_class3));
|
R.string.security_settings_face_enroll_introduction_message_class3));
|
||||||
|
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
|
||||||
|
View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -11,10 +11,7 @@
|
|||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings.fuelgauge;
|
package com.android.settings.fuelgauge;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@@ -29,6 +26,9 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.hardware.usb.UsbManager;
|
||||||
|
import android.hardware.usb.UsbPort;
|
||||||
|
import android.hardware.usb.UsbPortStatus;
|
||||||
import android.icu.text.NumberFormat;
|
import android.icu.text.NumberFormat;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
@@ -43,6 +43,7 @@ import com.android.settings.core.BasePreferenceController;
|
|||||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.SmartBatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.SmartBatteryTip;
|
||||||
|
import com.android.settings.testutils.BatteryTestUtils;
|
||||||
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
import com.android.settings.widget.EntityHeaderController;
|
import com.android.settings.widget.EntityHeaderController;
|
||||||
@@ -85,6 +86,13 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
private UsageProgressBarPreference mBatteryUsageProgressBarPref;
|
private UsageProgressBarPreference mBatteryUsageProgressBarPref;
|
||||||
@Mock
|
@Mock
|
||||||
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
|
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
|
||||||
|
@Mock
|
||||||
|
private UsbPort mUsbPort;
|
||||||
|
@Mock
|
||||||
|
private UsbManager mUsbManager;
|
||||||
|
@Mock
|
||||||
|
private UsbPortStatus mUsbPortStatus;
|
||||||
|
|
||||||
private BatteryHeaderPreferenceController mController;
|
private BatteryHeaderPreferenceController mController;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ShadowPowerManager mShadowPowerManager;
|
private ShadowPowerManager mShadowPowerManager;
|
||||||
@@ -99,6 +107,7 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
mLifecycleOwner = () -> mLifecycle;
|
mLifecycleOwner = () -> mLifecycle;
|
||||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
when(mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
|
||||||
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
|
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
|
||||||
|
|
||||||
mBatteryIntent = new Intent();
|
mBatteryIntent = new Intent();
|
||||||
@@ -289,6 +298,16 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(null);
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updatePreference_incompatibleCharger_showNotChargingState() {
|
||||||
|
BatteryTestUtils.setupIncompatibleEvent(mUsbPort, mUsbManager, mUsbPortStatus);
|
||||||
|
|
||||||
|
mController.updateHeaderPreference(mBatteryInfo);
|
||||||
|
|
||||||
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(
|
||||||
|
mContext.getString(R.string.battery_info_status_not_charging));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void quickUpdateHeaderPreference_onlyUpdateBatteryLevelAndChargingState() {
|
public void quickUpdateHeaderPreference_onlyUpdateBatteryLevelAndChargingState() {
|
||||||
mController.quickUpdateHeaderPreference();
|
mController.quickUpdateHeaderPreference();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.testutils.BatteryTestUtils;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
@@ -136,7 +137,7 @@ public class TopLevelBatteryPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDashboardLabel_incompatibleCharger_returnsCorrectLabel() {
|
public void getDashboardLabel_incompatibleCharger_returnsCorrectLabel() {
|
||||||
setupIncompatibleEvent();
|
BatteryTestUtils.setupIncompatibleEvent(mUsbPort, mUsbManager, mUsbPortStatus);
|
||||||
mController.mPreference = new Preference(mContext);
|
mController.mPreference = new Preference(mContext);
|
||||||
BatteryInfo info = new BatteryInfo();
|
BatteryInfo info = new BatteryInfo();
|
||||||
|
|
||||||
@@ -150,14 +151,4 @@ public class TopLevelBatteryPreferenceControllerTest {
|
|||||||
assertThat(mController.getSummary())
|
assertThat(mController.getSummary())
|
||||||
.isEqualTo(mContext.getString(R.string.battery_missing_message));
|
.isEqualTo(mContext.getString(R.string.battery_missing_message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupIncompatibleEvent() {
|
|
||||||
final List<UsbPort> usbPorts = new ArrayList<>();
|
|
||||||
usbPorts.add(mUsbPort);
|
|
||||||
when(mUsbManager.getPorts()).thenReturn(usbPorts);
|
|
||||||
when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
|
|
||||||
when(mUsbPort.supportsComplianceWarnings()).thenReturn(true);
|
|
||||||
when(mUsbPortStatus.isConnected()).thenReturn(true);
|
|
||||||
when(mUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import android.content.Context;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.util.FeatureFlagUtils;
|
||||||
import android.view.autofill.AutofillManager;
|
import android.view.autofill.AutofillManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.view.textservice.TextServicesManager;
|
import android.view.textservice.TextServicesManager;
|
||||||
@@ -119,6 +120,7 @@ public class LanguageAndInputSettingsTest {
|
|||||||
final Resources res = spy(RuntimeEnvironment.application.getResources());
|
final Resources res = spy(RuntimeEnvironment.application.getResources());
|
||||||
final InputManager inputManager = mock(InputManager.class);
|
final InputManager inputManager = mock(InputManager.class);
|
||||||
final TextServicesManager textServicesManager = mock(TextServicesManager.class);
|
final TextServicesManager textServicesManager = mock(TextServicesManager.class);
|
||||||
|
FeatureFlagUtils.setEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI, false);
|
||||||
when(inputManager.getInputDeviceIds()).thenReturn(new int[0]);
|
when(inputManager.getInputDeviceIds()).thenReturn(new int[0]);
|
||||||
doReturn(inputManager).when(context).getSystemService(Context.INPUT_SERVICE);
|
doReturn(inputManager).when(context).getSystemService(Context.INPUT_SERVICE);
|
||||||
doReturn(textServicesManager).when(context)
|
doReturn(textServicesManager).when(context)
|
||||||
|
|||||||
@@ -16,11 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.testutils;
|
package com.android.settings.testutils;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.hardware.usb.UsbManager;
|
||||||
|
import android.hardware.usb.UsbPort;
|
||||||
|
import android.hardware.usb.UsbPortStatus;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
|
|
||||||
import com.android.settings.fuelgauge.batteryusage.BatteryInformation;
|
import com.android.settings.fuelgauge.batteryusage.BatteryInformation;
|
||||||
@@ -36,6 +40,9 @@ import com.google.common.collect.ImmutableList;
|
|||||||
|
|
||||||
import org.robolectric.Shadows;
|
import org.robolectric.Shadows;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BatteryTestUtils {
|
public class BatteryTestUtils {
|
||||||
|
|
||||||
public static Intent getChargingIntent() {
|
public static Intent getChargingIntent() {
|
||||||
@@ -163,6 +170,7 @@ public class BatteryTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Gets customized battery changed intent. */
|
||||||
public static Intent getCustomBatteryIntent(int plugged, int level, int scale, int status) {
|
public static Intent getCustomBatteryIntent(int plugged, int level, int scale, int status) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(BatteryManager.EXTRA_PLUGGED, plugged);
|
intent.putExtra(BatteryManager.EXTRA_PLUGGED, plugged);
|
||||||
@@ -172,4 +180,16 @@ public class BatteryTestUtils {
|
|||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Configures the incompatible charger environment. */
|
||||||
|
public static void setupIncompatibleEvent(
|
||||||
|
UsbPort mockUsbPort, UsbManager mockUsbManager, UsbPortStatus mockUsbPortStatus) {
|
||||||
|
final List<UsbPort> usbPorts = new ArrayList<>();
|
||||||
|
usbPorts.add(mockUsbPort);
|
||||||
|
when(mockUsbManager.getPorts()).thenReturn(usbPorts);
|
||||||
|
when(mockUsbPort.getStatus()).thenReturn(mockUsbPortStatus);
|
||||||
|
when(mockUsbPort.supportsComplianceWarnings()).thenReturn(true);
|
||||||
|
when(mockUsbPortStatus.isConnected()).thenReturn(true);
|
||||||
|
when(mockUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEA
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Matchers.anyInt;
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|||||||
@@ -385,35 +385,19 @@ public class MobileNetworkUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isWifiCallingEnabled_hasPhoneAccountHandleAndHasActivityHandleIntent_returnTrue() {
|
public void isWifiCallingEnabled_wifiCallingIsReady_returnTrue() {
|
||||||
buildPhoneAccountConfigureIntent(true);
|
|
||||||
|
|
||||||
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
|
||||||
null, mPhoneAccountHandle));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isWifiCallingEnabled_hasPhoneAccountHandleAndNoActivityHandleIntent_returnFalse() {
|
|
||||||
buildPhoneAccountConfigureIntent(false);
|
|
||||||
|
|
||||||
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
|
||||||
null, mPhoneAccountHandle));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isWifiCallingEnabled_noPhoneAccountHandleAndWifiCallingIsReady_returnTrue() {
|
|
||||||
setWifiCallingEnabled(true);
|
setWifiCallingEnabled(true);
|
||||||
|
|
||||||
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
||||||
mMockQueryWfcState, null));
|
mMockQueryWfcState));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isWifiCallingEnabled_noPhoneAccountHandleAndWifiCallingNotReady_returnFalse() {
|
public void isWifiCallingEnabled_wifiCallingNotReady_returnFalse() {
|
||||||
setWifiCallingEnabled(false);
|
setWifiCallingEnabled(false);
|
||||||
|
|
||||||
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
|
||||||
mMockQueryWfcState, null));
|
mMockQueryWfcState));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWifiCallingEnabled(boolean enabled){
|
private void setWifiCallingEnabled(boolean enabled){
|
||||||
|
|||||||
Reference in New Issue
Block a user