Merge changes from topic "apex_available"
* changes:
Remove apex_test_build_features
Use apex_available instead of no_apex
diff --git a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
index 181046a..7e6f6f5 100644
--- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
+++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp
@@ -216,8 +216,8 @@
duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
}
- static const char* getZipFilePath() {
- return ds.GetPath(".zip").c_str();
+ static const std::string getZipFilePath() {
+ return ds.GetPath(".zip");
}
};
std::shared_ptr<std::vector<SectionInfo>> ZippedBugreportGenerationTest::sections =
@@ -226,12 +226,12 @@
std::chrono::milliseconds ZippedBugreportGenerationTest::duration = 0s;
TEST_F(ZippedBugreportGenerationTest, IsGeneratedWithoutErrors) {
- EXPECT_EQ(access(getZipFilePath(), F_OK), 0);
+ EXPECT_EQ(access(getZipFilePath().c_str(), F_OK), 0);
}
TEST_F(ZippedBugreportGenerationTest, Is3MBto30MBinSize) {
struct stat st;
- EXPECT_EQ(stat(getZipFilePath(), &st), 0);
+ EXPECT_EQ(stat(getZipFilePath().c_str(), &st), 0);
EXPECT_GE(st.st_size, 3000000 /* 3MB */);
EXPECT_LE(st.st_size, 30000000 /* 30MB */);
}
@@ -250,7 +250,7 @@
public:
ZipArchiveHandle handle;
void SetUp() {
- ASSERT_EQ(OpenArchive(ZippedBugreportGenerationTest::getZipFilePath(), &handle), 0);
+ ASSERT_EQ(OpenArchive(ZippedBugreportGenerationTest::getZipFilePath().c_str(), &handle), 0);
}
void TearDown() {
CloseArchive(handle);
@@ -314,7 +314,7 @@
class BugreportSectionTest : public Test {
public:
static void SetUpTestCase() {
- ParseSections(ZippedBugreportGenerationTest::getZipFilePath(),
+ ParseSections(ZippedBugreportGenerationTest::getZipFilePath().c_str(),
ZippedBugreportGenerationTest::sections.get());
}
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index 7eee749..838d11d 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -303,6 +303,9 @@
// Location of the apex image.
static const char* kApexImage = "/system/framework/apex.art";
+// Phenotype property name for enabling profiling the boot class path.
+static const char* PROFILE_BOOT_CLASS_PATH = "profilebootclasspath";
+
class RunDex2Oat : public ExecVHelper {
public:
RunDex2Oat(int zip_fd,
@@ -402,7 +405,15 @@
server_configurable_flags::GetServerConfigurableFlag(RUNTIME_NATIVE_BOOT_NAMESPACE,
ENABLE_APEX_IMAGE,
/*default_value=*/ "");
- if (use_apex_image == "true") {
+
+ std::string profile_boot_class_path = GetProperty("dalvik.vm.profilebootclasspath", "");
+ profile_boot_class_path =
+ server_configurable_flags::GetServerConfigurableFlag(
+ RUNTIME_NATIVE_BOOT_NAMESPACE,
+ PROFILE_BOOT_CLASS_PATH,
+ /*default_value=*/ profile_boot_class_path);
+
+ if (use_apex_image == "true" || profile_boot_class_path == "true") {
boot_image = StringPrintf("-Ximage:%s", kApexImage);
} else {
boot_image = MapPropertyToArg("dalvik.vm.boot-image", "-Ximage:%s");
@@ -709,8 +720,7 @@
const unique_fd& reference_profile_fd,
const std::vector<unique_fd>& apk_fds,
const std::vector<std::string>& dex_locations,
- bool copy_and_update,
- bool store_aggregation_counters) {
+ bool copy_and_update) {
// TODO(calin): Assume for now we run in the bg compile job (which is in
// most of the invocation). With the current data flow, is not very easy or
@@ -742,10 +752,6 @@
AddArg("--copy-and-update-profile-key");
}
- if (store_aggregation_counters) {
- AddArg("--store-aggregation-counters");
- }
-
// Do not add after dex2oat_flags, they should override others for debugging.
PrepareArgs(profman_bin);
}
@@ -753,14 +759,12 @@
void SetupMerge(const std::vector<unique_fd>& profiles_fd,
const unique_fd& reference_profile_fd,
const std::vector<unique_fd>& apk_fds = std::vector<unique_fd>(),
- const std::vector<std::string>& dex_locations = std::vector<std::string>(),
- bool store_aggregation_counters = false) {
+ const std::vector<std::string>& dex_locations = std::vector<std::string>()) {
SetupArgs(profiles_fd,
reference_profile_fd,
apk_fds,
dex_locations,
- /*copy_and_update=*/false,
- store_aggregation_counters);
+ /*copy_and_update=*/false);
}
void SetupCopyAndUpdate(unique_fd&& profile_fd,
@@ -777,8 +781,7 @@
reference_profile_fd_,
apk_fds_,
dex_locations,
- /*copy_and_update=*/true,
- /*store_aggregation_counters=*/false);
+ /*copy_and_update=*/true);
}
void SetupDump(const std::vector<unique_fd>& profiles_fd,
@@ -792,8 +795,7 @@
reference_profile_fd,
apk_fds,
dex_locations,
- /*copy_and_update=*/false,
- /*store_aggregation_counters=*/false);
+ /*copy_and_update=*/false);
}
void Exec() {
@@ -2828,8 +2830,7 @@
args.SetupMerge(profiles_fd,
snapshot_fd,
apk_fds,
- dex_locations,
- /*store_aggregation_counters=*/true);
+ dex_locations);
pid_t pid = fork();
if (pid == 0) {
/* child -- drop privileges before continuing */
diff --git a/cmds/servicemanager/Access.cpp b/cmds/servicemanager/Access.cpp
index 606477f..b7e520f 100644
--- a/cmds/servicemanager/Access.cpp
+++ b/cmds/servicemanager/Access.cpp
@@ -137,7 +137,7 @@
bool Access::actionAllowedFromLookup(const CallingContext& sctx, const std::string& name, const char *perm) {
char *tctx = nullptr;
- if (selabel_lookup(getSehandle(), &tctx, name.c_str(), 0) != 0) {
+ if (selabel_lookup(getSehandle(), &tctx, name.c_str(), SELABEL_CTX_ANDROID_SERVICE) != 0) {
LOG(ERROR) << "SELinux: No match for " << name << " in service_contexts.\n";
return false;
}
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index ee637e2..a30df14 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -43,6 +43,47 @@
using AidlServiceManager = android::os::IServiceManager;
using android::binder::Status;
+// libbinder's IServiceManager.h can't rely on the values generated by AIDL
+// because many places use its headers via include_dirs (meaning, without
+// declaring the dependency in the build system). So, for now, we can just check
+// the values here.
+static_assert(AidlServiceManager::DUMP_FLAG_PRIORITY_CRITICAL == IServiceManager::DUMP_FLAG_PRIORITY_CRITICAL);
+static_assert(AidlServiceManager::DUMP_FLAG_PRIORITY_HIGH == IServiceManager::DUMP_FLAG_PRIORITY_HIGH);
+static_assert(AidlServiceManager::DUMP_FLAG_PRIORITY_NORMAL == IServiceManager::DUMP_FLAG_PRIORITY_NORMAL);
+static_assert(AidlServiceManager::DUMP_FLAG_PRIORITY_DEFAULT == IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT);
+static_assert(AidlServiceManager::DUMP_FLAG_PRIORITY_ALL == IServiceManager::DUMP_FLAG_PRIORITY_ALL);
+static_assert(AidlServiceManager::DUMP_FLAG_PROTO == IServiceManager::DUMP_FLAG_PROTO);
+
+const String16& IServiceManager::getInterfaceDescriptor() const {
+ return AidlServiceManager::descriptor;
+}
+IServiceManager::IServiceManager() {}
+IServiceManager::~IServiceManager() {}
+
+// From the old libbinder IServiceManager interface to IServiceManager.
+class ServiceManagerShim : public IServiceManager
+{
+public:
+ explicit ServiceManagerShim (const sp<AidlServiceManager>& impl);
+
+ sp<IBinder> getService(const String16& name) const override;
+ sp<IBinder> checkService(const String16& name) const override;
+ status_t addService(const String16& name, const sp<IBinder>& service,
+ bool allowIsolated, int dumpsysPriority) override;
+ Vector<String16> listServices(int dumpsysPriority) override;
+ sp<IBinder> waitForService(const String16& name16) override;
+
+ // for legacy ABI
+ const String16& getInterfaceDescriptor() const override {
+ return mTheRealServiceManager->getInterfaceDescriptor();
+ }
+ IBinder* onAsBinder() override {
+ return IInterface::asBinder(mTheRealServiceManager).get();
+ }
+private:
+ sp<AidlServiceManager> mTheRealServiceManager;
+};
+
sp<IServiceManager> defaultServiceManager()
{
static Mutex gDefaultServiceManagerLock;
@@ -53,8 +94,9 @@
{
AutoMutex _l(gDefaultServiceManagerLock);
while (gDefaultServiceManager == nullptr) {
- gDefaultServiceManager = interface_cast<IServiceManager>(
- ProcessState::self()->getContextObject(nullptr));
+ gDefaultServiceManager = new ServiceManagerShim(
+ interface_cast<AidlServiceManager>(
+ ProcessState::self()->getContextObject(nullptr)));
if (gDefaultServiceManager == nullptr)
sleep(1);
}
@@ -147,142 +189,136 @@
// ----------------------------------------------------------------------
-class BpServiceManager : public BpInterface<IServiceManager>
-{
-public:
- explicit BpServiceManager(const sp<IBinder>& impl)
- : BpInterface<IServiceManager>(impl),
- mTheRealServiceManager(interface_cast<AidlServiceManager>(impl))
- {
- }
+ServiceManagerShim::ServiceManagerShim(const sp<AidlServiceManager>& impl)
+ : mTheRealServiceManager(impl)
+{}
- sp<IBinder> getService(const String16& name) const override
- {
- static bool gSystemBootCompleted = false;
+sp<IBinder> ServiceManagerShim::getService(const String16& name) const
+{
+ static bool gSystemBootCompleted = false;
+
+ sp<IBinder> svc = checkService(name);
+ if (svc != nullptr) return svc;
+
+ const bool isVendorService =
+ strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder") == 0;
+ const long timeout = uptimeMillis() + 5000;
+ // Vendor code can't access system properties
+ if (!gSystemBootCompleted && !isVendorService) {
+#ifdef __ANDROID__
+ char bootCompleted[PROPERTY_VALUE_MAX];
+ property_get("sys.boot_completed", bootCompleted, "0");
+ gSystemBootCompleted = strcmp(bootCompleted, "1") == 0 ? true : false;
+#else
+ gSystemBootCompleted = true;
+#endif
+ }
+ // retry interval in millisecond; note that vendor services stay at 100ms
+ const long sleepTime = gSystemBootCompleted ? 1000 : 100;
+
+ int n = 0;
+ while (uptimeMillis() < timeout) {
+ n++;
+ ALOGI("Waiting for service '%s' on '%s'...", String8(name).string(),
+ ProcessState::self()->getDriverName().c_str());
+ usleep(1000*sleepTime);
sp<IBinder> svc = checkService(name);
if (svc != nullptr) return svc;
+ }
+ ALOGW("Service %s didn't start. Returning NULL", String8(name).string());
+ return nullptr;
+}
- const bool isVendorService =
- strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder") == 0;
- const long timeout = uptimeMillis() + 5000;
- // Vendor code can't access system properties
- if (!gSystemBootCompleted && !isVendorService) {
-#ifdef __ANDROID__
- char bootCompleted[PROPERTY_VALUE_MAX];
- property_get("sys.boot_completed", bootCompleted, "0");
- gSystemBootCompleted = strcmp(bootCompleted, "1") == 0 ? true : false;
-#else
- gSystemBootCompleted = true;
-#endif
+sp<IBinder> ServiceManagerShim::checkService(const String16& name) const
+{
+ sp<IBinder> ret;
+ if (!mTheRealServiceManager->checkService(String8(name).c_str(), &ret).isOk()) {
+ return nullptr;
+ }
+ return ret;
+}
+
+status_t ServiceManagerShim::addService(const String16& name, const sp<IBinder>& service,
+ bool allowIsolated, int dumpsysPriority)
+{
+ Status status = mTheRealServiceManager->addService(
+ String8(name).c_str(), service, allowIsolated, dumpsysPriority);
+ return status.exceptionCode();
+}
+
+Vector<String16> ServiceManagerShim::listServices(int dumpsysPriority)
+{
+ std::vector<std::string> ret;
+ if (!mTheRealServiceManager->listServices(dumpsysPriority, &ret).isOk()) {
+ return {};
+ }
+
+ Vector<String16> res;
+ res.setCapacity(ret.size());
+ for (const std::string& name : ret) {
+ res.push(String16(name.c_str()));
+ }
+ return res;
+}
+
+sp<IBinder> ServiceManagerShim::waitForService(const String16& name16)
+{
+ class Waiter : public android::os::BnServiceCallback {
+ Status onRegistration(const std::string& /*name*/,
+ const sp<IBinder>& binder) override {
+ std::unique_lock<std::mutex> lock(mMutex);
+ mBinder = binder;
+ lock.unlock();
+ mCv.notify_one();
+ return Status::ok();
}
- // retry interval in millisecond; note that vendor services stay at 100ms
- const long sleepTime = gSystemBootCompleted ? 1000 : 100;
+ public:
+ sp<IBinder> mBinder;
+ std::mutex mMutex;
+ std::condition_variable mCv;
+ };
- int n = 0;
- while (uptimeMillis() < timeout) {
- n++;
- ALOGI("Waiting for service '%s' on '%s'...", String8(name).string(),
- ProcessState::self()->getDriverName().c_str());
- usleep(1000*sleepTime);
+ const std::string name = String8(name16).c_str();
- sp<IBinder> svc = checkService(name);
- if (svc != nullptr) return svc;
- }
- ALOGW("Service %s didn't start. Returning NULL", String8(name).string());
+ sp<IBinder> out;
+ if (!mTheRealServiceManager->getService(name, &out).isOk()) {
+ return nullptr;
+ }
+ if(out != nullptr) return out;
+
+ sp<Waiter> waiter = new Waiter;
+ if (!mTheRealServiceManager->registerForNotifications(
+ name, waiter).isOk()) {
return nullptr;
}
- sp<IBinder> checkService(const String16& name) const override {
- sp<IBinder> ret;
- if (!mTheRealServiceManager->checkService(String8(name).c_str(), &ret).isOk()) {
- return nullptr;
- }
- return ret;
- }
-
- status_t addService(const String16& name, const sp<IBinder>& service,
- bool allowIsolated, int dumpsysPriority) override {
- Status status = mTheRealServiceManager->addService(String8(name).c_str(), service, allowIsolated, dumpsysPriority);
- return status.exceptionCode();
- }
-
- virtual Vector<String16> listServices(int dumpsysPriority) {
- std::vector<std::string> ret;
- if (!mTheRealServiceManager->listServices(dumpsysPriority, &ret).isOk()) {
- return {};
+ while(true) {
+ {
+ std::unique_lock<std::mutex> lock(waiter->mMutex);
+ using std::literals::chrono_literals::operator""s;
+ waiter->mCv.wait_for(lock, 1s, [&] {
+ return waiter->mBinder != nullptr;
+ });
+ if (waiter->mBinder != nullptr) return waiter->mBinder;
}
- Vector<String16> res;
- res.setCapacity(ret.size());
- for (const std::string& name : ret) {
- res.push(String16(name.c_str()));
- }
- return res;
- }
-
- sp<IBinder> waitForService(const String16& name16) override {
- class Waiter : public android::os::BnServiceCallback {
- Status onRegistration(const std::string& /*name*/,
- const sp<IBinder>& binder) override {
- std::unique_lock<std::mutex> lock(mMutex);
- mBinder = binder;
- lock.unlock();
- mCv.notify_one();
- return Status::ok();
- }
- public:
- sp<IBinder> mBinder;
- std::mutex mMutex;
- std::condition_variable mCv;
- };
-
- const std::string name = String8(name16).c_str();
-
- sp<IBinder> out;
+ // Handle race condition for lazy services. Here is what can happen:
+ // - the service dies (not processed by init yet).
+ // - sm processes death notification.
+ // - sm gets getService and calls init to start service.
+ // - init gets the start signal, but the service already appears
+ // started, so it does nothing.
+ // - init gets death signal, but doesn't know it needs to restart
+ // the service
+ // - we need to request service again to get it to start
if (!mTheRealServiceManager->getService(name, &out).isOk()) {
return nullptr;
}
if(out != nullptr) return out;
- sp<Waiter> waiter = new Waiter;
- if (!mTheRealServiceManager->registerForNotifications(
- name, waiter).isOk()) {
- return nullptr;
- }
-
- while(true) {
- {
- std::unique_lock<std::mutex> lock(waiter->mMutex);
- using std::literals::chrono_literals::operator""s;
- waiter->mCv.wait_for(lock, 1s, [&] {
- return waiter->mBinder != nullptr;
- });
- if (waiter->mBinder != nullptr) return waiter->mBinder;
- }
-
- // Handle race condition for lazy services. Here is what can happen:
- // - the service dies (not processed by init yet).
- // - sm processes death notification.
- // - sm gets getService and calls init to start service.
- // - init gets the start signal, but the service already appears
- // started, so it does nothing.
- // - init gets death signal, but doesn't know it needs to restart
- // the service
- // - we need to request service again to get it to start
- if (!mTheRealServiceManager->getService(name, &out).isOk()) {
- return nullptr;
- }
- if(out != nullptr) return out;
-
- ALOGW("Waited one second for %s", name.c_str());
- }
+ ALOGW("Waited one second for %s", name.c_str());
}
-
-private:
- sp<AidlServiceManager> mTheRealServiceManager;
-};
-
-IMPLEMENT_META_INTERFACE(ServiceManager, "android.os.IServiceManager");
+}
} // namespace android
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h
index 5793a1c..28ffa48 100644
--- a/libs/binder/include/binder/IInterface.h
+++ b/libs/binder/include/binder/IInterface.h
@@ -88,8 +88,12 @@
public: \
+#define __IINTF_CONCAT(x, y) (x ## y)
#define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \
- const ::android::String16 I##INTERFACE::descriptor(NAME); \
+ const ::android::StaticString16 \
+ I##INTERFACE##_descriptor_static_str16(__IINTF_CONCAT(u, NAME));\
+ const ::android::String16 I##INTERFACE::descriptor( \
+ I##INTERFACE##_descriptor_static_str16); \
const ::android::String16& \
I##INTERFACE::getInterfaceDescriptor() const { \
return I##INTERFACE::descriptor; \
diff --git a/libs/binder/include/binder/IServiceManager.h b/libs/binder/include/binder/IServiceManager.h
index def1bea..a675513 100644
--- a/libs/binder/include/binder/IServiceManager.h
+++ b/libs/binder/include/binder/IServiceManager.h
@@ -26,12 +26,22 @@
// ----------------------------------------------------------------------
+/**
+ * Service manager for C++ services.
+ *
+ * IInterface is only for legacy ABI compatibility
+ */
class IServiceManager : public IInterface
{
public:
- DECLARE_META_INTERFACE(ServiceManager)
+ // for ABI compatibility
+ virtual const String16& getInterfaceDescriptor() const;
+
+ IServiceManager();
+ virtual ~IServiceManager();
+
/**
- * Must match values in IServiceManager.java
+ * Must match values in IServiceManager.aidl
*/
/* Allows services to dump sections according to priorities. */
static const int DUMP_FLAG_PRIORITY_CRITICAL = 1 << 0;