diff options
56 files changed, 1619 insertions, 479 deletions
diff --git a/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java b/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java index 47af7c0a5ed9..00d9efbb1fcd 100644 --- a/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +++ b/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java @@ -323,6 +323,28 @@ public class BlobStoreManager { } /** + * Opens a file descriptor to read the blob content already written into this session. + * + * @return a {@link ParcelFileDescriptor} for reading from the blob file. + * + * @throws IOException when there is an I/O error while opening the file to read. + * @throws SecurityException when the caller is not the owner of the session. + * @throws IllegalStateException when the caller tries to read the file after it is + * abandoned (using {@link #abandon()}) + * or closed (using {@link #close()}). + */ + public @NonNull ParcelFileDescriptor openRead() throws IOException { + try { + return mSession.openRead(); + } catch (ParcelableException e) { + e.maybeRethrow(IOException.class); + throw new RuntimeException(e); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Gets the size of the blob file that was written to the session so far. * * @return the size of the blob file so far. diff --git a/apex/blobstore/framework/java/android/app/blob/IBlobStoreSession.aidl b/apex/blobstore/framework/java/android/app/blob/IBlobStoreSession.aidl index 4ae919bfedab..4035b96938d9 100644 --- a/apex/blobstore/framework/java/android/app/blob/IBlobStoreSession.aidl +++ b/apex/blobstore/framework/java/android/app/blob/IBlobStoreSession.aidl @@ -21,6 +21,7 @@ import android.os.ParcelFileDescriptor; /** {@hide} */ interface IBlobStoreSession { ParcelFileDescriptor openWrite(long offsetBytes, long lengthBytes); + ParcelFileDescriptor openRead(); void allowPackageAccess(in String packageName, in byte[] certificate); void allowSameSignatureAccess(); diff --git a/apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java b/apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java index 29092b327fc7..612fd89ebbe0 100644 --- a/apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java +++ b/apex/blobstore/service/java/com/android/server/blob/BlobStoreSession.java @@ -17,6 +17,7 @@ package com.android.server.blob; import static android.app.blob.BlobStoreManager.COMMIT_RESULT_ERROR; import static android.system.OsConstants.O_CREAT; +import static android.system.OsConstants.O_RDONLY; import static android.system.OsConstants.O_RDWR; import static android.system.OsConstants.SEEK_SET; @@ -187,6 +188,40 @@ public class BlobStoreSession extends IBlobStoreSession.Stub { } @Override + @NonNull + public ParcelFileDescriptor openRead() { + assertCallerIsOwner(); + synchronized (mSessionLock) { + if (mState != STATE_OPENED) { + throw new IllegalStateException("Not allowed to read in state: " + + stateToString(mState)); + } + + try { + return openReadLocked(); + } catch (IOException e) { + throw ExceptionUtils.wrap(e); + } + } + } + + @GuardedBy("mSessionLock") + @NonNull + private ParcelFileDescriptor openReadLocked() throws IOException { + FileDescriptor fd = null; + try { + final File sessionFile = getSessionFile(); + if (sessionFile == null) { + throw new IllegalStateException("Couldn't get the file for this session"); + } + fd = Os.open(sessionFile.getPath(), O_RDONLY, 0); + } catch (ErrnoException e) { + e.rethrowAsIOException(); + } + return createRevocableFdLocked(fd); + } + + @Override @BytesLong public long getSize() { return 0; diff --git a/apex/statsd/framework/Android.bp b/apex/statsd/framework/Android.bp index 0b46645ad06f..f66f0340edab 100644 --- a/apex/statsd/framework/Android.bp +++ b/apex/statsd/framework/Android.bp @@ -24,7 +24,7 @@ java_library { name: "framework-statsd", installable: true, // TODO(b/146209659): Use system_current instead. - sdk_version: "core_current", + sdk_version: "core_platform", srcs: [ ":framework-statsd-sources", ], @@ -35,7 +35,9 @@ java_library { libs: [ "framework-annotations-lib", // TODO(b/146230220): Use framework-system-stubs instead. - "android_system_stubs_current", + //"android_system_stubs_current", + //"framework_module_lib_stubs_current", + "framework-all", ], hostdex: true, // for hiddenapi check visibility: [ @@ -52,12 +54,14 @@ java_library { droidstubs { name: "framework-statsd-stubs-docs", defaults: [ - "framework-module-stubs-defaults-publicapi" + "framework-module-stubs-defaults-systemapi" ], srcs: [ + ":framework-annotations", ":framework-statsd-sources", ], libs: [ + // TODO(b/148218250): Change to android_system_stubs_current "framework-all", ], sdk_version: "core_platform", @@ -70,6 +74,7 @@ java_library { ":framework-statsd-stubs-docs", ], libs: [ + // TODO(b/148218250): Change to android_system_stubs_current "framework-all", ], sdk_version: "core_platform", diff --git a/core/java/android/app/StatsManager.java b/apex/statsd/framework/java/android/app/StatsManager.java index 0ea05d8f683c..ad1ac95d667c 100644 --- a/core/java/android/app/StatsManager.java +++ b/apex/statsd/framework/java/android/app/StatsManager.java @@ -30,7 +30,7 @@ import android.os.IPullAtomResultReceiver; import android.os.IStatsManagerService; import android.os.IStatsd; import android.os.RemoteException; -import android.os.ServiceManager; +import android.os.StatsFrameworkInitializer; import android.util.AndroidException; import android.util.Slog; import android.util.StatsEvent; @@ -702,7 +702,10 @@ public final class StatsManager { return mStatsManagerService; } mStatsManagerService = IStatsManagerService.Stub.asInterface( - ServiceManager.getService(Context.STATS_MANAGER_SERVICE)); + StatsFrameworkInitializer + .getStatsServiceManager() + .getStatsManagerServiceRegisterer() + .get()); return mStatsManagerService; } diff --git a/apex/statsd/framework/java/android/os/StatsFrameworkInitializer.java b/apex/statsd/framework/java/android/os/StatsFrameworkInitializer.java new file mode 100644 index 000000000000..3d955336b45c --- /dev/null +++ b/apex/statsd/framework/java/android/os/StatsFrameworkInitializer.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2020 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. + */ +package android.os; + +import android.annotation.NonNull; +import android.annotation.SystemApi; +import android.app.StatsManager; +import android.app.SystemServiceRegistry; +import android.content.Context; + +/** + * Class for performing registration for all stats services + * + * TODO(b/148225705) Change to @SystemApi(client=MODULE_LIBRARIES) when the build system is ready. + * @hide + */ +@SystemApi +public class StatsFrameworkInitializer { + private StatsFrameworkInitializer() { + } + + private static volatile StatsServiceManager sStatsServiceManager; + + /** + * Sets an instance of {@link StatsServiceManager} that allows + * the statsd mainline module to register/obtain stats binder services. This is called + * by the platform during the system initialization. + * + * @param statsServiceManager instance of {@link StatsServiceManager} that allows + * the statsd mainline module to register/obtain statsd binder services. + */ + public static void setStatsServiceManager( + @NonNull StatsServiceManager statsServiceManager) { + if (sStatsServiceManager != null) { + throw new IllegalStateException("setStatsServiceManager called twice!"); + } + + if (statsServiceManager == null) { + throw new NullPointerException("statsServiceManager is null"); + } + + sStatsServiceManager = statsServiceManager; + } + + /** @hide */ + public static StatsServiceManager getStatsServiceManager() { + return sStatsServiceManager; + } + + /** + * Called by {@link SystemServiceRegistry}'s static initializer and registers all statsd + * services to {@link Context}, so that {@link Context#getSystemService} can return them. + * + * @throws IllegalStateException if this is called from anywhere besides + * {@link SystemServiceRegistry} + */ + public static void registerServiceWrappers() { + SystemServiceRegistry.registerContextAwareService( + Context.STATS_MANAGER, + StatsManager.class, + context -> new StatsManager(context) + ); + } +} diff --git a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java index bcbb5a1407f6..4c8790f47bb6 100644 --- a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java +++ b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java @@ -85,6 +85,7 @@ import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.StatsFrameworkInitializer; import android.os.StatFs; import android.os.StatsLogEventWrapper; import android.os.SynchronousResultReceiver; @@ -750,7 +751,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { * sStatsd with a null check. */ private static IStatsd fetchStatsdService() { - return IStatsd.Stub.asInterface(ServiceManager.getService("stats")); + return IStatsd.Stub.asInterface(StatsFrameworkInitializer + .getStatsServiceManager() + .getStatsdServiceRegisterer() + .get()); } /** diff --git a/api/current.txt b/api/current.txt index 082d76ef4c68..c05034744ac8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -333,6 +333,9 @@ package android { field public static final int autoUrlDetect = 16843404; // 0x101028c field public static final int autoVerify = 16844014; // 0x10104ee field public static final int autofillHints = 16844118; // 0x1010556 + field public static final int autofillInlineSuggestionChip = 16844307; // 0x1010613 + field public static final int autofillInlineSuggestionSubtitle = 16844309; // 0x1010615 + field public static final int autofillInlineSuggestionTitle = 16844308; // 0x1010614 field public static final int autofilledHighlight = 16844136; // 0x1010568 field public static final int background = 16842964; // 0x10100d4 field public static final int backgroundDimAmount = 16842802; // 0x1010032 @@ -2253,6 +2256,7 @@ package android { field public static final int ThemeOverlay_Material_Dialog = 16974550; // 0x10302d6 field public static final int ThemeOverlay_Material_Dialog_Alert = 16974551; // 0x10302d7 field public static final int ThemeOverlay_Material_Light = 16974410; // 0x103024a + field public static final int Theme_AutofillInlineSuggestion = 16974565; // 0x10302e5 field public static final int Theme_Black = 16973832; // 0x1030008 field public static final int Theme_Black_NoTitleBar = 16973833; // 0x1030009 field public static final int Theme_Black_NoTitleBar_Fullscreen = 16973834; // 0x103000a @@ -7543,6 +7547,7 @@ package android.app.blob { method public boolean isPackageAccessAllowed(@NonNull String, @NonNull byte[]) throws java.io.IOException; method public boolean isPublicAccessAllowed() throws java.io.IOException; method public boolean isSameSignatureAccessAllowed() throws java.io.IOException; + method @NonNull public android.os.ParcelFileDescriptor openRead() throws java.io.IOException; method @NonNull public android.os.ParcelFileDescriptor openWrite(long, long) throws java.io.IOException; } @@ -27650,6 +27655,8 @@ package android.media.audiofx { field public static final int CONTENT_TYPE_VOICE = 3; // 0x3 field public static final String EFFECT_AUXILIARY = "Auxiliary"; field public static final String EFFECT_INSERT = "Insert"; + field public static final String EFFECT_POST_PROCESSING = "Post Processing"; + field public static final String EFFECT_PRE_PROCESSING = "Pre Processing"; field public static final java.util.UUID EFFECT_TYPE_AEC; field public static final java.util.UUID EFFECT_TYPE_AGC; field public static final java.util.UUID EFFECT_TYPE_BASS_BOOST; @@ -47730,10 +47737,10 @@ package android.telephony.euicc { field public static final int ERROR_CERTIFICATE_ERROR = 10012; // 0x271c field public static final int ERROR_CONNECTION_ERROR = 10014; // 0x271e field public static final int ERROR_DISALLOWED_BY_PPR = 10010; // 0x271a - field public static final int ERROR_EUICC_GSMA_INSTALL_ERROR = 10009; // 0x2719 field public static final int ERROR_EUICC_INSUFFICIENT_MEMORY = 10004; // 0x2714 field public static final int ERROR_EUICC_MISSING = 10006; // 0x2716 field public static final int ERROR_INCOMPATIBLE_CARRIER = 10003; // 0x2713 + field public static final int ERROR_INSTALL_PROFILE = 10009; // 0x2719 field public static final int ERROR_INVALID_ACTIVATION_CODE = 10001; // 0x2711 field public static final int ERROR_INVALID_CONFIRMATION_CODE = 10002; // 0x2712 field public static final int ERROR_INVALID_RESPONSE = 10015; // 0x271f diff --git a/api/system-current.txt b/api/system-current.txt index b24474520089..675d20cb7d96 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -250,6 +250,7 @@ package android { public static final class R.attr { field public static final int allowClearUserDataOnFailedRestore = 16844288; // 0x1010600 + field public static final int isAutofillInlineSuggestionTheme = 16844310; // 0x1010616 field public static final int isVrOnly = 16844152; // 0x1010578 field public static final int minExtensionVersion = 16844306; // 0x1010612 field public static final int requiredSystemPropertyName = 16844133; // 0x1010565 @@ -2262,6 +2263,7 @@ package android.content.pm { field public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio"; field public static final String FEATURE_REBOOT_ESCROW = "android.hardware.reboot_escrow"; field public static final String FEATURE_TELEPHONY_CARRIERLOCK = "android.hardware.telephony.carrierlock"; + field public static final int FLAGS_PERMISSION_RESERVED_PERMISSIONCONTROLLER = -268435456; // 0xf0000000 field public static final int FLAG_PERMISSION_APPLY_RESTRICTION = 16384; // 0x4000 field public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 32; // 0x20 field public static final int FLAG_PERMISSION_GRANTED_BY_ROLE = 32768; // 0x8000 @@ -6093,8 +6095,8 @@ package android.net { method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_AIRPLANE_MODE, android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void setAirplaneMode(boolean); method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public boolean shouldAvoidBadWifi(); method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(@NonNull android.net.Network, @NonNull android.os.Bundle); - method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback); - method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback, android.os.Handler); + method @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback); + method @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback, android.os.Handler); method @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void stopTethering(int); method @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public void unregisterNetworkProvider(@NonNull android.net.NetworkProvider); method @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void unregisterTetheringEventCallback(@NonNull android.net.ConnectivityManager.OnTetheringEventCallback); @@ -6110,10 +6112,10 @@ package android.net { field @Deprecated public static final int TYPE_WIFI_P2P = 13; // 0xd } - public abstract static class ConnectivityManager.OnStartTetheringCallback { - ctor public ConnectivityManager.OnStartTetheringCallback(); - method public void onTetheringFailed(); - method public void onTetheringStarted(); + @Deprecated public abstract static class ConnectivityManager.OnStartTetheringCallback { + ctor @Deprecated public ConnectivityManager.OnStartTetheringCallback(); + method @Deprecated public void onTetheringFailed(); + method @Deprecated public void onTetheringStarted(); } @Deprecated public static interface ConnectivityManager.OnTetheringEntitlementResultListener { @@ -6194,13 +6196,18 @@ package android.net { public class LinkAddress implements android.os.Parcelable { ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int); + ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int, long, long); ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int); ctor public LinkAddress(@NonNull String); ctor public LinkAddress(@NonNull String, int, int); + method public long getDeprecationTime(); + method public long getExpirationTime(); method public boolean isGlobalPreferred(); method public boolean isIpv4(); method public boolean isIpv6(); method public boolean isSameAddressAs(@Nullable android.net.LinkAddress); + field public static final long LIFETIME_PERMANENT = 9223372036854775807L; // 0x7fffffffffffffffL + field public static final long LIFETIME_UNKNOWN = -1L; // 0xffffffffffffffffL } public final class LinkProperties implements android.os.Parcelable { @@ -6516,11 +6523,13 @@ package android.net { } public class TetheringManager { - method public void registerTetheringEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.TetheringEventCallback); - method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void requestLatestTetheringEntitlementResult(int, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.OnTetheringEntitlementResultListener); - method public void stopAllTethering(); - method public void stopTethering(int); - method public void unregisterTetheringEventCallback(@NonNull android.net.TetheringManager.TetheringEventCallback); + method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerTetheringEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.TetheringEventCallback); + method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public void requestLatestTetheringEntitlementResult(int, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.OnTetheringEntitlementResultListener); + method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public void startTethering(@NonNull android.net.TetheringManager.TetheringRequest, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.StartTetheringCallback); + method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public void startTethering(int, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.StartTetheringCallback); + method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public void stopAllTethering(); + method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public void stopTethering(int); + method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.ACCESS_NETWORK_STATE}) public void unregisterTetheringEventCallback(@NonNull android.net.TetheringManager.TetheringEventCallback); field public static final String ACTION_TETHER_STATE_CHANGED = "android.net.conn.TETHER_STATE_CHANGED"; field public static final String EXTRA_ACTIVE_LOCAL_ONLY = "android.net.extra.ACTIVE_LOCAL_ONLY"; field public static final String EXTRA_ACTIVE_TETHER = "tetherArray"; @@ -6553,6 +6562,12 @@ package android.net { method public void onTetheringEntitlementResult(int); } + public abstract static class TetheringManager.StartTetheringCallback { + ctor public TetheringManager.StartTetheringCallback(); + method public void onTetheringFailed(int); + method public void onTetheringStarted(); + } + public abstract static class TetheringManager.TetheringEventCallback { ctor public TetheringManager.TetheringEventCallback(); method public void onError(@NonNull String, int); @@ -6570,6 +6585,17 @@ package android.net { method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs(); } + public static class TetheringManager.TetheringRequest { + } + + public static class TetheringManager.TetheringRequest.Builder { + ctor public TetheringManager.TetheringRequest.Builder(int); + method @NonNull public android.net.TetheringManager.TetheringRequest build(); + method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean); + method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean); + method @NonNull @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public android.net.TetheringManager.TetheringRequest.Builder useStaticIpv4Addresses(@NonNull android.net.LinkAddress); + } + public class TrafficStats { method public static void setThreadStatsTagApp(); method public static void setThreadStatsTagBackup(); @@ -7601,11 +7627,8 @@ package android.net.wifi { method public boolean isPortableHotspotSupported(); method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isWifiApEnabled(); method public boolean isWifiScannerSupported(); - method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerNetworkRequestMatchCallback(@NonNull android.net.wifi.WifiManager.NetworkRequestMatchCallback); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerNetworkRequestMatchCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.NetworkRequestMatchCallback); - method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerSoftApCallback(@NonNull android.net.wifi.WifiManager.SoftApCallback); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerSoftApCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.SoftApCallback); - method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerTrafficStateCallback(@NonNull android.net.wifi.WifiManager.TrafficStateCallback); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerTrafficStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.TrafficStateCallback); method @RequiresPermission(android.Manifest.permission.WIFI_UPDATE_USABILITY_STATS_SCORE) public void removeOnWifiUsabilityStatsListener(@NonNull android.net.wifi.WifiManager.OnWifiUsabilityStatsListener); method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreBackupData(@NonNull byte[]); @@ -8341,22 +8364,22 @@ package android.os { method @NonNull public android.os.BatterySaverPolicyConfig.Builder setLocationMode(int); } - public class BatteryStatsManager { + public final class BatteryStatsManager { method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.os.connectivity.CellularBatteryStats getCellularBatteryStats(); method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.os.connectivity.WifiBatteryStats getWifiBatteryStats(); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteFullWifiLockAcquiredFromSource(@NonNull android.os.WorkSource); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteFullWifiLockReleasedFromSource(@NonNull android.os.WorkSource); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiBatchedScanStartedFromSource(@NonNull android.os.WorkSource, @IntRange(from=0) int); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiBatchedScanStoppedFromSource(@NonNull android.os.WorkSource); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiMulticastDisabled(int); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiMulticastEnabled(int); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiOff(); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiOn(); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiRssiChanged(@IntRange(from=0xffffff81, to=0) int); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiScanStartedFromSource(@NonNull android.os.WorkSource); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiScanStoppedFromSource(@NonNull android.os.WorkSource); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiState(int, @Nullable String); - method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiSupplicantStateChanged(int, boolean); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockAcquiredFromSource(@NonNull android.os.WorkSource); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportFullWifiLockReleasedFromSource(@NonNull android.os.WorkSource); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiBatchedScanStartedFromSource(@NonNull android.os.WorkSource, @IntRange(from=0) int); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiBatchedScanStoppedFromSource(@NonNull android.os.WorkSource); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiMulticastDisabled(int); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiMulticastEnabled(int); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiOff(); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiOn(); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiRssiChanged(@IntRange(from=0xffffff81, to=0) int); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiScanStartedFromSource(@NonNull android.os.WorkSource); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiScanStoppedFromSource(@NonNull android.os.WorkSource); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiState(int, @Nullable String); + method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void reportWifiSupplicantStateChanged(int, boolean); field public static final int WIFI_STATE_OFF = 0; // 0x0 field public static final int WIFI_STATE_OFF_SCANNING = 1; // 0x1 field public static final int WIFI_STATE_ON_CONNECTED_P2P = 5; // 0x5 @@ -8766,6 +8789,26 @@ package android.os { field public static final int TUPLE_VALUE_TYPE = 7; // 0x7 } + public class StatsFrameworkInitializer { + method public static void registerServiceWrappers(); + method public static void setStatsServiceManager(@NonNull android.os.StatsServiceManager); + } + + public class StatsServiceManager { + method @NonNull public android.os.StatsServiceManager.ServiceRegisterer getStatsCompanionServiceRegisterer(); + method @NonNull public android.os.StatsServiceManager.ServiceRegisterer getStatsManagerServiceRegisterer(); + method @NonNull public android.os.StatsServiceManager.ServiceRegisterer getStatsdServiceRegisterer(); + } + + public static class StatsServiceManager.ServiceNotFoundException extends java.lang.Exception { + ctor public StatsServiceManager.ServiceNotFoundException(@NonNull String); + } + + public static final class StatsServiceManager.ServiceRegisterer { + method @Nullable public android.os.IBinder get(); + method @Nullable public android.os.IBinder getOrThrow() throws android.os.StatsServiceManager.ServiceNotFoundException; + } + public class SystemConfigManager { method @NonNull @RequiresPermission(android.Manifest.permission.READ_CARRIER_APP_INFO) public java.util.Set<java.lang.String> getDisabledUntilUsedPreinstalledCarrierApps(); method @NonNull @RequiresPermission(android.Manifest.permission.READ_CARRIER_APP_INFO) public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getDisabledUntilUsedPreinstalledCarrierAssociatedApps(); @@ -8800,16 +8843,13 @@ package android.os { method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getEuiccCardControllerServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getEuiccControllerService(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getIccPhoneBookServiceRegisterer(); - method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getNetworkPolicyServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getOpportunisticNetworkServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getPackageManagerServiceRegisterer(); - method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getPermissionManagerServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getPhoneSubServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getSmsServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getSubscriptionServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getTelephonyImsServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getTelephonyRcsMessageServiceRegisterer(); - method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getTelephonyRegistryServiceRegisterer(); method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getTelephonyServiceRegisterer(); } @@ -9030,12 +9070,12 @@ package android.os.connectivity { public final class WifiBatteryStats implements android.os.Parcelable { method public int describeContents(); + method public long getAppScanRequestCount(); method public long getEnergyConsumedMaMillis(); method public long getIdleTimeMillis(); method public long getKernelActiveTimeMillis(); method public long getLoggingDurationMillis(); method public long getMonitoredRailChargeConsumedMaMillis(); - method public long getNumAppScanRequest(); method public long getNumBytesRx(); method public long getNumBytesTx(); method public long getNumPacketsRx(); @@ -9734,6 +9774,7 @@ package android.provider { field public static final String HPLMNS = "hplmns"; field public static final String ICC_ID = "icc_id"; field public static final String IMSI = "imsi"; + field public static final String IMS_RCS_UCE_ENABLED = "ims_rcs_uce_enabled"; field public static final String ISO_COUNTRY_CODE = "iso_country_code"; field public static final String IS_EMBEDDED = "is_embedded"; field public static final String IS_OPPORTUNISTIC = "is_opportunistic"; @@ -12320,6 +12361,7 @@ package android.telephony { public class TelephonyRegistryManager { method public void addOnOpportunisticSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener, @NonNull java.util.concurrent.Executor); method public void addOnSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnSubscriptionsChangedListener, @NonNull java.util.concurrent.Executor); + method public void listenForSubscriber(int, @NonNull String, @NonNull String, @NonNull android.telephony.PhoneStateListener, int, boolean); method public void notifyActiveDataSubIdChanged(int); method public void notifyBarringInfoChanged(int, int, @NonNull android.telephony.BarringInfo); method public void notifyCallForwardingChanged(int, boolean); @@ -12336,6 +12378,9 @@ package android.telephony { method public void notifyEmergencyNumberList(int, int); method public void notifyImsDisconnectCause(int, @NonNull android.telephony.ims.ImsReasonInfo); method public void notifyMessageWaitingChanged(int, int, boolean); + method public void notifyOpportunisticSubscriptionInfoChanged(); + method public void notifyOutgoingEmergencyCall(int, int, @NonNull android.telephony.emergency.EmergencyNumber); + method public void notifyOutgoingEmergencySms(int, int, @NonNull android.telephony.emergency.EmergencyNumber); method public void notifyPhoneCapabilityChanged(@NonNull android.telephony.PhoneCapability); method public void notifyPreciseCallState(int, int, int, int, int); method public void notifyPreciseDataConnectionFailed(int, int, int, @Nullable String, int); @@ -12344,6 +12389,7 @@ package android.telephony { method public void notifyServiceStateChanged(int, int, @NonNull android.telephony.ServiceState); method public void notifySignalStrengthChanged(int, int, @NonNull android.telephony.SignalStrength); method public void notifySrvccStateChanged(int, int); + method public void notifySubscriptionInfoChanged(); method public void notifyUserMobileDataStateChanged(int, int, boolean); method public void notifyVoiceActivationStateChanged(int, int, int); method public void removeOnOpportunisticSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener); @@ -12649,6 +12695,11 @@ package android.telephony.euicc { method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDefaultDownloadableSubscriptionList(android.app.PendingIntent); method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDownloadableSubscriptionMetadata(android.telephony.euicc.DownloadableSubscription, android.app.PendingIntent); method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public int getOtaStatus(); + method @NonNull @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public java.util.List<java.lang.String> getSupportedCountries(); + method @NonNull @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public java.util.List<java.lang.String> getUnsupportedCountries(); + method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public boolean isSupportedCountry(@NonNull String); + method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void setSupportedCountries(@NonNull java.util.List<java.lang.String>); + method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void setUnsupportedCountries(@NonNull java.util.List<java.lang.String>); field public static final String ACTION_DELETE_SUBSCRIPTION_PRIVILEGED = "android.telephony.euicc.action.DELETE_SUBSCRIPTION_PRIVILEGED"; field @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public static final String ACTION_OTA_STATUS_CHANGED = "android.telephony.euicc.action.OTA_STATUS_CHANGED"; field public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION = "android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION"; @@ -13343,6 +13394,29 @@ package android.telephony.ims { method @NonNull public android.telephony.ims.RcsContactUceCapability build(); } + public class RcsUceAdapter { + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isUceSettingEnabled() throws android.telephony.ims.ImsException; + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUceSettingEnabled(boolean) throws android.telephony.ims.ImsException; + field public static final int ERROR_ALREADY_IN_QUEUE = 13; // 0xd + field public static final int ERROR_FORBIDDEN = 6; // 0x6 + field public static final int ERROR_GENERIC_FAILURE = 1; // 0x1 + field public static final int ERROR_INSUFFICIENT_MEMORY = 11; // 0xb + field public static final int ERROR_LOST_NETWORK = 12; // 0xc + field public static final int ERROR_NOT_AUTHORIZED = 5; // 0x5 + field public static final int ERROR_NOT_AVAILABLE = 3; // 0x3 + field public static final int ERROR_NOT_ENABLED = 2; // 0x2 + field public static final int ERROR_NOT_FOUND = 7; // 0x7 + field public static final int ERROR_NOT_REGISTERED = 4; // 0x4 + field public static final int ERROR_REQUEST_TIMEOUT = 10; // 0xa + field public static final int ERROR_REQUEST_TOO_LARGE = 8; // 0x8 + field public static final int PUBLISH_STATE_200_OK = 1; // 0x1 + field public static final int PUBLISH_STATE_NOT_PUBLISHED = 2; // 0x2 + field public static final int PUBLISH_STATE_OTHER_ERROR = 6; // 0x6 + field public static final int PUBLISH_STATE_RCS_PROVISION_ERROR = 4; // 0x4 + field public static final int PUBLISH_STATE_REQUEST_TIMEOUT = 5; // 0x5 + field public static final int PUBLISH_STATE_VOLTE_PROVISION_ERROR = 3; // 0x3 + } + } package android.telephony.ims.feature { @@ -14274,3 +14348,4 @@ package android.webkit { } } + diff --git a/api/test-current.txt b/api/test-current.txt index 13a9cf428efa..259d401c2ada 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1621,9 +1621,12 @@ package android.net { public class LinkAddress implements android.os.Parcelable { ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int); + ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int, long, long); ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int); ctor public LinkAddress(@NonNull String); ctor public LinkAddress(@NonNull String, int, int); + method public long getDeprecationTime(); + method public long getExpirationTime(); method public boolean isGlobalPreferred(); method public boolean isIpv4(); method public boolean isIpv6(); @@ -1724,11 +1727,13 @@ package android.net { } public class TetheringManager { - method public void registerTetheringEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.TetheringEventCallback); - method @RequiresPermission("android.permission.TETHER_PRIVILEGED") public void requestLatestTetheringEntitlementResult(int, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.OnTetheringEntitlementResultListener); - method public void stopAllTethering(); - method public void stopTethering(int); - method public void unregisterTetheringEventCallback(@NonNull android.net.TetheringManager.TetheringEventCallback); + method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerTetheringEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.TetheringEventCallback); + method @RequiresPermission(anyOf={"android.permission.TETHER_PRIVILEGED", android.Manifest.permission.WRITE_SETTINGS}) public void requestLatestTetheringEntitlementResult(int, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.OnTetheringEntitlementResultListener); + method @RequiresPermission(anyOf={"android.permission.TETHER_PRIVILEGED", android.Manifest.permission.WRITE_SETTINGS}) public void startTethering(@NonNull android.net.TetheringManager.TetheringRequest, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.StartTetheringCallback); + method @RequiresPermission(anyOf={"android.permission.TETHER_PRIVILEGED", android.Manifest.permission.WRITE_SETTINGS}) public void startTethering(int, @NonNull java.util.concurrent.Executor, @NonNull android.net.TetheringManager.StartTetheringCallback); + method @RequiresPermission(anyOf={"android.permission.TETHER_PRIVILEGED", android.Manifest.permission.WRITE_SETTINGS}) public void stopAllTethering(); + method @RequiresPermission(anyOf={"android.permission.TETHER_PRIVILEGED", android.Manifest.permission.WRITE_SETTINGS}) public void stopTethering(int); + method @RequiresPermission(anyOf={"android.permission.TETHER_PRIVILEGED", android.Manifest.permission.ACCESS_NETWORK_STATE}) public void unregisterTetheringEventCallback(@NonNull android.net.TetheringManager.TetheringEventCallback); field public static final String ACTION_TETHER_STATE_CHANGED = "android.net.conn.TETHER_STATE_CHANGED"; field public static final String EXTRA_ACTIVE_LOCAL_ONLY = "android.net.extra.ACTIVE_LOCAL_ONLY"; field public static final String EXTRA_ACTIVE_TETHER = "tetherArray"; @@ -1761,6 +1766,12 @@ package android.net { method public void onTetheringEntitlementResult(int); } + public abstract static class TetheringManager.StartTetheringCallback { + ctor public TetheringManager.StartTetheringCallback(); + method public void onTetheringFailed(int); + method public void onTetheringStarted(); + } + public abstract static class TetheringManager.TetheringEventCallback { ctor public TetheringManager.TetheringEventCallback(); method public void onError(@NonNull String, int); @@ -1778,6 +1789,17 @@ package android.net { method @Deprecated @NonNull public java.util.List<java.lang.String> getTetherableWifiRegexs(); } + public static class TetheringManager.TetheringRequest { + } + + public static class TetheringManager.TetheringRequest.Builder { + ctor public TetheringManager.TetheringRequest.Builder(int); + method @NonNull public android.net.TetheringManager.TetheringRequest build(); + method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setExemptFromEntitlementCheck(boolean); + method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder setSilentProvisioning(boolean); + method @NonNull @RequiresPermission("android.permission.TETHER_PRIVILEGED") public android.net.TetheringManager.TetheringRequest.Builder useStaticIpv4Addresses(@NonNull android.net.LinkAddress); + } + public class TrafficStats { method public static long getLoopbackRxBytes(); method public static long getLoopbackRxPackets(); @@ -3497,6 +3519,7 @@ package android.telephony { public class TelephonyRegistryManager { method public void addOnOpportunisticSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnOpportunisticSubscriptionsChangedListener, @NonNull java.util.concurrent.Executor); method public void addOnSubscriptionsChangedListener(@NonNull android.telephony.SubscriptionManager.OnSubscriptionsChangedListener, @NonNull java.util.concurrent.Executor); + method public void listenForSubscriber(int, @NonNull String, @NonNull String, @NonNull android.telephony.PhoneStateListener, int, boolean); method public void notifyActiveDataSubIdChanged(int); method public void notifyBarringInfoChanged(int, int, @NonNull android.telephony.BarringInfo); method public void notifyCallForwardingChanged(int, boolean); @@ -3513,6 +3536,8 @@ package android.telephony { method public void notifyEmergencyNumberList(int, int); method public void notifyImsDisconnectCause(int, @NonNull android.telephony.ims.ImsReasonInfo); method public void notifyMessageWaitingChanged(int, int, boolean); + method public void notifyOutgoingEmergencyCall(int, int, @NonNull android.telephony.emergency.EmergencyNumber); + method public void notifyOutgoingEmergencySms(int, int, @NonNull android.telephony.emergency.EmergencyNumber); method public void notifyPhoneCapabilityChanged(@NonNull android.telephony.PhoneCapability); method public void notifyPreciseCallState(int, int, int, int, int); method public void notifyPreciseDataConnectionFailed(int, int, int, @Nullable String, int); @@ -4114,6 +4139,29 @@ package android.telephony.ims { method public void onProvisioningStringChanged(int, @NonNull String); } + public class RcsUceAdapter { + method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public boolean isUceSettingEnabled() throws android.telephony.ims.ImsException; + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUceSettingEnabled(boolean) throws android.telephony.ims.ImsException; + field public static final int ERROR_ALREADY_IN_QUEUE = 13; // 0xd + field public static final int ERROR_FORBIDDEN = 6; // 0x6 + field public static final int ERROR_GENERIC_FAILURE = 1; // 0x1 + field public static final int ERROR_INSUFFICIENT_MEMORY = 11; // 0xb + field public static final int ERROR_LOST_NETWORK = 12; // 0xc + field public static final int ERROR_NOT_AUTHORIZED = 5; // 0x5 + field public static final int ERROR_NOT_AVAILABLE = 3; // 0x3 + field public static final int ERROR_NOT_ENABLED = 2; // 0x2 + field public static final int ERROR_NOT_FOUND = 7; // 0x7 + field public static final int ERROR_NOT_REGISTERED = 4; // 0x4 + field public static final int ERROR_REQUEST_TIMEOUT = 10; // 0xa + field public static final int ERROR_REQUEST_TOO_LARGE = 8; // 0x8 + field public static final int PUBLISH_STATE_200_OK = 1; // 0x1 + field public static final int PUBLISH_STATE_NOT_PUBLISHED = 2; // 0x2 + field public static final int PUBLISH_STATE_OTHER_ERROR = 6; // 0x6 + field public static final int PUBLISH_STATE_RCS_PROVISION_ERROR = 4; // 0x4 + field public static final int PUBLISH_STATE_REQUEST_TIMEOUT = 5; // 0x5 + field public static final int PUBLISH_STATE_VOLTE_PROVISION_ERROR = 3; // 0x3 + } + } package android.telephony.ims.feature { diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 2ca5b1d5c76f..48f0087f6b30 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -111,6 +111,8 @@ import android.os.Process; import android.os.RemoteCallback; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.StatsFrameworkInitializer; +import android.os.StatsServiceManager; import android.os.StrictMode; import android.os.SystemClock; import android.os.SystemProperties; @@ -7523,6 +7525,7 @@ public final class ActivityThread extends ClientTransactionHandler { */ public static void initializeMainlineModules() { TelephonyFrameworkInitializer.setTelephonyServiceManager(new TelephonyServiceManager()); + StatsFrameworkInitializer.setStatsServiceManager(new StatsServiceManager()); } private void purgePendingResources() { diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 7f698653bef7..dcd179f8694d 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -150,6 +150,7 @@ import android.os.RecoverySystem; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager.ServiceNotFoundException; +import android.os.StatsFrameworkInitializer; import android.os.SystemConfigManager; import android.os.SystemUpdateManager; import android.os.SystemVibrator; @@ -601,13 +602,6 @@ public final class SystemServiceRegistry { return SensorPrivacyManager.getInstance(ctx); }}); - registerService(Context.STATS_MANAGER, StatsManager.class, - new CachedServiceFetcher<StatsManager>() { - @Override - public StatsManager createService(ContextImpl ctx) { - return new StatsManager(ctx.getOuterContext()); - }}); - registerService(Context.STATUS_BAR_SERVICE, StatusBarManager.class, new CachedServiceFetcher<StatusBarManager>() { @Override @@ -1327,6 +1321,7 @@ public final class SystemServiceRegistry { TelephonyFrameworkInitializer.registerServiceWrappers(); AppSearchManagerFrameworkInitializer.initialize(); WifiFrameworkInitializer.registerServiceWrappers(); + StatsFrameworkInitializer.registerServiceWrappers(); } finally { // If any of the above code throws, we're in a pretty bad shape and the process // will likely crash, but we'll reset it just in case there's an exception handler... diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 205617022aa1..9f8d32b96b6d 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -3328,6 +3328,15 @@ public abstract class PackageManager { public static final int FLAG_PERMISSION_ONE_TIME = 1 << 16; /** + * Permission flags: Reserved for use by the permission controller. + * + * @hide + */ + @SystemApi + public static final int FLAGS_PERMISSION_RESERVED_PERMISSIONCONTROLLER = 1 << 28 | 1 << 29 + | 1 << 30 | 1 << 31; + + /** * Permission flags: Bitwise or of all permission flags allowing an * exemption for a restricted permission. * @hide diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 753e754602d1..ce9693d88a97 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -33,7 +33,9 @@ import android.content.Context; import android.content.Intent; import android.net.IpSecManager.UdpEncapsulationSocket; import android.net.SocketKeepalive.Callback; +import android.net.TetheringManager.StartTetheringCallback; import android.net.TetheringManager.TetheringEventCallback; +import android.net.TetheringManager.TetheringRequest; import android.os.Binder; import android.os.Build; import android.os.Build.VERSION_CODES; @@ -2452,10 +2454,12 @@ public class ConnectivityManager { * * @param iface the interface name to tether. * @return error a {@code TETHER_ERROR} value indicating success or failure type + * @deprecated Use {@link TetheringManager#startTethering} instead * * {@hide} */ @UnsupportedAppUsage + @Deprecated public int tether(String iface) { return getTetheringManager().tether(iface); } @@ -2512,9 +2516,12 @@ public class ConnectivityManager { /** * Callback for use with {@link #startTethering} to find out whether tethering succeeded. + * + * @deprecated Use {@link TetheringManager.StartTetheringCallback} instead. * @hide */ @SystemApi + @Deprecated public static abstract class OnStartTetheringCallback { /** * Called when tethering has been successfully started. @@ -2531,9 +2538,12 @@ public class ConnectivityManager { * Convenient overload for * {@link #startTethering(int, boolean, OnStartTetheringCallback, Handler)} which passes a null * handler to run on the current thread's {@link Looper}. + * + * @deprecated Use {@link TetheringManager#startTethering} instead. * @hide */ @SystemApi + @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int type, boolean showProvisioningUi, final OnStartTetheringCallback callback) { @@ -2557,26 +2567,44 @@ public class ConnectivityManager { * @param callback an {@link OnStartTetheringCallback} which will be called to notify the caller * of the result of trying to tether. * @param handler {@link Handler} to specify the thread upon which the callback will be invoked. + * + * @deprecated Use {@link TetheringManager#startTethering} instead. * @hide */ @SystemApi + @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int type, boolean showProvisioningUi, final OnStartTetheringCallback callback, Handler handler) { Preconditions.checkNotNull(callback, "OnStartTetheringCallback cannot be null."); - ResultReceiver wrappedCallback = new ResultReceiver(handler) { + final Executor executor = new Executor() { @Override - protected void onReceiveResult(int resultCode, Bundle resultData) { - if (resultCode == TETHER_ERROR_NO_ERROR) { - callback.onTetheringStarted(); + public void execute(Runnable command) { + if (handler == null) { + command.run(); } else { - callback.onTetheringFailed(); + handler.post(command); } } }; - getTetheringManager().startTethering(type, wrappedCallback, showProvisioningUi); + final StartTetheringCallback tetheringCallback = new StartTetheringCallback() { + @Override + public void onTetheringStarted() { + callback.onTetheringStarted(); + } + + @Override + public void onTetheringFailed(final int resultCode) { + callback.onTetheringFailed(); + } + }; + + final TetheringRequest request = new TetheringRequest.Builder(type) + .setSilentProvisioning(!showProvisioningUi).build(); + + getTetheringManager().startTethering(request, executor, tetheringCallback); } /** @@ -2602,7 +2630,7 @@ public class ConnectivityManager { * Callback for use with {@link registerTetheringEventCallback} to find out tethering * upstream status. * - * @deprecated Use {@line TetheringManager#OnTetheringEventCallback} instead. + * @deprecated Use {@link TetheringManager#OnTetheringEventCallback} instead. * @hide */ @SystemApi @@ -2632,7 +2660,7 @@ public class ConnectivityManager { * @param executor the executor on which callback will be invoked. * @param callback the callback to be called when tethering has change events. * - * @deprecated Use {@line TetheringManager#registerTetheringEventCallback} instead. + * @deprecated Use {@link TetheringManager#registerTetheringEventCallback} instead. * @hide */ @SystemApi @@ -2749,10 +2777,12 @@ public class ConnectivityManager { * * @param enable a boolean - {@code true} to enable tethering * @return error a {@code TETHER_ERROR} value indicating success or failure type + * @deprecated Use {@link TetheringManager#startTethering} instead * * {@hide} */ @UnsupportedAppUsage + @Deprecated public int setUsbTethering(boolean enable) { return getTetheringManager().setUsbTethering(enable); } diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java index bf8b38fc7f84..8d9f0d068a57 100644 --- a/core/java/android/net/LinkAddress.java +++ b/core/java/android/net/LinkAddress.java @@ -19,6 +19,7 @@ package android.net; import static android.system.OsConstants.IFA_F_DADFAILED; import static android.system.OsConstants.IFA_F_DEPRECATED; import static android.system.OsConstants.IFA_F_OPTIMISTIC; +import static android.system.OsConstants.IFA_F_PERMANENT; import static android.system.OsConstants.IFA_F_TENTATIVE; import static android.system.OsConstants.RT_SCOPE_HOST; import static android.system.OsConstants.RT_SCOPE_LINK; @@ -34,6 +35,7 @@ import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; +import android.os.SystemClock; import android.util.Pair; import java.net.Inet4Address; @@ -41,6 +43,7 @@ import java.net.Inet6Address; import java.net.InetAddress; import java.net.InterfaceAddress; import java.net.UnknownHostException; +import java.util.Objects; /** * Identifies an IP address on a network link. @@ -58,6 +61,21 @@ import java.net.UnknownHostException; * </ul> */ public class LinkAddress implements Parcelable { + + /** + * Indicates the deprecation or expiration time is unknown + * @hide + */ + @SystemApi + public static final long LIFETIME_UNKNOWN = -1; + + /** + * Indicates this address is permanent. + * @hide + */ + @SystemApi + public static final long LIFETIME_PERMANENT = Long.MAX_VALUE; + /** * IPv4 or IPv6 address. */ @@ -71,7 +89,9 @@ public class LinkAddress implements Parcelable { private int prefixLength; /** - * Address flags. A bitmask of IFA_F_* values. + * Address flags. A bitmask of {@code IFA_F_*} values. Note that {@link #getFlags()} may not + * return these exact values. For example, it may set or clear the {@code IFA_F_DEPRECATED} + * flag depending on the current preferred lifetime. */ private int flags; @@ -81,6 +101,23 @@ public class LinkAddress implements Parcelable { private int scope; /** + * The time, as reported by {@link SystemClock#elapsedRealtime}, when this LinkAddress will be + * or was deprecated. {@link #LIFETIME_UNKNOWN} indicates this information is not available. At + * the time existing connections can still use this address until it expires, but new + * connections should use the new address. {@link #LIFETIME_PERMANENT} indicates this + * {@link LinkAddress} will never be deprecated. + */ + private long deprecationTime; + + /** + * The time, as reported by {@link SystemClock#elapsedRealtime}, when this {@link LinkAddress} + * will expire and be removed from the interface. {@link #LIFETIME_UNKNOWN} indicates this + * information is not available. {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} + * will never expire. + */ + private long expirationTime; + + /** * Utility function to determines the scope of a unicast address. Per RFC 4291 section 2.5 and * RFC 6724 section 3.2. * @hide @@ -152,7 +189,8 @@ public class LinkAddress implements Parcelable { /** * Utility function for the constructors. */ - private void init(InetAddress address, int prefixLength, int flags, int scope) { + private void init(InetAddress address, int prefixLength, int flags, int scope, + long deprecationTime, long expirationTime) { if (address == null || address.isMulticastAddress() || prefixLength < 0 || @@ -161,15 +199,42 @@ public class LinkAddress implements Parcelable { throw new IllegalArgumentException("Bad LinkAddress params " + address + "/" + prefixLength); } + + // deprecation time and expiration time must be both provided, or neither. + if ((deprecationTime == LIFETIME_UNKNOWN) != (expirationTime == LIFETIME_UNKNOWN)) { + throw new IllegalArgumentException( + "Must not specify only one of deprecation time and expiration time"); + } + + // deprecation time needs to be a positive value. + if (deprecationTime != LIFETIME_UNKNOWN && deprecationTime < 0) { + throw new IllegalArgumentException("invalid deprecation time " + deprecationTime); + } + + // expiration time needs to be a positive value. + if (expirationTime != LIFETIME_UNKNOWN && expirationTime < 0) { + throw new IllegalArgumentException("invalid expiration time " + expirationTime); + } + + // expiration time can't be earlier than deprecation time + if (deprecationTime != LIFETIME_UNKNOWN && expirationTime != LIFETIME_UNKNOWN + && expirationTime < deprecationTime) { + throw new IllegalArgumentException("expiration earlier than deprecation (" + + deprecationTime + ", " + expirationTime + ")"); + } + this.address = address; this.prefixLength = prefixLength; this.flags = flags; this.scope = scope; + this.deprecationTime = deprecationTime; + this.expirationTime = expirationTime; } /** * Constructs a new {@code LinkAddress} from an {@code InetAddress} and prefix length, with * the specified flags and scope. Flags and scope are not checked for validity. + * * @param address The IP address. * @param prefixLength The prefix length. Must be >= 0 and <= (32 or 128) (IPv4 or IPv6). * @param flags A bitmask of {@code IFA_F_*} values representing properties of the address. @@ -181,7 +246,39 @@ public class LinkAddress implements Parcelable { @TestApi public LinkAddress(@NonNull InetAddress address, @IntRange(from = 0, to = 128) int prefixLength, int flags, int scope) { - init(address, prefixLength, flags, scope); + init(address, prefixLength, flags, scope, LIFETIME_UNKNOWN, LIFETIME_UNKNOWN); + } + + /** + * Constructs a new {@code LinkAddress} from an {@code InetAddress}, prefix length, with + * the specified flags, scope, deprecation time, and expiration time. Flags and scope are not + * checked for validity. The value of the {@code IFA_F_DEPRECATED} and {@code IFA_F_PERMANENT} + * flag will be adjusted based on the passed-in lifetimes. + * + * @param address The IP address. + * @param prefixLength The prefix length. Must be >= 0 and <= (32 or 128) (IPv4 or IPv6). + * @param flags A bitmask of {@code IFA_F_*} values representing properties of the address. + * @param scope An integer defining the scope in which the address is unique (e.g., + * {@link OsConstants#RT_SCOPE_LINK} or {@link OsConstants#RT_SCOPE_SITE}). + * @param deprecationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when + * this {@link LinkAddress} will be or was deprecated. + * {@link #LIFETIME_UNKNOWN} indicates this information is not available. + * At the time existing connections can still use this address until it + * expires, but new connections should use the new address. + * {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} will + * never be deprecated. + * @param expirationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when this + * {@link LinkAddress} will expire and be removed from the interface. + * {@link #LIFETIME_UNKNOWN} indicates this information is not available. + * {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} will + * never expire. + * @hide + */ + @SystemApi + @TestApi + public LinkAddress(@NonNull InetAddress address, @IntRange(from = 0, to = 128) int prefixLength, + int flags, int scope, long deprecationTime, long expirationTime) { + init(address, prefixLength, flags, scope, deprecationTime, expirationTime); } /** @@ -237,7 +334,7 @@ public class LinkAddress implements Parcelable { // This may throw an IllegalArgumentException; catching it is the caller's responsibility. // TODO: consider rejecting mapped IPv4 addresses such as "::ffff:192.0.2.5/24". Pair<InetAddress, Integer> ipAndMask = NetworkUtils.parseIpAndMask(address); - init(ipAndMask.first, ipAndMask.second, flags, scope); + init(ipAndMask.first, ipAndMask.second, flags, scope, LIFETIME_UNKNOWN, LIFETIME_UNKNOWN); } /** @@ -265,10 +362,12 @@ public class LinkAddress implements Parcelable { return false; } LinkAddress linkAddress = (LinkAddress) obj; - return this.address.equals(linkAddress.address) && - this.prefixLength == linkAddress.prefixLength && - this.flags == linkAddress.flags && - this.scope == linkAddress.scope; + return this.address.equals(linkAddress.address) + && this.prefixLength == linkAddress.prefixLength + && this.flags == linkAddress.flags + && this.scope == linkAddress.scope + && this.deprecationTime == linkAddress.deprecationTime + && this.expirationTime == linkAddress.expirationTime; } /** @@ -276,7 +375,7 @@ public class LinkAddress implements Parcelable { */ @Override public int hashCode() { - return address.hashCode() + 11 * prefixLength + 19 * flags + 43 * scope; + return Objects.hash(address, prefixLength, flags, scope, deprecationTime, expirationTime); } /** @@ -329,6 +428,25 @@ public class LinkAddress implements Parcelable { * Returns the flags of this {@code LinkAddress}. */ public int getFlags() { + int flags = this.flags; + if (deprecationTime != LIFETIME_UNKNOWN) { + if (SystemClock.elapsedRealtime() >= deprecationTime) { + flags |= IFA_F_DEPRECATED; + } else { + // If deprecation time is in the future, or permanent. + flags &= ~IFA_F_DEPRECATED; + } + } + + if (expirationTime == LIFETIME_PERMANENT) { + flags |= IFA_F_PERMANENT; + } else if (expirationTime != LIFETIME_UNKNOWN) { + // If we know this address expired or will expire in the future or, then this address + // should not be permanent. + flags &= ~IFA_F_PERMANENT; + } + + // Do no touch the original flags. Return the adjusted flags here. return flags; } @@ -340,7 +458,35 @@ public class LinkAddress implements Parcelable { } /** - * Returns true if this {@code LinkAddress} is global scope and preferred. + * @return The time that this address will be deprecated. At the time the existing connection + * can still use this address until it expires, but the new connection should use the new + * address. This is the EPOCH time in milliseconds. 0 indicates this information is not + * available. + * + * @hide + */ + @SystemApi + @TestApi + public long getDeprecationTime() { + return deprecationTime; + } + + /** + * @return The time that this address will expire and will be no longer valid. This is the EPOCH + * time in milliseconds. 0 indicates this information is not available. + * + * @hide + */ + @SystemApi + @TestApi + public long getExpirationTime() { + return expirationTime; + } + + /** + * Returns true if this {@code LinkAddress} is global scope and preferred (i.e., not currently + * deprecated). + * * @hide */ @TestApi @@ -352,6 +498,7 @@ public class LinkAddress implements Parcelable { * state has cleared either DAD has succeeded or failed, and both * flags are cleared regardless). */ + int flags = getFlags(); return (scope == RT_SCOPE_UNIVERSE && !isIpv6ULA() && (flags & (IFA_F_DADFAILED | IFA_F_DEPRECATED)) == 0L @@ -373,6 +520,8 @@ public class LinkAddress implements Parcelable { dest.writeInt(prefixLength); dest.writeInt(this.flags); dest.writeInt(scope); + dest.writeLong(deprecationTime); + dest.writeLong(expirationTime); } /** @@ -392,7 +541,10 @@ public class LinkAddress implements Parcelable { int prefixLength = in.readInt(); int flags = in.readInt(); int scope = in.readInt(); - return new LinkAddress(address, prefixLength, flags, scope); + long deprecationTime = in.readLong(); + long expirationTime = in.readLong(); + return new LinkAddress(address, prefixLength, flags, scope, deprecationTime, + expirationTime); } public LinkAddress[] newArray(int size) { diff --git a/core/java/android/os/BatteryStatsManager.java b/core/java/android/os/BatteryStatsManager.java index 0545666ca743..f2e16b46422f 100644 --- a/core/java/android/os/BatteryStatsManager.java +++ b/core/java/android/os/BatteryStatsManager.java @@ -42,7 +42,7 @@ import java.lang.annotation.RetentionPolicy; */ @SystemApi @SystemService(Context.BATTERY_STATS_SERVICE) -public class BatteryStatsManager { +public final class BatteryStatsManager { /** * Wifi states. * @@ -166,7 +166,7 @@ public class BatteryStatsManager { * @param newRssi The new RSSI value. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiRssiChanged(@IntRange(from = -127, to = 0) int newRssi) { + public void reportWifiRssiChanged(@IntRange(from = -127, to = 0) int newRssi) { try { mBatteryStats.noteWifiRssiChanged(newRssi); } catch (RemoteException e) { @@ -178,7 +178,7 @@ public class BatteryStatsManager { * Indicates that wifi was toggled on. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiOn() { + public void reportWifiOn() { try { mBatteryStats.noteWifiOn(); } catch (RemoteException e) { @@ -190,7 +190,7 @@ public class BatteryStatsManager { * Indicates that wifi was toggled off. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiOff() { + public void reportWifiOff() { try { mBatteryStats.noteWifiOff(); } catch (RemoteException e) { @@ -205,7 +205,7 @@ public class BatteryStatsManager { * @param accessPoint SSID of the network if wifi is connected to STA, else null. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiState(@WifiState int newWifiState, + public void reportWifiState(@WifiState int newWifiState, @Nullable String accessPoint) { try { mBatteryStats.noteWifiState(newWifiState, accessPoint); @@ -220,7 +220,7 @@ public class BatteryStatsManager { * @param ws Worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiScanStartedFromSource(@NonNull WorkSource ws) { + public void reportWifiScanStartedFromSource(@NonNull WorkSource ws) { try { mBatteryStats.noteWifiScanStartedFromSource(ws); } catch (RemoteException e) { @@ -234,7 +234,7 @@ public class BatteryStatsManager { * @param ws Worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiScanStoppedFromSource(@NonNull WorkSource ws) { + public void reportWifiScanStoppedFromSource(@NonNull WorkSource ws) { try { mBatteryStats.noteWifiScanStoppedFromSource(ws); } catch (RemoteException e) { @@ -249,7 +249,7 @@ public class BatteryStatsManager { * @param csph Channels scanned per hour. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiBatchedScanStartedFromSource(@NonNull WorkSource ws, + public void reportWifiBatchedScanStartedFromSource(@NonNull WorkSource ws, @IntRange(from = 0) int csph) { try { mBatteryStats.noteWifiBatchedScanStartedFromSource(ws, csph); @@ -264,7 +264,7 @@ public class BatteryStatsManager { * @param ws Worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiBatchedScanStoppedFromSource(@NonNull WorkSource ws) { + public void reportWifiBatchedScanStoppedFromSource(@NonNull WorkSource ws) { try { mBatteryStats.noteWifiBatchedScanStoppedFromSource(ws); } catch (RemoteException e) { @@ -308,7 +308,7 @@ public class BatteryStatsManager { * @param ws Worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteFullWifiLockAcquiredFromSource(@NonNull WorkSource ws) { + public void reportFullWifiLockAcquiredFromSource(@NonNull WorkSource ws) { try { mBatteryStats.noteFullWifiLockAcquiredFromSource(ws); } catch (RemoteException e) { @@ -322,7 +322,7 @@ public class BatteryStatsManager { * @param ws Worksource (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteFullWifiLockReleasedFromSource(@NonNull WorkSource ws) { + public void reportFullWifiLockReleasedFromSource(@NonNull WorkSource ws) { try { mBatteryStats.noteFullWifiLockReleasedFromSource(ws); } catch (RemoteException e) { @@ -338,7 +338,7 @@ public class BatteryStatsManager { * authentication failure. */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiSupplicantStateChanged(@WifiSupplState int newSupplState, + public void reportWifiSupplicantStateChanged(@WifiSupplState int newSupplState, boolean failedAuth) { try { mBatteryStats.noteWifiSupplicantStateChanged(newSupplState, failedAuth); @@ -353,7 +353,7 @@ public class BatteryStatsManager { * @param uid UID of the app that acquired the wifi lock (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiMulticastEnabled(int uid) { + public void reportWifiMulticastEnabled(int uid) { try { mBatteryStats.noteWifiMulticastEnabled(uid); } catch (RemoteException e) { @@ -367,7 +367,7 @@ public class BatteryStatsManager { * @param uid UID of the app that released the wifi lock (to be used for battery blaming). */ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) - public void noteWifiMulticastDisabled(int uid) { + public void reportWifiMulticastDisabled(int uid) { try { mBatteryStats.noteWifiMulticastDisabled(uid); } catch (RemoteException e) { diff --git a/core/java/android/os/StatsServiceManager.java b/core/java/android/os/StatsServiceManager.java new file mode 100644 index 000000000000..d032e98da00c --- /dev/null +++ b/core/java/android/os/StatsServiceManager.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2020 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. + */ +package android.os; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.SystemApi; + +/** + * Provides a way to register and obtain the system service binder objects managed by the stats + * service. + * + * <p> Only the statsd mainline module will be able to access an instance of this class. + * + * TODO(b/148225705) Change to @SystemApi(client=MODULE_LIBRARIES) when the build system is ready. + * @hide + */ +@SystemApi +public class StatsServiceManager { + /** + * @hide + */ + public StatsServiceManager() {} + + /** + * A class that exposes the methods to register and obtain each system service. + */ + public static final class ServiceRegisterer { + private final String mServiceName; + + /** + * @hide + */ + public ServiceRegisterer(String serviceName) { + mServiceName = serviceName; + } + + /** + * Get the system server binding object for StatsManagerService. + * + * <p> This blocks until the service instance is ready. + * or a timeout happens, in which case it returns null. + */ + @Nullable + public IBinder get() { + return ServiceManager.getService(mServiceName); + } + + /** + * Get the system server binding object for a service. + * + * <p>This blocks until the service instance is ready, + * or a timeout happens, in which case it throws {@link ServiceNotFoundException}. + */ + @Nullable + public IBinder getOrThrow() throws ServiceNotFoundException { + try { + return ServiceManager.getServiceOrThrow(mServiceName); + } catch (ServiceManager.ServiceNotFoundException e) { + throw new ServiceNotFoundException(mServiceName); + } + } + + /** + * Get the system server binding object for a service. If the specified service is + * not available, it returns null. + */ + @Nullable + private IBinder tryGet() { + return ServiceManager.checkService(mServiceName); + } + } + + /** + * See {@link ServiceRegisterer#getOrThrow()} + */ + public static class ServiceNotFoundException extends ServiceManager.ServiceNotFoundException { + /** + * Constructor + * + * @param name the name of the binder service that cannot be found. + */ + public ServiceNotFoundException(@NonNull String name) { + super(name); + } + } + + /** + * Returns {@link ServiceRegisterer} for the "statscompanion" service. + */ + @NonNull + public ServiceRegisterer getStatsCompanionServiceRegisterer() { + return new ServiceRegisterer("statscompanion"); + } + + /** + * Returns {@link ServiceRegisterer} for the "statsmanager" service. + */ + @NonNull + public ServiceRegisterer getStatsManagerServiceRegisterer() { + return new ServiceRegisterer("statsmanager"); + } + + /** + * Returns {@link ServiceRegisterer} for the "statsd" service. + */ + @NonNull + public ServiceRegisterer getStatsdServiceRegisterer() { + return new ServiceRegisterer("stats"); + } +} diff --git a/core/java/android/os/TelephonyServiceManager.java b/core/java/android/os/TelephonyServiceManager.java index 4f5f3d69b6f3..c93eba6523f0 100644 --- a/core/java/android/os/TelephonyServiceManager.java +++ b/core/java/android/os/TelephonyServiceManager.java @@ -119,14 +119,6 @@ public class TelephonyServiceManager { } /** - * Returns {@link ServiceRegisterer} for the telephony registry service. - */ - @NonNull - public ServiceRegisterer getTelephonyRegistryServiceRegisterer() { - return new ServiceRegisterer("telephony.registry"); - } - - /** * Returns {@link ServiceRegisterer} for the telephony IMS service. */ @NonNull @@ -151,14 +143,6 @@ public class TelephonyServiceManager { } /** - * Returns {@link ServiceRegisterer} for the network policy service. - */ - @NonNull - public ServiceRegisterer getNetworkPolicyServiceRegisterer() { - return new ServiceRegisterer(Context.NETWORK_POLICY_SERVICE); - } - - /** * Returns {@link ServiceRegisterer} for the phone sub service. */ @NonNull @@ -198,6 +182,9 @@ public class TelephonyServiceManager { return new ServiceRegisterer("econtroller"); } + /** + * Returns {@link ServiceRegisterer} for the eUICC card controller service. + */ @NonNull public ServiceRegisterer getEuiccCardControllerServiceRegisterer() { return new ServiceRegisterer("euicc_card_controller"); @@ -212,14 +199,6 @@ public class TelephonyServiceManager { } /** - * Returns {@link ServiceRegisterer} for the permission manager service. - */ - @NonNull - public ServiceRegisterer getPermissionManagerServiceRegisterer() { - return new ServiceRegisterer("permissionmgr"); - } - - /** * Returns {@link ServiceRegisterer} for the ICC phone book service. */ @NonNull diff --git a/core/java/android/os/connectivity/WifiBatteryStats.java b/core/java/android/os/connectivity/WifiBatteryStats.java index 895d837a359e..3c30f6343405 100644 --- a/core/java/android/os/connectivity/WifiBatteryStats.java +++ b/core/java/android/os/connectivity/WifiBatteryStats.java @@ -15,11 +15,13 @@ */ package android.os.connectivity; +import static android.os.BatteryStats.NUM_WIFI_SIGNAL_STRENGTH_BINS; +import static android.os.BatteryStatsManager.NUM_WIFI_STATES; +import static android.os.BatteryStatsManager.NUM_WIFI_SUPPL_STATES; + import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; -import android.os.BatteryStats; -import android.os.BatteryStatsManager; import android.os.Parcel; import android.os.Parcelable; @@ -33,31 +35,50 @@ import java.util.Objects; */ @SystemApi public final class WifiBatteryStats implements Parcelable { - private long mLoggingDurationMillis = 0; - private long mKernelActiveTimeMillis = 0; - private long mNumPacketsTx = 0; - private long mNumBytesTx = 0; - private long mNumPacketsRx = 0; - private long mNumBytesRx = 0; - private long mSleepTimeMillis = 0; - private long mScanTimeMillis = 0; - private long mIdleTimeMillis = 0; - private long mRxTimeMillis = 0; - private long mTxTimeMillis = 0; - private long mEnergyConsumedMaMillis = 0; - private long mNumAppScanRequest = 0; - private long[] mTimeInStateMillis = - new long[BatteryStatsManager.NUM_WIFI_STATES]; - private long[] mTimeInSupplicantStateMillis = - new long[BatteryStatsManager.NUM_WIFI_SUPPL_STATES]; - private long[] mTimeInRxSignalStrengthLevelMillis = - new long[BatteryStats.NUM_WIFI_SIGNAL_STRENGTH_BINS]; - private long mMonitoredRailChargeConsumedMaMillis = 0; + private final long mLoggingDurationMillis; + private final long mKernelActiveTimeMillis; + private final long mNumPacketsTx; + private final long mNumBytesTx; + private final long mNumPacketsRx; + private final long mNumBytesRx; + private final long mSleepTimeMillis; + private final long mScanTimeMillis; + private final long mIdleTimeMillis; + private final long mRxTimeMillis; + private final long mTxTimeMillis; + private final long mEnergyConsumedMaMillis; + private final long mAppScanRequestCount; + private final long[] mTimeInStateMillis; + private final long[] mTimeInSupplicantStateMillis; + private final long[] mTimeInRxSignalStrengthLevelMillis; + private final long mMonitoredRailChargeConsumedMaMillis; public static final @NonNull Parcelable.Creator<WifiBatteryStats> CREATOR = new Parcelable.Creator<WifiBatteryStats>() { public WifiBatteryStats createFromParcel(Parcel in) { - return new WifiBatteryStats(in); + long loggingDurationMillis = in.readLong(); + long kernelActiveTimeMillis = in.readLong(); + long numPacketsTx = in.readLong(); + long numBytesTx = in.readLong(); + long numPacketsRx = in.readLong(); + long numBytesRx = in.readLong(); + long sleepTimeMillis = in.readLong(); + long scanTimeMillis = in.readLong(); + long idleTimeMillis = in.readLong(); + long rxTimeMillis = in.readLong(); + long txTimeMillis = in.readLong(); + long energyConsumedMaMillis = in.readLong(); + long appScanRequestCount = in.readLong(); + long[] timeInStateMillis = in.createLongArray(); + long[] timeInRxSignalStrengthLevelMillis = in.createLongArray(); + long[] timeInSupplicantStateMillis = in.createLongArray(); + long monitoredRailChargeConsumedMaMillis = in.readLong(); + return new WifiBatteryStats(loggingDurationMillis, kernelActiveTimeMillis, + numPacketsTx, numBytesTx, numPacketsRx, numBytesRx, sleepTimeMillis, + scanTimeMillis, idleTimeMillis, rxTimeMillis, txTimeMillis, + energyConsumedMaMillis, appScanRequestCount, timeInStateMillis, + timeInRxSignalStrengthLevelMillis, timeInSupplicantStateMillis, + monitoredRailChargeConsumedMaMillis); } public WifiBatteryStats[] newArray(int size) { @@ -84,7 +105,7 @@ public final class WifiBatteryStats implements Parcelable { out.writeLong(mRxTimeMillis); out.writeLong(mTxTimeMillis); out.writeLong(mEnergyConsumedMaMillis); - out.writeLong(mNumAppScanRequest); + out.writeLong(mAppScanRequestCount); out.writeLongArray(mTimeInStateMillis); out.writeLongArray(mTimeInRxSignalStrengthLevelMillis); out.writeLongArray(mTimeInSupplicantStateMillis); @@ -108,7 +129,7 @@ public final class WifiBatteryStats implements Parcelable { && this.mRxTimeMillis == otherStats.mRxTimeMillis && this.mTxTimeMillis == otherStats.mTxTimeMillis && this.mEnergyConsumedMaMillis == otherStats.mEnergyConsumedMaMillis - && this.mNumAppScanRequest == otherStats.mNumAppScanRequest + && this.mAppScanRequestCount == otherStats.mAppScanRequestCount && Arrays.equals(this.mTimeInStateMillis, otherStats.mTimeInStateMillis) && Arrays.equals(this.mTimeInSupplicantStateMillis, otherStats.mTimeInSupplicantStateMillis) @@ -123,33 +144,42 @@ public final class WifiBatteryStats implements Parcelable { return Objects.hash(mLoggingDurationMillis, mKernelActiveTimeMillis, mNumPacketsTx, mNumBytesTx, mNumPacketsRx, mNumBytesRx, mSleepTimeMillis, mScanTimeMillis, mIdleTimeMillis, mRxTimeMillis, mTxTimeMillis, mEnergyConsumedMaMillis, - mNumAppScanRequest, Arrays.hashCode(mTimeInStateMillis), + mAppScanRequestCount, Arrays.hashCode(mTimeInStateMillis), Arrays.hashCode(mTimeInSupplicantStateMillis), Arrays.hashCode(mTimeInRxSignalStrengthLevelMillis), mMonitoredRailChargeConsumedMaMillis); } /** @hide **/ - public WifiBatteryStats() {} - - private void readFromParcel(Parcel in) { - mLoggingDurationMillis = in.readLong(); - mKernelActiveTimeMillis = in.readLong(); - mNumPacketsTx = in.readLong(); - mNumBytesTx = in.readLong(); - mNumPacketsRx = in.readLong(); - mNumBytesRx = in.readLong(); - mSleepTimeMillis = in.readLong(); - mScanTimeMillis = in.readLong(); - mIdleTimeMillis = in.readLong(); - mRxTimeMillis = in.readLong(); - mTxTimeMillis = in.readLong(); - mEnergyConsumedMaMillis = in.readLong(); - mNumAppScanRequest = in.readLong(); - in.readLongArray(mTimeInStateMillis); - in.readLongArray(mTimeInRxSignalStrengthLevelMillis); - in.readLongArray(mTimeInSupplicantStateMillis); - mMonitoredRailChargeConsumedMaMillis = in.readLong(); + public WifiBatteryStats(long loggingDurationMillis, long kernelActiveTimeMillis, + long numPacketsTx, long numBytesTx, long numPacketsRx, long numBytesRx, + long sleepTimeMillis, long scanTimeMillis, long idleTimeMillis, long rxTimeMillis, + long txTimeMillis, long energyConsumedMaMillis, long appScanRequestCount, + @NonNull long[] timeInStateMillis, @NonNull long [] timeInRxSignalStrengthLevelMillis, + @NonNull long[] timeInSupplicantStateMillis, long monitoredRailChargeConsumedMaMillis) { + mLoggingDurationMillis = loggingDurationMillis; + mKernelActiveTimeMillis = kernelActiveTimeMillis; + mNumPacketsTx = numPacketsTx; + mNumBytesTx = numBytesTx; + mNumPacketsRx = numPacketsRx; + mNumBytesRx = numBytesRx; + mSleepTimeMillis = sleepTimeMillis; + mScanTimeMillis = scanTimeMillis; + mIdleTimeMillis = idleTimeMillis; + mRxTimeMillis = rxTimeMillis; + mTxTimeMillis = txTimeMillis; + mEnergyConsumedMaMillis = energyConsumedMaMillis; + mAppScanRequestCount = appScanRequestCount; + mTimeInStateMillis = Arrays.copyOfRange( + timeInStateMillis, 0, + Math.min(timeInStateMillis.length, NUM_WIFI_STATES)); + mTimeInRxSignalStrengthLevelMillis = Arrays.copyOfRange( + timeInRxSignalStrengthLevelMillis, 0, + Math.min(timeInRxSignalStrengthLevelMillis.length, NUM_WIFI_SIGNAL_STRENGTH_BINS)); + mTimeInSupplicantStateMillis = Arrays.copyOfRange( + timeInSupplicantStateMillis, 0, + Math.min(timeInSupplicantStateMillis.length, NUM_WIFI_SUPPL_STATES)); + mMonitoredRailChargeConsumedMaMillis = monitoredRailChargeConsumedMaMillis; } /** @@ -182,7 +212,7 @@ public final class WifiBatteryStats implements Parcelable { } /** - * Returns the number of packets received over wifi within + * Returns the number of bytes transmitted over wifi within * {@link #getLoggingDurationMillis()}. * * @return Number of packets received. @@ -192,7 +222,7 @@ public final class WifiBatteryStats implements Parcelable { } /** - * Returns the number of bytes transmitted over wifi within + * Returns the number of packets received over wifi within * {@link #getLoggingDurationMillis()}. * * @return Number of bytes transmitted. @@ -262,7 +292,7 @@ public final class WifiBatteryStats implements Parcelable { } /** - * Returns an estimation of energy consumed by wifi chip within + * Returns an estimation of energy consumed in millis by wifi chip within * {@link #getLoggingDurationMillis()}. * * @return Energy consumed in millis. @@ -276,8 +306,8 @@ public final class WifiBatteryStats implements Parcelable { * * @return Number of app scans. */ - public long getNumAppScanRequest() { - return mNumAppScanRequest; + public long getAppScanRequestCount() { + return mAppScanRequestCount; } /** @@ -288,113 +318,4 @@ public final class WifiBatteryStats implements Parcelable { public long getMonitoredRailChargeConsumedMaMillis() { return mMonitoredRailChargeConsumedMaMillis; } - - /** @hide */ - public void setLoggingDurationMillis(long t) { - mLoggingDurationMillis = t; - return; - } - - /** @hide */ - public void setKernelActiveTimeMillis(long t) { - mKernelActiveTimeMillis = t; - return; - } - - /** @hide */ - public void setNumPacketsTx(long n) { - mNumPacketsTx = n; - return; - } - - /** @hide */ - public void setNumBytesTx(long b) { - mNumBytesTx = b; - return; - } - - /** @hide */ - public void setNumPacketsRx(long n) { - mNumPacketsRx = n; - return; - } - - /** @hide */ - public void setNumBytesRx(long b) { - mNumBytesRx = b; - return; - } - - /** @hide */ - public void setSleepTimeMillis(long t) { - mSleepTimeMillis = t; - return; - } - - /** @hide */ - public void setScanTimeMillis(long t) { - mScanTimeMillis = t; - return; - } - - /** @hide */ - public void setIdleTimeMillis(long t) { - mIdleTimeMillis = t; - return; - } - - /** @hide */ - public void setRxTimeMillis(long t) { - mRxTimeMillis = t; - return; - } - - /** @hide */ - public void setTxTimeMillis(long t) { - mTxTimeMillis = t; - return; - } - - /** @hide */ - public void setEnergyConsumedMaMillis(long e) { - mEnergyConsumedMaMillis = e; - return; - } - - /** @hide */ - public void setNumAppScanRequest(long n) { - mNumAppScanRequest = n; - return; - } - - /** @hide */ - public void setTimeInStateMillis(long[] t) { - mTimeInStateMillis = Arrays.copyOfRange(t, 0, - Math.min(t.length, BatteryStatsManager.NUM_WIFI_STATES)); - return; - } - - /** @hide */ - public void setTimeInRxSignalStrengthLevelMillis(long[] t) { - mTimeInRxSignalStrengthLevelMillis = Arrays.copyOfRange(t, 0, - Math.min(t.length, BatteryStats.NUM_WIFI_SIGNAL_STRENGTH_BINS)); - return; - } - - /** @hide */ - public void setTimeInSupplicantStateMillis(long[] t) { - mTimeInSupplicantStateMillis = Arrays.copyOfRange( - t, 0, Math.min(t.length, BatteryStatsManager.NUM_WIFI_SUPPL_STATES)); - return; - } - - /** @hide */ - public void setMonitoredRailChargeConsumedMaMillis(long monitoredRailEnergyConsumedMaMillis) { - mMonitoredRailChargeConsumedMaMillis = monitoredRailEnergyConsumedMaMillis; - return; - } - - private WifiBatteryStats(Parcel in) { - readFromParcel(in); - } } diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index ee9d8f55f40e..f25cdf1b8c98 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -5111,6 +5111,12 @@ public final class Telephony { public static final String WFC_IMS_ROAMING_ENABLED = "wfc_ims_roaming_enabled"; /** + * Determines if the user has enabled IMS RCS User Capability Exchange (UCE) for this + * subscription. + */ + public static final String IMS_RCS_UCE_ENABLED = "ims_rcs_uce_enabled"; + + /** * TelephonyProvider column name for whether a subscription is opportunistic, that is, * whether the network it connects to is limited in functionality or coverage. * For example, CBRS. diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index 57375919e6cd..6787c46c046e 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -36,6 +36,7 @@ import android.telephony.Annotation.RadioPowerState; import android.telephony.Annotation.SimActivationState; import android.telephony.Annotation.SrvccState; import android.telephony.data.ApnSetting; +import android.telephony.emergency.EmergencyNumber; import android.telephony.ims.ImsReasonInfo; import android.util.Log; @@ -198,6 +199,25 @@ public class TelephonyRegistryManager { } /** + * Listen for incoming subscriptions + * @param subId Subscription ID + * @param pkg Package name + * @param featureId Feature ID + * @param listener Listener providing callback + * @param events Events + * @param notifyNow Whether to notify instantly + */ + public void listenForSubscriber(int subId, @NonNull String pkg, @NonNull String featureId, + @NonNull PhoneStateListener listener, int events, boolean notifyNow) { + try { + sRegistry.listenForSubscriber( + subId, pkg, featureId, listener.callback, events, notifyNow); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Informs the system of an intentional upcoming carrier network change by a carrier app. * This call only used to allow the system to provide alternative UI while telephony is * performing an action that may result in intentional, temporary network lack of connectivity. @@ -258,6 +278,32 @@ public class TelephonyRegistryManager { } /** + * Notify {@link SubscriptionInfo} change. + * @hide + */ + @SystemApi + public void notifySubscriptionInfoChanged() { + try { + sRegistry.notifySubscriptionInfoChanged(); + } catch (RemoteException ex) { + // system server crash + } + } + + /** + * Notify opportunistic {@link SubscriptionInfo} change. + * @hide + */ + @SystemApi + public void notifyOpportunisticSubscriptionInfoChanged() { + try { + sRegistry.notifyOpportunisticSubscriptionInfoChanged(); + } catch (RemoteException ex) { + // system server crash + } + } + + /** * Notify {@link ServiceState} update on certain subscription. * * @param subId for which the service state changed. @@ -394,6 +440,36 @@ public class TelephonyRegistryManager { } /** + * Notify outgoing emergency call. + * @param phoneId Sender phone ID. + * @param subId Sender subscription ID. + * @param emergencyNumber Emergency number. + */ + public void notifyOutgoingEmergencyCall(int phoneId, int subId, + @NonNull EmergencyNumber emergencyNumber) { + try { + sRegistry.notifyOutgoingEmergencyCall(phoneId, subId, emergencyNumber); + } catch (RemoteException ex) { + // system process is dead + } + } + + /** + * Notify outgoing emergency SMS. + * @param phoneId Sender phone ID. + * @param subId Sender subscription ID. + * @param emergencyNumber Emergency number. + */ + public void notifyOutgoingEmergencySms(int phoneId, int subId, + @NonNull EmergencyNumber emergencyNumber) { + try { + sRegistry.notifyOutgoingEmergencySms(phoneId, subId, emergencyNumber); + } catch (RemoteException ex) { + // system process is dead + } + } + + /** * Notify radio power state changed on certain subscription. * * @param subId for which radio power state changed. diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index cdf8c686ef00..7fd41508dfc3 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -5107,7 +5107,7 @@ public class Editor { int lineLeft = (int) layout.getLineLeft(line); lineLeft += mTextView.getTotalPaddingLeft() - mTextView.getScrollX(); int lineRight = (int) layout.getLineRight(line); - lineRight -= mTextView.getTotalPaddingRight() + mTextView.getScrollX(); + lineRight += mTextView.getTotalPaddingLeft() - mTextView.getScrollX(); mMagnifierAnimator.mMagnifier.setSourceHorizontalBounds(lineLeft, lineRight); } mMagnifierAnimator.show(showPosInView.x, showPosInView.y); diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index b3548b8c82f8..580c1f00d788 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -12644,7 +12644,6 @@ public class BatteryStatsImpl extends BatteryStats { /*@hide */ public WifiBatteryStats getWifiBatteryStats() { - WifiBatteryStats s = new WifiBatteryStats(); final int which = STATS_SINCE_CHARGED; final long rawRealTime = SystemClock.elapsedRealtime() * 1000; final ControllerActivityCounter counter = getWifiControllerActivity(); @@ -12675,24 +12674,16 @@ public class BatteryStatsImpl extends BatteryStats { for (int i=0; i<NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) { timeSignalStrengthTimeMs[i] = getWifiSignalStrengthTime(i, rawRealTime, which) / 1000; } - s.setLoggingDurationMillis(computeBatteryRealtime(rawRealTime, which) / 1000); - s.setKernelActiveTimeMillis(getWifiActiveTime(rawRealTime, which) / 1000); - s.setNumPacketsTx(getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which)); - s.setNumBytesTx(getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which)); - s.setNumPacketsRx(getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which)); - s.setNumBytesRx(getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which)); - s.setSleepTimeMillis(sleepTimeMs); - s.setIdleTimeMillis(idleTimeMs); - s.setRxTimeMillis(rxTimeMs); - s.setTxTimeMillis(txTimeMs); - s.setScanTimeMillis(scanTimeMs); - s.setEnergyConsumedMaMillis(energyConsumedMaMs); - s.setNumAppScanRequest(numAppScanRequest); - s.setTimeInStateMillis(timeInStateMs); - s.setTimeInSupplicantStateMillis(timeInSupplStateMs); - s.setTimeInRxSignalStrengthLevelMillis(timeSignalStrengthTimeMs); - s.setMonitoredRailChargeConsumedMaMillis(monitoredRailChargeConsumedMaMs); - return s; + return new WifiBatteryStats( + computeBatteryRealtime(rawRealTime, which) / 1000, + getWifiActiveTime(rawRealTime, which) / 1000, + getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which), + getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which), + getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which), + getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which), + sleepTimeMs, scanTimeMs, idleTimeMs, rxTimeMs, txTimeMs, energyConsumedMaMs, + numAppScanRequest, timeInStateMs, timeSignalStrengthTimeMs, timeInSupplStateMs, + monitoredRailChargeConsumedMaMs); } /*@hide */ diff --git a/core/jni/android_media_AudioEffectDescriptor.cpp b/core/jni/android_media_AudioEffectDescriptor.cpp index 5175a05c4c3b..37d8114052b8 100644 --- a/core/jni/android_media_AudioEffectDescriptor.cpp +++ b/core/jni/android_media_AudioEffectDescriptor.cpp @@ -39,17 +39,21 @@ jint convertAudioEffectDescriptorFromNative(JNIEnv* env, jobject* jDescriptor, jstring jImplementor; char str[EFFECT_STRING_LEN_MAX]; - if ((nDescriptor->flags & EFFECT_FLAG_TYPE_MASK) - == EFFECT_FLAG_TYPE_AUXILIARY) { - jConnect = env->NewStringUTF("Auxiliary"); - } else if ((nDescriptor->flags & EFFECT_FLAG_TYPE_MASK) - == EFFECT_FLAG_TYPE_INSERT) { - jConnect = env->NewStringUTF("Insert"); - } else if ((nDescriptor->flags & EFFECT_FLAG_TYPE_MASK) - == EFFECT_FLAG_TYPE_PRE_PROC) { - jConnect = env->NewStringUTF("Pre Processing"); - } else { - return (jint) AUDIO_JAVA_BAD_VALUE; + switch (nDescriptor->flags & EFFECT_FLAG_TYPE_MASK) { + case EFFECT_FLAG_TYPE_AUXILIARY: + jConnect = env->NewStringUTF("Auxiliary"); + break; + case EFFECT_FLAG_TYPE_INSERT: + jConnect = env->NewStringUTF("Insert"); + break; + case EFFECT_FLAG_TYPE_PRE_PROC: + jConnect = env->NewStringUTF("Pre Processing"); + break; + case EFFECT_FLAG_TYPE_POST_PROC: + jConnect = env->NewStringUTF("Post Processing"); + break; + default: + return (jint)AUDIO_JAVA_BAD_VALUE; } AudioEffect::guidToString(&nDescriptor->type, str, EFFECT_STRING_LEN_MAX); diff --git a/core/res/res/layout/autofill_inline_suggestion.xml b/core/res/res/layout/autofill_inline_suggestion.xml index f7ac1642f6b7..27faea4b00de 100644 --- a/core/res/res/layout/autofill_inline_suggestion.xml +++ b/core/res/res/layout/autofill_inline_suggestion.xml @@ -16,19 +16,20 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" + style="?android:attr/autofillInlineSuggestionChip" android:layout_width="wrap_content" - android:layout_height="56dp" - android:background="@color/white" - android:orientation="horizontal" - android:paddingStart="12dp" - android:paddingEnd="12dp"> + android:layout_height="wrap_content" + android:gravity="center" + android:paddingTop="4dp" + android:paddingBottom="4dp" + android:orientation="horizontal"> <ImageView android:id="@+id/autofill_inline_suggestion_start_icon" - android:layout_width="24dp" - android:layout_height="24dp" + android:layout_width="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" + android:scaleType="fitCenter" android:contentDescription="autofill_inline_suggestion_start_icon" /> <LinearLayout @@ -36,32 +37,33 @@ android:layout_height="match_parent" android:layout_gravity="center" android:layout_weight="1" - android:layout_marginStart="12dp" - android:layout_marginEnd="12dp" + android:paddingStart="4dp" + android:paddingEnd="4dp" android:orientation="vertical" - android:gravity="center_vertical"> + android:gravity="center"> <TextView + style="?android:attr/autofillInlineSuggestionTitle" android:id="@+id/autofill_inline_suggestion_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" - android:maxLines="1" - tools:text="username1"/> + android:maxLines="1"/> <TextView + style="?android:attr/autofillInlineSuggestionSubtitle" android:id="@+id/autofill_inline_suggestion_subtitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" - android:maxLines="1" - tools:text="inline fill service"/> + android:maxLines="1"/> </LinearLayout> <ImageView android:id="@+id/autofill_inline_suggestion_end_icon" - android:layout_width="24dp" - android:layout_height="24dp" + android:layout_width="wrap_content" + android:layout_height="match_parent" android:layout_gravity="center" + android:scaleType="fitCenter" android:contentDescription="autofill_inline_suggestion_end_icon" /> </LinearLayout> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 940e9f1ef88b..c9c47b92f782 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -9197,4 +9197,12 @@ </declare-styleable> <attr name="autoSizePresetSizes" /> + + <declare-styleable name="AutofillInlineSuggestion"> + <!-- @hide @SystemApi --> + <attr name="isAutofillInlineSuggestionTheme" format="boolean" /> + <attr name="autofillInlineSuggestionChip" format="reference" /> + <attr name="autofillInlineSuggestionTitle" format="reference" /> + <attr name="autofillInlineSuggestionSubtitle" format="reference" /> + </declare-styleable> </resources> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 42127e77317f..dadb92415839 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2685,6 +2685,11 @@ <!-- The amount to scale fullscreen snapshots for Overview and snapshot starting windows. --> <item name="config_fullTaskSnapshotScale" format="float" type="dimen">1.0</item> + <!-- The amount to scale reduced scale snapshots for Overview and snapshot starting windows. + Reduced scale snapshots are loaded before full screen snapshots to improve load times and + minimize the chance the user will see an empty task card. --> + <item name="config_reducedTaskSnapshotScale" format="float" type="dimen">0.5</item> + <!-- Feature flag to store TaskSnapshot in 16 bit pixel format to save memory. --> <bool name="config_use16BitTaskSnapshotPixelFormat">false</bool> @@ -4173,7 +4178,7 @@ where: IDs are unique per device, Modality as defined in BiometricAuthenticator.java, and Strength as defined in Authenticators.java --> <string-array name="config_biometric_sensors" translatable="false" > - <item>0:2:15</item> <!-- ID0:Fingerprint:Strong --> + <!-- <item>0:2:15</item> ID0:Fingerprint:Strong --> </string-array> <!-- Messages that should not be shown to the user during face auth enrollment. This should be diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 36dbcbd53977..d43c9fdb794a 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3012,12 +3012,18 @@ <public name="sdkVersion" /> <!-- @hide @SystemApi --> <public name="minExtensionVersion" /> + <public name="autofillInlineSuggestionChip" /> + <public name="autofillInlineSuggestionTitle" /> + <public name="autofillInlineSuggestionSubtitle" /> + <!-- @hide @SystemApi --> + <public name="isAutofillInlineSuggestionTheme" /> </public-group> <public-group type="drawable" first-id="0x010800b5"> </public-group> <public-group type="style" first-id="0x010302e5"> + <public name="Theme.AutofillInlineSuggestion" /> </public-group> <public-group type="id" first-id="0x0102004a"> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index bcce1f05f0dd..751eca036ba6 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -1482,6 +1482,22 @@ please see styles_device_defaults.xml. <item name="android:windowExitAnimation">@anim/slide_out_down</item> </style> + <!-- The style for the Autofill inline suggestion chip. --> + <!-- @hide --> + <style name="AutofillInlineSuggestionChip"> + <item name="background">@drawable/autofill_dataset_picker_background</item> + </style> + + <!-- @hide --> + <style name="AutofillInlineSuggestionTitle"> + <item name="android:textAppearance">@style/TextAppearance</item> + </style> + + <!-- @hide --> + <style name="AutofillInlineSuggestionSubtitle"> + <item name="android:textAppearance">@style/TextAppearance.Small</item> + </style> + <!-- The style for the container of media actions in a notification. --> <!-- @hide --> <style name="NotificationMediaActionContainer"> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ea8ca9aa1c49..d437318a3296 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -360,6 +360,7 @@ <java-symbol type="bool" name="config_enableNewAutoSelectNetworkUI"/> <java-symbol type="bool" name="config_disableUsbPermissionDialogs"/> <java-symbol type="dimen" name="config_fullTaskSnapshotScale" /> + <java-symbol type="dimen" name="config_reducedTaskSnapshotScale" /> <java-symbol type="bool" name="config_use16BitTaskSnapshotPixelFormat" /> <java-symbol type="bool" name="config_hasRecents" /> <java-symbol type="string" name="config_recentsComponentName" /> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index ad38f3d57c23..5e6dd8294776 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -893,4 +893,11 @@ please see themes_device_defaults.xml. <item name="windowActivityTransitions">false</item> </style> + <!-- Theme for the Autofill inline suggestion on IME --> + <style name="Theme.AutofillInlineSuggestion" parent="Theme.DeviceDefault"> + <item name="isAutofillInlineSuggestionTheme">true</item> + <item name="autofillInlineSuggestionChip">@style/AutofillInlineSuggestionChip</item> + <item name="autofillInlineSuggestionTitle">@style/AutofillInlineSuggestionTitle</item> + <item name="autofillInlineSuggestionSubtitle">@style/AutofillInlineSuggestionSubtitle</item> + </style> </resources> diff --git a/media/java/android/media/audiofx/AudioEffect.java b/media/java/android/media/audiofx/AudioEffect.java index cad5aa6aaa3c..c25a5333017b 100644 --- a/media/java/android/media/audiofx/AudioEffect.java +++ b/media/java/android/media/audiofx/AudioEffect.java @@ -356,10 +356,14 @@ public class AudioEffect { public static final String EFFECT_AUXILIARY = "Auxiliary"; /** * Effect connection mode is pre processing. - * The audio pre processing effects are attached to an audio input (AudioRecord). - * @hide + * The audio pre processing effects are attached to an audio input stream or device */ public static final String EFFECT_PRE_PROCESSING = "Pre Processing"; + /** + * Effect connection mode is post processing. + * The audio post processing effects are attached to an audio output stream or device + */ + public static final String EFFECT_POST_PROCESSING = "Post Processing"; // -------------------------------------------------------------------------- // Member variables diff --git a/media/java/android/media/tv/TvContentRating.java b/media/java/android/media/tv/TvContentRating.java index 9e671b1177cd..5babb1698c85 100644 --- a/media/java/android/media/tv/TvContentRating.java +++ b/media/java/android/media/tv/TvContentRating.java @@ -17,7 +17,6 @@ package android.media.tv; import android.annotation.NonNull; -import android.annotation.SystemApi; import android.text.TextUtils; import com.android.internal.util.Preconditions; @@ -725,16 +724,16 @@ import java.util.Objects; * <td>NZ_TV_G</td> * <td>Programmes which exclude material likely to be unsuitable for children. Programmes * may not necessarily be designed for child viewers but should not contain material likely - * to alarm or distress them.</td> + * to alarm or distress them</td> * </tr> * <tr> * <td>NZ_TV_PGR</td> * <td>Programmes containing material more suited for mature audiences but not necessarily - * unsuitable for child viewers when subject to the guidance of a parent or an adult.</td> + * unsuitable for child viewers when subject to the guidance of a parent or an adult</td> * </tr> * <tr> * <td>NZ_TV_AO</td> - * <td>Programmes containing adult themes and directed primarily at mature audiences.</td> + * <td>Programmes containing adult themes and directed primarily at mature audiences</td> * </tr> * <tr> * <td valign="top" rowspan="6">SG_TV</td> diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java index e7055847f034..6e23777babd9 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleViewInfoTask.java @@ -157,6 +157,7 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask PackageManager pm = c.getPackageManager(); ApplicationInfo appInfo; Drawable badgedIcon; + Drawable appIcon; try { appInfo = pm.getApplicationInfo( packageName, @@ -167,7 +168,7 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask if (appInfo != null) { info.appName = String.valueOf(pm.getApplicationLabel(appInfo)); } - Drawable appIcon = pm.getApplicationIcon(packageName); + appIcon = pm.getApplicationIcon(packageName); badgedIcon = pm.getUserBadgedIcon(appIcon, sbn.getUser()); } catch (PackageManager.NameNotFoundException exception) { // If we can't find package... don't think we should show the bubble. @@ -178,6 +179,11 @@ public class BubbleViewInfoTask extends AsyncTask<Void, Void, BubbleViewInfoTask // Badged bubble image Drawable bubbleDrawable = iconFactory.getBubbleDrawable(c, info.shortcutInfo, b.getEntry().getBubbleMetadata()); + if (bubbleDrawable == null) { + // Default to app icon + bubbleDrawable = appIcon; + } + BitmapInfo badgeBitmapInfo = iconFactory.getBadgeBitmap(badgedIcon); info.badgedBubbleImage = iconFactory.getBubbleBitmap(bubbleDrawable, badgeBitmapInfo).icon; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java index ac05c53c38dd..6839921e90a7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java @@ -56,7 +56,7 @@ public class FeatureFlags { } public boolean isNewNotifPipelineEnabled() { - return getDeviceConfigFlag("notification.newpipeline.enabled", false); + return getDeviceConfigFlag("notification.newpipeline.enabled", true); } public boolean isNewNotifPipelineRenderingEnabled() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java index 718522c9908a..6baf36c81d30 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java @@ -54,7 +54,8 @@ public class WifiSignalController extends mWifiTracker.setListening(true); mHasMobileData = hasMobileData; if (wifiManager != null) { - wifiManager.registerTrafficStateCallback(new WifiTrafficStateCallback()); + wifiManager.registerTrafficStateCallback(context.getMainExecutor(), + new WifiTrafficStateCallback()); } // WiFi only has one state. mCurrentState.iconGroup = mLastState.iconGroup = new IconGroup( diff --git a/packages/Tethering/common/TetheringLib/Android.bp b/packages/Tethering/common/TetheringLib/Android.bp index a8d1239a3c30..b0ef15399435 100644 --- a/packages/Tethering/common/TetheringLib/Android.bp +++ b/packages/Tethering/common/TetheringLib/Android.bp @@ -70,6 +70,7 @@ filegroup { "src/android/net/ITetheringConnector.aidl", "src/android/net/TetheringCallbackStartedParcel.aidl", "src/android/net/TetheringConfigurationParcel.aidl", + "src/android/net/TetheringRequestParcel.aidl", "src/android/net/TetherStatesParcel.aidl", ], path: "src" diff --git a/packages/Tethering/common/TetheringLib/src/android/net/ITetheringConnector.aidl b/packages/Tethering/common/TetheringLib/src/android/net/ITetheringConnector.aidl index d30c39986984..5febe73288bf 100644 --- a/packages/Tethering/common/TetheringLib/src/android/net/ITetheringConnector.aidl +++ b/packages/Tethering/common/TetheringLib/src/android/net/ITetheringConnector.aidl @@ -17,6 +17,7 @@ package android.net; import android.net.IIntResultListener; import android.net.ITetheringEventCallback; +import android.net.TetheringRequestParcel; import android.os.ResultReceiver; /** @hide */ @@ -27,8 +28,8 @@ oneway interface ITetheringConnector { void setUsbTethering(boolean enable, String callerPkg, IIntResultListener receiver); - void startTethering(int type, in ResultReceiver receiver, boolean showProvisioningUi, - String callerPkg); + void startTethering(in TetheringRequestParcel request, String callerPkg, + IIntResultListener receiver); void stopTethering(int type, String callerPkg, IIntResultListener receiver); diff --git a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java index e1b9c16b8185..58bc4e7633ce 100644 --- a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java +++ b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java @@ -15,6 +15,7 @@ */ package android.net; +import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; @@ -326,27 +327,171 @@ public class TetheringManager { } /** + * Use with {@link #startTethering} to specify additional parameters when starting tethering. + */ + public static class TetheringRequest { + /** A configuration set for TetheringRequest. */ + private final TetheringRequestParcel mRequestParcel; + + private TetheringRequest(final TetheringRequestParcel request) { + mRequestParcel = request; + } + + /** Builder used to create TetheringRequest. */ + public static class Builder { + private final TetheringRequestParcel mBuilderParcel; + + /** Default constructor of Builder. */ + public Builder(final int type) { + mBuilderParcel = new TetheringRequestParcel(); + mBuilderParcel.tetheringType = type; + mBuilderParcel.localIPv4Address = null; + mBuilderParcel.exemptFromEntitlementCheck = false; + mBuilderParcel.showProvisioningUi = true; + } + + /** + * Configure tethering with static IPv4 assignment (with DHCP disabled). + * + * @param localIPv4Address The preferred local IPv4 address to use. + */ + @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) + @NonNull + public Builder useStaticIpv4Addresses(@NonNull final LinkAddress localIPv4Address) { + mBuilderParcel.localIPv4Address = localIPv4Address; + return this; + } + + /** Start tethering without entitlement checks. */ + @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) + @NonNull + public Builder setExemptFromEntitlementCheck(boolean exempt) { + mBuilderParcel.exemptFromEntitlementCheck = exempt; + return this; + } + + /** Start tethering without showing the provisioning UI. */ + @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) + @NonNull + public Builder setSilentProvisioning(boolean silent) { + mBuilderParcel.showProvisioningUi = silent; + return this; + } + + /** Build {@link TetheringRequest] with the currently set configuration. */ + @NonNull + public TetheringRequest build() { + return new TetheringRequest(mBuilderParcel); + } + } + + /** + * Get a TetheringRequestParcel from the configuration + * @hide + */ + public TetheringRequestParcel getParcel() { + return mRequestParcel; + } + + /** String of TetheringRequest detail. */ + public String toString() { + return "TetheringRequest [ type= " + mRequestParcel.tetheringType + + ", localIPv4Address= " + mRequestParcel.localIPv4Address + + ", exemptFromEntitlementCheck= " + + mRequestParcel.exemptFromEntitlementCheck + ", showProvisioningUi= " + + mRequestParcel.showProvisioningUi + " ]"; + } + } + + /** + * Callback for use with {@link #startTethering} to find out whether tethering succeeded. + */ + public abstract static class StartTetheringCallback { + /** + * Called when tethering has been successfully started. + */ + public void onTetheringStarted() {} + + /** + * Called when starting tethering failed. + * + * @param resultCode One of the {@code TETHER_ERROR_*} constants. + */ + public void onTetheringFailed(final int resultCode) {} + } + + /** * Starts tethering and runs tether provisioning for the given type if needed. If provisioning * fails, stopTethering will be called automatically. - * @hide - */ - // TODO: improve the usage of ResultReceiver, b/145096122 - public void startTethering(final int type, @NonNull final ResultReceiver receiver, - final boolean showProvisioningUi) { + * + * <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will + * fail if a tethering entitlement check is required. + * + * @param request a {@link TetheringRequest} which can specify the preferred configuration. + * @param executor {@link Executor} to specify the thread upon which the callback of + * TetheringRequest will be invoked. + * @param callback A callback that will be called to indicate the success status of the + * tethering start request. + */ + @RequiresPermission(anyOf = { + android.Manifest.permission.TETHER_PRIVILEGED, + android.Manifest.permission.WRITE_SETTINGS + }) + public void startTethering(@NonNull final TetheringRequest request, + @NonNull final Executor executor, @NonNull final StartTetheringCallback callback) { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "startTethering caller:" + callerPkg); + final IIntResultListener listener = new IIntResultListener.Stub() { + @Override + public void onResult(final int resultCode) { + executor.execute(() -> { + if (resultCode == TETHER_ERROR_NO_ERROR) { + callback.onTetheringStarted(); + } else { + callback.onTetheringFailed(resultCode); + } + }); + } + }; try { - mConnector.startTethering(type, receiver, showProvisioningUi, callerPkg); + mConnector.startTethering(request.getParcel(), callerPkg, listener); } catch (RemoteException e) { throw new IllegalStateException(e); } } /** + * Starts tethering and runs tether provisioning for the given type if needed. If provisioning + * fails, stopTethering will be called automatically. + * + * <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will + * fail if a tethering entitlement check is required. + * + * @param type The tethering type, on of the {@code TetheringManager#TETHERING_*} constants. + * @param executor {@link Executor} to specify the thread upon which the callback of + * TetheringRequest will be invoked. + */ + @RequiresPermission(anyOf = { + android.Manifest.permission.TETHER_PRIVILEGED, + android.Manifest.permission.WRITE_SETTINGS + }) + public void startTethering(int type, @NonNull final Executor executor, + @NonNull final StartTetheringCallback callback) { + startTethering(new TetheringRequest.Builder(type).build(), executor, callback); + } + + /** * Stops tethering for the given type. Also cancels any provisioning rechecks for that type if * applicable. + * + * <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will + * fail if a tethering entitlement check is required. */ + @RequiresPermission(anyOf = { + android.Manifest.permission.TETHER_PRIVILEGED, + android.Manifest.permission.WRITE_SETTINGS + }) public void stopTethering(final int type) { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "stopTethering caller:" + callerPkg); @@ -386,6 +531,9 @@ public class TetheringManager { * {@link #TETHER_ERROR_ENTITLEMENT_UNKNOWN} will be returned. If {@code showEntitlementUi} is * true, entitlement will be run. * + * <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will + * fail if a tethering entitlement check is required. + * * @param type the downstream type of tethering. Must be one of {@code #TETHERING_*} constants. * @param showEntitlementUi a boolean indicating whether to run UI-based entitlement check. * @param executor the executor on which callback will be invoked. @@ -393,7 +541,10 @@ public class TetheringManager { * notify the caller of the result of entitlement check. The listener may be called zero * or one time. */ - @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) + @RequiresPermission(anyOf = { + android.Manifest.permission.TETHER_PRIVILEGED, + android.Manifest.permission.WRITE_SETTINGS + }) public void requestLatestTetheringEntitlementResult(int type, boolean showEntitlementUi, @NonNull Executor executor, @NonNull final OnTetheringEntitlementResultListener listener) { @@ -562,6 +713,7 @@ public class TetheringManager { * @param executor the executor on which callback will be invoked. * @param callback the callback to be called when tethering has change events. */ + @RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE) public void registerTetheringEventCallback(@NonNull Executor executor, @NonNull TetheringEventCallback callback) { final String callerPkg = mContext.getOpPackageName(); @@ -669,6 +821,10 @@ public class TetheringManager { * * @param callback previously registered callback. */ + @RequiresPermission(anyOf = { + Manifest.permission.TETHER_PRIVILEGED, + Manifest.permission.ACCESS_NETWORK_STATE + }) public void unregisterTetheringEventCallback(@NonNull final TetheringEventCallback callback) { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "unregisterTetheringEventCallback caller:" + callerPkg); @@ -833,7 +989,14 @@ public class TetheringManager { /** * Stop all active tethering. + * + * <p>Without {@link android.Manifest.permission.TETHER_PRIVILEGED} permission, the call will + * fail if a tethering entitlement check is required. */ + @RequiresPermission(anyOf = { + android.Manifest.permission.TETHER_PRIVILEGED, + android.Manifest.permission.WRITE_SETTINGS + }) public void stopAllTethering() { final String callerPkg = mContext.getOpPackageName(); Log.i(TAG, "stopAllTethering caller:" + callerPkg); diff --git a/packages/Tethering/common/TetheringLib/src/android/net/TetheringRequestParcel.aidl b/packages/Tethering/common/TetheringLib/src/android/net/TetheringRequestParcel.aidl new file mode 100644 index 000000000000..bf19d85f6a83 --- /dev/null +++ b/packages/Tethering/common/TetheringLib/src/android/net/TetheringRequestParcel.aidl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 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. + */ + +package android.net; + +import android.net.LinkAddress; + +/** + * Configuration details for requesting tethering. + * @hide + */ +parcelable TetheringRequestParcel { + int tetheringType; + LinkAddress localIPv4Address; + boolean exemptFromEntitlementCheck; + boolean showProvisioningUi; +} diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java index 5370145f1992..c47f2d6d4db2 100644 --- a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java +++ b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java @@ -66,6 +66,7 @@ import android.content.IntentFilter; import android.content.res.Resources; import android.hardware.usb.UsbManager; import android.net.ConnectivityManager; +import android.net.IIntResultListener; import android.net.INetd; import android.net.ITetheringEventCallback; import android.net.IpPrefix; @@ -76,6 +77,7 @@ import android.net.NetworkInfo; import android.net.TetherStatesParcel; import android.net.TetheringCallbackStartedParcel; import android.net.TetheringConfigurationParcel; +import android.net.TetheringRequestParcel; import android.net.ip.IpServer; import android.net.shared.NetdUtils; import android.net.util.BaseNetdUnsolicitedEventListener; @@ -424,9 +426,10 @@ public class Tethering { } } - void startTethering(int type, ResultReceiver receiver, boolean showProvisioningUi) { - mEntitlementMgr.startProvisioningIfNeeded(type, showProvisioningUi); - enableTetheringInternal(type, true /* enabled */, receiver); + void startTethering(final TetheringRequestParcel request, final IIntResultListener listener) { + mEntitlementMgr.startProvisioningIfNeeded(request.tetheringType, + request.showProvisioningUi); + enableTetheringInternal(request.tetheringType, true /* enabled */, listener); } void stopTethering(int type) { @@ -438,29 +441,32 @@ public class Tethering { * Enables or disables tethering for the given type. If provisioning is required, it will * schedule provisioning rechecks for the specified interface. */ - private void enableTetheringInternal(int type, boolean enable, ResultReceiver receiver) { + private void enableTetheringInternal(int type, boolean enable, + final IIntResultListener listener) { int result; switch (type) { case TETHERING_WIFI: result = setWifiTethering(enable); - sendTetherResult(receiver, result); + sendTetherResult(listener, result); break; case TETHERING_USB: result = setUsbTethering(enable); - sendTetherResult(receiver, result); + sendTetherResult(listener, result); break; case TETHERING_BLUETOOTH: - setBluetoothTethering(enable, receiver); + setBluetoothTethering(enable, listener); break; default: Log.w(TAG, "Invalid tether type."); - sendTetherResult(receiver, TETHER_ERROR_UNKNOWN_IFACE); + sendTetherResult(listener, TETHER_ERROR_UNKNOWN_IFACE); } } - private void sendTetherResult(ResultReceiver receiver, int result) { - if (receiver != null) { - receiver.send(result, null); + private void sendTetherResult(final IIntResultListener listener, int result) { + if (listener != null) { + try { + listener.onResult(result); + } catch (RemoteException e) { } } } @@ -486,12 +492,12 @@ public class Tethering { return TETHER_ERROR_MASTER_ERROR; } - private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) { + private void setBluetoothTethering(final boolean enable, final IIntResultListener listener) { final BluetoothAdapter adapter = mDeps.getBluetoothAdapter(); if (adapter == null || !adapter.isEnabled()) { Log.w(TAG, "Tried to enable bluetooth tethering with null or disabled adapter. null: " + (adapter == null)); - sendTetherResult(receiver, TETHER_ERROR_SERVICE_UNAVAIL); + sendTetherResult(listener, TETHER_ERROR_SERVICE_UNAVAIL); return; } @@ -520,7 +526,7 @@ public class Tethering { final int result = (((BluetoothPan) proxy).isTetheringOn() == enable) ? TETHER_ERROR_NO_ERROR : TETHER_ERROR_MASTER_ERROR; - sendTetherResult(receiver, result); + sendTetherResult(listener, result); adapter.closeProfileProxy(BluetoothProfile.PAN, proxy); } }, BluetoothProfile.PAN); diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java index cb7d3920e693..7dc5c5f2db8a 100644 --- a/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java +++ b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringService.java @@ -33,6 +33,7 @@ import android.net.ITetheringConnector; import android.net.ITetheringEventCallback; import android.net.NetworkCapabilities; import android.net.NetworkRequest; +import android.net.TetheringRequestParcel; import android.net.dhcp.DhcpServerCallbacks; import android.net.dhcp.DhcpServingParamsParcel; import android.net.ip.IpServer; @@ -143,11 +144,11 @@ public class TetheringService extends Service { } @Override - public void startTethering(int type, ResultReceiver receiver, boolean showProvisioningUi, - String callerPkg) { - if (checkAndNotifyCommonError(callerPkg, receiver)) return; + public void startTethering(TetheringRequestParcel request, String callerPkg, + IIntResultListener listener) { + if (checkAndNotifyCommonError(callerPkg, listener)) return; - mTethering.startTethering(type, receiver, showProvisioningUi); + mTethering.startTethering(request, listener); } @Override diff --git a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java index 9f0d8769b1f9..6fc0c659f397 100644 --- a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java +++ b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java @@ -88,6 +88,7 @@ import android.net.RouteInfo; import android.net.TetherStatesParcel; import android.net.TetheringCallbackStartedParcel; import android.net.TetheringConfigurationParcel; +import android.net.TetheringRequestParcel; import android.net.dhcp.DhcpServerCallbacks; import android.net.dhcp.DhcpServingParamsParcel; import android.net.dhcp.IDhcpServer; @@ -468,6 +469,16 @@ public class TetheringTest { return new Tethering(mTetheringDependencies); } + private TetheringRequestParcel createTetheringRquestParcel(final int type) { + final TetheringRequestParcel request = new TetheringRequestParcel(); + request.tetheringType = type; + request.localIPv4Address = null; + request.exemptFromEntitlementCheck = false; + request.showProvisioningUi = false; + + return request; + } + @After public void tearDown() { mServiceContext.unregisterReceiver(mBroadcastReceiver); @@ -573,7 +584,7 @@ public class TetheringTest { .thenReturn(upstreamState); // Emulate pressing the USB tethering button in Settings UI. - mTethering.startTethering(TETHERING_USB, null, false); + mTethering.startTethering(createTetheringRquestParcel(TETHERING_USB), null); mLooper.dispatchAll(); verify(mUsbManager, times(1)).setCurrentFunctions(UsbManager.FUNCTION_RNDIS); @@ -819,7 +830,7 @@ public class TetheringTest { when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true); // Emulate pressing the WiFi tethering button. - mTethering.startTethering(TETHERING_WIFI, null, false); + mTethering.startTethering(createTetheringRquestParcel(TETHERING_WIFI), null); mLooper.dispatchAll(); verify(mWifiManager, times(1)).startTetheredHotspot(null); verifyNoMoreInteractions(mWifiManager); @@ -846,7 +857,7 @@ public class TetheringTest { when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true); // Emulate pressing the WiFi tethering button. - mTethering.startTethering(TETHERING_WIFI, null, false); + mTethering.startTethering(createTetheringRquestParcel(TETHERING_WIFI), null); mLooper.dispatchAll(); verify(mWifiManager, times(1)).startTetheredHotspot(null); verifyNoMoreInteractions(mWifiManager); @@ -923,7 +934,7 @@ public class TetheringTest { doThrow(new RemoteException()).when(mNetd).ipfwdEnableForwarding(TETHERING_NAME); // Emulate pressing the WiFi tethering button. - mTethering.startTethering(TETHERING_WIFI, null, false); + mTethering.startTethering(createTetheringRquestParcel(TETHERING_WIFI), null); mLooper.dispatchAll(); verify(mWifiManager, times(1)).startTetheredHotspot(null); verifyNoMoreInteractions(mWifiManager); @@ -1188,7 +1199,7 @@ public class TetheringTest { tetherState = callback.pollTetherStatesChanged(); assertArrayEquals(tetherState.availableList, new String[] {TEST_WLAN_IFNAME}); - mTethering.startTethering(TETHERING_WIFI, null, false); + mTethering.startTethering(createTetheringRquestParcel(TETHERING_WIFI), null); sendWifiApStateChanged(WIFI_AP_STATE_ENABLED, TEST_WLAN_IFNAME, IFACE_IP_MODE_TETHERED); mLooper.dispatchAll(); tetherState = callback.pollTetherStatesChanged(); diff --git a/services/autofill/java/com/android/server/autofill/InlineSuggestionFactory.java b/services/autofill/java/com/android/server/autofill/InlineSuggestionFactory.java index 5e6f97e4f282..331eb3748715 100644 --- a/services/autofill/java/com/android/server/autofill/InlineSuggestionFactory.java +++ b/services/autofill/java/com/android/server/autofill/InlineSuggestionFactory.java @@ -20,7 +20,6 @@ import static com.android.server.autofill.Helper.sDebug; import android.annotation.NonNull; import android.annotation.Nullable; -import android.app.slice.Slice; import android.content.Context; import android.os.RemoteException; import android.service.autofill.Dataset; @@ -132,7 +131,7 @@ public final class InlineSuggestionFactory { } }; final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo, - createInlineContentProvider(inlinePresentation.getSlice(), inlineSuggestionUi, + createInlineContentProvider(inlinePresentation, inlineSuggestionUi, onClickListener)); return inlineSuggestion; } @@ -151,20 +150,22 @@ public final class InlineSuggestionFactory { client.fill(requestId, fieldIndex, dataset); }; final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo, - createInlineContentProvider(inlinePresentation.getSlice(), inlineSuggestionUi, + createInlineContentProvider(inlinePresentation, inlineSuggestionUi, onClickListener)); return inlineSuggestion; } private static IInlineContentProvider.Stub createInlineContentProvider( - @NonNull Slice slice, @NonNull InlineSuggestionUi inlineSuggestionUi, + @NonNull InlinePresentation inlinePresentation, + @NonNull InlineSuggestionUi inlineSuggestionUi, @Nullable View.OnClickListener onClickListener) { return new IInlineContentProvider.Stub() { @Override public void provideContent(int width, int height, IInlineContentCallback callback) { UiThread.getHandler().post(() -> { - SurfaceControl sc = inlineSuggestionUi.inflate(slice, width, height, + SurfaceControl sc = inlineSuggestionUi.inflate(inlinePresentation, width, + height, onClickListener); try { callback.onContent(sc); diff --git a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionUi.java b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionUi.java index 2460732d17dc..2adefeabfcc8 100644 --- a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionUi.java @@ -25,10 +25,17 @@ import android.annotation.Nullable; import android.app.slice.Slice; import android.app.slice.SliceItem; import android.content.Context; +import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.content.res.TypedArray; import android.graphics.PixelFormat; import android.graphics.drawable.Icon; +import android.graphics.fonts.SystemFonts; import android.os.IBinder; +import android.service.autofill.InlinePresentation; +import android.text.TextUtils; import android.util.Log; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.SurfaceControl; import android.view.SurfaceControlViewHost; @@ -41,6 +48,8 @@ import android.widget.TextView; import com.android.internal.R; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * This is a temporary inline suggestion UI inflater which will be replaced by the ExtServices @@ -54,6 +63,10 @@ public class InlineSuggestionUi { private static final String TAG = "InlineSuggestionUi"; + // The pattern to match the value can be obtained by calling {@code Resources#getResourceName + // (int)}. This name is a single string of the form "package:type/entry". + private static final Pattern RESOURCE_NAME_PATTERN = Pattern.compile("([^:]+):([^/]+)/(\\S+)"); + private final Context mContext; public InlineSuggestionUi(Context context) { @@ -65,28 +78,36 @@ public class InlineSuggestionUi { */ @MainThread @Nullable - public SurfaceControl inflate(@NonNull Slice slice, int width, int height, - @Nullable View.OnClickListener onClickListener) { + public SurfaceControl inflate(@NonNull InlinePresentation inlinePresentation, int width, + int height, @Nullable View.OnClickListener onClickListener) { Log.d(TAG, "Inflating the inline suggestion UI"); //TODO(b/137800469): Pass in inputToken from IME. final SurfaceControlViewHost wvr = new SurfaceControlViewHost(mContext, mContext.getDisplay(), (IBinder) null); final SurfaceControl sc = wvr.getSurfacePackage().getSurfaceControl(); - final ViewGroup suggestionView = (ViewGroup) renderSlice(slice); + + Context contextThemeWrapper = getContextThemeWrapper(mContext, + inlinePresentation.getInlinePresentationSpec().getStyle()); + if (contextThemeWrapper == null) { + contextThemeWrapper = getDefaultContextThemeWrapper(mContext); + } + final View suggestionView = renderSlice(inlinePresentation.getSlice(), + contextThemeWrapper); if (onClickListener != null) { suggestionView.setOnClickListener(onClickListener); } WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, height, - WindowManager.LayoutParams.TYPE_APPLICATION, 0, PixelFormat.TRANSPARENT); + WindowManager.LayoutParams.TYPE_APPLICATION, 0, + PixelFormat.TRANSPARENT); wvr.addView(suggestionView, lp); return sc; } - private View renderSlice(Slice slice) { - final LayoutInflater inflater = LayoutInflater.from(mContext); + private static View renderSlice(Slice slice, Context context) { + final LayoutInflater inflater = LayoutInflater.from(context); final ViewGroup suggestionView = (ViewGroup) inflater.inflate(R.layout.autofill_inline_suggestion, null); @@ -137,4 +158,96 @@ public class InlineSuggestionUi { return suggestionView; } + + private Context getDefaultContextThemeWrapper(@NonNull Context context) { + Resources.Theme theme = context.getResources().newTheme(); + theme.applyStyle(android.R.style.Theme_AutofillInlineSuggestion, true); + return new ContextThemeWrapper(context, theme); + } + + /** + * Returns a context wrapping the theme in the provided {@code style}, or null if {@code + * style} doesn't pass validation. + */ + @Nullable + private static Context getContextThemeWrapper(@NonNull Context context, + @Nullable String style) { + if (style == null) { + return null; + } + Matcher matcher = RESOURCE_NAME_PATTERN.matcher(style); + if (!matcher.matches()) { + Log.d(TAG, "Can not parse the style=" + style); + return null; + } + String packageName = matcher.group(1); + String type = matcher.group(2); + String entry = matcher.group(3); + if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(type) || TextUtils.isEmpty(entry)) { + Log.d(TAG, "Can not proceed with empty field values in the style=" + style); + return null; + } + Resources resources = null; + try { + resources = context.getPackageManager().getResourcesForApplication( + packageName); + } catch (PackageManager.NameNotFoundException e) { + return null; + } + int resId = resources.getIdentifier(entry, type, packageName); + if (resId == Resources.ID_NULL) { + return null; + } + Resources.Theme theme = resources.newTheme(); + theme.applyStyle(resId, true); + if (!validateBaseTheme(theme, resId)) { + Log.d(TAG, "Provided theme is not a child of Theme.InlineSuggestion, ignoring it."); + return null; + } + if (!validateFontFamilyForTextViewStyles(theme)) { + Log.d(TAG, + "Provided theme specifies a font family that is not system font, ignoring it."); + return null; + } + return new ContextThemeWrapper(context, theme); + } + + private static boolean validateFontFamilyForTextViewStyles(Resources.Theme theme) { + return validateFontFamily(theme, android.R.attr.autofillInlineSuggestionTitle) + && validateFontFamily(theme, android.R.attr.autofillInlineSuggestionSubtitle); + } + + private static boolean validateFontFamily(Resources.Theme theme, int styleAttr) { + TypedArray ta = null; + try { + ta = theme.obtainStyledAttributes(null, new int[]{android.R.attr.fontFamily}, + styleAttr, + 0); + if (ta.getIndexCount() == 0) { + return true; + } + String fontFamily = ta.getString(ta.getIndex(0)); + return SystemFonts.getRawSystemFallbackMap().containsKey(fontFamily); + } finally { + if (ta != null) { + ta.recycle(); + } + } + } + + private static boolean validateBaseTheme(Resources.Theme theme, int styleAttr) { + TypedArray ta = null; + try { + ta = theme.obtainStyledAttributes(null, + new int[]{android.R.attr.isAutofillInlineSuggestionTheme}, styleAttr, 0); + if (ta.getIndexCount() == 0) { + return false; + } + return ta.getBoolean(ta.getIndex(0), false); + } finally { + if (ta != null) { + ta.recycle(); + } + } + } } diff --git a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java index 38a7000803bd..828775a4b934 100644 --- a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java +++ b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java @@ -52,7 +52,6 @@ class TaskSnapshotPersister { private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskSnapshotPersister" : TAG_WM; private static final String SNAPSHOTS_DIRNAME = "snapshots"; private static final String REDUCED_POSTFIX = "_reduced"; - private static final float REDUCED_SCALE = .5f; private static final float LOW_RAM_REDUCED_SCALE = .8f; static final boolean DISABLE_FULL_SIZED_BITMAPS = ActivityManager.isLowRamDeviceStatic(); private static final long DELAY_MS = 100; @@ -84,8 +83,13 @@ class TaskSnapshotPersister { TaskSnapshotPersister(WindowManagerService service, DirectoryResolver resolver) { mDirectoryResolver = resolver; - mReducedScale = ActivityManager.isLowRamDeviceStatic() - ? LOW_RAM_REDUCED_SCALE : REDUCED_SCALE; + + if (ActivityManager.isLowRamDeviceStatic()) { + mReducedScale = LOW_RAM_REDUCED_SCALE; + } else { + mReducedScale = service.mContext.getResources().getFloat( + com.android.internal.R.dimen.config_reducedTaskSnapshotScale); + } mUse16BitFormat = service.mContext.getResources().getBoolean( com.android.internal.R.bool.config_use16BitTaskSnapshotPixelFormat); } diff --git a/telephony/OWNERS b/telephony/OWNERS index 58a7ea08da3f..628c48070314 100644 --- a/telephony/OWNERS +++ b/telephony/OWNERS @@ -1,18 +1,16 @@ set noparent -tgunn@google.com -breadley@google.com -hallliu@google.com -rgreenwalt@google.com -mpq@google.com amitmahajan@google.com +breadley@google.com fionaxu@google.com jackyu@google.com +hallliu@google.com +rgreenwalt@google.com +tgunn@google.com jminjie@google.com -satk@google.com shuoq@google.com refuhoo@google.com -paulye@google.com nazaninb@google.com sarahchin@google.com dbright@google.com +xiaotonj@google.com diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 63a85fa2845c..247ffd7313b9 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -54,6 +54,7 @@ import android.os.Looper; import android.os.ParcelUuid; import android.os.Process; import android.os.RemoteException; +import android.os.ServiceManager; import android.provider.Telephony.SimInfo; import android.telephony.euicc.EuiccManager; import android.telephony.ims.ImsMmTelManager; @@ -677,6 +678,13 @@ public class SubscriptionManager { public static final String WFC_IMS_ROAMING_ENABLED = SimInfo.WFC_IMS_ROAMING_ENABLED; /** + * Determines if the user has enabled IMS RCS User Capability Exchange (UCE) for this + * subscription. + * @hide + */ + public static final String IMS_RCS_UCE_ENABLED = SimInfo.IMS_RCS_UCE_ENABLED; + + /** * TelephonyProvider column name for whether a subscription is opportunistic, that is, * whether the network it connects to is limited in functionality or coverage. * For example, CBRS. @@ -976,10 +984,7 @@ public class SubscriptionManager { private INetworkPolicyManager getINetworkPolicyManager() { if (mNetworkPolicy == null) { mNetworkPolicy = INetworkPolicyManager.Stub.asInterface( - TelephonyFrameworkInitializer - .getTelephonyServiceManager() - .getNetworkPolicyServiceRegisterer() - .get()); + ServiceManager.getService(Context.NETWORK_POLICY_SERVICE)); } return mNetworkPolicy; } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 903be6f68282..1d89665c1670 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -99,7 +99,6 @@ import com.android.internal.telephony.IOns; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ISetOpportunisticDataCallback; import com.android.internal.telephony.ITelephony; -import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.IUpdateAvailableNetworksCallback; import com.android.internal.telephony.OperatorInfo; import com.android.internal.telephony.PhoneConstants; @@ -5624,14 +5623,6 @@ public class TelephonyManager { .getTelephonyServiceManager().getTelephonyServiceRegisterer().get()); } - private ITelephonyRegistry getTelephonyRegistry() { - return ITelephonyRegistry.Stub.asInterface( - TelephonyFrameworkInitializer - .getTelephonyServiceManager() - .getTelephonyRegistryServiceRegisterer() - .get()); - } - private IOns getIOns() { return IOns.Stub.asInterface( TelephonyFrameworkInitializer @@ -5685,29 +5676,27 @@ public class TelephonyManager { */ public void listen(PhoneStateListener listener, int events) { if (mContext == null) return; - try { - boolean notifyNow = (getITelephony() != null); - ITelephonyRegistry registry = getTelephonyRegistry(); - if (registry != null) { - // subId from PhoneStateListener is deprecated Q on forward, use the subId from - // TelephonyManager instance. keep using subId from PhoneStateListener for pre-Q. - int subId = mSubId; - if (Compatibility.isChangeEnabled(LISTEN_CODE_CHANGE)) { - // since mSubId in PhoneStateListener is deprecated from Q on forward, this is - // the only place to set mSubId and its for "informational" only. - // TODO: remove this once we completely get rid of mSubId in PhoneStateListener - listener.mSubId = (events == PhoneStateListener.LISTEN_NONE) - ? SubscriptionManager.INVALID_SUBSCRIPTION_ID : subId; - } else if (listener.mSubId != null) { - subId = listener.mSubId; - } - registry.listenForSubscriber(subId, getOpPackageName(), getFeatureId(), - listener.callback, events, notifyNow); - } else { - Rlog.w(TAG, "telephony registry not ready."); - } - } catch (RemoteException ex) { - // system process dead + boolean notifyNow = (getITelephony() != null); + TelephonyRegistryManager telephonyRegistry = + (TelephonyRegistryManager) + mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE); + if (telephonyRegistry != null) { + // subId from PhoneStateListener is deprecated Q on forward, use the subId from + // TelephonyManager instance. keep using subId from PhoneStateListener for pre-Q. + int subId = mSubId; + if (Compatibility.isChangeEnabled(LISTEN_CODE_CHANGE)) { + // since mSubId in PhoneStateListener is deprecated from Q on forward, this is + // the only place to set mSubId and its for "informational" only. + // TODO: remove this once we completely get rid of mSubId in PhoneStateListener + listener.mSubId = (events == PhoneStateListener.LISTEN_NONE) + ? SubscriptionManager.INVALID_SUBSCRIPTION_ID : subId; + } else if (listener.mSubId != null) { + subId = listener.mSubId; + } + telephonyRegistry.listenForSubscriber(subId, getOpPackageName(), getFeatureId(), + listener, events, notifyNow); + } else { + Rlog.w(TAG, "telephony registry not ready."); } } diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index 27a70228a433..7488a1aec0e5 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -38,6 +38,9 @@ import com.android.internal.telephony.euicc.IEuiccController; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; /** * EuiccManager is the application interface to eUICCs, or eSIMs/embedded SIMs. @@ -254,27 +257,38 @@ public class EuiccManager { * the error is related to download.Since the OperationCode only uses at most one byte, the * maximum allowed quantity is 255(0xFF). * - * ErrorCode is the remaing three bytes of the result code, and it denotes what happened. + * ErrorCode is the remaining three bytes of the result code, and it denotes what happened. * e.g a combination of {@link #OPERATION_DOWNLOAD} and {@link #ERROR_TIME_OUT} will suggest the * download operation has timed out. The only exception here is * {@link #OPERATION_SMDX_SUBJECT_REASON_CODE}, where instead of ErrorCode, SubjectCode[5.2.6.1 * from GSMA (SGP.22 v2.2) and ReasonCode[5.2.6.2] from GSMA (SGP.22 v2.2) are encoded. @see * {@link #EXTRA_EMBEDDED_SUBSCRIPTION_SMDX_SUBJECT_CODE} and * {@link #EXTRA_EMBEDDED_SUBSCRIPTION_SMDX_REASON_CODE} + * + * In the case where ErrorCode contains a value of 0, it means it's an unknown error. E.g Intent + * only contains {@link #OPERATION_DOWNLOAD} and ErrorCode is 0 implies this is an unknown + * Download error. + * + * @see {@link #EXTRA_EMBEDDED_SUBSCRIPTION_OPERATION_CODE} + * @see {@link #EXTRA_EMBEDDED_SUBSCRIPTION_ERROR_CODE} + * @see {@link #EXTRA_EMBEDDED_SUBSCRIPTION_SMDX_SUBJECT_CODE} + * @see {@link #EXTRA_EMBEDDED_SUBSCRIPTION_SMDX_REASON_CODE} */ public static final String EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_DETAILED_CODE"; /** * Key for an extra set on {@link PendingIntent} result callbacks providing a - * OperationCode of {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}. + * OperationCode of {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}, + * value will be an int. */ public static final String EXTRA_EMBEDDED_SUBSCRIPTION_OPERATION_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_OPERATION_CODE"; /** * Key for an extra set on {@link PendingIntent} result callbacks providing a - * ErrorCode of {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}. + * ErrorCode of {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}, + * value will be an int. */ public static final String EXTRA_EMBEDDED_SUBSCRIPTION_ERROR_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_ERROR_CODE"; @@ -283,6 +297,7 @@ public class EuiccManager { * Key for an extra set on {@link PendingIntent} result callbacks providing a * SubjectCode[5.2.6.1] from GSMA (SGP.22 v2.2) decoded from * {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}. + * The value of this extra will be a String. */ public static final String EXTRA_EMBEDDED_SUBSCRIPTION_SMDX_SUBJECT_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_SMDX_SUBJECT_CODE"; @@ -291,6 +306,7 @@ public class EuiccManager { * Key for an extra set on {@link PendingIntent} result callbacks providing a * ReasonCode[5.2.6.2] from GSMA (SGP.22 v2.2) decoded from * {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}. + * The value of this extra will be a String. */ public static final String EXTRA_EMBEDDED_SUBSCRIPTION_SMDX_REASON_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_SMDX_REASON_CODE"; @@ -665,7 +681,7 @@ public class EuiccManager { ERROR_EUICC_MISSING, ERROR_UNSUPPORTED_VERSION, ERROR_SIM_MISSING, - ERROR_EUICC_GSMA_INSTALL_ERROR, + ERROR_INSTALL_PROFILE, ERROR_DISALLOWED_BY_PPR, ERROR_ADDRESS_MISSING, ERROR_CERTIFICATE_ERROR, @@ -733,14 +749,14 @@ public class EuiccManager { public static final int ERROR_SIM_MISSING = 10008; /** - * Failure to load the profile onto the eUICC card. i.e + * Failure to load the profile onto the eUICC card. e.g * 1. iccid of the profile already exists on the eUICC. * 2. GSMA(.22 v2.2) Profile Install Result - installFailedDueToDataMismatch * 3. operation was interrupted * 4. SIMalliance error in PEStatus(SGP.22 v2.2 section 2.5.6.1) * @see {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE} for details */ - public static final int ERROR_EUICC_GSMA_INSTALL_ERROR = 10009; + public static final int ERROR_INSTALL_PROFILE = 10009; /** * Failed to load profile onto eUICC due to Profile Poicly Rules. @@ -1235,6 +1251,138 @@ public class EuiccManager { } /** + * Sets the supported countries for eUICC. + * + * <p>Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * <p>The supported country list will be replaced by {@code supportedCountries}. For how we + * determine whether a country is supported please check {@link #isSupportedCountry}. + * + * @param supportedCountries is a list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + public void setSupportedCountries(@NonNull List<String> supportedCountries) { + if (!isEnabled()) { + return; + } + try { + getIEuiccController().setSupportedCountries( + true /* isSupported */, + supportedCountries.stream() + .map(String::toUpperCase).collect(Collectors.toList())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Sets the unsupported countries for eUICC. + * + * <p>Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * <p>The unsupported country list will be replaced by {@code unsupportedCountries}. For how we + * determine whether a country is supported please check {@link #isSupportedCountry}. + * + * @param unsupportedCountries is a list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + public void setUnsupportedCountries(@NonNull List<String> unsupportedCountries) { + if (!isEnabled()) { + return; + } + try { + getIEuiccController().setSupportedCountries( + false /* isSupported */, + unsupportedCountries.stream() + .map(String::toUpperCase).collect(Collectors.toList())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Gets the supported countries for eUICC. + * + * <p>Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * @return list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + @NonNull + public List<String> getSupportedCountries() { + if (!isEnabled()) { + return Collections.emptyList(); + } + try { + return getIEuiccController().getSupportedCountries(true /* isSupported */); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Gets the unsupported countries for eUICC. + * + * <p>Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * @return list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + @NonNull + public List<String> getUnsupportedCountries() { + if (!isEnabled()) { + return Collections.emptyList(); + } + try { + return getIEuiccController().getSupportedCountries(false /* isSupported */); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Returns whether the given country supports eUICC. + * + * <p>Supported country list has a higher prority than unsupported country list. If the + * supported country list is not empty, {@code countryIso} will be considered as supported when + * it exists in the supported country list. Otherwise {@code countryIso} is not supported. If + * the supported country list is empty, {@code countryIso} will be considered as supported if it + * does not exist in the unsupported country list. Otherwise {@code countryIso} is not + * supported. If both supported and unsupported country lists are empty, then all countries are + * consider be supported. For how to set supported and unsupported country list, please check + * {@link #setSupportedCountries} and {@link #setUnsupportedCountries}. + * + * @param countryIso should be the ISO-3166 country code is provided in uppercase 2 character + * format. + * @return whether the given country supports eUICC or not. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + public boolean isSupportedCountry(@NonNull String countryIso) { + if (!isEnabled()) { + return false; + } + try { + return getIEuiccController().isSupportedCountry(countryIso.toUpperCase()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Refreshes the cardId if its uninitialized, and returns whether we should continue the * operation. * <p> diff --git a/telephony/java/android/telephony/ims/RcsUceAdapter.java b/telephony/java/android/telephony/ims/RcsUceAdapter.java index 2e3f59a13670..72167761c88d 100644 --- a/telephony/java/android/telephony/ims/RcsUceAdapter.java +++ b/telephony/java/android/telephony/ims/RcsUceAdapter.java @@ -21,6 +21,8 @@ import android.annotation.CallbackExecutor; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.RequiresPermission; +import android.annotation.SystemApi; +import android.annotation.TestApi; import android.net.Uri; import android.os.Binder; import android.os.IBinder; @@ -28,6 +30,7 @@ import android.os.RemoteException; import android.telephony.TelephonyFrameworkInitializer; import android.telephony.ims.aidl.IImsRcsController; import android.telephony.ims.aidl.IRcsUceControllerCallback; +import android.telephony.ims.feature.RcsFeature; import android.util.Log; import java.lang.annotation.Retention; @@ -41,6 +44,8 @@ import java.util.concurrent.Executor; * @see ImsRcsManager#getUceAdapter() for information on creating an instance of this class. * @hide */ +@SystemApi +@TestApi public class RcsUceAdapter { private static final String TAG = "RcsUceAdapter"; @@ -169,6 +174,7 @@ public class RcsUceAdapter { * Provides a one-time callback for the response to a UCE request. After this callback is called * by the framework, the reference to this callback will be discarded on the service side. * @see #requestCapabilities(Executor, List, CapabilitiesCallback) + * @hide */ public static class CapabilitiesCallback { @@ -196,6 +202,7 @@ public class RcsUceAdapter { /** * Not to be instantiated directly, use * {@link ImsRcsManager#getUceAdapter()} to instantiate this manager class. + * @hide */ RcsUceAdapter(int subId) { mSubId = subId; @@ -219,6 +226,7 @@ public class RcsUceAdapter { * {@link RcsUceAdapter} is valid, but the ImsService associated with the subscription is not * available. This can happen if the ImsService has crashed, for example, or if the subscription * becomes inactive. See {@link ImsException#getCode()} for more information on the error codes. + * @hide */ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void requestCapabilities(@CallbackExecutor Executor executor, @@ -281,6 +289,7 @@ public class RcsUceAdapter { * {@link RcsUceAdapter} is valid, but the ImsService associated with the subscription is not * available. This can happen if the ImsService has crashed, for example, or if the subscription * becomes inactive. See {@link ImsException#getCode()} for more information on the error codes. + * @hide */ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @PublishState int getUcePublishState() throws ImsException { @@ -305,7 +314,7 @@ public class RcsUceAdapter { * for the associated subscription. * * @return true if the user’s setting for UCE is enabled, false otherwise. If false, - * {@link ImsRcsManager#isCapable(int)} will return false for + * {@link ImsRcsManager#isCapable(int, int)} will return false for * {@link RcsFeature.RcsImsCapabilities#CAPABILITY_TYPE_OPTIONS_UCE} and * {@link RcsFeature.RcsImsCapabilities#CAPABILITY_TYPE_PRESENCE_UCE} * @see #setUceSettingEnabled(boolean) diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 0db86d6054b3..9ac8cb136c6b 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -480,6 +480,7 @@ public interface RILConstants { int RIL_REQUEST_STOP_KEEPALIVE = 145; int RIL_REQUEST_ENABLE_MODEM = 146; int RIL_REQUEST_GET_MODEM_STATUS = 147; + int RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE = 148; /* The following requests are not defined in RIL.h */ int RIL_REQUEST_HAL_NON_RIL_BASE = 200; diff --git a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl index 7422863d862c..35e8a12e898a 100644 --- a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl +++ b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl @@ -21,6 +21,7 @@ import android.content.Intent; import android.os.Bundle; import android.telephony.euicc.DownloadableSubscription; import android.telephony.euicc.EuiccInfo; +import java.util.List; /** @hide */ interface IEuiccController { @@ -47,4 +48,7 @@ interface IEuiccController { oneway void eraseSubscriptionsWithOptions( int cardId, int options, in PendingIntent callbackIntent); oneway void retainSubscriptionsForFactoryReset(int cardId, in PendingIntent callbackIntent); + void setSupportedCountries(boolean isSupported, in List<String> countriesList); + List<String> getSupportedCountries(boolean isSupported); + boolean isSupportedCountry(String countryIso); } diff --git a/tests/net/common/java/android/net/LinkAddressTest.java b/tests/net/common/java/android/net/LinkAddressTest.java index b2e573b6c74b..096f7bdca088 100644 --- a/tests/net/common/java/android/net/LinkAddressTest.java +++ b/tests/net/common/java/android/net/LinkAddressTest.java @@ -38,6 +38,8 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import android.os.SystemClock; + import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -316,11 +318,83 @@ public class LinkAddressTest { l = new LinkAddress(V6_ADDRESS, 64, 123, 456); assertParcelingIsLossless(l); + l = new LinkAddress(V6_ADDRESS, 64, 123, 456, + 1L, 3600000L); + assertParcelingIsLossless(l); l = new LinkAddress(V4 + "/28", IFA_F_PERMANENT, RT_SCOPE_LINK); - assertParcelSane(l, 4); + assertParcelSane(l, 6); } + @Test + public void testDeprecationTime() { + try { + new LinkAddress(V6_ADDRESS, 64, 0, 456, + LinkAddress.LIFETIME_UNKNOWN, + SystemClock.elapsedRealtime() + 200000); + fail("Only one time provided should cause exception"); + } catch (IllegalArgumentException expected) { } + + try { + new LinkAddress(V6_ADDRESS, 64, 0, 456, + SystemClock.elapsedRealtime() - 100000, + SystemClock.elapsedRealtime() - 200000); + fail("deprecation time later than expiration time should cause exception"); + } catch (IllegalArgumentException expected) { } + + try { + new LinkAddress(V6_ADDRESS, 64, 0, 456, + -2, SystemClock.elapsedRealtime()); + fail("negative deprecation time should cause exception"); + } catch (IllegalArgumentException expected) { } + } + + @Test + public void testExpirationTime() { + try { + new LinkAddress(V6_ADDRESS, 64, 0, 456, + SystemClock.elapsedRealtime() + 200000, + LinkAddress.LIFETIME_UNKNOWN); + fail("Only one time provided should cause exception"); + } catch (IllegalArgumentException expected) { } + + try { + new LinkAddress(V6_ADDRESS, 64, 0, 456, + SystemClock.elapsedRealtime() - 10000, -2); + fail("negative expiration time should cause exception"); + } catch (IllegalArgumentException expected) { } + } + + @Test + public void testGetFlags() { + LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, RT_SCOPE_HOST); + assertEquals(123, l.getFlags()); + + // Test if deprecated bit was added/remove automatically based on the provided deprecation + // time + l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST, + SystemClock.elapsedRealtime() - 100000, LinkAddress.LIFETIME_PERMANENT); + // Check if the flag is added automatically. + assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0); + + l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED, RT_SCOPE_HOST, + SystemClock.elapsedRealtime() + 100000, LinkAddress.LIFETIME_PERMANENT); + // Check if the flag is removed automatically. + assertTrue((l.getFlags() & IFA_F_DEPRECATED) == 0); + + l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED, RT_SCOPE_HOST, + LinkAddress.LIFETIME_PERMANENT, LinkAddress.LIFETIME_PERMANENT); + // Check if the permanent flag is added. + assertTrue((l.getFlags() & IFA_F_PERMANENT) != 0); + + l = new LinkAddress(V6_ADDRESS, 64, IFA_F_PERMANENT, RT_SCOPE_HOST, + SystemClock.elapsedRealtime() - 100000, + SystemClock.elapsedRealtime() + 100000); + // Check if the permanent flag is removed + assertTrue((l.getFlags() & IFA_F_PERMANENT) == 0); + } + + private void assertGlobalPreferred(LinkAddress l, String msg) { assertTrue(msg, l.isGlobalPreferred()); } @@ -389,5 +463,12 @@ public class LinkAddressTest { (IFA_F_TEMPORARY|IFA_F_TENTATIVE|IFA_F_OPTIMISTIC), RT_SCOPE_UNIVERSE); assertGlobalPreferred(l, "v6,global,tempaddr+optimistic"); + + l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED, + RT_SCOPE_UNIVERSE, SystemClock.elapsedRealtime() + 100000, + SystemClock.elapsedRealtime() + 200000); + // Although the deprecated bit is set, but the deprecation time is in the future, test + // if the flag is removed automatically. + assertGlobalPreferred(l, "v6,global,tempaddr+deprecated in the future"); } } diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 0e8c6ed8774e..7f99fe4f64b4 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1793,18 +1793,6 @@ public class WifiManager { } /** - * Same as {@link #registerNetworkRequestMatchCallback(Executor, NetworkRequestMatchCallback)}, - * except that the callback will be executed on the application's main thread. - * @param callback Callback for network match events to register. - * @hide - */ - @SystemApi - @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) - public void registerNetworkRequestMatchCallback(@NonNull NetworkRequestMatchCallback callback) { - registerNetworkRequestMatchCallback(mContext.getMainExecutor(), callback); - } - - /** * Registers a callback for NetworkRequest matches. See {@link NetworkRequestMatchCallback}. * Caller can unregister a previously registered callback using * {@link #unregisterNetworkRequestMatchCallback(NetworkRequestMatchCallback)} @@ -3719,18 +3707,6 @@ public class WifiManager { } /** - * Same as {@link #registerSoftApCallback(Executor, SoftApCallback)}, - * except that the callback will be executed on the application's main thread. - * @param callback Callback for soft AP events - * @hide - */ - @SystemApi - @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) - public void registerSoftApCallback(@NonNull SoftApCallback callback) { - registerSoftApCallback(mContext.getMainExecutor(), callback); - } - - /** * Registers a callback for Soft AP. See {@link SoftApCallback}. Caller will receive the current * soft AP state and number of connected devices immediately after a successful call to this API * via callback. Note that receiving an immediate WIFI_AP_STATE_FAILED value for soft AP state @@ -5152,18 +5128,6 @@ public class WifiManager { } /** - * Same as {@link #registerTrafficStateCallback(Executor, TrafficStateCallback)}, - * except that the callback will be executed on the application's main thread. - * @param callback Callback for traffic state events - * @hide - */ - @SystemApi - @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) - public void registerTrafficStateCallback(@NonNull TrafficStateCallback callback) { - registerTrafficStateCallback(mContext.getMainExecutor(), callback); - } - - /** * Registers a callback for monitoring traffic state. See {@link TrafficStateCallback}. These * callbacks will be invoked periodically by platform to inform clients about the current * traffic state. Caller can unregister a previously registered callback using diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java index f369203e05ab..3846473911a0 100644 --- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java +++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java @@ -881,17 +881,6 @@ public class WifiManagerTest { } /** - * Verify main looper is used when handler is not provided. - */ - @Test - public void registerSoftApCallbackUsesMainExecutorOnNoExecutorProvided() { - when(mContext.getMainExecutor()).thenReturn( - new HandlerExecutor(new Handler(mLooper.getLooper()))); - mWifiManager.registerSoftApCallback(mSoftApCallback); - verify(mContext).getMainExecutor(); - } - - /** * Verify the call to registerSoftApCallback goes to WifiServiceImpl. */ @Test @@ -1389,11 +1378,10 @@ public class WifiManagerTest { @Test public void registerTrafficStateCallbackUsesMainLooperOnNullArgumentForHandler() throws Exception { - when(mContext.getMainExecutor()).thenReturn( - new HandlerExecutor(new Handler(mLooper.getLooper()))); ArgumentCaptor<ITrafficStateCallback.Stub> callbackCaptor = ArgumentCaptor.forClass(ITrafficStateCallback.Stub.class); - mWifiManager.registerTrafficStateCallback(mTrafficStateCallback); + mWifiManager.registerTrafficStateCallback( + new HandlerExecutor(new Handler(mLooper.getLooper())), mTrafficStateCallback); verify(mWifiService).registerTrafficStateCallback( any(IBinder.class), callbackCaptor.capture(), anyInt()); @@ -1474,11 +1462,11 @@ public class WifiManagerTest { @Test public void registerNetworkRequestMatchCallbackCallGoesToWifiServiceImpl() throws Exception { - when(mContext.getMainExecutor()).thenReturn( - new HandlerExecutor(new Handler(mLooper.getLooper()))); ArgumentCaptor<INetworkRequestMatchCallback.Stub> callbackCaptor = ArgumentCaptor.forClass(INetworkRequestMatchCallback.Stub.class); - mWifiManager.registerNetworkRequestMatchCallback(mNetworkRequestMatchCallback); + mWifiManager.registerNetworkRequestMatchCallback( + new HandlerExecutor(new Handler(mLooper.getLooper())), + mNetworkRequestMatchCallback); verify(mWifiService).registerNetworkRequestMatchCallback( any(IBinder.class), callbackCaptor.capture(), anyInt()); @@ -1530,11 +1518,11 @@ public class WifiManagerTest { @Test public void networkRequestUserSelectionCallbackCallGoesToWifiServiceImpl() throws Exception { - when(mContext.getMainExecutor()).thenReturn( - new HandlerExecutor(new Handler(mLooper.getLooper()))); ArgumentCaptor<INetworkRequestMatchCallback.Stub> callbackCaptor = ArgumentCaptor.forClass(INetworkRequestMatchCallback.Stub.class); - mWifiManager.registerNetworkRequestMatchCallback(mNetworkRequestMatchCallback); + mWifiManager.registerNetworkRequestMatchCallback( + new HandlerExecutor(new Handler(mLooper.getLooper())), + mNetworkRequestMatchCallback); verify(mWifiService).registerNetworkRequestMatchCallback( any(IBinder.class), callbackCaptor.capture(), anyInt()); |