Merge changes from topics "2374762-android-bp", "2374763-android-bp"
* changes:
cronet: sync Android.bp with aosp/2374763
cronet: sync Android.bp with aosp/2374762
diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java
index b3ec805..e1b7016 100644
--- a/Tethering/src/com/android/networkstack/tethering/Tethering.java
+++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java
@@ -2407,6 +2407,9 @@
/** Unregister tethering event callback */
void unregisterTetheringEventCallback(ITetheringEventCallback callback) {
+ if (callback == null) {
+ throw new NullPointerException();
+ }
mHandler.post(() -> {
mTetheringEventCallbacks.unregister(callback);
});
diff --git a/bpf_progs/netd.c b/bpf_progs/netd.c
index b0246f6..43920d0 100644
--- a/bpf_progs/netd.c
+++ b/bpf_progs/netd.c
@@ -109,8 +109,9 @@
// (this is because these are currently attached by the mainline provided libnetd_updatable .so
// which is loaded into netd and thus runs as netd uid/gid/selinux context)
#define DEFINE_NETD_BPF_PROG_KVER_RANGE(SECTION_NAME, prog_uid, prog_gid, the_prog, minKV, maxKV) \
- DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, \
- minKV, maxKV, false, "fs_bpf_netd_readonly", "")
+ DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, \
+ minKV, maxKV, BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, false, \
+ "fs_bpf_netd_readonly", "", false, false, false)
#define DEFINE_NETD_BPF_PROG_KVER(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv) \
DEFINE_NETD_BPF_PROG_KVER_RANGE(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, KVER_INF)
@@ -120,8 +121,9 @@
// programs that only need to be usable by the system server
#define DEFINE_SYS_BPF_PROG(SECTION_NAME, prog_uid, prog_gid, the_prog) \
- DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, \
- KVER_NONE, KVER_INF, false, "fs_bpf_net_shared", "")
+ DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, KVER_NONE, KVER_INF, \
+ BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, false, "fs_bpf_net_shared", \
+ "", false, false, false)
static __always_inline int is_system_uid(uint32_t uid) {
// MIN_SYSTEM_UID is AID_ROOT == 0, so uint32_t is *always* >= 0
diff --git a/framework-t/src/android/net/IpSecManager.java b/framework-t/src/android/net/IpSecManager.java
index 1c83e09..ff021d6 100644
--- a/framework-t/src/android/net/IpSecManager.java
+++ b/framework-t/src/android/net/IpSecManager.java
@@ -610,7 +610,7 @@
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
- mCloseGuard.open("constructor");
+ mCloseGuard.open("close");
}
/** Get the encapsulation socket's file descriptor. */
@@ -890,7 +890,7 @@
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
- mCloseGuard.open("constructor");
+ mCloseGuard.open("close");
}
/**
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index cf53002..3a17bdd 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -69,6 +69,7 @@
import android.annotation.Nullable;
import android.annotation.TargetApi;
import android.app.AlarmManager;
+import android.app.BroadcastOptions;
import android.app.PendingIntent;
import android.app.usage.NetworkStatsManager;
import android.content.ApexEnvironment;
@@ -114,6 +115,7 @@
import android.net.netstats.provider.NetworkStatsProvider;
import android.os.Binder;
import android.os.Build;
+import android.os.Bundle;
import android.os.DropBoxManager;
import android.os.Environment;
import android.os.Handler;
@@ -149,6 +151,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FileRotator;
+import com.android.modules.utils.build.SdkLevel;
import com.android.net.module.util.BaseNetdUnsolicitedEventListener;
import com.android.net.module.util.BestClock;
import com.android.net.module.util.BinderUtils;
@@ -166,6 +169,9 @@
import com.android.net.module.util.Struct.U8;
import com.android.net.module.util.bpf.CookieTagMapKey;
import com.android.net.module.util.bpf.CookieTagMapValue;
+import com.android.networkstack.apishim.BroadcastOptionsShimImpl;
+import com.android.networkstack.apishim.ConstantsShim;
+import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
import com.android.server.BpfNetMaps;
import java.io.File;
@@ -526,8 +532,22 @@
case MSG_BROADCAST_NETWORK_STATS_UPDATED: {
final Intent updatedIntent = new Intent(ACTION_NETWORK_STATS_UPDATED);
updatedIntent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
+ Bundle opts = null;
+ if (SdkLevel.isAtLeastU()) {
+ try {
+ // This allows us to discard older broadcasts still waiting to
+ // be delivered.
+ opts = BroadcastOptionsShimImpl.newInstance(
+ BroadcastOptions.makeBasic())
+ .setDeliveryGroupPolicy(
+ ConstantsShim.DELIVERY_GROUP_POLICY_MOST_RECENT)
+ .toBundle();
+ } catch (UnsupportedApiLevelException e) {
+ Log.wtf(TAG, "Using unsupported API" + e);
+ }
+ }
mContext.sendBroadcastAsUser(updatedIntent, UserHandle.ALL,
- READ_NETWORK_USAGE_HISTORY);
+ READ_NETWORK_USAGE_HISTORY, opts);
break;
}
}