Add startSkDestroyListener flag to native_init
This CL prepares for upcoming CL. Upcoming CL will add SkDestroyListener with Java BpfMap and switch current C SkDestroyListener and new Java SkDestroyListener based on the experiment flag. Bug: 217624062 Test: atest SkDestroyListenerTest Change-Id: I5ebb319d1b2262199d4ef6a3549894fee24c4ccf
This commit is contained in:
parent
116af0d892
commit
3af8f0e8d6
4 changed files with 11 additions and 7 deletions
|
|
@ -47,8 +47,8 @@ namespace android {
|
|||
ALOGE("%s failed, error code = %d", __func__, status.code()); \
|
||||
} while (0)
|
||||
|
||||
static void native_init(JNIEnv* env, jclass clazz) {
|
||||
Status status = mTc.start();
|
||||
static void native_init(JNIEnv* env, jclass clazz, jboolean startSkDestroyListener) {
|
||||
Status status = mTc.start(startSkDestroyListener);
|
||||
CHECK_LOG(status);
|
||||
if (!isOk(status)) {
|
||||
uid_t uid = getuid();
|
||||
|
|
@ -201,7 +201,7 @@ static jint native_synchronizeKernelRCU(JNIEnv* env, jobject self) {
|
|||
// clang-format off
|
||||
static const JNINativeMethod gMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{"native_init", "()V",
|
||||
{"native_init", "(Z)V",
|
||||
(void*)native_init},
|
||||
{"native_addNaughtyApp", "(I)I",
|
||||
(void*)native_addNaughtyApp},
|
||||
|
|
|
|||
|
|
@ -181,9 +181,13 @@ Status TrafficController::initMaps() {
|
|||
return netdutils::status::ok;
|
||||
}
|
||||
|
||||
Status TrafficController::start() {
|
||||
Status TrafficController::start(bool startSkDestroyListener) {
|
||||
RETURN_IF_NOT_OK(initMaps());
|
||||
|
||||
if (!startSkDestroyListener) {
|
||||
return netdutils::status::ok;
|
||||
}
|
||||
|
||||
auto result = makeSkDestroyListener();
|
||||
if (!isOk(result)) {
|
||||
ALOGE("Unable to create SkDestroyListener: %s", toString(result).c_str());
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class TrafficController {
|
|||
/*
|
||||
* Initialize the whole controller
|
||||
*/
|
||||
netdutils::Status start();
|
||||
netdutils::Status start(bool startSkDestroyListener);
|
||||
|
||||
/*
|
||||
* Swap the stats map config from current active stats map to the idle one.
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ public class BpfNetMaps {
|
|||
Log.d(TAG, "BpfNetMaps is initialized with sEnableJavaBpfMap=" + sEnableJavaBpfMap);
|
||||
|
||||
initBpfMaps();
|
||||
native_init();
|
||||
native_init(true /* startSkDestroyListener */);
|
||||
sInitialized = true;
|
||||
}
|
||||
|
||||
|
|
@ -839,7 +839,7 @@ public class BpfNetMaps {
|
|||
native_dump(fd, verbose);
|
||||
}
|
||||
|
||||
private static native void native_init();
|
||||
private static native void native_init(boolean startSkDestroyListener);
|
||||
private native int native_addNaughtyApp(int uid);
|
||||
private native int native_removeNaughtyApp(int uid);
|
||||
private native int native_addNiceApp(int uid);
|
||||
|
|
|
|||
Loading…
Reference in a new issue