Merge changes I4753cae7,Ic6554d9b am: d752b7b746 am: 4a14072d74
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1948287 Change-Id: Id9cde9eee1e5c555a1d83507ac5000d6e99a13ce
This commit is contained in:
@@ -242,6 +242,7 @@ cc_library_shared {
|
|||||||
"audioflinger-aidl-cpp",
|
"audioflinger-aidl-cpp",
|
||||||
"av-types-aidl-cpp",
|
"av-types-aidl-cpp",
|
||||||
"android.hardware.camera.device@3.2",
|
"android.hardware.camera.device@3.2",
|
||||||
|
"libandroid_net",
|
||||||
"libandroidicu",
|
"libandroidicu",
|
||||||
"libbpf_android",
|
"libbpf_android",
|
||||||
"libnetdbpf",
|
"libnetdbpf",
|
||||||
|
|||||||
@@ -15,24 +15,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_TAG "NMST_QTagUidNative"
|
#define LOG_TAG "NMST_QTagUidNative"
|
||||||
#include <utils/Log.h>
|
|
||||||
|
|
||||||
#include <nativehelper/JNIPlatformHelp.h>
|
#include <android/multinetwork.h>
|
||||||
|
|
||||||
#include "jni.h"
|
|
||||||
#include <utils/misc.h>
|
|
||||||
#include <cutils/qtaguid.h>
|
#include <cutils/qtaguid.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <nativehelper/JNIPlatformHelp.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <utils/Log.h>
|
||||||
|
#include <utils/misc.h>
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
static jint QTagUid_tagSocketFd(JNIEnv* env, jclass,
|
static jint tagSocketFd(JNIEnv* env, jclass, jobject fileDescriptor,
|
||||||
jobject fileDescriptor,
|
jint tagNum, jint uid) {
|
||||||
jint tagNum, jint uid) {
|
|
||||||
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
|
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
|
||||||
|
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
@@ -40,15 +39,14 @@ static jint QTagUid_tagSocketFd(JNIEnv* env, jclass,
|
|||||||
return (jint)-1;
|
return (jint)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = qtaguid_tagSocket(userFd, tagNum, uid);
|
int res = android_tag_socket_with_uid(userFd, tagNum, uid);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return (jint)-errno;
|
return (jint)-errno;
|
||||||
}
|
}
|
||||||
return (jint)res;
|
return (jint)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint QTagUid_untagSocketFd(JNIEnv* env, jclass,
|
static jint untagSocketFd(JNIEnv* env, jclass, jobject fileDescriptor) {
|
||||||
jobject fileDescriptor) {
|
|
||||||
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
|
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
|
||||||
|
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
@@ -56,16 +54,14 @@ static jint QTagUid_untagSocketFd(JNIEnv* env, jclass,
|
|||||||
return (jint)-1;
|
return (jint)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = qtaguid_untagSocket(userFd);
|
int res = android_untag_socket(userFd);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return (jint)-errno;
|
return (jint)-errno;
|
||||||
}
|
}
|
||||||
return (jint)res;
|
return (jint)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint QTagUid_setCounterSet(JNIEnv* env, jclass,
|
static jint setCounterSet(JNIEnv* env, jclass, jint setNum, jint uid) {
|
||||||
jint setNum, jint uid) {
|
|
||||||
|
|
||||||
int res = qtaguid_setCounterSet(setNum, uid);
|
int res = qtaguid_setCounterSet(setNum, uid);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return (jint)-errno;
|
return (jint)-errno;
|
||||||
@@ -73,9 +69,7 @@ static jint QTagUid_setCounterSet(JNIEnv* env, jclass,
|
|||||||
return (jint)res;
|
return (jint)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint QTagUid_deleteTagData(JNIEnv* env, jclass,
|
static jint deleteTagData(JNIEnv* env, jclass, jint tagNum, jint uid) {
|
||||||
jint tagNum, jint uid) {
|
|
||||||
|
|
||||||
int res = qtaguid_deleteTagData(tagNum, uid);
|
int res = qtaguid_deleteTagData(tagNum, uid);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
return (jint)-errno;
|
return (jint)-errno;
|
||||||
@@ -84,10 +78,10 @@ static jint QTagUid_deleteTagData(JNIEnv* env, jclass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const JNINativeMethod gQTagUidMethods[] = {
|
static const JNINativeMethod gQTagUidMethods[] = {
|
||||||
{ "native_tagSocketFd", "(Ljava/io/FileDescriptor;II)I", (void*)QTagUid_tagSocketFd},
|
{ "native_tagSocketFd", "(Ljava/io/FileDescriptor;II)I", (void*)tagSocketFd},
|
||||||
{ "native_untagSocketFd", "(Ljava/io/FileDescriptor;)I", (void*)QTagUid_untagSocketFd},
|
{ "native_untagSocketFd", "(Ljava/io/FileDescriptor;)I", (void*)untagSocketFd},
|
||||||
{ "native_setCounterSet", "(II)I", (void*)QTagUid_setCounterSet},
|
{ "native_setCounterSet", "(II)I", (void*)setCounterSet},
|
||||||
{ "native_deleteTagData", "(II)I", (void*)QTagUid_deleteTagData},
|
{ "native_deleteTagData", "(II)I", (void*)deleteTagData},
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_server_NetworkManagementSocketTagger(JNIEnv* env) {
|
int register_android_server_NetworkManagementSocketTagger(JNIEnv* env) {
|
||||||
|
|||||||
Reference in New Issue
Block a user