diff options
25 files changed, 325 insertions, 76 deletions
diff --git a/Android.bp b/Android.bp index ec8636d40f8d..57f651319562 100644 --- a/Android.bp +++ b/Android.bp @@ -687,6 +687,7 @@ java_defaults { static_libs: [ "apex_aidl_interface-java", "framework-protos", + "game-driver-protos", "android.hidl.base-V1.0-java", "android.hardware.cas-V1.0-java", "android.hardware.contexthub-V1.0-java", diff --git a/api/current.txt b/api/current.txt index b7df38068263..4dcba8348d8c 100755 --- a/api/current.txt +++ b/api/current.txt @@ -29116,7 +29116,6 @@ package android.nfc { method @Deprecated public void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage); method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle); method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context); - method @NonNull public java.util.List<java.lang.String> getSupportedOffHostSecureElements(); method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler); method @Deprecated public boolean invokeBeam(android.app.Activity); method public boolean isEnabled(); @@ -29209,10 +29208,10 @@ package android.nfc.cardemulation { method public boolean isDefaultServiceForCategory(android.content.ComponentName, String); method public boolean registerAidsForService(android.content.ComponentName, String, java.util.List<java.lang.String>); method public boolean removeAidsForService(android.content.ComponentName, String); - method public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String); + method @RequiresPermission(android.Manifest.permission.NFC) @NonNull public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String); method public boolean setPreferredService(android.app.Activity, android.content.ComponentName); method public boolean supportsAidPrefixRegistration(); - method public boolean unsetOffHostForService(@NonNull android.content.ComponentName); + method @RequiresPermission(android.Manifest.permission.NFC) @NonNull public boolean unsetOffHostForService(@NonNull android.content.ComponentName); method public boolean unsetPreferredService(android.app.Activity); field public static final String ACTION_CHANGE_DEFAULT = "android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT"; field public static final String CATEGORY_OTHER = "other"; diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index b90a60e5bca0..eb347e7e253e 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -526,6 +526,7 @@ public final class NfcAdapter { * @return List<String> containing secure elements on the device which supports * off host card emulation. eSE for Embedded secure element, * SIM for UICC and so on. + * @hide */ public @NonNull List<String> getSupportedOffHostSecureElements() { List<String> offHostSE = new ArrayList<String>(); diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 911ec8430ddd..ab0a0ef517c7 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -432,7 +432,15 @@ public final class ApduServiceInfo implements Parcelable { mDynamicAidGroups.put(aidGroup.getCategory(), aidGroup); } - @UnsupportedAppUsage + /** + * Sets the off host Secure Element. + * @param offHost Secure Element to set. Only accept strings with prefix SIM or prefix eSE. + * Ref: GSMA TS.26 - NFC Handset Requirements + * TS26_NFC_REQ_069: For UICC, Secure Element Name SHALL be SIM[smartcard slot] + * (e.g. SIM/SIM1, SIM2… SIMn). + * TS26_NFC_REQ_070: For embedded SE, Secure Element Name SHALL be eSE[number] + * (e.g. eSE/eSE1, eSE2, etc.). + */ public void setOffHostSecureElement(String offHost) { mOffHostName = offHost; } @@ -441,7 +449,6 @@ public final class ApduServiceInfo implements Parcelable { * Resets the off host Secure Element to statically defined * by the service in the manifest file. */ - @UnsupportedAppUsage public void unsetOffHostSecureElement() { mOffHostName = mStaticOffHostName; } @@ -581,10 +588,9 @@ public final class ApduServiceInfo implements Parcelable { pw.println(" On Host Service"); } else { pw.println(" Off-host Service"); - pw.println(" " + "Current off-host SE" + mOffHostName - + " static off-host: " + mOffHostName); + pw.println(" " + "Current off-host SE:" + mOffHostName + + " static off-host SE:" + mStaticOffHostName); } - pw.println(" Static off-host Secure Element:"); pw.println(" Static AID groups:"); for (AidGroup group : mStaticAidGroups.values()) { pw.println(" Category: " + group.category); diff --git a/core/java/android/nfc/cardemulation/CardEmulation.java b/core/java/android/nfc/cardemulation/CardEmulation.java index f23dc2da291a..4c9885c402fa 100644 --- a/core/java/android/nfc/cardemulation/CardEmulation.java +++ b/core/java/android/nfc/cardemulation/CardEmulation.java @@ -17,6 +17,7 @@ package android.nfc.cardemulation; import android.annotation.NonNull; +import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.Activity; @@ -360,6 +361,8 @@ public final class CardEmulation { * @param service The component name of the service * @return whether the registration was successful. */ + @RequiresPermission(android.Manifest.permission.NFC) + @NonNull public boolean unsetOffHostForService(@NonNull ComponentName service) { NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext); if (adapter == null) { @@ -391,7 +394,9 @@ public final class CardEmulation { * through the manifest, or dynamically by using this API), * it will be replaced with this one. All AIDs registered by * this service will be re-routed to this Secure Element if - * successful. + * successful. AIDs that was statically assigned using manifest + * will re-route to off-host SE that stated in manifest after NFC + * toggle. * * <p>Note that you can only set off-host SE for a service that * is running under the same UID as the caller of this API. Typically @@ -403,9 +408,19 @@ public final class CardEmulation { * exists on the device. * * @param service The component name of the service - * @param offHostSecureElement Secure Element to register the AID to + * @param offHostSecureElement Secure Element to register the AID to. Only accept strings with + * prefix SIM or prefix eSE. + * Ref: GSMA TS.26 - NFC Handset Requirements + * TS26_NFC_REQ_069: For UICC, Secure Element Name SHALL be + * SIM[smartcard slot] + * (e.g. SIM/SIM1, SIM2… SIMn). + * TS26_NFC_REQ_070: For embedded SE, Secure Element Name SHALL be + * eSE[number] + * (e.g. eSE/eSE1, eSE2, etc.). * @return whether the registration was successful. */ + @RequiresPermission(android.Manifest.permission.NFC) + @NonNull public boolean setOffHostForService(@NonNull ComponentName service, @NonNull String offHostSecureElement) { boolean validSecureElement = false; @@ -421,6 +436,10 @@ public final class CardEmulation { return false; } + if (!offHostSecureElement.startsWith("eSE") && !offHostSecureElement.startsWith("SIM")) { + return false; + } + if (offHostSecureElement.equals("eSE")) { offHostSecureElement = "eSE1"; } else if (offHostSecureElement.equals("SIM")) { diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index 606c8f398563..d46cf3cb974a 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -20,12 +20,17 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; +import android.gamedriver.GameDriverProto.Blacklist; +import android.gamedriver.GameDriverProto.Blacklists; import android.opengl.EGL14; import android.os.Build; import android.os.SystemProperties; import android.provider.Settings; +import android.util.Base64; import android.util.Log; +import com.android.framework.protobuf.InvalidProtocolBufferException; + import dalvik.system.VMRuntime; import java.io.BufferedReader; @@ -33,6 +38,9 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** @hide */ public class GraphicsEnvironment { @@ -49,7 +57,9 @@ public class GraphicsEnvironment { private static final boolean DEBUG = false; private static final String TAG = "GraphicsEnvironment"; private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0"; - private static final String GUP_WHITELIST_FILENAME = "whitelist.txt"; + private static final String GAME_DRIVER_WHITELIST_FILENAME = "whitelist.txt"; + private static final String GAME_DRIVER_BLACKLIST_FLAG = "blacklist"; + private static final int BASE64_FLAGS = Base64.NO_PADDING | Base64.NO_WRAP; private ClassLoader mClassLoader; private String mLayerPath; @@ -136,6 +146,19 @@ public class GraphicsEnvironment { setLayerPaths(mClassLoader, layerPaths); } + private static List<String> getGlobalSettingsString(Bundle bundle, String globalSetting) { + List<String> valueList = null; + String settingsValue = bundle.getString(globalSetting); + + if (settingsValue != null) { + valueList = new ArrayList<>(Arrays.asList(settingsValue.split(","))); + } else { + valueList = new ArrayList<>(); + } + + return valueList; + } + /** * Choose whether the current process should use the builtin or an updated driver. */ @@ -145,27 +168,6 @@ public class GraphicsEnvironment { return; } - // To minimize risk of driver updates crippling the device beyond user repair, never use an - // updated driver for privileged or non-updated system apps. Presumably pre-installed apps - // were tested thoroughly with the pre-installed driver. - ApplicationInfo ai = context.getApplicationInfo(); - if (ai.isPrivilegedApp() || (ai.isSystemApp() && !ai.isUpdatedSystemApp())) { - if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app"); - return; - } - - String applicationPackageName = context.getPackageName(); - String devOptInApplicationName = coreSettings.getString( - Settings.Global.GUP_DEV_OPT_IN_APPS); - boolean devOptIn = applicationPackageName.equals(devOptInApplicationName); - boolean whitelisted = onWhitelist(context, driverPackageName, ai.packageName); - if (!devOptIn && !whitelisted) { - if (DEBUG) { - Log.w(TAG, applicationPackageName + " is not on the whitelist."); - } - return; - } - ApplicationInfo driverInfo; try { driverInfo = context.getPackageManager().getApplicationInfo(driverPackageName, @@ -184,6 +186,78 @@ public class GraphicsEnvironment { return; } + // To minimize risk of driver updates crippling the device beyond user repair, never use an + // updated driver for privileged or non-updated system apps. Presumably pre-installed apps + // were tested thoroughly with the pre-installed driver. + ApplicationInfo ai = context.getApplicationInfo(); + if (ai.isPrivilegedApp() || (ai.isSystemApp() && !ai.isUpdatedSystemApp())) { + if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app"); + return; + } + + // GAME_DRIVER_ALL_APPS + // 0: Default (Invalid values fallback to default as well) + // 1: All apps use Game Driver + // 2: All apps use system graphics driver + int gameDriverAllApps = coreSettings.getInt(Settings.Global.GAME_DRIVER_ALL_APPS, 0); + if (gameDriverAllApps == 2) { + if (DEBUG) { + Log.w(TAG, "Game Driver is turned off on this device"); + } + return; + } + + if (gameDriverAllApps != 1) { + // GAME_DRIVER_OPT_OUT_APPS has higher priority than GAME_DRIVER_OPT_IN_APPS + if (getGlobalSettingsString(coreSettings, Settings.Global.GAME_DRIVER_OPT_OUT_APPS) + .contains(ai.packageName)) { + if (DEBUG) { + Log.w(TAG, ai.packageName + " opts out from Game Driver."); + } + return; + } + boolean isOptIn = + getGlobalSettingsString(coreSettings, Settings.Global.GAME_DRIVER_OPT_IN_APPS) + .contains(ai.packageName); + + if (!isOptIn && !onWhitelist(context, driverPackageName, ai.packageName)) { + if (DEBUG) { + Log.w(TAG, ai.packageName + " is not on the whitelist."); + } + return; + } + + if (!isOptIn) { + // At this point, the application is on the whitelist only, check whether it's + // on the blacklist, terminate early when it's on the blacklist. + try { + // TODO(b/121350991) Switch to DeviceConfig with property listener. + String base64String = + coreSettings.getString(Settings.Global.GAME_DRIVER_BLACKLIST); + if (base64String != null && !base64String.isEmpty()) { + Blacklists blacklistsProto = Blacklists.parseFrom( + Base64.decode(base64String, BASE64_FLAGS)); + List<Blacklist> blacklists = blacklistsProto.getBlacklistsList(); + long driverVersionCode = driverInfo.longVersionCode; + for (Blacklist blacklist : blacklists) { + if (blacklist.getVersionCode() == driverVersionCode) { + for (String packageName : blacklist.getPackageNamesList()) { + if (packageName == ai.packageName) { + return; + } + } + break; + } + } + } + } catch (InvalidProtocolBufferException e) { + if (DEBUG) { + Log.w(TAG, "Can't parse blacklist, skip and continue..."); + } + } + } + } + String abi = chooseAbi(driverInfo); if (abi == null) { if (DEBUG) { @@ -245,7 +319,7 @@ public class GraphicsEnvironment { Context driverContext = context.createPackageContext(driverPackageName, Context.CONTEXT_RESTRICTED); AssetManager assets = driverContext.getAssets(); - InputStream stream = assets.open(GUP_WHITELIST_FILENAME); + InputStream stream = assets.open(GAME_DRIVER_WHITELIST_FILENAME); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); for (String packageName; (packageName = reader.readLine()) != null; ) { if (packageName.equals(applicationPackageName)) { diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index bf33e0619304..a0e4d0dcb90e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -11446,16 +11446,41 @@ public final class Settings { public static final String GPU_DEBUG_APP = "gpu_debug_app"; /** - * Apps that are selected to use Game Update Package. + * Game Driver global preference for all Apps. + * 0 = Default + * 1 = All Apps use Game Driver + * 2 = All Apps use system graphics driver * @hide */ - public static final String GUP_DEV_OPT_IN_APPS = "gup_dev_opt_in_apps"; + public static final String GAME_DRIVER_ALL_APPS = "game_driver_all_apps"; /** - * Apps on the black list that are forbidden to useGame Update Package. + * List of Apps selected to use Game Driver. + * i.e. <pkg1>,<pkg2>,...,<pkgN> * @hide */ - public static final String GUP_BLACK_LIST = "gup_black_list"; + public static final String GAME_DRIVER_OPT_IN_APPS = "game_driver_opt_in_apps"; + + /** + * List of Apps selected not to use Game Driver. + * i.e. <pkg1>,<pkg2>,...,<pkgN> + * @hide + */ + public static final String GAME_DRIVER_OPT_OUT_APPS = "game_driver_opt_out_apps"; + + /** + * Apps on the blacklist that are forbidden to use Game Driver. + * @hide + */ + public static final String GAME_DRIVER_BLACKLIST = "game_driver_blacklist"; + + /** + * Apps on the whitelist that are allowed to use Game Driver. + * The string is a list of application package names, seperated by comma. + * i.e. <apk1>,<apk2>,...,<apkN> + * @hide + */ + public static final String GAME_DRIVER_WHITELIST = "game_driver_whitelist"; /** * Ordered GPU debug layer list diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java index 46edf475e398..53e145eb15fd 100755 --- a/core/java/android/widget/DatePickerCalendarDelegate.java +++ b/core/java/android/widget/DatePickerCalendarDelegate.java @@ -597,7 +597,7 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate { case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: - return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? 29 : 28; + return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } diff --git a/core/java/android/widget/SimpleMonthView.java b/core/java/android/widget/SimpleMonthView.java index 9982732384da..80de6fc65f90 100644 --- a/core/java/android/widget/SimpleMonthView.java +++ b/core/java/android/widget/SimpleMonthView.java @@ -850,7 +850,7 @@ class SimpleMonthView extends View { case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: - return (year % 4 == 0) ? 29 : 28; + return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28; default: throw new IllegalArgumentException("Invalid Month"); } diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto index 7c9176aa9eb7..5aa3992d73f0 100644 --- a/core/proto/android/providers/settings/global.proto +++ b/core/proto/android/providers/settings/global.proto @@ -384,11 +384,21 @@ message GlobalSettingsProto { // App allowed to load GPU debug layers. optional SettingProto debug_app = 1; optional SettingProto debug_layers = 2 [ (android.privacy).dest = DEST_AUTOMATIC ]; - // Apps opt in to load graphics driver from Game Update Package - // instead of native graphcis driver through developer options. - optional SettingProto gup_dev_opt_in_apps = 8; - // Apps on the black list that are forbidden to useGame Update Package. - optional SettingProto gup_black_list = 9; + // Game Driver - global preference for all Apps + // 0 = Default + // 1 = All Apps use Game Driver + // 2 = All Apps use system graphics driver + optional SettingProto game_driver_all_apps = 8; + // Game Driver - List of Apps selected to use Game Driver + // i.e. <pkg1>,<pkg2>,...,<pkgN> + optional SettingProto game_driver_opt_in_apps = 9; + // Game Driver - List of Apps selected not to use Game Driver + // i.e. <pkg1>,<pkg2>,...,<pkgN> + optional SettingProto game_driver_opt_out_apps = 10; + // Game Driver - List of Apps that are forbidden to use Game Driver + optional SettingProto game_driver_blacklist = 11; + // Game Driver - List of Apps that are allowed to use Game Driver + optional SettingProto game_driver_whitelist = 12; } optional Gpu gpu = 59; diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 3fe8689b8552..e074db603f04 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3691,7 +3691,7 @@ the settings for this service. --> <attr name="settingsActivity"/> <!-- Secure Element which the AIDs should be routed to --> - <attr name="secureElementName"/> + <attr name="secureElementName" format="string"/> </declare-styleable> <!-- Specify one or more <code>aid-group</code> elements inside a diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index 7b729284a063..c1664087fb31 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -444,8 +444,11 @@ public class SettingsBackupTest { Settings.Global.ENABLE_GPU_DEBUG_LAYERS, Settings.Global.GPU_DEBUG_APP, Settings.Global.GPU_DEBUG_LAYERS, - Settings.Global.GUP_DEV_OPT_IN_APPS, - Settings.Global.GUP_BLACK_LIST, + Settings.Global.GAME_DRIVER_ALL_APPS, + Settings.Global.GAME_DRIVER_OPT_IN_APPS, + Settings.Global.GAME_DRIVER_OPT_OUT_APPS, + Settings.Global.GAME_DRIVER_BLACKLIST, + Settings.Global.GAME_DRIVER_WHITELIST, Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT, Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS, diff --git a/graphics/proto/Android.bp b/graphics/proto/Android.bp new file mode 100644 index 000000000000..1d06348fb02f --- /dev/null +++ b/graphics/proto/Android.bp @@ -0,0 +1,11 @@ +java_library_static { + name: "game-driver-protos", + host_supported: true, + proto: { + type: "lite", + }, + srcs: ["game_driver.proto"], + no_framework_libs: true, + jarjar_rules: "jarjar-rules.txt", + sdk_version: "28", +} diff --git a/graphics/proto/game_driver.proto b/graphics/proto/game_driver.proto new file mode 100644 index 000000000000..fd7ffccac24c --- /dev/null +++ b/graphics/proto/game_driver.proto @@ -0,0 +1,31 @@ +/* + * Copyright 2019 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. + */ + +syntax = "proto2"; + +package android.gamedriver; + +option java_package = "android.gamedriver"; +option java_outer_classname = "GameDriverProto"; + +message Blacklist { + optional int64 version_code = 1; + repeated string package_names = 2; +} + +message Blacklists { + repeated Blacklist blacklists = 1; +} diff --git a/graphics/proto/jarjar-rules.txt b/graphics/proto/jarjar-rules.txt new file mode 100644 index 000000000000..4e4063706352 --- /dev/null +++ b/graphics/proto/jarjar-rules.txt @@ -0,0 +1 @@ +rule com.google.protobuf.** com.android.framework.protobuf.@1 diff --git a/packages/NetworkStack/src/android/net/util/NetworkStackUtils.java b/packages/NetworkStack/src/android/net/util/NetworkStackUtils.java index 547f04d55c64..fb03c544fd30 100644 --- a/packages/NetworkStack/src/android/net/util/NetworkStackUtils.java +++ b/packages/NetworkStack/src/android/net/util/NetworkStackUtils.java @@ -34,6 +34,34 @@ public class NetworkStackUtils { // TODO: Refer to DeviceConfig definition. public static final String NAMESPACE_CONNECTIVITY = "connectivity"; + /** + * A list of captive portal detection specifications used in addition to the fallback URLs. + * Each spec has the format url@@/@@statusCodeRegex@@/@@contentRegex. Specs are separated + * by "@@,@@". + */ + public static final String CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS = + "captive_portal_fallback_probe_specs"; + + /** + * A comma separated list of URLs used for captive portal detection in addition to the + * fallback HTTP url associated with the CAPTIVE_PORTAL_FALLBACK_URL settings. + */ + public static final String CAPTIVE_PORTAL_OTHER_FALLBACK_URLS = + "captive_portal_other_fallback_urls"; + + /** + * Which User-Agent string to use in the header of the captive portal detection probes. + * The User-Agent field is unset when this setting has no value (HttpUrlConnection default). + */ + public static final String CAPTIVE_PORTAL_USER_AGENT = "captive_portal_user_agent"; + + /** + * Whether to use HTTPS for network validation. This is enabled by default and the setting + * needs to be set to 0 to disable it. This setting is a misnomer because captive portals + * don't actually use HTTPS, but it's consistent with the other settings. + */ + public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https"; + static { System.loadLibrary("networkstackutilsjni"); } diff --git a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java index 27d420328017..093235e66214 100644 --- a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java +++ b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java @@ -43,6 +43,10 @@ import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_EVALUATION_TYPE import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_MIN_EVALUATE_TIME_MS; import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_VALID_DNS_TIME_THRESHOLD_MS; import static android.net.util.DataStallUtils.DEFAULT_DNS_LOG_SIZE; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USER_AGENT; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USE_HTTPS; import static android.net.util.NetworkStackUtils.NAMESPACE_CONNECTIVITY; import static android.net.util.NetworkStackUtils.isEmpty; @@ -1171,7 +1175,8 @@ public class NetworkMonitor extends StateMachine { } private boolean getUseHttpsValidation() { - return mDependencies.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_USE_HTTPS, 1) == 1; + return mDependencies.getDeviceConfigPropertyInt(NAMESPACE_CONNECTIVITY, + CAPTIVE_PORTAL_USE_HTTPS, 1) == 1; } private String getCaptivePortalServerHttpsUrl() { @@ -1224,8 +1229,8 @@ public class NetworkMonitor extends StateMachine { final URL[] settingProviderUrls; if (!TextUtils.isEmpty(firstUrl)) { - final String otherUrls = mDependencies.getSetting(mContext, - Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, ""); + final String otherUrls = mDependencies.getDeviceConfigProperty( + NAMESPACE_CONNECTIVITY, CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, ""); // otherUrls may be empty, but .split() ignores trailing empty strings final String separator = ","; final String[] urls = (firstUrl + separator + otherUrls).split(separator); @@ -1245,8 +1250,9 @@ public class NetworkMonitor extends StateMachine { private CaptivePortalProbeSpec[] makeCaptivePortalFallbackProbeSpecs() { try { - final String settingsValue = mDependencies.getSetting( - mContext, Settings.Global.CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS, null); + final String settingsValue = mDependencies.getDeviceConfigProperty( + NAMESPACE_CONNECTIVITY, CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS, null); + final CaptivePortalProbeSpec[] emptySpecs = new CaptivePortalProbeSpec[0]; final CaptivePortalProbeSpec[] providerValue = TextUtils.isEmpty(settingsValue) ? emptySpecs @@ -1340,8 +1346,8 @@ public class NetworkMonitor extends StateMachine { } private String getCaptivePortalUserAgent() { - return mDependencies.getSetting(mContext, - Settings.Global.CAPTIVE_PORTAL_USER_AGENT, DEFAULT_USER_AGENT); + return mDependencies.getDeviceConfigProperty(NAMESPACE_CONNECTIVITY, + CAPTIVE_PORTAL_USER_AGENT, DEFAULT_USER_AGENT); } private URL nextFallbackUrl() { diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java index 910bdc7e600f..594f2cae996d 100644 --- a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java +++ b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java @@ -26,6 +26,9 @@ import static android.net.util.DataStallUtils.CONFIG_DATA_STALL_EVALUATION_TYPE; import static android.net.util.DataStallUtils.CONFIG_DATA_STALL_MIN_EVALUATE_INTERVAL; import static android.net.util.DataStallUtils.CONFIG_DATA_STALL_VALID_DNS_TIME_THRESHOLD; import static android.net.util.DataStallUtils.DATA_STALL_EVALUATION_TYPE_DNS; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS; +import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USE_HTTPS; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; @@ -160,7 +163,7 @@ public class NetworkMonitorTest { when(mDependencies.getRandom()).thenReturn(mRandom); when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_MODE), anyInt())) .thenReturn(Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); - when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_USE_HTTPS), + when(mDependencies.getDeviceConfigPropertyInt(any(), eq(CAPTIVE_PORTAL_USE_HTTPS), anyInt())).thenReturn(1); when(mDependencies.getSetting(any(), eq(Settings.Global.CAPTIVE_PORTAL_HTTP_URL), any())) .thenReturn(TEST_HTTP_URL); @@ -683,13 +686,13 @@ public class NetworkMonitorTest { } private void setOtherFallbackUrls(String urls) { - when(mDependencies.getSetting(any(), - eq(Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS), any())).thenReturn(urls); + when(mDependencies.getDeviceConfigProperty(any(), + eq(CAPTIVE_PORTAL_OTHER_FALLBACK_URLS), any())).thenReturn(urls); } private void setFallbackSpecs(String specs) { - when(mDependencies.getSetting(any(), - eq(Settings.Global.CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS), any())).thenReturn(specs); + when(mDependencies.getDeviceConfigProperty(any(), + eq(CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS), any())).thenReturn(specs); } private void setCaptivePortalMode(int mode) { diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 2c4abaeb9949..d5b121768a66 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -1131,7 +1131,4 @@ <!-- The notice header of Third-party licenses. not translatable --> <string name="notice_header" translatable="false"></string> - - <!-- UI debug setting: opt in to use updated graphics driver? [CHAR LIMIT=100] --> - <string name="gup_dev_opt_in_app_summary">Opt in app to use Game Update Package in developement</string> </resources> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index 759b51c853da..43c1a267468e 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -648,11 +648,20 @@ class SettingsProtoDumpUtil { Settings.Global.GPU_DEBUG_LAYERS, GlobalSettingsProto.Gpu.DEBUG_LAYERS); dumpSetting(s, p, - Settings.Global.GUP_DEV_OPT_IN_APPS, - GlobalSettingsProto.Gpu.GUP_DEV_OPT_IN_APPS); + Settings.Global.GAME_DRIVER_ALL_APPS, + GlobalSettingsProto.Gpu.GAME_DRIVER_ALL_APPS); dumpSetting(s, p, - Settings.Global.GUP_BLACK_LIST, - GlobalSettingsProto.Gpu.GUP_BLACK_LIST); + Settings.Global.GAME_DRIVER_OPT_IN_APPS, + GlobalSettingsProto.Gpu.GAME_DRIVER_OPT_IN_APPS); + dumpSetting(s, p, + Settings.Global.GAME_DRIVER_OPT_OUT_APPS, + GlobalSettingsProto.Gpu.GAME_DRIVER_OPT_OUT_APPS); + dumpSetting(s, p, + Settings.Global.GAME_DRIVER_BLACKLIST, + GlobalSettingsProto.Gpu.GAME_DRIVER_BLACKLIST); + dumpSetting(s, p, + Settings.Global.GAME_DRIVER_WHITELIST, + GlobalSettingsProto.Gpu.GAME_DRIVER_WHITELIST); p.end(gpuToken); final long hdmiToken = p.start(GlobalSettingsProto.HDMI); diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index d79d833f2233..6902a706e91f 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -6492,6 +6492,11 @@ message MetricsEvent { // OS: Q ACTION_EMERGENCY_DIALER_FROM_POWER_MENU = 1569; + // OPEN: Settings > Developer Options > Game Driver Preference + // CATEGORY: SETTINGS + // OS: Q + SETTINGS_GAME_DRIVER_DASHBOARD = 1613; + // ---- End Q Constants, all Q constants go above this line ---- // Add new aosp constants above this line. diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 85787f25336f..a172fde2e637 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -2283,6 +2283,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { .setCallingPid(r.callerPid) .setCallingUid(r.callerUid) .setMethod("TelephonyRegistry push") + .setLogAsInfo(true) // we don't need to log an error every time we push .setMinSdkVersionForFine(minSdk) .build(); @@ -2300,6 +2301,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { .setCallingPid(r.callerPid) .setCallingUid(r.callerUid) .setMethod("TelephonyRegistry push") + .setLogAsInfo(true) // we don't need to log an error every time we push .setMinSdkVersionForCoarse(minSdk) .build(); diff --git a/services/core/java/com/android/server/am/CoreSettingsObserver.java b/services/core/java/com/android/server/am/CoreSettingsObserver.java index 63300a1c05cd..75da9b54c662 100644 --- a/services/core/java/com/android/server/am/CoreSettingsObserver.java +++ b/services/core/java/com/android/server/am/CoreSettingsObserver.java @@ -55,8 +55,11 @@ final class CoreSettingsObserver extends ContentObserver { // add other system settings here... sGlobalSettingToTypeMap.put(Settings.Global.DEBUG_VIEW_ATTRIBUTES, int.class); - sGlobalSettingToTypeMap.put(Settings.Global.GUP_DEV_OPT_IN_APPS, String.class); - sGlobalSettingToTypeMap.put(Settings.Global.GUP_BLACK_LIST, String.class); + sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_ALL_APPS, int.class); + sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_OPT_IN_APPS, String.class); + sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_OPT_OUT_APPS, String.class); + sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_BLACKLIST, String.class); + sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_WHITELIST, String.class); // add other global settings here... } diff --git a/telephony/java/android/telephony/LocationAccessPolicy.java b/telephony/java/android/telephony/LocationAccessPolicy.java index b9d8eb637c34..eb744f619f2e 100644 --- a/telephony/java/android/telephony/LocationAccessPolicy.java +++ b/telephony/java/android/telephony/LocationAccessPolicy.java @@ -63,15 +63,18 @@ public final class LocationAccessPolicy { public final int callingPid; public final int minSdkVersionForCoarse; public final int minSdkVersionForFine; + public final boolean logAsInfo; public final String method; private LocationPermissionQuery(String callingPackage, int callingUid, int callingPid, - int minSdkVersionForCoarse, int minSdkVersionForFine, String method) { + int minSdkVersionForCoarse, int minSdkVersionForFine, boolean logAsInfo, + String method) { this.callingPackage = callingPackage; this.callingUid = callingUid; this.callingPid = callingPid; this.minSdkVersionForCoarse = minSdkVersionForCoarse; this.minSdkVersionForFine = minSdkVersionForFine; + this.logAsInfo = logAsInfo; this.method = method; } @@ -81,6 +84,7 @@ public final class LocationAccessPolicy { private int mCallingPid; private int mMinSdkVersionForCoarse = Integer.MAX_VALUE; private int mMinSdkVersionForFine = Integer.MAX_VALUE; + private boolean mLogAsInfo = false; private String mMethod; /** @@ -135,14 +139,27 @@ public final class LocationAccessPolicy { return this; } + /** + * If called with {@code true}, log messages will only be printed at the info level. + */ + public Builder setLogAsInfo(boolean logAsInfo) { + mLogAsInfo = logAsInfo; + return this; + } + public LocationPermissionQuery build() { return new LocationPermissionQuery(mCallingPackage, mCallingUid, - mCallingPid, mMinSdkVersionForCoarse, mMinSdkVersionForFine, mMethod); + mCallingPid, mMinSdkVersionForCoarse, mMinSdkVersionForFine, + mLogAsInfo, mMethod); } } } - private static void logError(Context context, String errorMsg) { + private static void logError(Context context, LocationPermissionQuery query, String errorMsg) { + if (query.logAsInfo) { + Log.i(TAG, errorMsg); + return; + } Log.e(TAG, errorMsg); try { if (Build.IS_DEBUGGABLE) { @@ -201,13 +218,13 @@ public final class LocationAccessPolicy { + " because we're not enforcing API " + minSdkVersion + " yet." + " Please fix this app because it will break in the future. Called from " + query.method; - logError(context, errorMsg); + logError(context, query, errorMsg); return null; } else if (!isAppAtLeastSdkVersion(context, query.callingPackage, minSdkVersion)) { String errorMsg = "Allowing " + query.callingPackage + " " + locationTypeForLog + " because it doesn't target API " + minSdkVersion + " yet." + " Please fix this app. Called from " + query.method; - logError(context, errorMsg); + logError(context, query, errorMsg); return null; } else { // If we're not allowing it due to the above two conditions, this means that the app diff --git a/telephony/java/android/telephony/ims/ImsService.java b/telephony/java/android/telephony/ims/ImsService.java index c008711ff236..e6777c17203a 100644 --- a/telephony/java/android/telephony/ims/ImsService.java +++ b/telephony/java/android/telephony/ims/ImsService.java @@ -40,8 +40,6 @@ import android.util.SparseArray; import com.android.ims.internal.IImsFeatureStatusCallback; import com.android.internal.annotations.VisibleForTesting; -import static android.Manifest.permission.MODIFY_PHONE_STATE; - /** * Main ImsService implementation, which binds via the Telephony ImsResolver. Services that extend * ImsService must register the service in their AndroidManifest to be detected by the framework. @@ -229,8 +227,8 @@ public class ImsService extends Service { private void setupFeature(ImsFeature f, int slotId, int featureType, IImsFeatureStatusCallback c) { - f.addImsFeatureStatusCallback(c); f.initialize(this, slotId); + f.addImsFeatureStatusCallback(c); addImsFeature(slotId, featureType, f); } |