Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 17 | #include <android/binder_manager.h> |
| 18 | #include <android/binder_stability.h> |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 19 | #include <binder/Binder.h> |
| 20 | #include <binder/IBinder.h> |
| 21 | #include <binder/IPCThreadState.h> |
| 22 | #include <binder/IServiceManager.h> |
| 23 | #include <binder/Parcel.h> |
| 24 | #include <binder/Stability.h> |
| 25 | #include <gtest/gtest.h> |
| 26 | |
| 27 | #include <sys/prctl.h> |
| 28 | |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 29 | #include "aidl/BnBinderStabilityTest.h" |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 30 | #include "BnBinderStabilityTest.h" |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 31 | |
| 32 | using namespace android; |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 33 | using namespace ndk; |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 34 | using android::binder::Status; |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 35 | using android::internal::Stability; // for testing only! |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 36 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 37 | const String16 kSystemStabilityServer = String16("binder_stability_test_service_system"); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 38 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 39 | // This is handwritten so that we can test different stability levels w/o having the AIDL |
| 40 | // compiler assign them. Hand-writing binder interfaces is considered a bad practice |
| 41 | // sanity reasons. YOU SHOULD DEFINE AN AIDL INTERFACE INSTEAD! |
| 42 | class BadStableBinder : public BBinder { |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 43 | public: |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 44 | static constexpr uint32_t USER_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION; |
| 45 | static String16 kDescriptor; |
| 46 | |
| 47 | bool gotUserTransaction = false; |
| 48 | |
| 49 | static status_t doUserTransaction(const sp<IBinder>& binder) { |
| 50 | Parcel data, reply; |
| 51 | data.writeInterfaceToken(kDescriptor); |
| 52 | return binder->transact(USER_TRANSACTION, data, &reply, 0/*flags*/); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 53 | } |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 54 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 55 | status_t onTransact(uint32_t code, |
| 56 | const Parcel& data, Parcel* reply, uint32_t flags) override { |
| 57 | if (code == USER_TRANSACTION) { |
| 58 | // not interested in this kind of stability. Make sure |
| 59 | // we have a test failure |
| 60 | LOG_ALWAYS_FATAL_IF(!data.enforceInterface(kDescriptor)); |
| 61 | |
| 62 | gotUserTransaction = true; |
| 63 | |
| 64 | ALOGE("binder stability: Got user transaction"); |
| 65 | return OK; |
| 66 | } |
| 67 | return BBinder::onTransact(code, data, reply, flags); |
| 68 | } |
| 69 | |
| 70 | static sp<BadStableBinder> undef() { |
| 71 | sp<BadStableBinder> iface = new BadStableBinder(); |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 72 | return iface; |
| 73 | } |
| 74 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 75 | static sp<BadStableBinder> system() { |
| 76 | sp<BadStableBinder> iface = new BadStableBinder(); |
| 77 | Stability::markCompilationUnit(iface.get()); // <- for test only |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 78 | return iface; |
| 79 | } |
| 80 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 81 | static sp<BadStableBinder> vintf() { |
| 82 | sp<BadStableBinder> iface = new BadStableBinder(); |
| 83 | Stability::markVintf(iface.get()); // <- for test only |
| 84 | return iface; |
| 85 | } |
| 86 | |
| 87 | static sp<BadStableBinder> vendor() { |
| 88 | sp<BadStableBinder> iface = new BadStableBinder(); |
| 89 | Stability::markVndk(iface.get()); // <- for test only |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 90 | return iface; |
| 91 | } |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 92 | }; |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 93 | String16 BadStableBinder::kDescriptor = String16("BadStableBinder.test"); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 94 | |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 95 | // NO! NO! NO! Do not even think of doing something like this! |
| 96 | // This is for testing! If a class like this was actually used in production, |
| 97 | // it would ruin everything! |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 98 | class MyBinderStabilityTest : public BnBinderStabilityTest { |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 99 | public: |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 100 | Status sendBinder(const sp<IBinder>& /*binder*/) override { |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 101 | return Status::ok(); |
| 102 | } |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 103 | Status sendAndCallBinder(const sp<IBinder>& binder) override { |
| 104 | Stability::debugLogStability("sendAndCallBinder got binder", binder); |
| 105 | return Status::fromExceptionCode(BadStableBinder::doUserTransaction(binder)); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 106 | } |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 107 | Status returnNoStabilityBinder(sp<IBinder>* _aidl_return) override { |
| 108 | *_aidl_return = BadStableBinder::undef(); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 109 | return Status::ok(); |
| 110 | } |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 111 | Status returnLocalStabilityBinder(sp<IBinder>* _aidl_return) override { |
| 112 | *_aidl_return = BadStableBinder::system(); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 113 | return Status::ok(); |
| 114 | } |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 115 | Status returnVintfStabilityBinder(sp<IBinder>* _aidl_return) override { |
| 116 | *_aidl_return = BadStableBinder::vintf(); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 117 | return Status::ok(); |
| 118 | } |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 119 | Status returnVendorStabilityBinder(sp<IBinder>* _aidl_return) override { |
| 120 | *_aidl_return = BadStableBinder::vendor(); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 121 | return Status::ok(); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 122 | } |
| 123 | }; |
| 124 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 125 | TEST(BinderStability, CantCallVendorBinderInSystemContext) { |
| 126 | sp<IBinder> serverBinder = android::defaultServiceManager()->getService(kSystemStabilityServer); |
| 127 | auto server = interface_cast<IBinderStabilityTest>(serverBinder); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 128 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 129 | ASSERT_NE(nullptr, server.get()); |
| 130 | ASSERT_NE(nullptr, IInterface::asBinder(server)->remoteBinder()); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 131 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 132 | EXPECT_TRUE(server->sendBinder(BadStableBinder::undef()).isOk()); |
| 133 | EXPECT_TRUE(server->sendBinder(BadStableBinder::system()).isOk()); |
| 134 | EXPECT_TRUE(server->sendBinder(BadStableBinder::vintf()).isOk()); |
| 135 | EXPECT_TRUE(server->sendBinder(BadStableBinder::vendor()).isOk()); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 136 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 137 | { |
| 138 | sp<BadStableBinder> binder = BadStableBinder::undef(); |
| 139 | EXPECT_TRUE(server->sendAndCallBinder(binder).isOk()); |
| 140 | EXPECT_TRUE(binder->gotUserTransaction); |
| 141 | } |
| 142 | { |
| 143 | sp<BadStableBinder> binder = BadStableBinder::system(); |
| 144 | EXPECT_TRUE(server->sendAndCallBinder(binder).isOk()); |
| 145 | EXPECT_TRUE(binder->gotUserTransaction); |
| 146 | } |
| 147 | { |
| 148 | sp<BadStableBinder> binder = BadStableBinder::vintf(); |
| 149 | EXPECT_TRUE(server->sendAndCallBinder(binder).isOk()); |
| 150 | EXPECT_TRUE(binder->gotUserTransaction); |
| 151 | } |
| 152 | { |
| 153 | // !!! user-defined transaction may not be stable for remote server !!! |
| 154 | // !!! so, it does not work !!! |
| 155 | sp<BadStableBinder> binder = BadStableBinder::vendor(); |
| 156 | EXPECT_EQ(BAD_TYPE, server->sendAndCallBinder(binder).exceptionCode()); |
| 157 | EXPECT_FALSE(binder->gotUserTransaction); |
| 158 | } |
| 159 | |
| 160 | sp<IBinder> out; |
| 161 | EXPECT_TRUE(server->returnNoStabilityBinder(&out).isOk()); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 162 | ASSERT_NE(nullptr, out.get()); |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 163 | EXPECT_EQ(OK, out->pingBinder()); |
| 164 | EXPECT_EQ(OK, BadStableBinder::doUserTransaction(out)); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 165 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 166 | EXPECT_TRUE(server->returnLocalStabilityBinder(&out).isOk()); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 167 | ASSERT_NE(nullptr, out.get()); |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 168 | EXPECT_EQ(OK, out->pingBinder()); |
| 169 | EXPECT_EQ(OK, BadStableBinder::doUserTransaction(out)); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 170 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 171 | EXPECT_TRUE(server->returnVintfStabilityBinder(&out).isOk()); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 172 | ASSERT_NE(nullptr, out.get()); |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 173 | EXPECT_EQ(OK, out->pingBinder()); |
| 174 | EXPECT_EQ(OK, BadStableBinder::doUserTransaction(out)); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 175 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 176 | EXPECT_TRUE(server->returnVendorStabilityBinder(&out).isOk()); |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 177 | ASSERT_NE(nullptr, out.get()); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 178 | |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 179 | // !!! libbinder-defined transaction works !!! |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 180 | EXPECT_EQ(OK, out->pingBinder()); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 181 | |
Steven Moreland | c709dd8 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 182 | // !!! user-defined transaction may not be stable !!! |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 183 | // !!! so, it does not work !!! |
| 184 | EXPECT_EQ(BAD_TYPE, BadStableBinder::doUserTransaction(out)); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 187 | // This is handwritten so that we can test different stability levels w/o having the AIDL |
| 188 | // compiler assign them. Hand-writing binder interfaces is considered a bad practice |
| 189 | // sanity reasons. YOU SHOULD DEFINE AN AIDL INTERFACE INSTEAD! |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 190 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 191 | struct NdkBinderStable_DataClass { |
| 192 | bool gotUserTransaction = false; |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 193 | }; |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 194 | void* NdkBadStableBinder_Class_onCreate(void* args) { |
| 195 | LOG_ALWAYS_FATAL_IF(args != nullptr, "Takes no args"); |
| 196 | return static_cast<void*>(new NdkBinderStable_DataClass); |
| 197 | } |
| 198 | void NdkBadStableBinder_Class_onDestroy(void* userData) { |
| 199 | delete static_cast<NdkBinderStable_DataClass*>(userData); |
| 200 | } |
| 201 | NdkBinderStable_DataClass* NdkBadStableBinder_getUserData(AIBinder* binder) { |
| 202 | LOG_ALWAYS_FATAL_IF(binder == nullptr); |
| 203 | void* userData = AIBinder_getUserData(binder); |
| 204 | LOG_ALWAYS_FATAL_IF(userData == nullptr, "null data - binder is remote?"); |
| 205 | |
| 206 | return static_cast<NdkBinderStable_DataClass*>(userData); |
| 207 | } |
| 208 | binder_status_t NdkBadStableBinder_Class_onTransact( |
| 209 | AIBinder* binder, transaction_code_t code, const AParcel* /*in*/, AParcel* /*out*/) { |
| 210 | |
| 211 | if (code == BadStableBinder::USER_TRANSACTION) { |
| 212 | ALOGE("ndk binder stability: Got user transaction"); |
| 213 | NdkBadStableBinder_getUserData(binder)->gotUserTransaction = true; |
| 214 | return STATUS_OK; |
| 215 | } |
| 216 | |
| 217 | return STATUS_UNKNOWN_TRANSACTION; |
| 218 | } |
| 219 | |
| 220 | static AIBinder_Class* kNdkBadStableBinder = |
| 221 | AIBinder_Class_define(String8(BadStableBinder::kDescriptor).c_str(), |
| 222 | NdkBadStableBinder_Class_onCreate, |
| 223 | NdkBadStableBinder_Class_onDestroy, |
| 224 | NdkBadStableBinder_Class_onTransact); |
| 225 | |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 226 | // for testing only to get around __ANDROID_VNDK__ guard. |
| 227 | extern "C" void AIBinder_markVendorStability(AIBinder* binder); // <- BAD DO NOT COPY |
| 228 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 229 | TEST(BinderStability, NdkCantCallVendorBinderInSystemContext) { |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 230 | SpAIBinder binder = SpAIBinder(AServiceManager_getService( |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 231 | String8(kSystemStabilityServer).c_str())); |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 232 | |
| 233 | std::shared_ptr<aidl::IBinderStabilityTest> remoteServer = |
| 234 | aidl::IBinderStabilityTest::fromBinder(binder); |
| 235 | |
| 236 | ASSERT_NE(nullptr, remoteServer.get()); |
| 237 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 238 | SpAIBinder comp = SpAIBinder(AIBinder_new(kNdkBadStableBinder, nullptr /*args*/)); |
| 239 | EXPECT_TRUE(remoteServer->sendBinder(comp).isOk()); |
| 240 | EXPECT_TRUE(remoteServer->sendAndCallBinder(comp).isOk()); |
| 241 | EXPECT_TRUE(NdkBadStableBinder_getUserData(comp.get())->gotUserTransaction); |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 242 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 243 | SpAIBinder vendor = SpAIBinder(AIBinder_new(kNdkBadStableBinder, nullptr /*args*/)); |
| 244 | AIBinder_markVendorStability(vendor.get()); |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 245 | EXPECT_TRUE(remoteServer->sendBinder(vendor).isOk()); |
| 246 | EXPECT_FALSE(remoteServer->sendAndCallBinder(vendor).isOk()); |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 247 | EXPECT_FALSE(NdkBadStableBinder_getUserData(vendor.get())->gotUserTransaction); |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 250 | class MarksStabilityInConstructor : public BBinder { |
| 251 | public: |
| 252 | static bool gDestructed; |
| 253 | |
| 254 | MarksStabilityInConstructor() { |
Steven Moreland | 12300a0 | 2019-08-02 13:27:15 -0700 | [diff] [blame] | 255 | Stability::markCompilationUnit(this); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 256 | } |
| 257 | ~MarksStabilityInConstructor() { |
| 258 | gDestructed = true; |
| 259 | } |
| 260 | }; |
| 261 | bool MarksStabilityInConstructor::gDestructed = false; |
| 262 | |
| 263 | TEST(BinderStability, MarkingObjectNoDestructTest) { |
| 264 | ASSERT_FALSE(MarksStabilityInConstructor::gDestructed); |
| 265 | |
| 266 | // best practice is to put this directly in an sp, but for this test, we |
| 267 | // want to explicitly check what happens before that happens |
| 268 | MarksStabilityInConstructor* binder = new MarksStabilityInConstructor(); |
| 269 | ASSERT_FALSE(MarksStabilityInConstructor::gDestructed); |
| 270 | |
| 271 | sp<MarksStabilityInConstructor> binderSp = binder; |
| 272 | ASSERT_FALSE(MarksStabilityInConstructor::gDestructed); |
| 273 | |
| 274 | binderSp = nullptr; |
| 275 | ASSERT_TRUE(MarksStabilityInConstructor::gDestructed); |
| 276 | } |
| 277 | |
| 278 | int main(int argc, char** argv) { |
| 279 | ::testing::InitGoogleTest(&argc, argv); |
| 280 | |
| 281 | if (fork() == 0) { |
| 282 | // child process |
| 283 | prctl(PR_SET_PDEATHSIG, SIGHUP); |
| 284 | |
Steven Moreland | 43564fd | 2019-08-08 17:27:12 -0700 | [diff] [blame^] | 285 | sp<IBinder> server = new MyBinderStabilityTest; |
| 286 | android::defaultServiceManager()->addService(kSystemStabilityServer, server); |
Steven Moreland | dea3cf9 | 2019-07-16 18:06:55 -0700 | [diff] [blame] | 287 | |
| 288 | IPCThreadState::self()->joinThreadPool(true); |
| 289 | exit(1); // should not reach |
| 290 | } |
| 291 | |
| 292 | // This is not racey. Just giving these services some time to register before we call |
| 293 | // getService which sleeps for much longer... |
| 294 | usleep(10000); |
| 295 | |
| 296 | return RUN_ALL_TESTS(); |
| 297 | } |