summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Veit <claymore1298@gmail.com>2025-12-07 21:15:42 +0000
committerJulian Veit <claymore1298@gmail.com>2025-12-07 21:15:42 +0000
commit8c019759ef5a6c48fe0d4f579ddc1dc9a7ec0314 (patch)
tree718aa806667e1105dc3661fb050651b76d40693a /src
parentbfce05cfd6c193b5c835f6b97ca47cb467a3b17e (diff)
parentcee9137640af063f184a0e7a5e4308463fe5fa80 (diff)
Merge https://github.com/LineageOS/android_packages_apps_Settings into HEADw16.0
Change-Id: I0bb12b8388769880a62fa840779c6a69b12e519e
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/biometrics/BiometricEnrollBase.java7
-rw-r--r--src/com/android/settings/biometrics/face/FaceEnroll.kt9
-rw-r--r--src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java5
-rw-r--r--src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java70
-rw-r--r--src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java29
-rw-r--r--src/com/android/settings/nfc/DefaultPaymentSettings.java29
-rw-r--r--src/com/android/settings/nfc/PaymentBackend.java19
7 files changed, 111 insertions, 57 deletions
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index c4c8dc0f7ed..e4765d8ea0d 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -182,7 +182,12 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
EXTRA_LAUNCHED_POSTURE_GUIDANCE);
mNextLaunched = savedInstanceState.getBoolean(EXTRA_KEY_NEXT_LAUNCHED);
}
- mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
+ final String callingPackage = getLaunchedFromPackage();
+ if (callingPackage == null || !getPackageName().equals(callingPackage)) {
+ mUserId = UserHandle.myUserId();
+ } else {
+ mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
+ }
mPostureGuidanceIntent = FeatureFactory.getFeatureFactory()
.getFaceFeatureProvider().getPostureGuidanceIntent(getApplicationContext());
diff --git a/src/com/android/settings/biometrics/face/FaceEnroll.kt b/src/com/android/settings/biometrics/face/FaceEnroll.kt
index 74f1613aafe..48ea527c032 100644
--- a/src/com/android/settings/biometrics/face/FaceEnroll.kt
+++ b/src/com/android/settings/biometrics/face/FaceEnroll.kt
@@ -20,6 +20,7 @@ import android.app.ComponentCaller
import android.content.Intent
import android.os.Bundle
import android.util.Log
+import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AppCompatActivity
import com.android.settings.biometrics.BiometricEnrollBase.RESULT_FINISHED
import com.android.settings.biometrics.combination.CombinedBiometricStatusUtils
@@ -38,6 +39,9 @@ class FaceEnroll: AppCompatActivity() {
private val enrollActivityProvider: FaceEnrollActivityClassProvider
get() = featureFactory.faceFeatureProvider.enrollActivityClassProvider
+ @VisibleForTesting
+ var launchedFromProvider: () -> String? = { launchedFromPackage }
+
private var isLaunched = false
override fun onCreate(savedInstanceState: Bundle?) {
@@ -56,6 +60,11 @@ class FaceEnroll: AppCompatActivity() {
Log.d("FaceEnroll", "forward to $nextActivityClass")
val nextIntent = Intent(this, nextActivityClass)
nextIntent.putExtras(intent)
+
+ // drop extras that are not allowed from external packages before launching
+ if (launchedFromProvider() != packageName) {
+ nextIntent.removeExtra(Intent.EXTRA_USER_ID)
+ }
startActivityForResult(nextIntent, 0)
isLaunched = true
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 946d9b3eb25..f5944561580 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -239,9 +239,8 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
if (token != null) {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
}
- final int userId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
- if (userId != UserHandle.USER_NULL) {
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
+ if (mUserId != UserHandle.USER_NULL) {
+ intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
index 476f00206fe..5079c03ca35 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
@@ -18,8 +18,6 @@ package com.android.settings.bluetooth;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
@@ -47,7 +45,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
* for the bluetooth device.
*/
public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment implements
- TextWatcher, OnClickListener {
+ TextWatcher {
private static final String TAG = "BTPairingDialogFragment";
@@ -108,22 +106,19 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
@Override
public void afterTextChanged(Editable s) {
// enable the positive button when we detect potentially valid input
- Button positiveButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
- if (positiveButton != null) {
- positiveButton.setEnabled(mPairingController.isPasskeyValid(s));
- }
+ mDialog.findViewById(R.id.positive_button).setEnabled(mPairingController.isPasskeyValid(s));
// notify the controller about user input
mPairingController.updateUserInput(s.toString());
}
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- mPositiveClicked = true;
- mPairingController.onDialogPositiveClick(this);
- } else if (which == DialogInterface.BUTTON_NEGATIVE) {
- mPairingController.onDialogNegativeClick(this);
- }
+ protected void onAcceptButtonClicked() {
+ mPositiveClicked = true;
+ mPairingController.onDialogPositiveClick(this);
+ mPairingDialogActivity.dismiss();
+ }
+
+ protected void onDeclineButtonClicked() {
+ mPairingController.onDialogNegativeClick(this);
mPairingDialogActivity.dismiss();
}
@@ -224,12 +219,10 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
mBuilder.setTitle(getString(R.string.bluetooth_pairing_request,
mPairingController.getDeviceName()));
mBuilder.setView(createPinEntryView());
- mBuilder.setPositiveButton(getString(android.R.string.ok), this);
- mBuilder.setNegativeButton(getString(android.R.string.cancel), this);
AlertDialog dialog = mBuilder.create();
dialog.setOnShowListener(d -> {
if (TextUtils.isEmpty(getPairingViewText())) {
- mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
+ mDialog.findViewById(R.id.positive_button).setEnabled(false);
}
if (mPairingView != null && mPairingView.requestFocus()) {
InputMethodManager imm = (InputMethodManager)
@@ -294,6 +287,11 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
pairingView.setFilters(new InputFilter[]{
new LengthFilter(maxLength)});
+ Button negativeButton = view.findViewById(R.id.negative_button);
+ negativeButton.setOnClickListener(v -> onDeclineButtonClicked());
+ Button positiveButton = view.findViewById(R.id.positive_button);
+ positiveButton.setOnClickListener(v -> onAcceptButtonClicked());
+
return view;
}
@@ -301,13 +299,13 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
* Creates a dialog with UI elements that allow the user to confirm a pairing request.
*/
private AlertDialog createConfirmationDialog() {
- mBuilder.setTitle(getString(R.string.bluetooth_pairing_request,
- mPairingController.getDeviceName()));
+ if (mPairingController.hasPairingContent()) {
+ mBuilder.setTitle(getString(R.string.bluetooth_pairing_confirmation_title));
+ } else {
+ mBuilder.setTitle(getString(R.string.bluetooth_pairing_request,
+ mPairingController.getDeviceName()));
+ }
mBuilder.setView(createView());
- mBuilder.setPositiveButton(
- getString(com.android.settingslib.R.string.bluetooth_pairing_accept), this);
- mBuilder.setNegativeButton(
- getString(com.android.settingslib.R.string.bluetooth_pairing_decline), this);
AlertDialog dialog = mBuilder.create();
return dialog;
}
@@ -327,7 +325,6 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
mBuilder.setTitle(getString(R.string.bluetooth_pairing_request,
mPairingController.getDeviceName()));
mBuilder.setView(createView());
- mBuilder.setNegativeButton(getString(android.R.string.cancel), this);
AlertDialog dialog = mBuilder.create();
// Tell the controller the dialog has been created.
@@ -342,6 +339,8 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
*/
private View createView() {
View view = getActivity().getLayoutInflater().inflate(R.layout.bluetooth_pin_confirm, null);
+ TextView pairingConfirmationHint =
+ (TextView) view.findViewById(R.id.pairing_confirmation_hint);
TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption);
TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead);
TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message);
@@ -356,11 +355,20 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
messagePairing.setVisibility(mPairingController.isDisplayPairingKeyVariant()
? View.VISIBLE : View.GONE);
if (mPairingController.hasPairingContent()) {
- pairingViewCaption.setVisibility(View.VISIBLE);
+ if (mPairingController.isDisplayPairingKeyVariant()) {
+ pairingViewCaption.setVisibility(View.VISIBLE);
+ } else {
+ pairingConfirmationHint.setText(
+ getString(
+ R.string.bluetooth_pairing_confirmation_msg,
+ mPairingController.getDeviceName()));
+ pairingConfirmationHint.setVisibility(View.VISIBLE);
+ }
pairingViewContent.setVisibility(View.VISIBLE);
pairingViewContent.setText(mPairingController.getPairingContent());
}
final TextView messagePairingSet = (TextView) view.findViewById(R.id.pairing_group_message);
+
if (mPairingController.isLateBonding()) {
messagePairingSet.setText(getString(R.string.bluetooth_pairing_group_late_bonding));
}
@@ -369,6 +377,16 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
mPairingController.isCoordinatedSetMemberDevice() || mPairingController.isLateBonding();
messagePairingSet.setVisibility(setPairingMessage ? View.VISIBLE : View.GONE);
+
+ Button negativeButton = view.findViewById(R.id.negative_button);
+ negativeButton.setVisibility(View.VISIBLE);
+ negativeButton.setOnClickListener(v -> onDeclineButtonClicked());
+ if (mPairingController.getDialogType() == BluetoothPairingController.CONFIRMATION_DIALOG) {
+ Button positiveButton = view.findViewById(R.id.positive_button);
+ positiveButton.setVisibility(View.VISIBLE);
+ positiveButton.setOnClickListener(v -> onAcceptButtonClicked());
+ }
+
return view;
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java
index 1f5374dac8a..f263884d72f 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java
@@ -63,7 +63,8 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
TipType.BATTERY_DEFENDER,
TipType.DOCK_DEFENDER,
TipType.INCOMPATIBLE_CHARGER,
- TipType.BATTERY_WARNING
+ TipType.BATTERY_WARNING,
+ TipType.BATTERY_HEALTH
})
public @interface TipType {
int SMART_BATTERY_MANAGER = 0;
@@ -78,24 +79,26 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
int DOCK_DEFENDER = 9;
int INCOMPATIBLE_CHARGER = 10;
int BATTERY_WARNING = 11;
+ int BATTERY_HEALTH = 12;
}
@VisibleForTesting static final SparseIntArray TIP_ORDER;
static {
TIP_ORDER = new SparseIntArray();
- TIP_ORDER.append(TipType.BATTERY_SAVER, 0);
- TIP_ORDER.append(TipType.LOW_BATTERY, 1);
- TIP_ORDER.append(TipType.BATTERY_DEFENDER, 2);
- TIP_ORDER.append(TipType.DOCK_DEFENDER, 3);
- TIP_ORDER.append(TipType.INCOMPATIBLE_CHARGER, 4);
- TIP_ORDER.append(TipType.APP_RESTRICTION, 5);
- TIP_ORDER.append(TipType.HIGH_DEVICE_USAGE, 6);
- TIP_ORDER.append(TipType.SUMMARY, 7);
- TIP_ORDER.append(TipType.SMART_BATTERY_MANAGER, 8);
- TIP_ORDER.append(TipType.REDUCED_BATTERY, 9);
- TIP_ORDER.append(TipType.REMOVE_APP_RESTRICTION, 10);
- TIP_ORDER.append(TipType.BATTERY_WARNING, 11);
+ TIP_ORDER.append(TipType.BATTERY_HEALTH, 0);
+ TIP_ORDER.append(TipType.BATTERY_SAVER, 1);
+ TIP_ORDER.append(TipType.LOW_BATTERY, 2);
+ TIP_ORDER.append(TipType.BATTERY_DEFENDER, 3);
+ TIP_ORDER.append(TipType.DOCK_DEFENDER, 4);
+ TIP_ORDER.append(TipType.INCOMPATIBLE_CHARGER, 5);
+ TIP_ORDER.append(TipType.APP_RESTRICTION, 6);
+ TIP_ORDER.append(TipType.HIGH_DEVICE_USAGE, 7);
+ TIP_ORDER.append(TipType.SUMMARY, 8);
+ TIP_ORDER.append(TipType.SMART_BATTERY_MANAGER, 9);
+ TIP_ORDER.append(TipType.REDUCED_BATTERY, 10);
+ TIP_ORDER.append(TipType.REMOVE_APP_RESTRICTION, 11);
+ TIP_ORDER.append(TipType.BATTERY_WARNING, 12);
}
private static final String KEY_PREFIX = "key_battery_tip";
diff --git a/src/com/android/settings/nfc/DefaultPaymentSettings.java b/src/com/android/settings/nfc/DefaultPaymentSettings.java
index ddac08beb00..440f09e3d9b 100644
--- a/src/com/android/settings/nfc/DefaultPaymentSettings.java
+++ b/src/com/android/settings/nfc/DefaultPaymentSettings.java
@@ -17,7 +17,6 @@
package com.android.settings.nfc;
import android.app.settings.SettingsEnums;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -45,6 +44,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
/**
* DefaultPaymentSettings handles the NFC default payment app selection.
@@ -53,7 +55,7 @@ public class DefaultPaymentSettings extends DefaultAppPickerFragment {
public static final String TAG = "DefaultPaymentSettings";
private PaymentBackend mPaymentBackend;
- private List<PaymentAppInfo> mAppInfos;
+ private Map<String, PaymentAppInfo> mAppInfos;
private FooterPreference mFooterPreference;
@Override
@@ -67,22 +69,19 @@ public class DefaultPaymentSettings extends DefaultAppPickerFragment {
}
@Override
+ @SuppressWarnings("NullAway")
protected String getDefaultKey() {
PaymentAppInfo defaultAppInfo = mPaymentBackend.getDefaultApp();
- if (defaultAppInfo != null) {
- return defaultAppInfo.componentName.flattenToString() + " "
- + defaultAppInfo.userHandle.getIdentifier();
- }
- return null;
+ if (defaultAppInfo == null) return null;
+ return defaultAppInfo.getKey();
}
@Override
protected boolean setDefaultKey(String key) {
- String[] keys = key.split(" ");
- if (keys.length >= 2) {
- mPaymentBackend.setDefaultPaymentApp(ComponentName.unflattenFromString(keys[0]),
- Integer.parseInt(keys[1]));
- }
+ PaymentAppInfo appInfo = mAppInfos.get(key);
+ if (appInfo == null) return true;
+ mPaymentBackend.setDefaultPaymentApp(
+ appInfo.componentName, appInfo.userHandle.getIdentifier());
return true;
}
@@ -90,7 +89,9 @@ public class DefaultPaymentSettings extends DefaultAppPickerFragment {
public void onAttach(Context context) {
super.onAttach(context);
mPaymentBackend = new PaymentBackend(getActivity());
- mAppInfos = mPaymentBackend.getPaymentAppInfos();
+ mAppInfos = mPaymentBackend.getPaymentAppInfos()
+ .stream()
+ .collect(Collectors.toMap(PaymentAppInfo::getKey, Function.identity()));
}
@Override
@@ -147,7 +148,7 @@ public class DefaultPaymentSettings extends DefaultAppPickerFragment {
@Override
protected List<? extends CandidateInfo> getCandidates() {
final List<NfcPaymentCandidateInfo> candidates = new ArrayList<>();
- for (PaymentAppInfo appInfo: mAppInfos) {
+ for (PaymentAppInfo appInfo: mAppInfos.values()) {
UserManager um = getContext().createContextAsUser(
appInfo.userHandle, /*flags=*/0).getSystemService(UserManager.class);
boolean isManagedProfile = um.isManagedProfile(appInfo.userHandle.getIdentifier());
diff --git a/src/com/android/settings/nfc/PaymentBackend.java b/src/com/android/settings/nfc/PaymentBackend.java
index 021d673e152..de733081a1d 100644
--- a/src/com/android/settings/nfc/PaymentBackend.java
+++ b/src/com/android/settings/nfc/PaymentBackend.java
@@ -36,6 +36,7 @@ import com.android.internal.content.PackageMonitor;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
public class PaymentBackend {
public static final String TAG = "Settings.PaymentBackend";
@@ -52,6 +53,24 @@ public class PaymentBackend {
public ComponentName settingsComponent;
public UserHandle userHandle;
public Drawable icon;
+
+ public String getKey() {
+ return Integer.toString(hashCode());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(componentName, userHandle);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PaymentAppInfo)) return false;
+ PaymentAppInfo appInfo = (PaymentAppInfo) o;
+ return componentName.equals(appInfo.componentName)
+ && userHandle.equals(appInfo.userHandle);
+ }
}
/**