From 988a76f5bbc68a18d514e79633fc1eeb66005a1f Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 14 Jun 2022 10:16:34 +0200 Subject: [PATCH 1/3] Settings: Make NetworkScanHelper max search time customizable Default max search time (300) fails on some devices. Test: Network scan works on OnePlus 9 after overlaying max network scan search time to 254. Change-Id: Ia0038fac6d2000748e0aa08fd6a53f11876728d7 --- res/values/config.xml | 3 +++ .../network/telephony/NetworkScanHelper.java | 13 ++++++++++++- .../network/telephony/NetworkSelectSettings.java | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/res/values/config.xml b/res/values/config.xml index 987eaf97254..5ccbaa60f7d 100755 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -557,4 +557,7 @@ false + + + 300 diff --git a/src/com/android/settings/network/telephony/NetworkScanHelper.java b/src/com/android/settings/network/telephony/NetworkScanHelper.java index 740b6bba2bc..ddbad3b6c97 100644 --- a/src/com/android/settings/network/telephony/NetworkScanHelper.java +++ b/src/com/android/settings/network/telephony/NetworkScanHelper.java @@ -17,6 +17,7 @@ package com.android.settings.network.telephony; import android.annotation.IntDef; +import android.content.Context; import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.CellInfo; import android.telephony.NetworkScan; @@ -31,6 +32,8 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.telephony.CellNetworkScanResult; +import com.android.settings.R; + import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -129,6 +132,7 @@ public class NetworkScanHelper { private final TelephonyScanManager.NetworkScanCallback mInternalNetworkScanCallback; private final Executor mExecutor; + private int mMaxSearchTimeSec = MAX_SEARCH_TIME_SEC; private NetworkScan mNetworkScanRequester; /** Callbacks for sync network scan */ @@ -141,6 +145,13 @@ public class NetworkScanHelper { mExecutor = executor; } + public NetworkScanHelper(Context context, TelephonyManager tm, NetworkScanCallback callback, + Executor executor) { + this(tm, callback, executor); + mMaxSearchTimeSec = context.getResources().getInteger( + R.integer.config_network_scan_helper_max_search_time_sec); + } + @VisibleForTesting NetworkScanRequest createNetworkScanForPreferredAccessNetworks() { long networkTypeBitmap3gpp = mTelephonyManager.getPreferredNetworkTypeBitmask() @@ -183,7 +194,7 @@ public class NetworkScanHelper { radioAccessSpecifiers.toArray( new RadioAccessSpecifier[radioAccessSpecifiers.size()]), SEARCH_PERIODICITY_SEC, - MAX_SEARCH_TIME_SEC, + mMaxSearchTimeSec, INCREMENTAL_RESULTS, INCREMENTAL_RESULTS_PERIODICITY_SEC, null /* List of PLMN ids (MCC-MNC) */); diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java index 9faecbb1805..4e231813861 100644 --- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java +++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java @@ -112,7 +112,7 @@ public class NetworkSelectSettings extends DashboardFragment { mTelephonyManager = getContext().getSystemService(TelephonyManager.class) .createForSubscriptionId(mSubId); mNetworkScanHelper = new NetworkScanHelper( - mTelephonyManager, mCallback, mNetworkScanExecutor); + getContext(), mTelephonyManager, mCallback, mNetworkScanExecutor); PersistableBundle bundle = ((CarrierConfigManager) getContext().getSystemService( Context.CARRIER_CONFIG_SERVICE)).getConfigForSubId(mSubId); if (bundle != null) { From 5d4488e7f4d5e0ecb8b742594fdae3a7b08ac60c Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Wed, 27 Jul 2022 13:38:59 +0800 Subject: [PATCH 2/3] Clean up unused string resources Bug: 234570979 Test: make Settings app Change-Id: Ic0166c5dd45fb28f5d53920ed7b5e69384fa1e82 --- res/values/strings.xml | 344 ----------------------------------------- 1 file changed, 344 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index eb5bddec147..2c18441151a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4914,12 +4914,6 @@ Languages, input & gestures - - - - - - Languages & input @@ -6093,42 +6087,6 @@ %1$s left (New ML est) %1$s left (Old est) - - Amount of time screen has been on since full charge - - Device usage since full charge - - Battery use since unplugged - - Battery use since reset - - %1$s on battery - - %1$s since unplugged - - Charging - - Screen on - - GPS on - - Camera on - - Flashlight on - - Wi\u2011Fi - - Awake - - Mobile network signal - - @string/menu_stats_last_unplugged - - Device awake time - - Wi\u2011Fi on time - - Wi\u2011Fi on time Battery usage @@ -6280,8 +6238,6 @@ Detecting when apps drain battery - - Off %1$d app restricted @@ -6298,48 +6254,6 @@ Tap to learn more about this error - - Stop app? - - Your phone can\'t manage battery normally because %1$s is keeping your phone awake.\n\nTo try to fix this issue, you can stop the app.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance. - - Your tablet can\'t manage battery normally because %1$s is keeping your tablet awake.\n\nTo try to fix this issue, you can stop the app.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance. - - Your device can\'t manage battery normally because %1$s is keeping your device awake.\n\nTo try to fix this issue, you can stop the app.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance. - - - Your phone can\'t manage battery normally because %1$s keeps waking up your phone.\n\nTo try to fix this issue, you can stop %1$s.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance. - - Your tablet can\'t manage battery normally because %1$s keeps waking up your tablet.\n\nTo try to fix this issue, you can stop %1$s.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance. - - Your device can\'t manage battery normally because %1$s keeps waking up your device.\n\nTo try to fix this issue, you can stop %1$s.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance. - - - Stop app - - - Turn off background usage & stop app? - - Your phone can\'t manage battery normally because %1$s keeps waking up your phone.\n\nTo try to fix this issue, you can stop %1$s and prevent it from running in the background. - - Your tablet can\'t manage battery normally because %1$s keeps waking up your tablet.\n\nTo try to fix this issue, you can stop %1$s and prevent it from running in the background. - - Your device can\'t manage battery normally because %1$s keeps waking up your device.\n\nTo try to fix this issue, you can stop %1$s and prevent it from running in the background. - - Turn off - - - Turn off location? - - Your phone can\'t manage battery normally because %1$s keeps requesting your location when you\'re not using the app.\n\nTo fix this issue, you can turn off location for this app. - - Your tablet can\'t manage battery normally because %1$s keeps requesting your location when you\'re not using the app.\n\nTo fix this issue, you can turn off location for this app. - - Your device can\'t manage battery normally because %1$s keeps requesting your location when you\'re not using the app.\n\nTo fix this issue, you can turn off location for this app. - - - Turn off - Screen @@ -6358,126 +6272,6 @@ Tablet idle Phone idle - - Miscellaneous - - Over-counted - - - CPU total - - CPU foreground - - Keep awake - - GPS - - Wi\u2011Fi running - - Tablet - - Phone - - Mobile packets sent - - Mobile packets received - - Mobile radio active - - Wi\u2011Fi packets sent - - Wi\u2011Fi packets received - - Audio - - Video - - Camera - - Flashlight - - Time on - - Time without a signal - - Total battery capacity - - Computed power use - - Observed power use - - Force stop - - App info - - App settings - - Screen settings - - Wi\u2011Fi settings - - Bluetooth settings - - - Battery used by voice calls - - - Battery used when tablet is idle - - Battery used when phone is idle - - - Battery used by cell radio - - Switch to airplane mode to save power in areas with no cell coverage - - - Battery used by the flashlight - - - Battery used by the camera - - - Battery used by the display and backlight - - Reduce the screen brightness and/or screen timeout - - - Battery used by Wi\u2011Fi - - Turn off Wi\u2011Fi when not using it or when it isn\u2019t available - - - Battery used by Bluetooth - - Turn off Bluetooth when you aren\u2019t using it - - Try connecting to a different Bluetooth device - - - Battery used by app - - Stop or uninstall the app - - Select battery-saving mode - - The app may offer settings to reduce battery use - - - Battery used by user - - - Miscellaneous power use - - Battery use is an approximation of power - use and does not include every source of battery drain. Miscellaneous is the difference - between the computed approximate power use and the actual drain observed on the - battery. - - Over-counted power use - - %d mAh Used for ^1 @@ -6563,15 +6357,6 @@ Estimate may change based on usage - - %1$s since unplugged - - While last unplugged for %1$s - - Usage totals - - Refresh - Mediaserver @@ -7136,12 +6921,6 @@ Delete - - Misc files - - selected %1$d out of %2$d - - %1$s out of %2$s Select all @@ -7149,44 +6928,6 @@ Data usage Mobile data & Wi\u2011Fi - - Carrier data accounting may differ from your device. - - App usage - - APP INFO - - Mobile data - - Set data limit - - Data usage cycle - - App usage - - Data roaming - - Restrict background data - - Allow background data - - Separate 4G usage - - Show Wi\u2011Fi - - Hide Wi\u2011Fi - - Show Ethernet usage - - Hide Ethernet usage - - Network restrictions - - Auto-sync data - - SIM cards - - Paused at limit Auto-sync data @@ -8259,8 +8000,6 @@ data usage Use 24-hour format - - Download Open with @@ -12201,18 +11940,9 @@ This device - - Photos & videos - - - Music & audio - Games - - Other apps - Files @@ -12249,13 +11979,6 @@ Empty trash - - ^1 ^2 - - Used of %1$s - - used - %1$s %2$s used @@ -12359,29 +12082,12 @@ Display network name in status bar - - Storage Manager: ^1 - - - Off - - - On - Instant app Turn off the storage manager? - - Movie & TV apps - - - Carrier Provisioning Info - - Trigger Carrier Provisioning - @@ -12548,51 +12254,15 @@ This device - - Phone - - - Tablet - - - Device - Unavailable during calls - - Unavailable - - - Add outputs - - - Group - - - 1 device selected - - - %1$d devices selected - - - Switching\u2026 - Take call on This APN cannot be changed. - - Improve tablet\'s battery life - - Improve device\'s battery life - - Improve phone\'s battery life - - - Prevent ringing @@ -13265,8 +12935,6 @@ You may lose access to any remaining time or data. Check with your provider before removing. - - content capture, app content App content @@ -13360,15 +13028,6 @@ This choice is no longer valid. Try again. - - device controls - - - Cards & passes - - - cards & passes - Press & hold power button @@ -13506,9 +13165,6 @@ Wi\u2011Fi calling Make and receive calls over Wi\u2011Fi - - With Wi\u2011Fi calling, calls are made and received over non\u2011carrier Wi\u2011Fi networks. - Learn more Calls From 5cf2b7ff1f8cc9fb3cd99c0477bc3fbf94b433bf Mon Sep 17 00:00:00 2001 From: Hugh Chen Date: Fri, 29 Jul 2022 02:45:12 +0000 Subject: [PATCH 3/3] Refactor the condition order Bug: 239984274 Test: atest -c VpnSettingsTest Change-Id: Ic9e8c775b044fffd5dec5047fb53d75209418d85 --- src/com/android/settings/vpn2/VpnSettings.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java index 2cb07022372..3b875eb1293 100644 --- a/src/com/android/settings/vpn2/VpnSettings.java +++ b/src/com/android/settings/vpn2/VpnSettings.java @@ -635,11 +635,13 @@ public class VpnSettings extends RestrictedSettingsFragment implements if (apps != null) { for (AppOpsManager.PackageOps pkg : apps) { int userId = UserHandle.getUserId(pkg.getUid()); - if (!profileIds.contains(userId) - || isAdvancedVpn(featureProvider, pkg.getPackageName(), context)) { + if (!profileIds.contains(userId)) { // Skip packages for users outside of our profile group. continue; } + if (isAdvancedVpn(featureProvider, pkg.getPackageName(), context)) { + continue; + } // Look for a MODE_ALLOWED permission to activate VPN. boolean allowed = false; for (AppOpsManager.OpEntry op : pkg.getOps()) {