Application context when run C++ app in shell

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Application context when run C++ app in shell

Nguyễn Trung Thành
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

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/016ef892-b652-416e-b550-31ccc19787b0n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Application context when run C++ app in shell

Glenn Kasten
Can you please confirm: did you use NDK to create this app?
If so can you please a short code snippet?

On Thursday, October 15, 2020 at 9:26:30 AM UTC-7, Nguyễn Trung Thành wrote:
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

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/8a87feb5-f879-49be-bdcc-41b63ab67d7eo%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Application context when run C++ app in shell

Nguyễn Trung Thành
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",
    ],
}

On Thursday, October 15, 2020 at 11:34:19 PM UTC+7 Glenn Kasten wrote:
Can you please confirm: did you use NDK to create this app?
If so can you please a short code snippet?


On Thursday, October 15, 2020 at 9:26:30 AM UTC-7, Nguyễn Trung Thành wrote:
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

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1173733e-d245-459b-86e0-50fff577018en%40googlegroups.com.