summaryrefslogtreecommitdiff
path: root/packages/SettingsLib/src
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2021-03-23 20:33:04 +0000
committerScott Lobdell <slobdell@google.com>2021-03-24 02:40:01 +0000
commit757dbb836469bbdd7eb8312deaf584fe0c99c17d (patch)
treea678b33ad5f0f024d0f942f127b91665f0616193 /packages/SettingsLib/src
parent7710a95746be8dba8c6ffe7172f9c01334a2ca81 (diff)
parentf022dd1e6827ebf7c52b06aa40f2059a3f0f5cad (diff)
Merge SP1A.210311.001
Change-Id: Id1a205bf3f0609c0b13e4bea377056c3b06299fa
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/Utils.java9
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java8
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/connectivity/ConnectivitySubsystemsRecoveryManager.java15
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java50
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java2
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/media/MediaOutputConstants.java3
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java41
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/mobile/TelephonyIcons.java8
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java7
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/users/EditUserPhotoController.java9
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java5
11 files changed, 85 insertions, 72 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java
index f38f3d1db72e..f4117cec3652 100644
--- a/packages/SettingsLib/src/com/android/settingslib/Utils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java
@@ -25,6 +25,7 @@ import android.location.LocationManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
+import android.net.TetheringManager;
import android.net.vcn.VcnTransportInfo;
import android.net.wifi.WifiInfo;
import android.os.BatteryManager;
@@ -114,10 +115,10 @@ public class Utils {
* Return string resource that best describes combination of tethering
* options available on this device.
*/
- public static int getTetheringLabel(ConnectivityManager cm) {
- String[] usbRegexs = cm.getTetherableUsbRegexs();
- String[] wifiRegexs = cm.getTetherableWifiRegexs();
- String[] bluetoothRegexs = cm.getTetherableBluetoothRegexs();
+ public static int getTetheringLabel(TetheringManager tm) {
+ String[] usbRegexs = tm.getTetherableUsbRegexs();
+ String[] wifiRegexs = tm.getTetherableWifiRegexs();
+ String[] bluetoothRegexs = tm.getTetherableBluetoothRegexs();
boolean usbAvailable = usbRegexs.length != 0;
boolean wifiAvailable = wifiRegexs.length != 0;
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index fc6183be6fb4..7ef3001461fe 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -966,11 +966,11 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
if (BluetoothUuid.containsAnyUuid(uuids, PbapServerProfile.PBAB_CLIENT_UUIDS)) {
// The pairing dialog now warns of phone-book access for paired devices.
// No separate prompt is displayed after pairing.
+ final BluetoothClass bluetoothClass = mDevice.getBluetoothClass();
if (mDevice.getPhonebookAccessPermission() == BluetoothDevice.ACCESS_UNKNOWN) {
- if ((mDevice.getBluetoothClass() != null) &&
- (mDevice.getBluetoothClass().getDeviceClass()
- == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE ||
- mDevice.getBluetoothClass().getDeviceClass()
+ if (bluetoothClass != null && (bluetoothClass.getDeviceClass()
+ == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE
+ || bluetoothClass.getDeviceClass()
== BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)) {
EventLog.writeEvent(0x534e4554, "138529441", -1, "");
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/connectivity/ConnectivitySubsystemsRecoveryManager.java b/packages/SettingsLib/src/com/android/settingslib/connectivity/ConnectivitySubsystemsRecoveryManager.java
index 43717aba3abd..dfde3c7a2512 100644
--- a/packages/SettingsLib/src/com/android/settingslib/connectivity/ConnectivitySubsystemsRecoveryManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/connectivity/ConnectivitySubsystemsRecoveryManager.java
@@ -27,7 +27,7 @@ import android.net.wifi.WifiManager.SubsystemRestartTrackingCallback;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.provider.Settings;
-import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -72,7 +72,10 @@ public class ConnectivitySubsystemsRecoveryManager {
checkIfAllSubsystemsRestartsAreDone();
}
};
- private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
+ private final MobileTelephonyCallback mTelephonyCallback = new MobileTelephonyCallback();
+
+ private class MobileTelephonyCallback extends TelephonyCallback implements
+ TelephonyCallback.RadioPowerStateListener {
@Override
public void onRadioPowerStateChanged(int state) {
if (!mTelephonyRestartInProgress || mCurrentRecoveryCallback == null) {
@@ -85,7 +88,7 @@ public class ConnectivitySubsystemsRecoveryManager {
checkIfAllSubsystemsRestartsAreDone();
}
}
- };
+ }
public ConnectivitySubsystemsRecoveryManager(@NonNull Context context,
@NonNull Handler handler) {
@@ -201,12 +204,12 @@ public class ConnectivitySubsystemsRecoveryManager {
}
private void startTrackingTelephonyRestart() {
- mTelephonyManager.registerPhoneStateListener(new HandlerExecutor(mHandler),
- mPhoneStateListener);
+ mTelephonyManager.registerTelephonyCallback(new HandlerExecutor(mHandler),
+ mTelephonyCallback);
}
private void stopTrackingTelephonyRestart() {
- mTelephonyManager.unregisterPhoneStateListener(mPhoneStateListener);
+ mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
}
private void checkIfAllSubsystemsRestartsAreDone() {
diff --git a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java
index 228de039fc1b..35499c9b449a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java
+++ b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationAccesses.java
@@ -80,7 +80,8 @@ public class RecentLocationAccesses {
* Fills a list of applications which queried location recently within specified time.
* Apps are sorted by recency. Apps with more recent location accesses are in the front.
*/
- public List<Access> getAppList() {
+ @VisibleForTesting
+ List<Access> getAppList(boolean showSystemApps) {
// Retrieve a location usage list from AppOps
PackageManager pm = mContext.getPackageManager();
AppOpsManager aoManager =
@@ -108,22 +109,26 @@ public class RecentLocationAccesses {
// Don't show apps that do not have user sensitive location permissions
boolean showApp = true;
- for (int op : LOCATION_OPS) {
- final String permission = AppOpsManager.opToPermission(op);
- final int permissionFlags = pm.getPermissionFlags(permission, packageName, user);
- if (PermissionChecker.checkPermissionForPreflight(mContext, permission,
- PermissionChecker.PID_UNKNOWN, uid, packageName)
- == PermissionChecker.PERMISSION_GRANTED) {
- if ((permissionFlags
- & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED) == 0) {
- showApp = false;
- break;
- }
- } else {
- if ((permissionFlags
- & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED) == 0) {
- showApp = false;
- break;
+ if (!showSystemApps) {
+ for (int op : LOCATION_OPS) {
+ final String permission = AppOpsManager.opToPermission(op);
+ final int permissionFlags = pm.getPermissionFlags(permission, packageName,
+ user);
+ if (PermissionChecker.checkPermissionForPreflight(mContext, permission,
+ PermissionChecker.PID_UNKNOWN, uid, packageName)
+ == PermissionChecker.PERMISSION_GRANTED) {
+ if ((permissionFlags
+ & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED)
+ == 0) {
+ showApp = false;
+ break;
+ }
+ } else {
+ if ((permissionFlags
+ & PackageManager.FLAG_PERMISSION_USER_SENSITIVE_WHEN_DENIED) == 0) {
+ showApp = false;
+ break;
+ }
}
}
}
@@ -137,8 +142,15 @@ public class RecentLocationAccesses {
return accesses;
}
- public List<Access> getAppListSorted() {
- List<Access> accesses = getAppList();
+
+ /**
+ * Gets a list of apps that accessed location recently, sorting by recency.
+ *
+ * @param showSystemApps whether includes system apps in the list.
+ * @return the list of apps that recently accessed location.
+ */
+ public List<Access> getAppListSorted(boolean showSystemApps) {
+ List<Access> accesses = getAppList(showSystemApps);
// Sort the list of Access by recency. Most recent accesses first.
Collections.sort(accesses, Collections.reverseOrder(new Comparator<Access>() {
@Override
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
index 32419f49d8c9..1f3e0e9fe038 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/LocalMediaManager.java
@@ -205,7 +205,6 @@ public class LocalMediaManager implements BluetoothCallback {
void dispatchDeviceListUpdate() {
final List<MediaDevice> mediaDevices = new ArrayList<>(mMediaDevices);
- Collections.sort(mediaDevices, COMPARATOR);
for (DeviceCallback callback : getCallbacks()) {
callback.onDeviceListUpdate(mediaDevices);
}
@@ -472,6 +471,7 @@ public class LocalMediaManager implements BluetoothCallback {
synchronized (mMediaDevicesLock) {
mMediaDevices.clear();
mMediaDevices.addAll(devices);
+ Collections.sort(devices, COMPARATOR);
// Add disconnected bluetooth devices only when phone output device is available.
for (MediaDevice device : devices) {
final int type = device.getDeviceType();
diff --git a/packages/SettingsLib/src/com/android/settingslib/media/MediaOutputConstants.java b/packages/SettingsLib/src/com/android/settingslib/media/MediaOutputConstants.java
index 647fd2acf7c8..552fa11a42b7 100644
--- a/packages/SettingsLib/src/com/android/settingslib/media/MediaOutputConstants.java
+++ b/packages/SettingsLib/src/com/android/settingslib/media/MediaOutputConstants.java
@@ -39,8 +39,7 @@ public class MediaOutputConstants {
/**
* A string extra specifying a media package name.
*/
- public static final String EXTRA_PACKAGE_NAME =
- "com.android.settings.panel.extra.PACKAGE_NAME";
+ public static final String EXTRA_PACKAGE_NAME = "package_name";
/**
* An intent action to launch media output dialog.
diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java
index 26d9c57b2d27..1fb7f078c5d0 100644
--- a/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java
@@ -17,11 +17,11 @@ package com.android.settingslib.mobile;
import android.os.Handler;
import android.os.Looper;
-import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -43,9 +43,9 @@ public class MobileStatusTracker {
private final SubscriptionInfo mSubscriptionInfo;
private final Callback mCallback;
private final MobileStatus mMobileStatus;
- private final PhoneStateListener mPhoneStateListener;
private final SubscriptionDefaults mDefaults;
private final Handler mReceiverHandler;
+ private final MobileTelephonyCallback mTelephonyCallback;
/**
* MobileStatusTracker constructors
@@ -61,7 +61,7 @@ public class MobileStatusTracker {
SubscriptionInfo info, SubscriptionDefaults defaults, Callback callback) {
mPhone = phone;
mReceiverHandler = new Handler(receiverLooper);
- mPhoneStateListener = new MobilePhoneStateListener();
+ mTelephonyCallback = new MobileTelephonyCallback();
mSubscriptionInfo = info;
mDefaults = defaults;
mCallback = callback;
@@ -71,8 +71,8 @@ public class MobileStatusTracker {
/* updateTelephony= */false, new MobileStatus(mMobileStatus)));
}
- public PhoneStateListener getPhoneStateListener() {
- return mPhoneStateListener;
+ public MobileTelephonyCallback getTelephonyCallback() {
+ return mTelephonyCallback;
}
/**
@@ -80,9 +80,9 @@ public class MobileStatusTracker {
*/
public void setListening(boolean listening) {
if (listening) {
- mPhone.registerPhoneStateListener(mReceiverHandler::post, mPhoneStateListener);
+ mPhone.registerTelephonyCallback(mReceiverHandler::post, mTelephonyCallback);
} else {
- mPhone.unregisterPhoneStateListener(mPhoneStateListener);
+ mPhone.unregisterTelephonyCallback(mTelephonyCallback);
}
}
@@ -109,15 +109,14 @@ public class MobileStatusTracker {
|| activity == TelephonyManager.DATA_ACTIVITY_OUT;
}
- private class MobilePhoneStateListener extends PhoneStateListener implements
- PhoneStateListener.ServiceStateChangedListener,
- PhoneStateListener.SignalStrengthsChangedListener,
- PhoneStateListener.CallStateChangedListener,
- PhoneStateListener.DataConnectionStateChangedListener,
- PhoneStateListener.DataActivityListener,
- PhoneStateListener.CarrierNetworkChangeListener,
- PhoneStateListener.ActiveDataSubscriptionIdChangedListener,
- PhoneStateListener.DisplayInfoChangedListener{
+ public class MobileTelephonyCallback extends TelephonyCallback implements
+ TelephonyCallback.ServiceStateListener,
+ TelephonyCallback.SignalStrengthsListener,
+ TelephonyCallback.DataConnectionStateListener,
+ TelephonyCallback.DataActivityListener,
+ TelephonyCallback.CarrierNetworkListener,
+ TelephonyCallback.ActiveDataSubscriptionIdListener,
+ TelephonyCallback.DisplayInfoListener{
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
@@ -193,16 +192,6 @@ public class MobileStatusTracker {
mCallback.onMobileStatusChanged(
/* updateTelephony= */ true, new MobileStatus(mMobileStatus));
}
-
- @Override
- public void onCallStateChanged(int state, String phoneNumber) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "onCallStateChanged: state=" + state);
- }
- // TODO(b/177344083) re-implement as necessary.
- // updateTelephony();
- }
-
}
/**
diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/TelephonyIcons.java b/packages/SettingsLib/src/com/android/settingslib/mobile/TelephonyIcons.java
index d6e74f22258a..0129e0dddadd 100644
--- a/packages/SettingsLib/src/com/android/settingslib/mobile/TelephonyIcons.java
+++ b/packages/SettingsLib/src/com/android/settingslib/mobile/TelephonyIcons.java
@@ -403,19 +403,19 @@ public class TelephonyIcons {
}
public static final int[] WIFI_CALL_STRENGTH_ICONS = {
- R.drawable.ic_wifi_call_strength_1,
+ R.drawable.ic_wifi_call_strength_0,
R.drawable.ic_wifi_call_strength_1,
R.drawable.ic_wifi_call_strength_2,
R.drawable.ic_wifi_call_strength_3,
- R.drawable.ic_wifi_call_strength_3
+ R.drawable.ic_wifi_call_strength_4
};
public static final int[] MOBILE_CALL_STRENGTH_ICONS = {
- R.drawable.ic_mobile_call_strength_1,
+ R.drawable.ic_mobile_call_strength_0,
R.drawable.ic_mobile_call_strength_1,
R.drawable.ic_mobile_call_strength_2,
R.drawable.ic_mobile_call_strength_3,
- R.drawable.ic_mobile_call_strength_3
+ R.drawable.ic_mobile_call_strength_4
};
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java b/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java
index dad82ee61e08..02326ea85ff6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java
+++ b/packages/SettingsLib/src/com/android/settingslib/net/UidDetailProvider.java
@@ -26,7 +26,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import android.net.TrafficStats;
import android.os.Process;
import android.os.RemoteException;
@@ -123,9 +123,8 @@ public class UidDetailProvider {
detail.icon = pm.getDefaultActivityIcon();
return detail;
case TrafficStats.UID_TETHERING:
- final ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
- Context.CONNECTIVITY_SERVICE);
- detail.label = res.getString(Utils.getTetheringLabel(cm));
+ final TetheringManager tm = mContext.getSystemService(TetheringManager.class);
+ detail.label = res.getString(Utils.getTetheringLabel(tm));
detail.icon = pm.getDefaultActivityIcon();
return detail;
case Process.OTA_UPDATE_UID:
diff --git a/packages/SettingsLib/src/com/android/settingslib/users/EditUserPhotoController.java b/packages/SettingsLib/src/com/android/settingslib/users/EditUserPhotoController.java
index ecd40667843e..f9584a3e15e9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/users/EditUserPhotoController.java
+++ b/packages/SettingsLib/src/com/android/settingslib/users/EditUserPhotoController.java
@@ -38,6 +38,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.provider.ContactsContract.DisplayPhoto;
import android.provider.MediaStore;
+import android.util.EventLog;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
@@ -126,6 +127,14 @@ public class EditUserPhotoController {
}
final Uri pictureUri = data != null && data.getData() != null
? data.getData() : mTakePictureUri;
+
+ // Check if the result is a content uri
+ if (!ContentResolver.SCHEME_CONTENT.equals(pictureUri.getScheme())) {
+ Log.e(TAG, "Invalid pictureUri scheme: " + pictureUri.getScheme());
+ EventLog.writeEvent(0x534e4554, "172939189", -1, pictureUri.getPath());
+ return false;
+ }
+
switch (requestCode) {
case REQUEST_CODE_CROP_PHOTO:
onPhotoCropped(pictureUri);
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index 79b243af68ad..0c5cd1a11be6 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -233,8 +233,9 @@ public class AccessPoint implements Comparable<AccessPoint> {
public static final int SECURITY_OWE = 4;
public static final int SECURITY_SAE = 5;
public static final int SECURITY_EAP_SUITE_B = 6;
- public static final int SECURITY_DPP = 7;
- public static final int SECURITY_MAX_VAL = 8; // Has to be the last
+ public static final int SECURITY_EAP_WPA3_ENTERPRISE = 7;
+ public static final int SECURITY_DPP = 8;
+ public static final int SECURITY_MAX_VAL = 9; // Has to be the last
private static final int PSK_UNKNOWN = 0;
private static final int PSK_WPA = 1;