Loading fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot_merge_stats.h 0 → 100644 +48 −0 Original line number Diff line number Diff line // // Copyright (C) 2021 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. // #pragma once #include <memory> #include <gmock/gmock.h> #include <libsnapshot/snapshot_stats.h> namespace android::snapshot { class MockSnapshotMergeStats final : public ISnapshotMergeStats { public: virtual ~MockSnapshotMergeStats() = default; // Called when merge starts or resumes. MOCK_METHOD(bool, Start, (), (override)); MOCK_METHOD(void, set_state, (android::snapshot::UpdateState, bool), (override)); MOCK_METHOD(void, set_cow_file_size, (uint64_t), ()); MOCK_METHOD(void, set_total_cow_size_bytes, (uint64_t), (override)); MOCK_METHOD(void, set_estimated_cow_size_bytes, (uint64_t), (override)); MOCK_METHOD(void, set_boot_complete_time_ms, (uint32_t), (override)); MOCK_METHOD(void, set_boot_complete_to_merge_start_time_ms, (uint32_t), (override)); MOCK_METHOD(uint64_t, cow_file_size, (), (override)); MOCK_METHOD(uint64_t, total_cow_size_bytes, (), (override)); MOCK_METHOD(uint64_t, estimated_cow_size_bytes, (), (override)); MOCK_METHOD(uint32_t, boot_complete_time_ms, (), (override)); MOCK_METHOD(uint32_t, boot_complete_to_merge_start_time_ms, (), (override)); MOCK_METHOD(std::unique_ptr<Result>, Finish, (), (override)); using ISnapshotMergeStats::Result; // Return nullptr if any failure. }; } // namespace android::snapshot init/property_service.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -1200,6 +1200,22 @@ static void ProcessKernelCmdline() { // emulator specific, should be retired once emulator migrates to // androidboot. InitPropertySet("ro.boot." + key, value); } else if (key == "android.bootanim" && value == "0") { // emulator specific, should be retired once emulator migrates to // androidboot. InitPropertySet("ro.boot.debug.sf.nobootanimation", "1"); } else if (key == "android.checkjni") { // emulator specific, should be retired once emulator migrates to // androidboot. std::string value_bool; if (value == "0") { value_bool = "false"; } else if (value == "1") { value_bool = "true"; } else { value_bool = value; } InitPropertySet("ro.boot.dalvik.vm.checkjni", value_bool); } }); } Loading libutils/RefBase_test.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -242,12 +242,12 @@ TEST(RefBase, ReplacedComparison) { } TEST(RefBase, AssertWeakRefExistsSuccess) { // uses some other refcounting method, or non at all bool isDeleted; sp<Foo> foo = sp<Foo>::make(&isDeleted); wp<Foo> weakFoo = foo; EXPECT_EQ(weakFoo, wp<Foo>::fromExisting(foo.get())); EXPECT_EQ(weakFoo.unsafe_get(), wp<Foo>::fromExisting(foo.get()).unsafe_get()); EXPECT_FALSE(isDeleted); foo = nullptr; Loading @@ -255,7 +255,7 @@ TEST(RefBase, AssertWeakRefExistsSuccess) { } TEST(RefBase, AssertWeakRefExistsDeath) { // uses some other refcounting method, or non at all // uses some other refcounting method, or none at all bool isDeleted; Foo* foo = new Foo(&isDeleted); Loading libutils/include/utils/RefBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -547,6 +547,7 @@ wp<T> wp<T>::fromExisting(T* other) { refs->incWeakRequireWeak(other); wp<T> ret; ret.m_ptr = other; ret.m_refs = refs; return ret; } Loading libutils/include/utils/StrongPointer.h +12 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ public: template<typename U> sp(const sp<U>& other); // NOLINT(implicit) template<typename U> sp(sp<U>&& other); // NOLINT(implicit) // Cast a strong pointer directly from one type to another. Constructors // allow changing types, but only if they are pointer-compatible. This does // a static_cast internally. template <typename U> static inline sp<T> cast(const sp<U>& other); ~sp(); // Assignment Loading Loading @@ -279,6 +285,12 @@ sp<T>::sp(sp<U>&& other) other.m_ptr = nullptr; } template <typename T> template <typename U> sp<T> sp<T>::cast(const sp<U>& other) { return sp<T>::fromExisting(static_cast<T*>(other.get())); } template<typename T> sp<T>::~sp() { if (m_ptr) Loading Loading
fs_mgr/libsnapshot/include/libsnapshot/mock_snapshot_merge_stats.h 0 → 100644 +48 −0 Original line number Diff line number Diff line // // Copyright (C) 2021 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. // #pragma once #include <memory> #include <gmock/gmock.h> #include <libsnapshot/snapshot_stats.h> namespace android::snapshot { class MockSnapshotMergeStats final : public ISnapshotMergeStats { public: virtual ~MockSnapshotMergeStats() = default; // Called when merge starts or resumes. MOCK_METHOD(bool, Start, (), (override)); MOCK_METHOD(void, set_state, (android::snapshot::UpdateState, bool), (override)); MOCK_METHOD(void, set_cow_file_size, (uint64_t), ()); MOCK_METHOD(void, set_total_cow_size_bytes, (uint64_t), (override)); MOCK_METHOD(void, set_estimated_cow_size_bytes, (uint64_t), (override)); MOCK_METHOD(void, set_boot_complete_time_ms, (uint32_t), (override)); MOCK_METHOD(void, set_boot_complete_to_merge_start_time_ms, (uint32_t), (override)); MOCK_METHOD(uint64_t, cow_file_size, (), (override)); MOCK_METHOD(uint64_t, total_cow_size_bytes, (), (override)); MOCK_METHOD(uint64_t, estimated_cow_size_bytes, (), (override)); MOCK_METHOD(uint32_t, boot_complete_time_ms, (), (override)); MOCK_METHOD(uint32_t, boot_complete_to_merge_start_time_ms, (), (override)); MOCK_METHOD(std::unique_ptr<Result>, Finish, (), (override)); using ISnapshotMergeStats::Result; // Return nullptr if any failure. }; } // namespace android::snapshot
init/property_service.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -1200,6 +1200,22 @@ static void ProcessKernelCmdline() { // emulator specific, should be retired once emulator migrates to // androidboot. InitPropertySet("ro.boot." + key, value); } else if (key == "android.bootanim" && value == "0") { // emulator specific, should be retired once emulator migrates to // androidboot. InitPropertySet("ro.boot.debug.sf.nobootanimation", "1"); } else if (key == "android.checkjni") { // emulator specific, should be retired once emulator migrates to // androidboot. std::string value_bool; if (value == "0") { value_bool = "false"; } else if (value == "1") { value_bool = "true"; } else { value_bool = value; } InitPropertySet("ro.boot.dalvik.vm.checkjni", value_bool); } }); } Loading
libutils/RefBase_test.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -242,12 +242,12 @@ TEST(RefBase, ReplacedComparison) { } TEST(RefBase, AssertWeakRefExistsSuccess) { // uses some other refcounting method, or non at all bool isDeleted; sp<Foo> foo = sp<Foo>::make(&isDeleted); wp<Foo> weakFoo = foo; EXPECT_EQ(weakFoo, wp<Foo>::fromExisting(foo.get())); EXPECT_EQ(weakFoo.unsafe_get(), wp<Foo>::fromExisting(foo.get()).unsafe_get()); EXPECT_FALSE(isDeleted); foo = nullptr; Loading @@ -255,7 +255,7 @@ TEST(RefBase, AssertWeakRefExistsSuccess) { } TEST(RefBase, AssertWeakRefExistsDeath) { // uses some other refcounting method, or non at all // uses some other refcounting method, or none at all bool isDeleted; Foo* foo = new Foo(&isDeleted); Loading
libutils/include/utils/RefBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -547,6 +547,7 @@ wp<T> wp<T>::fromExisting(T* other) { refs->incWeakRequireWeak(other); wp<T> ret; ret.m_ptr = other; ret.m_refs = refs; return ret; } Loading
libutils/include/utils/StrongPointer.h +12 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ public: template<typename U> sp(const sp<U>& other); // NOLINT(implicit) template<typename U> sp(sp<U>&& other); // NOLINT(implicit) // Cast a strong pointer directly from one type to another. Constructors // allow changing types, but only if they are pointer-compatible. This does // a static_cast internally. template <typename U> static inline sp<T> cast(const sp<U>& other); ~sp(); // Assignment Loading Loading @@ -279,6 +285,12 @@ sp<T>::sp(sp<U>&& other) other.m_ptr = nullptr; } template <typename T> template <typename U> sp<T> sp<T>::cast(const sp<U>& other) { return sp<T>::fromExisting(static_cast<T*>(other.get())); } template<typename T> sp<T>::~sp() { if (m_ptr) Loading