-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathandroid.cpp
More file actions
31 lines (24 loc) · 751 Bytes
/
Copy pathandroid.cpp
File metadata and controls
31 lines (24 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <sys/system_properties.h>
#include <cstring>
#include <climits>
#include <fcntl.h>
#include <unistd.h>
#include <cstdlib>
namespace android {
int GetApiLevel() {
static int apiLevel = 0;
if (apiLevel > 0) return apiLevel;
char buf[PROP_VALUE_MAX + 1];
if (__system_property_get("ro.build.version.sdk", buf) > 0)
apiLevel = atoi(buf);
return apiLevel;
}
int GetPreviewApiLevel() {
static int previewApiLevel = 0;
if (previewApiLevel > 0) return previewApiLevel;
char buf[PROP_VALUE_MAX + 1];
if (__system_property_get("ro.build.version.preview_sdk", buf) > 0)
previewApiLevel = atoi(buf);
return previewApiLevel;
}
}