Snap for 10071751 from 2330c13289 to udc-qpr1-release

Change-Id: I4f3820151f3ffc018e6b8007653518374cc49ccc
This commit is contained in:
Android Build Coastguard Worker
2023-05-05 01:32:28 +00:00
30 changed files with 312 additions and 161 deletions

View File

@@ -17,9 +17,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportWidth="960"
android:viewportHeight="960">
<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"/>
</vector>

View 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>

View 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>

View File

@@ -79,6 +79,7 @@
android:textSize="@dimen/dream_item_title_text_size"
android:textColor="@color/dream_card_text_color_state_list"
android:drawablePadding="@dimen/dream_item_icon_padding"
android:drawableTint="@color/dream_card_icon_color_state_list"
app:layout_constraintTop_toBottomOf="@+id/preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -29,11 +29,11 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
android:layout_marginEnd="8dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_marginBottom="48dip"
android:layout_weight="1">
<Button
@@ -46,7 +46,7 @@
android:layout_alignParentStart="true"
android:paddingVertical="14dp"
android:drawablePadding="9dp"
style="@style/ModifierKeyButtonCancel"
style="@style/TrackpadButtonCancel"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/gesture_button_skip"/>
@@ -60,15 +60,16 @@
android:layout_alignParentStart="true"
android:paddingVertical="14dp"
android:drawablePadding="9dp"
style="@style/ModifierKeyButtonCancel"
style="@style/TrackpadButtonCancel"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/gesture_button_restart"/>
<LinearLayout
android:id="@+id/viewGroup"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:gravity="center"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/button_next"
@@ -80,7 +81,7 @@
android:layout_alignParentEnd="true"
android:paddingVertical="14dp"
android:drawablePadding="9dp"
style="@style/ModifierKeyButtonDone"
style="@style/TrackpadButtonDone"
android:textColor="?androidprv:attr/materialColorOnPrimary"
android:text="@string/gesture_button_next"/>
@@ -94,7 +95,7 @@
android:layout_alignParentEnd="true"
android:paddingVertical="14dp"
android:drawablePadding="9dp"
style="@style/ModifierKeyButtonDone"
style="@style/TrackpadButtonDone"
android:textColor="?androidprv:attr/materialColorOnPrimary"
android:text="@string/gesture_button_done"/>
</RelativeLayout>

View File

@@ -380,6 +380,20 @@
<item name="android:padding">4dp</item>
</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">
<item name="android:gravity">center</item>
<item name="android:maxHeight">@dimen/biometric_auth_pattern_view_max_size</item>

View File

@@ -562,6 +562,7 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
List<String> enabledServices = getEnabledSettings();
mCredentialManager.setEnabledProviders(
new ArrayList<String>(), // TODO(240466271): pass down primary providers
enabledServices,
getUser(),
mExecutor,

View File

@@ -356,6 +356,7 @@ public class DefaultCombinedPicker extends DefaultAppPickerFragment {
}
service.setEnabledProviders(
new ArrayList<String>(), // TODO(240466271): pass down primary providers.
credManProviders,
mUserId,
ContextCompat.getMainExecutor(getContext()),

View File

@@ -182,16 +182,11 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
boolean isFaceStrong = sensors.get(0).sensorStrength
== SensorProperties.STRENGTH_STRONG;
if (mIsFaceStrong == isFaceStrong) {
return;
}
mIsFaceStrong = isFaceStrong;
onFaceStrengthChanged();
}
});
onFaceStrengthChanged();
// This path is an entry point for SetNewPasswordController, e.g.
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {

View File

@@ -107,10 +107,9 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
new BluetoothAdapter.OnMetadataChangedListener() {
@Override
public void onMetadataChanged(BluetoothDevice device, int key, byte[] value) {
if (DEBUG) {
Log.d(TAG, String.format("Metadata updated in Device %s: %d = %s.", device,
key, value == null ? null : new String(value)));
}
Log.d(TAG, String.format("Metadata updated in Device %s: %d = %s.",
device.getAnonymizedAddress(),
key, value == null ? null : new String(value)));
refresh();
}
};
@@ -276,11 +275,22 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
}
final int batteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, batteryMetaKey);
final boolean charging = BluetoothUtils.getBooleanMetaData(bluetoothDevice, chargeMetaKey);
if (DEBUG) {
Log.d(TAG, "updateSubLayout() icon : " + iconMetaKey + ", battery : " + batteryMetaKey
+ ", charge : " + chargeMetaKey + ", batteryLevel : " + batteryLevel
+ ", charging : " + charging + ", iconUri : " + iconUri);
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;
}
}
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) {
showBatteryPredictionIfNecessary(linearLayout, deviceId, batteryLevel);
}
@@ -291,15 +301,6 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
batterySummaryView.setText(
com.android.settings.Utils.formatPercentage(batteryLevel));
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);
} else {
if (deviceId == MAIN_DEVICE_ID) {
@@ -320,7 +321,15 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
}
}
} 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);
if (deviceId == MAIN_DEVICE_ID) {

View File

@@ -41,7 +41,7 @@ import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
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.FooterButton;
@@ -85,6 +85,7 @@ public abstract class StorageWizardBase extends FragmentActivity {
this.setTheme(sudTheme);
ThemeHelper.trySetDynamicColor(this);
super.onCreate(savedInstanceState);
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
mStorage = getSystemService(StorageManager.class);

View File

@@ -19,7 +19,6 @@ package com.android.settings.dream;
import android.annotation.LayoutRes;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.text.TextUtils;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
@@ -86,10 +85,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
final Drawable icon = item.isActive()
? mContext.getDrawable(R.drawable.ic_dream_check_circle)
: 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(
R.dimen.dream_item_icon_size);
icon.setBounds(0, 0, iconSize, iconSize);

View File

@@ -11,8 +11,6 @@
* 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.
*
*
*/
package com.android.settings.fuelgauge;
@@ -25,6 +23,7 @@ import android.icu.text.NumberFormat;
import android.os.BatteryManager;
import android.os.PowerManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceFragmentCompat;
@@ -48,6 +47,8 @@ import com.android.settingslib.widget.UsageProgressBarPreference;
public class BatteryHeaderPreferenceController extends BasePreferenceController
implements PreferenceControllerMixin, LifecycleObserver, OnStart,
BatteryPreferenceController {
private static final String TAG = "BatteryHeaderPreferenceController";
@VisibleForTesting
static final String KEY_BATTERY_HEADER = "battery_header";
private static final int BATTERY_MAX_LEVEL = 100;
@@ -86,7 +87,7 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
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(
mContext.getString(R.string.settings_license_activity_loading));
@@ -109,7 +110,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
}
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;
} else if (info.remainingLabel == null
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
@@ -151,12 +154,14 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
* Callback which receives text for the summary line.
*/
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() {
Intent batteryBroadcast = mContext.registerReceiver(null,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
Intent batteryBroadcast = com.android.settingslib.fuelgauge.BatteryUtils
.getBatteryIntent(mContext);
final int batteryLevel = Utils.getBatteryLevel(batteryBroadcast);
final boolean discharging =
batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;

View File

@@ -164,6 +164,7 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
if (summary != null) {
mPreference.setSummary(summary);
}
Log.d(TAG, "updateBatteryStatus: " + label + " summary: " + summary);
}
@VisibleForTesting

View File

@@ -1754,7 +1754,7 @@ public final class DataProcessor {
private static Set<String> getSystemAppsPackageNames(Context context) {
return sTestSystemAppsPackageNames != null ? sTestSystemAppsPackageNames
: AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId(), false);
: AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId());
}
private static Set<Integer> getSystemAppsUids(Context context) {

View File

@@ -17,17 +17,21 @@
package com.android.settings.inputmethod;
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.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
@@ -87,21 +91,36 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
if (window == null) {
return;
}
setLayoutEdgeToEdge(window);
final Point size = getScreenSize();
final WindowManager.LayoutParams attributes = window.getAttributes();
attributes.width = (int) (size.x * 0.75);
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
public Dialog onCreateDialog(final Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
mInflater = mContext.getSystemService(LayoutInflater.class);
View gestureEducationView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
addViewPager(gestureEducationView);
dialog.setContentView(gestureEducationView);
View contentView = mInflater.inflate(R.layout.trackpad_gesture_preview, null);
addViewPager(contentView);
dialog.setContentView(contentView);
Window gestureDialogWindow = dialog.getWindow();
gestureDialogWindow.setType(TYPE_SYSTEM_DIALOG);
@@ -109,8 +128,40 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
FrameLayout bottomSheet = (FrameLayout)
dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
bottomSheet.setBackgroundResource(android.R.color.transparent);
BottomSheetBehavior.from(bottomSheet)
.setState(BottomSheetBehavior.STATE_EXPANDED);
BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
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;
}
@@ -263,4 +314,16 @@ public class TrackpadGestureDialogFragment extends BottomSheetDialogFragment {
display.getSize(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);
}
}

View File

@@ -25,10 +25,10 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@@ -232,13 +232,12 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
mSubscriptionInfoEntityList.forEach(entity -> {
if (entity.getSubId() == mSubId) {
mSubscriptionInfoEntity = entity;
if (entity.getSubId() == SubscriptionManager.getDefaultDataSubscriptionId()) {
mDefaultSubId = entity.getSubId();
}
}
});
int subId = mSubscriptionInfoEntity.getSubId();
if (mSubscriptionInfoEntity != null
&& subId == SubscriptionManager.getDefaultDataSubscriptionId()) {
mDefaultSubId = subId;
}
update();
refreshSummary(mPreference);
}

View File

@@ -940,28 +940,11 @@ public class MobileNetworkUtils {
* Copied from WifiCallingPreferenceController#isWifiCallingEnabled()
*/
public static boolean isWifiCallingEnabled(Context context, int subId,
@Nullable WifiCallingQueryImsState queryImsState,
@Nullable PhoneAccountHandle phoneAccountHandle) {
if (phoneAccountHandle == null){
phoneAccountHandle = context.getSystemService(TelecomManager.class)
.getSimCallManagerForSubscription(subId);
@Nullable WifiCallingQueryImsState queryImsState) {
if (queryImsState == null) {
queryImsState = new WifiCallingQueryImsState(context, subId);
}
boolean isWifiCallingEnabled;
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;
return queryImsState.isReadyToWifiCalling();
}
/**

View File

@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.PersistableBundle;
import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -314,8 +313,7 @@ public class NetworkProviderWifiCallingGroup extends
@VisibleForTesting
protected boolean shouldShowWifiCallingForSub(int subId) {
if (SubscriptionManager.isValidSubscriptionId(subId)
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, queryImsState(subId),
null)) {
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, queryImsState(subId))) {
return true;
}
return false;

View File

@@ -71,7 +71,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
@Override
public int getAvailabilityStatus(int subId) {
return SubscriptionManager.isValidSubscriptionId(subId)
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, null, null)
&& MobileNetworkUtils.isWifiCallingEnabled(mContext, subId, null)
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}

View File

@@ -853,6 +853,19 @@ public class ChooseLockGeneric extends SettingsActivity {
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
public void onDestroy() {
super.onDestroy();

View File

@@ -257,8 +257,10 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
for (SubscriptionInfo subInfo : subInfoList) {
int subId = subInfo.getSubscriptionId();
try {
if (MobileNetworkUtils.isWifiCallingEnabled(getContext(), subId,
queryImsState(subId), null)) {
if (MobileNetworkUtils.isWifiCallingEnabled(
getContext(),
subId,
queryImsState(subId))) {
selectedList.add(subInfo);
}
} catch (Exception exception) {}

View File

@@ -29,8 +29,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import androidx.annotation.NonNull;
import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
import org.json.JSONException;
@@ -43,8 +41,8 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
@RunWith(RobolectricTestRunner.class)
public class SettingsDumpServiceTest {
@@ -102,15 +100,16 @@ public class SettingsDumpServiceTest {
}
@Test
public void testDump_ReturnJsonObject() throws JSONException {
public void testDump_printServiceAsKey() {
mResolveInfo.activityInfo = new ActivityInfo();
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);
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;
}
}
/**
* 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;
}
}
}

View File

@@ -32,7 +32,6 @@ import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
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.password.ChooseLockSettingsHelper;
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.ShadowLockPatternUtils;
import com.android.settings.testutils.shadow.ShadowSensorPrivacyManager;
@@ -98,7 +98,8 @@ import java.util.List;
ShadowUserManager.class,
ShadowUtils.class,
ShadowDevicePolicyManager.class,
ShadowSensorPrivacyManager.class
ShadowSensorPrivacyManager.class,
SettingsShadowResources.class
})
public class FaceEnrollIntroductionTest {
@@ -188,7 +189,6 @@ public class FaceEnrollIntroductionTest {
mController = Robolectric.buildActivity(
TestFaceEnrollIntroduction.class, testIntent);
mActivity = (TestFaceEnrollIntroduction) spy(mController.get());
doReturn(mFaceManager).when(mActivity).getFaceManager();
when(mActivity.getPostureGuidanceIntent()).thenReturn(null);
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(mFaceManager);
@@ -313,11 +313,15 @@ public class FaceEnrollIntroductionTest {
@Test
public void testFaceEnrollIntroduction_hasDescription_weakFace() throws Exception {
setupActivity();
SettingsShadowResources.overrideResource(
R.bool.config_face_intro_show_less_secure,
true);
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));
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
View.GONE);
List<FaceSensorPropertiesInternal> props = List.of(new FaceSensorPropertiesInternal(
0 /* id */,
@@ -329,18 +333,27 @@ public class FaceEnrollIntroductionTest {
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresChallenge */));
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));
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
View.VISIBLE);
}
@Test
public void testFaceEnrollIntroduction_hasDescriptionNoLessSecure_strongFace()
throws Exception {
setupActivity();
SettingsShadowResources.overrideResource(
R.bool.config_face_intro_show_less_secure,
true);
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(
0 /* id */,
FaceSensorProperties.STRENGTH_STRONG,
@@ -351,11 +364,12 @@ public class FaceEnrollIntroductionTest {
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresChallenge */));
mCaptor.getValue().onAllAuthenticatorsRegistered(props);
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_class3));
assertThat(mActivity.findViewById(R.id.info_row_less_secure).getVisibility()).isEqualTo(
View.GONE);
}
@Test

View File

@@ -11,10 +11,7 @@
* 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.
*
*
*/
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
@@ -29,6 +26,9 @@ import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.Context;
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.os.BatteryManager;
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.LowBatteryTip;
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.ShadowUtils;
import com.android.settings.widget.EntityHeaderController;
@@ -85,6 +86,13 @@ public class BatteryHeaderPreferenceControllerTest {
private UsageProgressBarPreference mBatteryUsageProgressBarPref;
@Mock
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
@Mock
private UsbPort mUsbPort;
@Mock
private UsbManager mUsbManager;
@Mock
private UsbPortStatus mUsbPortStatus;
private BatteryHeaderPreferenceController mController;
private Context mContext;
private ShadowPowerManager mShadowPowerManager;
@@ -99,6 +107,7 @@ public class BatteryHeaderPreferenceControllerTest {
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
mBatteryIntent = new Intent();
@@ -289,6 +298,16 @@ public class BatteryHeaderPreferenceControllerTest {
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
public void quickUpdateHeaderPreference_onlyUpdateBatteryLevelAndChargingState() {
mController.quickUpdateHeaderPreference();

View File

@@ -36,6 +36,7 @@ import androidx.preference.Preference;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.testutils.BatteryTestUtils;
import org.junit.Before;
import org.junit.Ignore;
@@ -136,7 +137,7 @@ public class TopLevelBatteryPreferenceControllerTest {
@Test
public void getDashboardLabel_incompatibleCharger_returnsCorrectLabel() {
setupIncompatibleEvent();
BatteryTestUtils.setupIncompatibleEvent(mUsbPort, mUsbManager, mUsbPortStatus);
mController.mPreference = new Preference(mContext);
BatteryInfo info = new BatteryInfo();
@@ -150,14 +151,4 @@ public class TopLevelBatteryPreferenceControllerTest {
assertThat(mController.getSummary())
.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});
}
}

View File

@@ -32,6 +32,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.hardware.input.InputManager;
import android.os.UserManager;
import android.util.FeatureFlagUtils;
import android.view.autofill.AutofillManager;
import android.view.inputmethod.InputMethodManager;
import android.view.textservice.TextServicesManager;
@@ -119,6 +120,7 @@ public class LanguageAndInputSettingsTest {
final Resources res = spy(RuntimeEnvironment.application.getResources());
final InputManager inputManager = mock(InputManager.class);
final TextServicesManager textServicesManager = mock(TextServicesManager.class);
FeatureFlagUtils.setEnabled(context, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI, false);
when(inputManager.getInputDeviceIds()).thenReturn(new int[0]);
doReturn(inputManager).when(context).getSystemService(Context.INPUT_SERVICE);
doReturn(textServicesManager).when(context)

View File

@@ -16,11 +16,15 @@
package com.android.settings.testutils;
import static org.mockito.Mockito.when;
import android.content.Context;
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.UserManager;
import androidx.room.Room;
import com.android.settings.fuelgauge.batteryusage.BatteryInformation;
@@ -36,6 +40,9 @@ import com.google.common.collect.ImmutableList;
import org.robolectric.Shadows;
import java.util.ArrayList;
import java.util.List;
public class BatteryTestUtils {
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) {
Intent intent = new Intent();
intent.putExtra(BatteryManager.EXTRA_PLUGGED, plugged);
@@ -172,4 +180,16 @@ public class BatteryTestUtils {
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});
}
}

View File

@@ -20,7 +20,6 @@ import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEA
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.spy;
import static org.mockito.Mockito.verify;

View File

@@ -385,35 +385,19 @@ public class MobileNetworkUtilsTest {
}
@Test
public void isWifiCallingEnabled_hasPhoneAccountHandleAndHasActivityHandleIntent_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() {
public void isWifiCallingEnabled_wifiCallingIsReady_returnTrue() {
setWifiCallingEnabled(true);
assertTrue(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
mMockQueryWfcState, null));
mMockQueryWfcState));
}
@Test
public void isWifiCallingEnabled_noPhoneAccountHandleAndWifiCallingNotReady_returnFalse() {
public void isWifiCallingEnabled_wifiCallingNotReady_returnFalse() {
setWifiCallingEnabled(false);
assertFalse(MobileNetworkUtils.isWifiCallingEnabled(mContext, SUB_ID_1,
mMockQueryWfcState, null));
mMockQueryWfcState));
}
private void setWifiCallingEnabled(boolean enabled){