Skip to content

Commit 4a5441f

Browse files
author
Yu-Ting Tseng
committed
Placeholder for binder freeze notification API.
Adding the placeholder APIs to validate whether this breaks existing prebuilts. Bug: 338097747 Change-Id: Id7357076ad98c1f220a78186fe509326047cf922 Test: m
1 parent ac72879 commit 4a5441f

5 files changed

Lines changed: 43 additions & 3 deletions

File tree

libs/binder/Binder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ status_t BBinder::unlinkToDeath(
441441
return INVALID_OPERATION;
442442
}
443443

444+
status_t BBinder::addFrozenStateChangeCallback(const wp<FrozenStateChangeCallback>&) {
445+
return INVALID_OPERATION;
446+
}
447+
448+
status_t BBinder::removeFrozenStateChangeCallback(const wp<FrozenStateChangeCallback>&) {
449+
return INVALID_OPERATION;
450+
}
451+
444452
status_t BBinder::dump(int /*fd*/, const Vector<String16>& /*args*/)
445453
{
446454
return NO_ERROR;

libs/binder/BpBinder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ void BpBinder::sendObituary()
557557
}
558558
}
559559

560+
status_t BpBinder::addFrozenStateChangeCallback(const wp<FrozenStateChangeCallback>&) {
561+
return INVALID_OPERATION;
562+
}
563+
564+
status_t BpBinder::removeFrozenStateChangeCallback(const wp<FrozenStateChangeCallback>&) {
565+
return INVALID_OPERATION;
566+
}
567+
560568
void BpBinder::reportOneDeath(const Obituary& obit)
561569
{
562570
sp<DeathRecipient> recipient = obit.recipient.promote();

libs/binder/include/binder/Binder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class BBinder : public IBinder {
5050
void* cookie = nullptr, uint32_t flags = 0,
5151
wp<DeathRecipient>* outRecipient = nullptr);
5252

53+
// Placeholders to test if adding virtual functions here breaks things.
54+
// Will be replaced by an actual API once things are verified to work.
55+
LIBBINDER_EXPORTED virtual status_t addFrozenStateChangeCallback(
56+
const wp<FrozenStateChangeCallback>& callback);
57+
LIBBINDER_EXPORTED virtual status_t removeFrozenStateChangeCallback(
58+
const wp<FrozenStateChangeCallback>& callback);
59+
5360
LIBBINDER_EXPORTED virtual void* attachObject(const void* objectID, void* object,
5461
void* cleanupCookie,
5562
object_cleanup_func func) final;

libs/binder/include/binder/BpBinder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class BpBinder : public IBinder {
6666
void* cookie = nullptr, uint32_t flags = 0,
6767
wp<DeathRecipient>* outRecipient = nullptr);
6868

69+
[[nodiscard]] virtual status_t addFrozenStateChangeCallback(
70+
const wp<FrozenStateChangeCallback>& recipient);
71+
72+
[[nodiscard]] virtual status_t removeFrozenStateChangeCallback(
73+
const wp<FrozenStateChangeCallback>& recipient);
74+
6975
LIBBINDER_EXPORTED virtual void* attachObject(const void* objectID, void* object,
7076
void* cleanupCookie,
7177
object_cleanup_func func) final;

libs/binder/include/binder/IBinder.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,14 @@ class [[clang::lto_visibility_public]] LIBBINDER_EXPORTED IBinder : public virtu
198198
virtual void binderDied(const wp<IBinder>& who) = 0;
199199
};
200200

201-
#if defined(__clang__)
202-
#pragma clang diagnostic pop
203-
#endif
201+
class FrozenStateChangeCallback : public virtual RefBase {
202+
public:
203+
virtual void onStateChanged(const wp<IBinder>& who, bool isFrozen) = 0;
204+
};
205+
206+
#if defined(__clang__)
207+
#pragma clang diagnostic pop
208+
#endif
204209

205210
/**
206211
* Register the @a recipient for a notification if this binder
@@ -249,6 +254,12 @@ class [[clang::lto_visibility_public]] LIBBINDER_EXPORTED IBinder : public virtu
249254
uint32_t flags = 0,
250255
wp<DeathRecipient>* outRecipient = nullptr) = 0;
251256

257+
// Placeholders. See Binder.h for details.
258+
[[nodiscard]] virtual status_t addFrozenStateChangeCallback(
259+
const wp<FrozenStateChangeCallback>& callback) = 0;
260+
[[nodiscard]] virtual status_t removeFrozenStateChangeCallback(
261+
const wp<FrozenStateChangeCallback>& callback) = 0;
262+
252263
virtual bool checkSubclass(const void* subclassID) const;
253264

254265
typedef void (*object_cleanup_func)(const void* id, void* obj, void* cleanupCookie);

0 commit comments

Comments
 (0)