Merge changes from topics "ms34-tm", "ms40-clock" am: beb9fb3cc8

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1914533

Change-Id: I719edc4e4f98b0fdabb50736156551d3f8d35bd1
This commit is contained in:
Junyu Lai
2022-01-06 14:02:58 +00:00
committed by Automerger Merge Worker
11 changed files with 76 additions and 38 deletions

View File

@@ -32074,6 +32074,7 @@ package android.os {
public final class SystemClock { public final class SystemClock {
method @NonNull public static java.time.Clock currentGnssTimeClock(); method @NonNull public static java.time.Clock currentGnssTimeClock();
method @NonNull public static java.time.Clock currentNetworkTimeClock();
method public static long currentThreadTimeMillis(); method public static long currentThreadTimeMillis();
method public static long elapsedRealtime(); method public static long elapsedRealtime();
method public static long elapsedRealtimeNanos(); method public static long elapsedRealtimeNanos();

View File

@@ -237,6 +237,43 @@ package android.net {
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStateSnapshot> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStateSnapshot> CREATOR;
} }
public final class NetworkTemplate implements android.os.Parcelable {
method public int describeContents();
method public int getDefaultNetworkStatus();
method public int getMatchRule();
method public int getMeteredness();
method public int getOemManaged();
method public int getRatType();
method public int getRoaming();
method @NonNull public java.util.Set<java.lang.String> getSubscriberIds();
method @NonNull public java.util.Set<java.lang.String> getWifiNetworkKeys();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkTemplate> CREATOR;
field public static final int MATCH_BLUETOOTH = 8; // 0x8
field public static final int MATCH_CARRIER = 10; // 0xa
field public static final int MATCH_ETHERNET = 5; // 0x5
field public static final int MATCH_MOBILE = 1; // 0x1
field public static final int MATCH_WIFI = 4; // 0x4
field public static final int NETWORK_TYPE_ALL = -1; // 0xffffffff
field public static final int OEM_MANAGED_ALL = -1; // 0xffffffff
field public static final int OEM_MANAGED_NO = 0; // 0x0
field public static final int OEM_MANAGED_PAID = 1; // 0x1
field public static final int OEM_MANAGED_PRIVATE = 2; // 0x2
field public static final int OEM_MANAGED_YES = -2; // 0xfffffffe
}
public static final class NetworkTemplate.Builder {
ctor public NetworkTemplate.Builder(int);
method @NonNull public android.net.NetworkTemplate build();
method @NonNull public android.net.NetworkTemplate.Builder setDefaultNetworkStatus(int);
method @NonNull public android.net.NetworkTemplate.Builder setMeteredness(int);
method @NonNull public android.net.NetworkTemplate.Builder setOemManaged(int);
method @NonNull public android.net.NetworkTemplate.Builder setRatType(int);
method @NonNull public android.net.NetworkTemplate.Builder setRoaming(int);
method @NonNull public android.net.NetworkTemplate.Builder setSubscriberIds(@NonNull java.util.Set<java.lang.String>);
method @NonNull public android.net.NetworkTemplate.Builder setWifiNetworkKeys(@NonNull java.util.Set<java.lang.String>);
}
public class NetworkWatchlistManager { public class NetworkWatchlistManager {
method @Nullable public byte[] getWatchlistConfigHash(); method @Nullable public byte[] getWatchlistConfigHash();
} }
@@ -321,6 +358,10 @@ package android.os {
method @Nullable public android.os.IBinder getOrThrow() throws android.os.StatsServiceManager.ServiceNotFoundException; method @Nullable public android.os.IBinder getOrThrow() throws android.os.StatsServiceManager.ServiceNotFoundException;
} }
public final class StrictMode {
method public static void noteUntaggedSocket();
}
public class SystemConfigManager { public class SystemConfigManager {
method @NonNull public java.util.List<android.content.ComponentName> getEnabledComponentOverrides(@NonNull String); method @NonNull public java.util.List<android.content.ComponentName> getEnabledComponentOverrides(@NonNull String);
} }

View File

@@ -7509,13 +7509,17 @@ package android.net {
method @NonNull public android.net.NetworkStats subtract(@NonNull android.net.NetworkStats); method @NonNull public android.net.NetworkStats subtract(@NonNull android.net.NetworkStats);
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStats> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.net.NetworkStats> CREATOR;
field public static final int DEFAULT_NETWORK_ALL = -1; // 0xffffffff
field public static final int DEFAULT_NETWORK_NO = 0; // 0x0 field public static final int DEFAULT_NETWORK_NO = 0; // 0x0
field public static final int DEFAULT_NETWORK_YES = 1; // 0x1 field public static final int DEFAULT_NETWORK_YES = 1; // 0x1
field public static final String IFACE_VT = "vt_data0"; field public static final String IFACE_VT = "vt_data0";
field public static final int METERED_ALL = -1; // 0xffffffff
field public static final int METERED_NO = 0; // 0x0 field public static final int METERED_NO = 0; // 0x0
field public static final int METERED_YES = 1; // 0x1 field public static final int METERED_YES = 1; // 0x1
field public static final int ROAMING_ALL = -1; // 0xffffffff
field public static final int ROAMING_NO = 0; // 0x0 field public static final int ROAMING_NO = 0; // 0x0
field public static final int ROAMING_YES = 1; // 0x1 field public static final int ROAMING_YES = 1; // 0x1
field public static final int SET_ALL = -1; // 0xffffffff
field public static final int SET_DEFAULT = 0; // 0x0 field public static final int SET_DEFAULT = 0; // 0x0
field public static final int SET_FOREGROUND = 1; // 0x1 field public static final int SET_FOREGROUND = 1; // 0x1
field public static final int TAG_NONE = 0; // 0x0 field public static final int TAG_NONE = 0; // 0x0

View File

@@ -339,7 +339,8 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> {
out.writeInt(template.getMatchRule()); out.writeInt(template.getMatchRule());
BackupUtils.writeString(out, template.getSubscriberIds().iterator().next()); BackupUtils.writeString(out, template.getSubscriberIds().iterator().next());
BackupUtils.writeString(out, template.getWifiNetworkKey()); BackupUtils.writeString(out, template.getWifiNetworkKeys().isEmpty()
? null : template.getWifiNetworkKeys().iterator().next());
out.writeInt(template.getMeteredness()); out.writeInt(template.getMeteredness());
return baos.toByteArray(); return baos.toByteArray();

View File

@@ -15,10 +15,13 @@
*/ */
package android.os; package android.os;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi; import android.annotation.TestApi;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityThread; import android.app.ActivityThread;
@@ -2694,6 +2697,12 @@ public final class StrictMode {
((AndroidBlockGuardPolicy) policy).onCustomSlowCall(name); ((AndroidBlockGuardPolicy) policy).onCustomSlowCall(name);
} }
/** @hide */
@SystemApi(client = MODULE_LIBRARIES)
public static void noteUntaggedSocket() {
if (vmUntaggedSocketEnabled()) onUntaggedSocket();
}
/** /**
* For code to note that a resource was obtained using a type other than its defined type. This * For code to note that a resource was obtained using a type other than its defined type. This
* is a no-op unless the current thread's {@link android.os.StrictMode.ThreadPolicy} has {@link * is a no-op unless the current thread's {@link android.os.StrictMode.ThreadPolicy} has {@link

View File

@@ -311,7 +311,6 @@ public final class SystemClock {
* time or throw. * time or throw.
* *
* @throws DateTimeException when no accurate network time can be provided. * @throws DateTimeException when no accurate network time can be provided.
* @hide
*/ */
public static @NonNull Clock currentNetworkTimeClock() { public static @NonNull Clock currentNetworkTimeClock() {
return new SimpleClock(ZoneOffset.UTC) { return new SimpleClock(ZoneOffset.UTC) {

View File

@@ -70,8 +70,8 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
Log.d(TAG, "tagSocket(" + fd.getInt$() + ") with statsTag=0x" Log.d(TAG, "tagSocket(" + fd.getInt$() + ") with statsTag=0x"
+ Integer.toHexString(options.statsTag) + ", statsUid=" + options.statsUid); + Integer.toHexString(options.statsTag) + ", statsUid=" + options.statsUid);
} }
if (options.statsTag == -1 && StrictMode.vmUntaggedSocketEnabled()) { if (options.statsTag == -1) {
StrictMode.onUntaggedSocket(); StrictMode.noteUntaggedSocket();
} }
// TODO: skip tagging when options would be no-op // TODO: skip tagging when options would be no-op
tagSocketFd(fd, options.statsTag, options.statsUid); tagSocketFd(fd, options.statsTag, options.statsUid);

View File

@@ -83,10 +83,7 @@ public final class NetworkStats implements Parcelable {
*/ */
// TODO: Rename TAG_ALL to TAG_ANY. // TODO: Rename TAG_ALL to TAG_ANY.
public static final int TAG_ALL = -1; public static final int TAG_ALL = -1;
/** /** {@link #set} value for all sets combined, not including debug sets. */
* {@link #set} value for all sets combined, not including debug sets.
* @hide
*/
public static final int SET_ALL = -1; public static final int SET_ALL = -1;
/** {@link #set} value where background data is accounted. */ /** {@link #set} value where background data is accounted. */
public static final int SET_DEFAULT = 0; public static final int SET_DEFAULT = 0;
@@ -114,9 +111,6 @@ public final class NetworkStats implements Parcelable {
SET_ALL, SET_ALL,
SET_DEFAULT, SET_DEFAULT,
SET_FOREGROUND, SET_FOREGROUND,
SET_DEBUG_START,
SET_DBG_VPN_IN,
SET_DBG_VPN_OUT
}) })
public @interface State { public @interface State {
} }
@@ -131,10 +125,7 @@ public final class NetworkStats implements Parcelable {
// TODO: Rename TAG_NONE to TAG_ALL. // TODO: Rename TAG_NONE to TAG_ALL.
public static final int TAG_NONE = 0; public static final int TAG_NONE = 0;
/** /** {@link #metered} value to account for all metered states. */
* {@link #metered} value to account for all metered states.
* @hide
*/
public static final int METERED_ALL = -1; public static final int METERED_ALL = -1;
/** {@link #metered} value where native, unmetered data is accounted. */ /** {@link #metered} value where native, unmetered data is accounted. */
public static final int METERED_NO = 0; public static final int METERED_NO = 0;
@@ -152,10 +143,7 @@ public final class NetworkStats implements Parcelable {
} }
/** /** {@link #roaming} value to account for all roaming states. */
* {@link #roaming} value to account for all roaming states.
* @hide
*/
public static final int ROAMING_ALL = -1; public static final int ROAMING_ALL = -1;
/** {@link #roaming} value where native, non-roaming data is accounted. */ /** {@link #roaming} value where native, non-roaming data is accounted. */
public static final int ROAMING_NO = 0; public static final int ROAMING_NO = 0;
@@ -172,10 +160,7 @@ public final class NetworkStats implements Parcelable {
public @interface Roaming { public @interface Roaming {
} }
/** /** {@link #onDefaultNetwork} value to account for all default network states. */
* {@link #onDefaultNetwork} value to account for all default network states.
* @hide
*/
public static final int DEFAULT_NETWORK_ALL = -1; public static final int DEFAULT_NETWORK_ALL = -1;
/** {@link #onDefaultNetwork} value to account for usage while not the default network. */ /** {@link #onDefaultNetwork} value to account for usage while not the default network. */
public static final int DEFAULT_NETWORK_NO = 0; public static final int DEFAULT_NETWORK_NO = 0;

View File

@@ -16,6 +16,7 @@
package android.net; package android.net;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
import static android.net.ConnectivityManager.TYPE_BLUETOOTH; import static android.net.ConnectivityManager.TYPE_BLUETOOTH;
import static android.net.ConnectivityManager.TYPE_ETHERNET; import static android.net.ConnectivityManager.TYPE_ETHERNET;
import static android.net.ConnectivityManager.TYPE_MOBILE; import static android.net.ConnectivityManager.TYPE_MOBILE;
@@ -39,7 +40,9 @@ import static android.net.NetworkStats.ROAMING_YES;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.net.wifi.WifiInfo;
import android.os.Build; import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -70,7 +73,7 @@ import java.util.TreeSet;
* *
* @hide * @hide
*/ */
// @SystemApi(client = MODULE_LIBRARIES) @SystemApi(client = MODULE_LIBRARIES)
public final class NetworkTemplate implements Parcelable { public final class NetworkTemplate implements Parcelable {
/** @hide */ /** @hide */
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@@ -572,6 +575,7 @@ public final class NetworkTemplate implements Parcelable {
/** /**
* Get subscriber Id of the template. * Get subscriber Id of the template.
* @hide
*/ */
@Nullable @Nullable
@UnsupportedAppUsage @UnsupportedAppUsage
@@ -588,26 +592,19 @@ public final class NetworkTemplate implements Parcelable {
} }
/** /**
* Get Wifi Network Key of the template. See {@link WifiInfo#getCurrentNetworkKey()}. * Get the set of Wifi Network Keys of the template.
* See {@link WifiInfo#getCurrentNetworkKey()}.
*/ */
@Nullable @NonNull
public String getWifiNetworkKey() {
return CollectionUtils.isEmpty(mMatchWifiNetworkKeys) ? null : mMatchWifiNetworkKeys[0];
}
/**
* Get set of Wifi Network Keys of the template.
*/
@Nullable
public Set<String> getWifiNetworkKeys() { public Set<String> getWifiNetworkKeys() {
return new ArraySet<>(Arrays.asList(mMatchWifiNetworkKeys)); return new ArraySet<>(Arrays.asList(mMatchWifiNetworkKeys));
} }
/** @hide */ /** @hide */
// TODO: Remove this and replace all callers with {@link #getWifiNetworkKey()}. // TODO: Remove this and replace all callers with {@link #getWifiNetworkKeys()}.
@Nullable @Nullable
public String getNetworkId() { public String getNetworkId() {
return getWifiNetworkKey(); return getWifiNetworkKeys().isEmpty() ? null : getWifiNetworkKeys().iterator().next();
} }
/** /**

View File

@@ -113,7 +113,6 @@ import android.net.Uri;
import android.net.netstats.provider.INetworkStatsProvider; import android.net.netstats.provider.INetworkStatsProvider;
import android.net.netstats.provider.INetworkStatsProviderCallback; import android.net.netstats.provider.INetworkStatsProviderCallback;
import android.net.netstats.provider.NetworkStatsProvider; import android.net.netstats.provider.NetworkStatsProvider;
import android.os.BestClock;
import android.os.Binder; import android.os.Binder;
import android.os.DropBoxManager; import android.os.DropBoxManager;
import android.os.Environment; import android.os.Environment;
@@ -149,6 +148,7 @@ import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FileRotator; import com.android.internal.util.FileRotator;
import com.android.net.module.util.BestClock;
import com.android.net.module.util.BinderUtils; import com.android.net.module.util.BinderUtils;
import com.android.net.module.util.CollectionUtils; import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.NetworkStatsUtils; import com.android.net.module.util.NetworkStatsUtils;

View File

@@ -101,7 +101,8 @@ public class NetworkStatsSubscriptionsMonitor extends
// with empty IMSI. So filter the subs w/o a valid IMSI to prevent such registration. // with empty IMSI. So filter the subs w/o a valid IMSI to prevent such registration.
final List<Pair<Integer, String>> filteredNewSubs = new ArrayList<>(); final List<Pair<Integer, String>> filteredNewSubs = new ArrayList<>();
for (final int subId : newSubs) { for (final int subId : newSubs) {
final String subscriberId = mTeleManager.getSubscriberId(subId); final String subscriberId =
mTeleManager.createForSubscriptionId(subId).getSubscriberId();
if (!TextUtils.isEmpty(subscriberId)) { if (!TextUtils.isEmpty(subscriberId)) {
filteredNewSubs.add(new Pair(subId, subscriberId)); filteredNewSubs.add(new Pair(subId, subscriberId));
} }