源码位置: frameworks/native/libs/binder/BpBinder.cpp
frameworks/native/include/binder/BpBinder.h
方法
-
构造函数
138 BpBinder::BpBinder(int32_t handle, int32_t trackedUid) 139 : mHandle(handle) 140 , mAlive(1) 141 , mObitsSent(0) 142 , mObituaries(nullptr) 143 , mTrackedUid(trackedUid) 144 { 145 ALOGV("Creating BpBinder %p handle %d\n", this, mHandle); 146 147 extendObjectLifetime(OBJECT_LIFETIME_WEAK); 148 IPCThreadState::self()->incWeakHandle(handle, this); 149 }
-
create
109 BpBinder* BpBinder::create(int32_t handle) { 110 int32_t trackedUid = -1; 111 if (sCountByUidEnabled) { 112 trackedUid = IPCThreadState::self()->getCallingUid(); 113 AutoMutex _l(sTrackingLock); 114 uint32_t trackedValue = sTrackingMap[trackedUid]; 115 if (CC_UNLIKELY(trackedValue & LIMIT_REACHED_MASK)) { 116 if (sBinderProxyThrottleCreate) { 117 return nullptr; 118 } 119 } else { 120 if ((trackedValue & COUNTING_VALUE_MASK) >= sBinderProxyCountHighWatermark) { 121 ALOGE("Too many binder proxy objects sent to uid %d from uid %d (%d proxies held)", 122 getuid(), trackedUid, trackedValue); 123 sTrackingMap[trackedUid] |= LIMIT_REACHED_MASK; 124 if (sLimitCallback) sLimitCallback(trackedUid); 125 if (sBinderProxyThrottleCreate) { 126 ALOGI("Throttling binder proxy creates from uid %d in uid %d until binder proxy" 127 " count drops below %d", 128 trackedUid, getuid(), sBinderProxyCountLowWatermark); 129 return nullptr; 130 } 131 } 132 } 133 sTrackingMap[trackedUid]++; 134 } 135 return new BpBinder(handle, trackedUid); 136 }
IPCThreadState类见http://xinyiworld.top/wordpress_it/?p=14487
0 条评论