Application context when run C++ app in shell

瀏覽次數:126 次
跳到第一則未讀訊息

Nguyễn Trung Thành

未讀,
2020年10月15日 中午12:26:302020/10/15
收件者:android-ndk
Hello,

I create an app in C++. I run it in shell however I cannot change context of the app. It run under u:r:su:s0 install my context

Result of ps -A -Z
u:r:su:s0                      root           2554   2552   15960   5516 0                   0 R TestApp

My sepolicy here:
type vendor_testapp, domain;
type vendor_testapp_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(vendor_testapp)

in file_contexts
/vendor/bin/TestApp     u:object_r:vendor_testapp_exec:s0

Anyone can help me?

Regards,
Thanh

Glenn Kasten

未讀,
2020年10月15日 中午12:34:192020/10/15
收件者:android-ndk
Can you please confirm: did you use NDK to create this app?
If so can you please a short code snippet?

Nguyễn Trung Thành

未讀,
2020年10月16日 晚上11:03:592020/10/16
收件者:android-ndk
I write C++ inside AOSP source code. It is simple code to play with IVehicle

main.c
#define LOG_TAG "Test app"
#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
#include <android/hardware/automotive/vehicle/2.0/types.h>

#include <hidl/Status.h>
#include <hidl/LegacySupport.h>
#include <utils/misc.h>
#include <utils/Log.h>


#include <stdio.h>
#include <string.h>

using android::hardware::automotive::vehicle::V2_0::VehiclePropValue;
using android::sp;
using android::hardware::hidl_vec;
using namespace std;

using android::hardware::automotive::vehicle::V2_0::IVehicle;

int main(int argc, char** argv) {
size_t pos = 0;
android::sp<IVehicle> ser = IVehicle::getService();

ser->set(propValues);

return 0;
}

Android.bp
cc_binary {
    name: "TestApp",
    defaults: ["hidl_defaults"],
    //proprietary: true,
    vendor: true,
    srcs: ["main.cpp"],
 
    shared_libs: [
        "android.hardware.automotive.vehicle@2.0",
        "libhidlbase",
        "liblog",
        "libutils",
    ],
}
回覆所有人
回覆作者
轉寄
0 則新訊息