LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux
# ZipArchive support, the order matters here to get all symbols.
-LOCAL_STATIC_LIBRARIES := libziparchive libz libbase libmincrypt
+LOCAL_STATIC_LIBRARIES := libziparchive libz libbase libcrypto_static
LOCAL_HAL_STATIC_LIBRARIES := libdumpstate
LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
LOCAL_INIT_RC := dumpstate.rc
#include "ScopedFd.h"
#include "ziparchive/zip_writer.h"
-#include "mincrypt/sha256.h"
+#include <openssl/sha.h>
using android::base::StringPrintf;
}
SHA256_CTX ctx;
- SHA256_init(&ctx);
+ SHA256_Init(&ctx);
std::vector<uint8_t> buffer(65536);
while (1) {
return NULL;
}
- SHA256_update(&ctx, buffer.data(), bytes_read);
+ SHA256_Update(&ctx, buffer.data(), bytes_read);
}
- uint8_t hash[SHA256_DIGEST_SIZE];
- memcpy(hash, SHA256_final(&ctx), SHA256_DIGEST_SIZE);
- char hash_buffer[SHA256_DIGEST_SIZE * 2 + 1];
- for(size_t i = 0; i < SHA256_DIGEST_SIZE; i++) {
+ uint8_t hash[SHA256_DIGEST_LENGTH];
+ SHA256_Final(hash, &ctx);
+
+ char hash_buffer[SHA256_DIGEST_LENGTH * 2 + 1];
+ for(size_t i = 0; i < SHA256_DIGEST_LENGTH; i++) {
sprintf(hash_buffer + (i * 2), "%02x", hash[i]);
}
hash_buffer[sizeof(hash_buffer) - 1] = 0;
#include <sys/capability.h>
#include <sys/inotify.h>
#include <sys/stat.h>
-#include <sys/sysconf.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/klog.h>
void for_each_pid(for_each_pid_func func, const char *header) {
ON_DRY_RUN_RETURN();
- __for_each_pid(for_each_pid_helper, header, (void *)func);
+ __for_each_pid(for_each_pid_helper, header, (void *) func);
}
static void for_each_tid_helper(int pid, const char *cmdline, void *arg) {
* stuck.
*/
int dump_file_from_fd(const char *title, const char *path, int fd) {
+ ON_DRY_RUN_RETURN(0);
int flags = fcntl(fd, F_GETFL);
if (flags == -1) {
printf("*** %s: failed to get flags on fd %d: %s\n", path, fd, strerror(errno));
PLOG(ERROR) << "Could not rename " << from << " to " << to;
return false;
}
-
return true;
}
const char *oat_dir,
const char *apk_path,
const char *instruction_set) {
- char *file_name_start;
- char *file_name_end;
+ const char *file_name_start;
+ const char *file_name_end;
file_name_start = strrchr(apk_path, '/');
if (file_name_start == NULL) {
const char16_t* readString16Inplace(size_t* outLen) const;
sp<IBinder> readStrongBinder() const;
status_t readStrongBinder(sp<IBinder>* val) const;
+ status_t readNullableStrongBinder(sp<IBinder>* val) const;
wp<IBinder> readWeakBinder() const;
template<typename T>
template<typename T>
status_t readStrongBinder(sp<T>* val) const;
+ template<typename T>
+ status_t readNullableStrongBinder(sp<T>* val) const;
+
status_t readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const;
status_t readStrongBinderVector(std::vector<sp<IBinder>>* val) const;
return ret;
}
+template<typename T>
+status_t Parcel::readNullableStrongBinder(sp<T>* val) const {
+ sp<IBinder> tmp;
+ status_t ret = readNullableStrongBinder(&tmp);
+
+ if (ret == OK) {
+ *val = interface_cast<T>(tmp);
+
+ if (val->get() == nullptr) {
+ return UNKNOWN_ERROR;
+ }
+ }
+}
+
template<typename T, typename U>
status_t Parcel::unsafeReadTypedVector(
std::vector<T>* val,
#define ANDROID_PERSISTABLE_BUNDLE_H
#include <map>
+#include <set>
#include <vector>
#include <binder/Parcelable.h>
bool getStringVector(const String16& key, std::vector<String16>* out) const;
bool getPersistableBundle(const String16& key, PersistableBundle* out) const;
+ /* Getters for all keys for each value type */
+ std::set<String16> getBooleanKeys() const;
+ std::set<String16> getIntKeys() const;
+ std::set<String16> getLongKeys() const;
+ std::set<String16> getDoubleKeys() const;
+ std::set<String16> getStringKeys() const;
+ std::set<String16> getBooleanVectorKeys() const;
+ std::set<String16> getIntVectorKeys() const;
+ std::set<String16> getLongVectorKeys() const;
+ std::set<String16> getDoubleVectorKeys() const;
+ std::set<String16> getStringVectorKeys() const;
+ std::set<String16> getPersistableBundleKeys() const;
+
friend bool operator==(const PersistableBundle& lhs, const PersistableBundle& rhs) {
return (lhs.mBoolMap == rhs.mBoolMap && lhs.mIntMap == rhs.mIntMap &&
lhs.mLongMap == rhs.mLongMap && lhs.mDoubleMap == rhs.mDoubleMap &&
#define ANDROID_BINDER_STATUS_H
#include <cstdint>
+#include <sstream>
#include <binder/Parcel.h>
#include <utils/String8.h>
}; // class Status
// For gtest output logging
-template<typename T>
-T& operator<< (T& stream, const Status& s) {
- stream << s.toString8().string();
- return stream;
-}
+std::stringstream& operator<< (std::stringstream& stream, const Status& s);
} // namespace binder
} // namespace android
* limitations under the License.
*/
+#include <mutex>
#include <binder/AppOpsManager.h>
#include <binder/Binder.h>
#include <binder/IServiceManager.h>
namespace android {
+namespace {
+
+#if defined(__BRILLO__)
+// Because Brillo has no application model, security policy is managed
+// statically (at build time) with SELinux controls.
+// As a consequence, it also never runs the AppOpsManager service.
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_ALLOWED;
+#else
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_IGNORED;
+#endif // defined(__BRILLO__)
+
+} // namespace
+
static String16 _appops("appops");
static pthread_mutex_t gTokenMutex = PTHREAD_MUTEX_INITIALIZER;
static sp<IBinder> gToken;
{
}
+#if defined(__BRILLO__)
+// There is no AppOpsService on Brillo
+sp<IAppOpsService> AppOpsManager::getService() { return NULL; }
+#else
sp<IAppOpsService> AppOpsManager::getService()
{
+
+ std::lock_guard<Mutex> scoped_lock(mLock);
int64_t startTime = 0;
- mLock.lock();
sp<IAppOpsService> service = mService;
while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) {
sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
ALOGI("Waiting for app ops service");
} else if ((uptimeMillis()-startTime) > 10000) {
ALOGW("Waiting too long for app ops service, giving up");
- return NULL;
+ service = NULL;
+ break;
}
sleep(1);
} else {
mService = service;
}
}
- mLock.unlock();
return service;
}
+#endif // defined(__BRILLO__)
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
{
sp<IAppOpsService> service = getService();
- return service != NULL ? service->checkOperation(op, uid, callingPackage) : MODE_IGNORED;
+ return service != NULL
+ ? service->checkOperation(op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
sp<IAppOpsService> service = getService();
- return service != NULL ? service->noteOperation(op, uid, callingPackage) : MODE_IGNORED;
+ return service != NULL
+ ? service->noteOperation(op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
sp<IAppOpsService> service = getService();
- return service != NULL ? service->startOperation(getToken(service), op, uid, callingPackage)
- : MODE_IGNORED;
+ return service != NULL
+ ? service->startOperation(getToken(service), op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {
delete st;
pthread_setspecific(gTLS, NULL);
}
+ pthread_key_delete(gTLS);
gHaveTLS = false;
}
}
bool checkPermission(const String16& permission, pid_t pid, uid_t uid)
{
-#ifdef __BRILLO__
- // Brillo doesn't currently run ActivityManager or support framework permissions.
- return true;
-#endif
-
sp<IPermissionController> pc;
gDefaultServiceManagerLock.lock();
pc = gPermissionController;
}
status_t Parcel::readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const {
- return readNullableTypedVector(val, &Parcel::readStrongBinder);
+ return readNullableTypedVector(val, &Parcel::readNullableStrongBinder);
}
status_t Parcel::readStrongBinderVector(std::vector<sp<IBinder>>* val) const {
status_t Parcel::readStrongBinder(sp<IBinder>* val) const
{
+ status_t status = readNullableStrongBinder(val);
+ if (status == OK && !val->get()) {
+ status = UNEXPECTED_NULL;
+ }
+ return status;
+}
+
+status_t Parcel::readNullableStrongBinder(sp<IBinder>* val) const
+{
return unflatten_binder(ProcessState::self(), *this, val);
}
sp<IBinder> Parcel::readStrongBinder() const
{
sp<IBinder> val;
- readStrongBinder(&val);
+ // Note that a lot of code in Android reads binders by hand with this
+ // method, and that code has historically been ok with getting nullptr
+ // back (while ignoring error codes).
+ readNullableStrongBinder(&val);
return val;
}
using android::sp;
using android::status_t;
using android::UNEXPECTED_NULL;
+using std::map;
+using std::set;
+using std::vector;
enum {
// Keep in sync with BUNDLE_MAGIC in frameworks/base/core/java/android/os/BaseBundle.java.
namespace {
template <typename T>
-bool getValue(const android::String16& key, T* out, const std::map<android::String16, T>& map) {
+bool getValue(const android::String16& key, T* out, const map<android::String16, T>& map) {
const auto& it = map.find(key);
if (it == map.end()) return false;
*out = it->second;
return true;
}
+
+template <typename T>
+set<android::String16> getKeys(const map<android::String16, T>& map) {
+ if (map.empty()) return set<android::String16>();
+ set<android::String16> keys;
+ for (const auto& key_value_pair : map) {
+ keys.emplace(key_value_pair.first);
+ }
+ return keys;
+}
} // namespace
namespace android {
mStringMap[key] = value;
}
-void PersistableBundle::putBooleanVector(const String16& key, const std::vector<bool>& value) {
+void PersistableBundle::putBooleanVector(const String16& key, const vector<bool>& value) {
erase(key);
mBoolVectorMap[key] = value;
}
-void PersistableBundle::putIntVector(const String16& key, const std::vector<int32_t>& value) {
+void PersistableBundle::putIntVector(const String16& key, const vector<int32_t>& value) {
erase(key);
mIntVectorMap[key] = value;
}
-void PersistableBundle::putLongVector(const String16& key, const std::vector<int64_t>& value) {
+void PersistableBundle::putLongVector(const String16& key, const vector<int64_t>& value) {
erase(key);
mLongVectorMap[key] = value;
}
-void PersistableBundle::putDoubleVector(const String16& key, const std::vector<double>& value) {
+void PersistableBundle::putDoubleVector(const String16& key, const vector<double>& value) {
erase(key);
mDoubleVectorMap[key] = value;
}
-void PersistableBundle::putStringVector(const String16& key, const std::vector<String16>& value) {
+void PersistableBundle::putStringVector(const String16& key, const vector<String16>& value) {
erase(key);
mStringVectorMap[key] = value;
}
return getValue(key, out, mStringMap);
}
-bool PersistableBundle::getBooleanVector(const String16& key, std::vector<bool>* out) const {
+bool PersistableBundle::getBooleanVector(const String16& key, vector<bool>* out) const {
return getValue(key, out, mBoolVectorMap);
}
-bool PersistableBundle::getIntVector(const String16& key, std::vector<int32_t>* out) const {
+bool PersistableBundle::getIntVector(const String16& key, vector<int32_t>* out) const {
return getValue(key, out, mIntVectorMap);
}
-bool PersistableBundle::getLongVector(const String16& key, std::vector<int64_t>* out) const {
+bool PersistableBundle::getLongVector(const String16& key, vector<int64_t>* out) const {
return getValue(key, out, mLongVectorMap);
}
-bool PersistableBundle::getDoubleVector(const String16& key, std::vector<double>* out) const {
+bool PersistableBundle::getDoubleVector(const String16& key, vector<double>* out) const {
return getValue(key, out, mDoubleVectorMap);
}
-bool PersistableBundle::getStringVector(const String16& key, std::vector<String16>* out) const {
+bool PersistableBundle::getStringVector(const String16& key, vector<String16>* out) const {
return getValue(key, out, mStringVectorMap);
}
return getValue(key, out, mPersistableBundleMap);
}
+set<String16> PersistableBundle::getBooleanKeys() const {
+ return getKeys(mBoolMap);
+}
+
+set<String16> PersistableBundle::getIntKeys() const {
+ return getKeys(mIntMap);
+}
+
+set<String16> PersistableBundle::getLongKeys() const {
+ return getKeys(mLongMap);
+}
+
+set<String16> PersistableBundle::getDoubleKeys() const {
+ return getKeys(mDoubleMap);
+}
+
+set<String16> PersistableBundle::getStringKeys() const {
+ return getKeys(mStringMap);
+}
+
+set<String16> PersistableBundle::getBooleanVectorKeys() const {
+ return getKeys(mBoolVectorMap);
+}
+
+set<String16> PersistableBundle::getIntVectorKeys() const {
+ return getKeys(mIntVectorMap);
+}
+
+set<String16> PersistableBundle::getLongVectorKeys() const {
+ return getKeys(mLongVectorMap);
+}
+
+set<String16> PersistableBundle::getDoubleVectorKeys() const {
+ return getKeys(mDoubleVectorMap);
+}
+
+set<String16> PersistableBundle::getStringVectorKeys() const {
+ return getKeys(mStringVectorMap);
+}
+
+set<String16> PersistableBundle::getPersistableBundleKeys() const {
+ return getKeys(mPersistableBundleMap);
+}
+
status_t PersistableBundle::writeToParcelInner(Parcel* parcel) const {
/*
* To keep this implementation in sync with writeArrayMapInternal() in
ProcessState::~ProcessState()
{
+ if (mDriverFD >= 0) {
+ if (mVMStart != MAP_FAILED) {
+ munmap(mVMStart, BINDER_VM_SIZE);
+ }
+ close(mDriverFD);
+ }
+ mDriverFD = -1;
}
}; // namespace android
return ret;
}
+std::stringstream& operator<< (std::stringstream& stream, const Status& s) {
+ stream << s.toString8().string();
+ return stream;
+}
+
} // namespace binder
} // namespace android
LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
endif
+ifeq ($(TARGET_BOARD_HAS_NO_SURFACE_FLINGER), true)
+ LOCAL_CFLAGS += -DHAVE_NO_SURFACE_FLINGER
+endif
+
include $(BUILD_SHARED_LIBRARY)
ifeq (,$(ONE_SHOT_MAKEFILE))
#include <inttypes.h>
+#include <cutils/properties.h>
+
#include <gui/BufferItem.h>
#include <gui/BufferQueueCore.h>
+#include <gui/GraphicBufferAlloc.h>
#include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
HAL_DATASPACE_UNKNOWN)
{
if (allocator == NULL) {
- sp<ISurfaceComposer> composer(ComposerService::getComposerService());
- mAllocator = composer->createGraphicBufferAlloc();
+
+#ifdef HAVE_NO_SURFACE_FLINGER
+ // Without a SurfaceFlinger, allocate in-process. This only makes
+ // sense in systems with static SELinux configurations and no
+ // applications (since applications need dynamic SELinux policy).
+ mAllocator = new GraphicBufferAlloc();
+#else
+ // Run time check for headless, where we also allocate in-process.
+ char value[PROPERTY_VALUE_MAX];
+ property_get("config.headless", value, "0");
+ if (atoi(value) == 1) {
+ mAllocator = new GraphicBufferAlloc();
+ } else {
+ sp<ISurfaceComposer> composer(ComposerService::getComposerService());
+ mAllocator = composer->createGraphicBufferAlloc();
+ }
+#endif // HAVE_NO_SURFACE_FLINGER
+
if (mAllocator == NULL) {
BQ_LOGE("createGraphicBufferAlloc failed");
}
TextureRenderer.cpp \
LOCAL_SHARED_LIBRARIES := \
+ liblog \
libEGL \
libGLESv1_CM \
libGLESv2 \
merge = false;
break;
}
- p++, q++;
+ p++;
+ q++;
}
}
}
GLES_CM/gl.cpp.arm \
#
-LOCAL_CLANG := false
LOCAL_SHARED_LIBRARIES += libcutils liblog libEGL
LOCAL_MODULE:= libGLESv1_CM
GLES2/gl2.cpp \
#
-LOCAL_CLANG := false
LOCAL_ARM_MODE := arm
LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
LOCAL_MODULE:= libGLESv2
GLES2/gl2.cpp \
#
-LOCAL_CLANG := false
LOCAL_ARM_MODE := arm
LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
LOCAL_MODULE:= libGLESv3
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
#if USE_SLOW_BINDING
#define API_ENTRY(_api) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
if (_c) return _c->_api(__VA_ARGS__);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0;
+
+ // This stays blank, since void functions will implicitly return, and
+ // all of the other functions will return 0 based on the previous macro.
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__arm__)
#define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
- #define API_ENTRY(_api) __attribute__((noinline)) _api
-
- #define CALL_GL_API(_api, ...) \
- asm volatile( \
- GET_TLS(r12) \
- "ldr r12, [r12, %[tls]] \n" \
- "cmp r12, #0 \n" \
- "ldrne pc, [r12, %[api]] \n" \
- : \
- : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
- [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "r12" \
- );
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ GET_TLS(r12) \
+ "ldr r12, [r12, %[tls]] \n" \
+ "cmp r12, #0 \n" \
+ "ldrne pc, [r12, %[api]] \n" \
+ : \
+ : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
+ [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "r0", "r1", "r2", "r3", "r12" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov r0, #0 \n" \
+ : \
+ : \
+ : "r0" \
+ );
+
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "bx lr \n" \
+ : \
+ : \
+ : "r0" \
+ );
#elif defined(__aarch64__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
"mrs x16, tpidr_el0\n" \
"ldr x16, [x16, %[tls]]\n" \
: \
: [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "x16" \
+ : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov w0, wzr \n" \
+ : \
+ : \
+ : "w0" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "ret \n" \
+ : \
+ : \
+ : \
);
#elif defined(__i386__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void** fn; \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
__asm__ volatile( \
- "mov %%gs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ "mov %%gs:0, %%eax\n" \
+ "mov %P[tls](%%eax), %%eax\n" \
+ "test %%eax, %%eax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%eax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
+ : "cc", "%eax" \
);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "ret\n" \
+ : \
+ : \
+ : \
+ );
+
#elif defined(__x86_64__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void** fn; \
- __asm__ volatile( \
- "mov %%fs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ __asm__ volatile( \
+ "mov %%fs:0, %%rax\n" \
+ "mov %P[tls](%%rax), %%rax\n" \
+ "test %%rax, %%rax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%rax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
- );
+ : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", \
+ "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+ "%xmm6", "%xmm7" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "retq\n" \
+ : \
+ : \
+ : \
+ );
#elif defined(__mips64)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
-
- #define CALL_GL_API(_api, ...) \
- register unsigned long _t0 asm("$12"); \
- register unsigned long _fn asm("$25"); \
- register unsigned long _tls asm("$3"); \
- register unsigned long _v0 asm("$2"); \
- asm volatile( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "ld %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn], $ra\n\t" \
- "ld %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " nop\n\t" \
- "move %[fn], %[t0]\n\t" \
- "1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
- ".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
- : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
- [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+ // t0: $12
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ ".set push\n\t" \
+ ".set noreorder\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "ld $12, %[OPENGL_API]($3)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " move $25, $ra\n\t" \
+ "ld $12, %[API]($12)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " nop\n\t" \
+ "move $25, $12\n\t" \
+ "1:\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
+ ".set pop\n\t" \
+ : \
+ : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
+ [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", \
+ "$10", "$11", "$12", "$25" \
);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__mips__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register unsigned int _t0 asm("$8"); \
- register unsigned int _fn asm("$25"); \
- register unsigned int _tls asm("$3"); \
- register unsigned int _v0 asm("$2"); \
+ // t0: $8
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
".set push\n\t" \
".set noreorder\n\t" \
".set mips32r2\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "lw %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn],$ra\n\t" \
- "lw %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "lw $3, %[OPENGL_API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
+ " move $25,$ra\n\t" \
+ "lw $3, %[API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
" nop\n\t" \
- "move %[fn], %[t0]\n\t" \
+ "move $25, $3\n\t" \
"1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
+ : \
: [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \
[API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
- );
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25" \
+ );
-#endif
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
-#define CALL_GL_API_RETURN(_api, ...) \
- CALL_GL_API(_api, __VA_ARGS__) \
- return 0;
+#endif
+#define CALL_GL_API(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_DO_RETURN
+#define CALL_GL_API_RETURN(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ CALL_GL_API_INTERNAL_DO_RETURN
extern "C" {
#pragma GCC diagnostic ignored "-Wunused-parameter"
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
/*
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
#if USE_SLOW_BINDING
#define API_ENTRY(_api) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
if (_c) return _c->_api(__VA_ARGS__);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0;
+
+ // This stays blank, since void functions will implicitly return, and
+ // all of the other functions will return 0 based on the previous macro.
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__arm__)
#define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- asm volatile( \
- GET_TLS(r12) \
- "ldr r12, [r12, %[tls]] \n" \
- "cmp r12, #0 \n" \
- "ldrne pc, [r12, %[api]] \n" \
- : \
- : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
- [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "r12" \
- );
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ GET_TLS(r12) \
+ "ldr r12, [r12, %[tls]] \n" \
+ "cmp r12, #0 \n" \
+ "ldrne pc, [r12, %[api]] \n" \
+ : \
+ : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
+ [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "r0", "r1", "r2", "r3", "r12" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov r0, #0 \n" \
+ : \
+ : \
+ : "r0" \
+ );
+
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "bx lr \n" \
+ : \
+ : \
+ : "r0" \
+ );
#elif defined(__aarch64__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
"mrs x16, tpidr_el0\n" \
"ldr x16, [x16, %[tls]]\n" \
: \
: [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "x16" \
+ : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov w0, wzr \n" \
+ : \
+ : \
+ : "w0" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "ret \n" \
+ : \
+ : \
+ : \
);
#elif defined(__i386__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void* fn; \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
__asm__ volatile( \
- "mov %%gs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ "mov %%gs:0, %%eax\n" \
+ "mov %P[tls](%%eax), %%eax\n" \
+ "test %%eax, %%eax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%eax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
- );
+ : "cc", "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "ret\n" \
+ : \
+ : \
+ : \
+ );
#elif defined(__x86_64__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void** fn; \
- __asm__ volatile( \
- "mov %%fs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ __asm__ volatile( \
+ "mov %%fs:0, %%rax\n" \
+ "mov %P[tls](%%rax), %%rax\n" \
+ "test %%rax, %%rax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%rax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
- );
+ : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", \
+ "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+ "%xmm6", "%xmm7" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "retq\n" \
+ : \
+ : \
+ : \
+ );
#elif defined(__mips64)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
-
- #define CALL_GL_API(_api, ...) \
- register unsigned long _t0 asm("$12"); \
- register unsigned long _fn asm("$25"); \
- register unsigned long _tls asm("$3"); \
- register unsigned long _v0 asm("$2"); \
- asm volatile( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "ld %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn], $ra\n\t" \
- "ld %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " nop\n\t" \
- "move %[fn], %[t0]\n\t" \
- "1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
- ".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
- : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
- [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
+
+ // t0: $12
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ ".set push\n\t" \
+ ".set noreorder\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "ld $12, %[OPENGL_API]($3)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " move $25, $ra\n\t" \
+ "ld $12, %[API]($12)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " nop\n\t" \
+ "move $25, $12\n\t" \
+ "1:\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
+ ".set pop\n\t" \
+ : \
+ : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
+ [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", \
+ "$10", "$11", "$12", "$25" \
);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__mips__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register unsigned int _t0 asm("$8"); \
- register unsigned int _fn asm("$25"); \
- register unsigned int _tls asm("$3"); \
- register unsigned int _v0 asm("$2"); \
+ // t0: $8
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
".set push\n\t" \
".set noreorder\n\t" \
".set mips32r2\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "lw %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn], $ra\n\t" \
- "lw %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "lw $3, %[OPENGL_API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
+ " move $25,$ra\n\t" \
+ "lw $3, %[API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
" nop\n\t" \
- "move %[fn], %[t0]\n\t" \
+ "move $25, $3\n\t" \
"1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
+ : \
: [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \
[API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
- );
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
#endif
-#define CALL_GL_API_RETURN(_api, ...) \
- CALL_GL_API(_api, __VA_ARGS__) \
- return 0;
+#define CALL_GL_API(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_DO_RETURN
+#define CALL_GL_API_RETURN(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ CALL_GL_API_INTERNAL_DO_RETURN
extern "C" {
#pragma GCC diagnostic ignored "-Wunused-parameter"
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
/*
--- /dev/null
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+BinPackArguments: true
+BinPackParameters: true
+ColumnLimit: 80
+CommentPragmas: NOLINT:.*
+ContinuationIndentWidth: 8
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
--- /dev/null
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := nativeperms
+LOCAL_SRC_FILES := \
+ nativeperms.cpp \
+ android/os/IPermissionController.aidl
+LOCAL_CFLAGS := -Wall -Werror
+LOCAL_SHARED_LIBRARIES := \
+ libbinder \
+ libbrillo \
+ libbrillo-binder \
+ libchrome \
+ libutils
+LOCAL_INIT_RC := nativeperms.rc
+include $(BUILD_EXECUTABLE)
--- /dev/null
+/* //device/java/android/android/os/IPowerManager.aidl
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.os;
+
+/** @hide */
+interface IPermissionController {
+ boolean checkPermission(String permission, int pid, int uid);
+ String[] getPackagesForUid(int uid);
+ boolean isRuntimePermission(String permission);
+}
--- /dev/null
+IPermissionController.aidl in this directory is a verbatim copy of
+https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/IPermissionController.aidl,
+because some Brillo manifests do not currently include the frameworks/base repo.
+TODO(jorgelo): Figure out a way to use the .aidl file in frameworks/base.
--- /dev/null
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <base/at_exit.h>
+#include <base/logging.h>
+#include <base/message_loop/message_loop.h>
+#include <binder/IServiceManager.h>
+#include <binder/Status.h>
+#include <brillo/binder_watcher.h>
+#include <brillo/message_loops/base_message_loop.h>
+#include <brillo/syslog_logging.h>
+#include <utils/String16.h>
+
+#include "android/os/BnPermissionController.h"
+
+namespace {
+static android::String16 serviceName("permission");
+}
+
+namespace android {
+
+class PermissionService : public android::os::BnPermissionController {
+ public:
+ ::android::binder::Status checkPermission(
+ const ::android::String16& permission, int32_t pid, int32_t uid,
+ bool* _aidl_return) {
+ (void)permission;
+ (void)pid;
+ (void)uid;
+ *_aidl_return = true;
+ return binder::Status::ok();
+ }
+
+ ::android::binder::Status getPackagesForUid(
+ int32_t uid, ::std::vector<::android::String16>* _aidl_return) {
+ (void)uid;
+ // Brillo doesn't currently have installable packages.
+ if (_aidl_return) {
+ _aidl_return->clear();
+ }
+ return binder::Status::ok();
+ }
+
+ ::android::binder::Status isRuntimePermission(
+ const ::android::String16& permission, bool* _aidl_return) {
+ (void)permission;
+ // Brillo doesn't currently have runtime permissions.
+ *_aidl_return = false;
+ return binder::Status::ok();
+ }
+};
+
+} // namespace android
+
+int main() {
+ base::AtExitManager atExitManager;
+ brillo::InitLog(brillo::kLogToSyslog);
+ // Register the service with servicemanager.
+ android::status_t status = android::defaultServiceManager()->addService(
+ serviceName, new android::PermissionService());
+ CHECK(status == android::OK) << "Failed to get IPermissionController "
+ "binder from servicemanager.";
+
+ // Create a message loop.
+ base::MessageLoopForIO messageLoopForIo;
+ brillo::BaseMessageLoop messageLoop{&messageLoopForIo};
+
+ // Initialize a binder watcher.
+ brillo::BinderWatcher watcher(&messageLoop);
+ watcher.Init();
+
+ // Run the message loop.
+ messageLoop.Run();
+}
--- /dev/null
+service nativeperms /system/bin/nativeperms
+ class main
+ user system
+ group system
mSurfaceFlingerConsumer->setContentsChangedListener(this);
mSurfaceFlingerConsumer->setName(mName);
-#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
-#warning "disabling triple buffering"
-#else
+#ifndef TARGET_DISABLE_TRIPLE_BUFFERING
mProducer->setMaxDequeuedBufferCount(2);
#endif