xref: /OK3568_Linux_fs/buildroot/package/mtp/0001-Fix-compile-error.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 2bf12a6c7c52f88fd9ef4cd5652d1391a7b3f25c Mon Sep 17 00:00:00 2001
2From: "zain.wang" <wzz@rock-chips.com>
3Date: Thu, 9 Aug 2018 10:22:20 +0800
4Subject: [PATCH 1/3] Fix compile error
5
6Remove some code about dbus and properties.
7
8Signed-off-by: zain.wang <wzz@rock-chips.com>
9---
10 CMakeLists.txt        |   3 +-
11 server/CMakeLists.txt |   1 -
12 server/server.cpp     | 120 +-----------------------------------------
13 src/MtpServer.cpp     |  10 ++--
14 4 files changed, 7 insertions(+), 127 deletions(-)
15
16diff --git a/CMakeLists.txt b/CMakeLists.txt
17index 46bff47..707b7f8 100644
18--- a/CMakeLists.txt
19+++ b/CMakeLists.txt
20@@ -14,7 +14,7 @@ set(MTP_VERSION_MINOR 0)
21 set(MTP_VERSION_PATCH 0)
22
23 find_package(Boost REQUIRED COMPONENTS thread system filesystem unit_test_framework)
24-pkg_check_modules(DBUSCPP REQUIRED dbus-cpp)
25+pkg_check_modules(DBUSCPP REQUIRED dbus-c++-1)
26 pkg_check_modules(GLOG REQUIRED libglog)
27
28 set(
29@@ -71,7 +71,6 @@ add_library(
30
31 target_link_libraries(
32   mtpserver
33-  android-properties
34   ${GLOG_LIBRARIES}
35   ${DBUSCPP_LIBRARIES}
36 )
37diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
38index 411ff46..9acb974 100644
39--- a/server/CMakeLists.txt
40+++ b/server/CMakeLists.txt
41@@ -11,7 +11,6 @@ target_link_libraries(
42     mtp-server
43     mtpserver
44     usbhost
45-    android-properties
46     ${Boost_LIBRARIES}
47     ${Boost_thread_LIBRARIES}
48     ${Boost_system_LIBRARIES}
49diff --git a/server/server.cpp b/server/server.cpp
50index 0a9a846..d08c13c 100644
51--- a/server/server.cpp
52+++ b/server/server.cpp
53@@ -32,73 +32,10 @@
54 #include <libintl.h>
55 #include <locale.h>
56
57-#include <hybris/properties/properties.h>
58 #include <glog/logging.h>
59
60-#include <core/dbus/bus.h>
61-#include <core/dbus/object.h>
62-#include <core/dbus/property.h>
63-#include <core/dbus/service.h>
64-#include <core/dbus/signal.h>
65-
66-#include <core/dbus/asio/executor.h>
67-#include <core/dbus/types/stl/tuple.h>
68-#include <core/dbus/types/stl/vector.h>
69-#include <core/dbus/types/struct.h>
70-
71-
72-namespace dbus = core::dbus;
73 using namespace android;
74
75-namespace core
76-{
77-dbus::Bus::Ptr the_session_bus()
78-{
79-    static dbus::Bus::Ptr session_bus = std::make_shared<dbus::Bus>(dbus::WellKnownBus::session);
80-    return session_bus;
81-}
82-
83-struct UnityGreeter
84-{
85-    struct Properties
86-    {
87-        struct IsActive
88-        {
89-            inline static std::string name()
90-            {
91-                return "IsActive";
92-            };
93-            typedef UnityGreeter Interface;
94-            typedef bool ValueType;
95-            static const bool readable = true;
96-            static const bool writable = false;
97-        };
98-    };
99-};
100-}
101-
102-namespace core
103-{
104-namespace dbus
105-{
106-namespace traits
107-{
108-template<>
109-struct Service<core::UnityGreeter>
110-{
111-    inline static const std::string& interface_name()
112-    {
113-        static const std::string s
114-        {
115-            "com.canonical.UnityGreeter"
116-        };
117-        return s;
118-    }
119-};
120-}
121-}
122-}
123-
124 namespace
125 {
126 struct FileSystemConfig
127@@ -114,7 +51,6 @@ class MtpDaemon
128
129 private:
130     struct passwd *userdata;
131-    dbus::Bus::Ptr bus;
132     boost::thread dbus_thread;
133
134     // Mtp stuff
135@@ -124,8 +60,7 @@ private:
136     MtpDatabase* mtp_database;
137
138     // Security
139-    std::shared_ptr<core::dbus::Property<core::UnityGreeter::Properties::IsActive> > is_active;
140-    bool screen_locked = true;
141+    bool screen_locked = false;
142
143     // inotify stuff
144     boost::thread notifier_thread;
145@@ -242,17 +177,6 @@ private:
146         read_more_notify();
147     }
148
149-    void drive_bus()
150-    {
151-        try {
152-            bus->run();
153-        }
154-        catch (...) {
155-            PLOG(ERROR) << "There was an unexpected error in DBus; terminating.";
156-            server->stop();
157-        }
158-    }
159-
160 public:
161
162     MtpDaemon(int fd):
163@@ -285,28 +209,14 @@ public:
164                 userdata->pw_gid,
165                 FileSystemConfig::file_perm,
166                 FileSystemConfig::directory_perm);
167-
168-        // security / screen locking
169-        bus = core::the_session_bus();
170-        bus->install_executor(core::dbus::asio::make_executor(bus));
171-        dbus_thread = boost::thread(&MtpDaemon::drive_bus, this);
172-        auto greeter_service = dbus::Service::use_service(bus, "com.canonical.UnityGreeter");
173-        dbus::Object::Ptr greeter = greeter_service->object_for_path(dbus::types::ObjectPath("/"));
174-
175-        is_active = greeter->get_property<core::UnityGreeter::Properties::IsActive>();
176     }
177
178     void initStorage()
179     {
180-        char product_name[PROP_VALUE_MAX];
181-
182-        // Local storage
183-        property_get ("ro.product.model", product_name, "Ubuntu Touch device");
184-
185         home_storage = new MtpStorage(
186             MTP_STORAGE_FIXED_RAM,
187             userdata->pw_dir,
188-	    product_name,
189+            "MTP",
190             1024 * 1024 * 100,  /* 100 MB reserved space, to avoid filling the disk */
191             false,
192             0  /* Do not check sizes for internal storage */);
193@@ -360,31 +270,6 @@ public:
194
195     void run()
196     {
197-        if (is_active->get()) {
198-            is_active->changed().connect([this](bool active)
199-            {
200-                if (!active) {
201-                    screen_locked = active;
202-                    VLOG(2) << "device was unlocked, adding storage";
203-                    if (home_storage && !home_storage_added) {
204-                        server->addStorage(home_storage);
205-                        home_storage_added = true;
206-                    }
207-                    BOOST_FOREACH(std::string name, removables | boost::adaptors::map_keys) {
208-                        auto t = removables.at(name);
209-                        MtpStorage *storage = std::get<0>(t);
210-                        bool added = std::get<1>(t);
211-                        if (!added) {
212-                            mtp_database->addStoragePath(storage->getPath(),
213-                                                         std::string(),
214-                                                         storage->getStorageID(),
215-                                                         true);
216-                            server->addStorage(storage);
217-                        }
218-                    }
219-                }
220-            });
221-        } else {
222             screen_locked = false;
223             VLOG(2) << "device is not locked, adding storage";
224             if (home_storage) {
225@@ -403,7 +288,6 @@ public:
226                     server->addStorage(storage);
227                 }
228             }
229-        }
230
231         // start the MtpServer main loop
232         server->run();
233diff --git a/src/MtpServer.cpp b/src/MtpServer.cpp
234index b2d9e9c..ba95c5a 100644
235--- a/src/MtpServer.cpp
236+++ b/src/MtpServer.cpp
237@@ -41,8 +41,6 @@
238
239 #include <linux/usb/f_mtp.h>
240
241-#include <hybris/properties/properties.h>
242-
243 #include <glog/logging.h>
244
245 namespace android {
246@@ -468,7 +466,7 @@ bool MtpServer::handleRequest() {
247 MtpResponseCode MtpServer::doGetDeviceInfo() {
248     VLOG(1) <<  __PRETTY_FUNCTION__;
249     MtpStringBuffer   string;
250-    char prop_value[PROP_VALUE_MAX];
251+    char prop_value[64];
252
253     MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats();
254     MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats();
255@@ -500,17 +498,17 @@ MtpResponseCode MtpServer::doGetDeviceInfo() {
256     mData.putAUInt16(captureFormats); // Capture Formats
257     mData.putAUInt16(playbackFormats);  // Playback Formats
258
259-    property_get("ro.product.manufacturer", prop_value, "unknown manufacturer");
260+    strcpy(prop_value, "---MANUFACTURER---");
261     string.set(prop_value);
262     mData.putString(string);   // Manufacturer
263
264-    property_get("ro.product.model", prop_value, "MTP Device");
265+    strcpy(prop_value, "---MODEL---");
266     string.set(prop_value);
267     mData.putString(string);   // Model
268     string.set("1.0");
269     mData.putString(string);   // Device Version
270
271-    property_get("ro.serialno", prop_value, "????????");
272+    strcpy(prop_value, "---SERIAL---");
273     string.set(prop_value);
274     mData.putString(string);   // Serial Number
275
276--
2772.17.1
278
279