Merge "Added intro lottie for foldable." into tm-qpr-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8334466..564d5c2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2976,6 +2976,7 @@
android:taskAffinity="com.android.settings.FallbackHome"
android:exported="true"
android:theme="@style/FallbackHome"
+ android:permission="android.permission.DEVICE_POWER"
android:configChanges="keyboardHidden">
<intent-filter android:priority="-1000">
<action android:name="android.intent.action.MAIN" />
diff --git a/res/layout/sfps_enroll_finish_base.xml b/res/layout/sfps_enroll_finish_base.xml
index 8d062d9..1773337 100644
--- a/res/layout/sfps_enroll_finish_base.xml
+++ b/res/layout/sfps_enroll_finish_base.xml
@@ -30,12 +30,14 @@
android:clipToPadding="false"
android:clipChildren="false">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical">
+ <com.android.settings.biometrics.fingerprint.FingerprintRequireScreenOnToAuthToggle
+ style="@style/SudSwitchStyle"
+ android:id="@+id/require_screen_on_to_auth_toggle"
+ android:layout_gravity="start"
+ android:paddingLeft="0dp"
+ android:paddingStart="0dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
<com.google.android.setupdesign.view.FillContentLayout
android:layout_width="@dimen/sfps_enrollment_finished_icon_max_size"
@@ -54,21 +56,6 @@
android:importantForAccessibility="no"
android:src="@drawable/sfps_enroll_finish" />
</com.google.android.setupdesign.view.FillContentLayout>
-
- <Space
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <com.android.settings.biometrics.fingerprint.FingerprintRequireScreenOnToAuthToggle
- style="@style/SudSwitchStyle"
- android:id="@+id/require_screen_on_to_auth_toggle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal|bottom" />
-
- </LinearLayout>
-
</LinearLayout>
-</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
+</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/sfps_require_screen_on_to_auth_toggle.xml b/res/layout/sfps_require_screen_on_to_auth_toggle.xml
index 929b64b..02bb979 100644
--- a/res/layout/sfps_require_screen_on_to_auth_toggle.xml
+++ b/res/layout/sfps_require_screen_on_to_auth_toggle.xml
@@ -19,24 +19,16 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_gravity="start"
style="?attr/fingerprint_layout_theme">
- <!-- Top divider -->
- <View
- android:layout_alignParentTop="true"
- android:layout_width="match_parent"
- android:layout_height="1dp"
- android:background="?android:attr/listDivider" />
-
<!-- Title -->
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/title"
- android:paddingHorizontal="8dp"
android:paddingTop="8dp"
android:paddingBottom="4dp"
- android:gravity="start"
android:layout_alignParentStart="true"
- android:layout_toStartOf="@+id/toggle"
+ android:textAlignment="viewStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/security_settings_require_screen_on_to_auth_title"
@@ -47,9 +39,9 @@
<!-- Subtitle -->
<TextView
android:id="@+id/subtitle"
- android:paddingHorizontal="8dp"
android:paddingBottom="8dp"
android:layout_alignParentStart="true"
+ android:textAlignment="viewStart"
android:layout_toStartOf="@+id/toggle"
android:layout_below="@+id/title"
android:layout_width="wrap_content"
@@ -57,16 +49,6 @@
android:text="@string/security_settings_require_screen_on_to_auth_description"
android:textColor="?android:attr/textColorSecondary"/>
- <!-- Vertical divider -->
- <View
- android:layout_centerVertical="true"
- android:layout_alignTop="@+id/toggle"
- android:layout_alignBottom="@+id/toggle"
- android:layout_toStartOf="@+id/toggle"
- android:layout_width="1dp"
- android:layout_height="wrap_content"
- android:background="?android:attr/listDivider" />
-
<!-- Toggle -->
<Switch
android:layout_alignParentEnd="true"
@@ -74,6 +56,7 @@
android:layout_height="wrap_content"
android:id="@+id/toggle"
android:layout_centerVertical="true"
- android:checked="false"/>
+ android:checked="false"
+ style="@style/SudSwitchStyle"/>
</RelativeLayout>
\ No newline at end of file
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 1c7c891..2cbef99 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -243,7 +243,9 @@
}
private void updateDialog() {
- setRequireScreenOnToAuthVisibility();
+ if (isSfps()) {
+ setRequireScreenOnToAuthVisibility();
+ }
RenameDialog renameDialog = (RenameDialog) getFragmentManager().
findFragmentByTag(RenameDialog.class.getName());
if (renameDialog != null) {
@@ -455,6 +457,15 @@
return false;
}
+ private boolean isSfps() {
+ for (FingerprintSensorPropertiesInternal prop : mSensorProperties) {
+ if (prop.isAnySidefpsType()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
protected void removeFingerprintPreference(int fingerprintId) {
String name = genKey(fingerprintId);
Preference prefToRemove = findPreference(name);
@@ -493,6 +504,10 @@
mRequireScreenOnToAuthPreferenceController.setChecked(!isChecked);
return true;
});
+ mRequireScreenOnToAuthPreference.setVisible(false);
+ if (isSfps()) {
+ setRequireScreenOnToAuthVisibility();
+ }
setPreferenceScreen(root);
return root;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index 8542fcd..a62bbe1 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -24,6 +24,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.os.PowerManager;
import android.os.UserManager;
import android.util.Log;
@@ -125,8 +126,15 @@
// Create an intent triggered by clicking on the
// "Clear All Notifications" button
+ String bluetoothName;
+ try {
+ bluetoothName = Utils.findBluetoothPackageName(context);
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ return;
+ }
Intent deleteIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
- deleteIntent.setPackage("com.android.bluetooth");
+ deleteIntent.setPackage(bluetoothName);
deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
BluetoothDevice.CONNECTION_ACCESS_NO);
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
old mode 100755
new mode 100644
index ca8f9d3..24fe4e1
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -16,11 +16,18 @@
package com.android.settings.bluetooth;
+import static android.os.Process.BLUETOOTH_UID;
+
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
@@ -189,4 +196,48 @@
}
return false;
}
+
+ /**
+ * Returns the Bluetooth Package name
+ */
+ public static String findBluetoothPackageName(Context context)
+ throws NameNotFoundException {
+ // this activity will always be in the package where the rest of Bluetooth lives
+ String sentinelActivity = "com.android.bluetooth.opp.BluetoothOppLauncherActivity";
+ PackageManager packageManager = context.createContextAsUser(UserHandle.SYSTEM, 0)
+ .getPackageManager();
+ String[] allPackages = packageManager.getPackagesForUid(BLUETOOTH_UID);
+ String matchedPackage = null;
+ for (String candidatePackage : allPackages) {
+ PackageInfo packageInfo;
+ try {
+ packageInfo =
+ packageManager.getPackageInfo(
+ candidatePackage,
+ PackageManager.GET_ACTIVITIES
+ | PackageManager.MATCH_ANY_USER
+ | PackageManager.MATCH_UNINSTALLED_PACKAGES
+ | PackageManager.MATCH_DISABLED_COMPONENTS);
+ } catch (NameNotFoundException e) {
+ // rethrow
+ throw e;
+ }
+ if (packageInfo.activities == null) {
+ continue;
+ }
+ for (ActivityInfo activity : packageInfo.activities) {
+ if (sentinelActivity.equals(activity.name)) {
+ if (matchedPackage == null) {
+ matchedPackage = candidatePackage;
+ } else {
+ throw new NameNotFoundException("multiple main bluetooth packages found");
+ }
+ }
+ }
+ }
+ if (matchedPackage != null) {
+ return matchedPackage;
+ }
+ throw new NameNotFoundException("Could not find main bluetooth package");
+ }
}
diff --git a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
index bd8169a..f1677f2 100644
--- a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
@@ -16,9 +16,8 @@
package com.android.settings.development;
+import android.bluetooth.BluetoothManager;
import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
@@ -42,18 +41,15 @@
private int mDefaultMaxConnectedAudioDevices = 0;
+ private final BluetoothManager mBluetoothManager;
+
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
super(context);
- try {
- Resources res = context.getPackageManager().getResourcesForApplication(
- "com.android.bluetooth");
- mDefaultMaxConnectedAudioDevices = res.getInteger(res.getIdentifier(
- "config_bluetooth_max_connected_audio_devices",
- "integer", "com.android.bluetooth"));
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
+ mBluetoothManager = context.getSystemService(BluetoothManager.class);
+
+ mDefaultMaxConnectedAudioDevices =
+ mBluetoothManager.getAdapter().getMaxConnectedAudioDevices();
}
@Override
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index de29aa4..4aa7f44 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -1681,7 +1681,10 @@
}
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
- Bitmap icon = BitmapFactory.decodeStream(avatarDataStream);
+ Bitmap decodedIcon = BitmapFactory.decodeStream(avatarDataStream);
+ CircleFramedDrawable drawable = CircleFramedDrawable.getInstance(context, decodedIcon);
+ Bitmap icon = UserIcons.convertToBitmapAtUserIconSize(context.getResources(), drawable);
+
um.setUserIcon(userId, icon);
try {
avatarDataStream.close();
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
index 72477b9..7ab311f 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
@@ -24,9 +24,9 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.os.SystemProperties;
@@ -54,6 +54,11 @@
@Spy
private Context mSpyContext = RuntimeEnvironment.application;
+ @Mock
+ private BluetoothManager mBluetoothManager;
+ @Mock
+ private BluetoothAdapter mBluetoothAdapter;
+
private ListPreference mPreference;
private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
@@ -63,19 +68,15 @@
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
+ doReturn(mBluetoothManager).when(mSpyContext).getSystemService(BluetoothManager.class);
+ doReturn(mBluetoothAdapter).when(mBluetoothManager).getAdapter();
// Get XML values without mock
// Setup test list preference using XML values
mPreference = new ListPreference(mSpyContext);
mPreference.setEntries(R.array.bluetooth_max_connected_audio_devices);
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
- // Retrieve default max connected audio devices to a test controlled value
- try {
- Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth");
- TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "com.android.bluetooth"));
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
-
+ doReturn(TEST_MAX_CONNECTED_AUDIO_DEVICES).when(mBluetoothAdapter)
+ .getMaxConnectedAudioDevices();
// Init the actual controller
mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mSpyContext);
// Construct preference in the controller via a mocked preference screen object