当前位置:网站首页>NDK learning notes (VII) system configuration, users and groups
NDK learning notes (VII) system configuration, users and groups
2022-06-11 05:34:00 【Come and go】
List of articles
1. The system configuration
Bionic Provides a set of functions that allow native applications to query Xu Tong's properties .
Need header file
#include <sys/system_properties.h>
Each system attribute complies with no more than PROP_NAME_MAX Attribute names with characters and no more than PROP_VALUE_MAX Attribute value of characters .
(1) Get the system attribute value by name
char value[PROP_VALUE_MAX];
// If the attribute is not defined , The return size is 0 Value
if (0 == __system_property_get("ro.product.model", value)) {
} else {
__android_log_print(ANDROID_LOG_INFO, "123321", "%s", value);
}
effect 
(2) Get system properties by name
const prop_info *p;
// obtain ro.product.model System attribute
p = __system_property_find("ro.product.model");
if (NULL == p) {
} else {
char name[PROP_NAME_MAX];
char value[PROP_VALUE_MAX];
// Get the system attribute name and value
if (0 == __system_property_read(p, name, value)) {
} else {
__android_log_print(ANDROID_LOG_INFO, "123321", "%s:%s", name, value);
}
}
effect 
2. Users and groups
Bionic Provide basic support for user and group information functions .
The required header file
Insert a code chip here
(1) Get the users and groups of the application ID
Users of normal applications ID And groups ID from 10000 At the beginning ;ID Small values are used for system services .
getuid() user id
getgid() Group id
__android_log_print(ANDROID_LOG_INFO, "123321", "%d:%d", getuid(), getgid());
effect
2020-04-05 16:48:25.825 13132-13132/com.example.testnt I/123321: 10069:10069
(2) Get the application user name
Installed applications get the user name assigned to the user .
__android_log_print(ANDROID_LOG_INFO, "123321", "%s",getlogin());
effect
2020-04-05 16:52:42.705 13220-13220/com.example.testnt I/123321: u0_a69
边栏推荐
- Concurrent search set
- Handle double quotation mark escape in JSON string
- Multithreading tutorial (XXI) double checked locking problem
- Section IV: composition and materials of asphalt mixture (1) -- structure composition and classification
- Zed2 camera manual
- String sorting times --- bubble sorting deformation
- Opencv learning path (2-2) -- Deep parsing namedwindow function
- Analyzing while experimenting - memory leakage caused by non static inner classes
- Preliminary test of running vins-fusion with zed2 binocular camera
- WinForm (II) advanced WinForm and use of complex controls
猜你喜欢

Preliminary test of running vins-fusion with zed2 binocular camera

微信小程序text内置组件换行符不换行的原因-wxs处理换行符,正则加段首空格

jvm调优五:jvm调优工具和调优实战

Big meal count (time complexity) -- leetcode daily question

Zed2 running vins-mono preliminary test

Deep search + backtracking

Tightly coupled laser vision inertial navigation slam system: paper notes_ S2D. 66_ ICRA_ 2021_ LVI-SAM

1. use alicloud object OSS (basic)

QT Road (2) -- HelloWorld

Zed2 camera calibration -- binocular, IMU, joint calibration
随机推荐
Concurrent search set
Multithreading tutorial (XXVI) field updater and atomic accumulator
English digital converter
Share an RSA encryption and decryption tool class, including public key encryption, private key decryption, private key encryption, public key decryption, private key signature, public key verificatio
Deep search + backtracking
1.使用阿里云对象OSS(初级)
Zed2 camera manual
Combing route - Compaction Technology
Section I: classification and classification of urban roads
微信小程序,购买商品属性自动换行,固定div个数,超出部分自动换行
MySQL circulates multiple values foreach, XML writing method
Intercept file extension
Opencv learning path (2-1) -- Deep parsing imread function
Linked list de duplication
code
Bert knowledge distillation
Maximum number of points on the line ----- hash table solution
自定义View之基础篇
Basics of customized view
Games101 job 7-path tracing implementation process & detailed interpretation of code