Mir

Merge lp:~brandontschaefer/mir/no-android-input-channel into lp:mir

Proposed by Brandon Schaefer
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~brandontschaefer/mir/no-android-input-channel
Merge into: lp:mir
Diff against target: 818 lines (+222/-263)
20 files modified
3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h (+0/-6)
3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+0/-29)
src/server/input/CMakeLists.txt (+2/-0)
src/server/input/android/CMakeLists.txt (+0/-2)
src/server/input/android/android_input_channel.cpp (+0/-48)
src/server/input/android/android_input_channel.h (+0/-59)
src/server/input/android/input_channel_factory.cpp (+0/-28)
src/server/input/android/input_channel_factory.h (+0/-44)
src/server/input/channel.cpp (+64/-0)
src/server/input/channel.h (+48/-0)
src/server/input/channel_factory.cpp (+28/-0)
src/server/input/channel_factory.h (+43/-0)
src/server/input/default_configuration.cpp (+2/-2)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+19/-28)
tests/unit-tests/input/CMakeLists.txt (+1/-0)
tests/unit-tests/input/android/CMakeLists.txt (+0/-1)
tests/unit-tests/input/android/test_android_communication_package.cpp (+4/-5)
tests/unit-tests/input/android/test_android_input_sender.cpp (+2/-3)
tests/unit-tests/input/android/test_input_consumer.cpp (+3/-2)
tests/unit-tests/input/test_input_channel_factory.cpp (+6/-6)
To merge this branch: bzr merge lp:~brandontschaefer/mir/no-android-input-channel
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Kevin DuBois (community) Approve
Cemil Azizoglu (community) Needs Fixing
Review via email: mp+290942@code.launchpad.net

Commit message

Remove the usage of android input channel. Slowly removing all usage of the android input sender/receiver as well as the input channel.

Description of the change

Remove the usage of android input channel. Slowly removing all usage of the android input sender/receiver as well as the input channel.

To post a comment you must log in.
3440. By Brandon Schaefer on 2016-04-05

* Should have just bzr mv'ed those files... but fix copyright headers

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3439
https://mir-jenkins.ubuntu.com/job/mir-ci/747/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/723/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/760
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/751
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/751
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/732/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/732
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/732/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/732/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/732/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/732
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/732/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/747/rebuild

review: Needs Fixing (continuous-integration)
3441. By Brandon Schaefer on 2016-04-05

* Not sure why i used auto

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3440
https://mir-jenkins.ubuntu.com/job/mir-ci/748/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/724/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/761
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/753
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/753
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/734/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/734
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/734/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/734/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/734/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/734
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/734/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/748/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3441
https://mir-jenkins.ubuntu.com/job/mir-ci/750/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/727/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/764
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/755
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/755
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/736
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/736/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/736
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/736/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/736/console
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/736/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/736
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/736/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/736
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/736/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/750/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Now that this code is out of the Android realm and is in the Mir realm, we should use Mir facilities, i.e. use 'mir::fd' instead of 'int'.

review: Needs Fixing
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Rather, 'mir::Fd'

3442. By Brandon Schaefer on 2016-04-05

* Use mir::Fd

Revision history for this message
Kevin DuBois (kdub) wrote :

nit:
+ mir::Fd server_fd_;
no need for mir::, already in correct namespace

Diff size would be much reduced with bzr mv. If its not too much trouble, it could still be done.

The rest looks alright to me.

nb:
+mi::Channel::Channel()
Although I don't think I see an opportunity for an exception to be thrown between the socketpair and setting mir::Fd (only C functions are used), in general the fd's should be put in the RAII wrapper right after the resource is acquired for exception safety.

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3442
https://mir-jenkins.ubuntu.com/job/mir-ci/759/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/742
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/779
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/770
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/770
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/751
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/751/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/751
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/751/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/751
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/751/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/751
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/751/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/751
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/751/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/759/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Unmerged revisions

3442. By Brandon Schaefer on 2016-04-05

* Use mir::Fd

3441. By Brandon Schaefer on 2016-04-05

* Not sure why i used auto

3440. By Brandon Schaefer on 2016-04-05

* Should have just bzr mv'ed those files... but fix copyright headers

3439. By Brandon Schaefer on 2016-04-05

* Remove the dependency on the android input channel and just create our own.
* The start of slowly removing all the android input sender/receiver!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h'
2--- 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2016-01-29 08:18:22 +0000
3+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2016-04-05 19:30:54 +0000
4@@ -141,12 +141,6 @@
5 public:
6 InputChannel(const String8& name, int fd);
7
8- /* Creates a pair of input channels.
9- *
10- * Returns OK on success.
11- */
12- static status_t openInputFdPair(int& server_fd, int& client_fd);
13-
14 inline String8 getName() const { return mName; }
15 inline int getFd() const { return mFd; }
16
17
18=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp'
19--- 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2016-03-23 06:39:56 +0000
20+++ 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2016-04-05 19:30:54 +0000
21@@ -32,12 +32,6 @@
22
23 namespace android {
24
25-// Socket buffer size. The default is typically about 128KB, which is much larger than
26-// we really need. So we make it smaller. It just needs to be big enough to hold
27-// a few dozen large multi-finger motion events in the case where an application gets
28-// behind processing touches.
29-static const size_t SOCKET_BUFFER_SIZE = 32 * 1024;
30-
31 // Nanoseconds per milliseconds.
32 static constexpr const std::chrono::nanoseconds NANOS_PER_MS = std::chrono::nanoseconds(1000000);
33
34@@ -117,29 +111,6 @@
35 #endif
36 }
37
38-status_t InputChannel::openInputFdPair(int& server_fd, int& client_fd) {
39- int sockets[2];
40- if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets)) {
41- status_t result = -errno;
42- ALOGE("InputChannel ~ Could not create socket pair. errno=%d",
43- errno);
44- server_fd = client_fd = 0;
45-
46- return result;
47- }
48-
49- int bufferSize = SOCKET_BUFFER_SIZE;
50- setsockopt(sockets[0], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize));
51- setsockopt(sockets[0], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize));
52- setsockopt(sockets[1], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize));
53- setsockopt(sockets[1], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize));
54-
55- server_fd = sockets[0];
56- client_fd = sockets[1];
57-
58- return OK;
59-}
60-
61 status_t InputChannel::sendMessage(const InputMessage* msg) {
62 size_t msgLength = msg->size();
63 ssize_t nWrite;
64
65=== modified file 'src/server/input/CMakeLists.txt'
66--- src/server/input/CMakeLists.txt 2016-03-23 06:39:56 +0000
67+++ src/server/input/CMakeLists.txt 2016-04-05 19:30:54 +0000
68@@ -6,6 +6,8 @@
69
70 basic_seat.cpp
71 builtin_cursor_images.cpp
72+ channel.cpp
73+ channel_factory.cpp
74 cursor_controller.cpp
75 default_configuration.cpp
76 default_device.cpp
77
78=== modified file 'src/server/input/android/CMakeLists.txt'
79--- src/server/input/android/CMakeLists.txt 2016-01-29 08:18:22 +0000
80+++ src/server/input/android/CMakeLists.txt 2016-04-05 19:30:54 +0000
81@@ -1,7 +1,5 @@
82 list(
83 APPEND INPUT_SOURCES
84- ${CMAKE_CURRENT_SOURCE_DIR}/android_input_channel.cpp
85- ${CMAKE_CURRENT_SOURCE_DIR}/input_channel_factory.cpp
86 ${CMAKE_CURRENT_SOURCE_DIR}/input_sender.cpp
87 )
88
89
90=== removed file 'src/server/input/android/android_input_channel.cpp'
91--- src/server/input/android/android_input_channel.cpp 2014-03-06 06:05:17 +0000
92+++ src/server/input/android/android_input_channel.cpp 1970-01-01 00:00:00 +0000
93@@ -1,48 +0,0 @@
94-/*
95- * Copyright © 2013 Canonical Ltd.
96- *
97- * This program is free software: you can redistribute it and/or modify it
98- * under the terms of the GNU General Public License version 3,
99- * as published by the Free Software Foundation.
100- *
101- * This program is distributed in the hope that it will be useful,
102- * but WITHOUT ANY WARRANTY; without even the implied warranty of
103- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104- * GNU General Public License for more details.
105- *
106- * You should have received a copy of the GNU General Public License
107- * along with this program. If not, see <http://www.gnu.org/licenses/>.
108- *
109- * Authored by: Robert Carr <robert.carr@canonical.com>
110- */
111-
112-#include "android_input_channel.h"
113-
114-#include <androidfw/InputTransport.h>
115-
116-#include <unistd.h>
117-
118-namespace mia = mir::input::android;
119-namespace droidinput = android;
120-
121-mia::AndroidInputChannel::AndroidInputChannel()
122-{
123-
124- droidinput::InputChannel::openInputFdPair(s_fd, c_fd);
125-}
126-
127-mia::AndroidInputChannel::~AndroidInputChannel()
128-{
129- close(s_fd);
130- close(c_fd);
131-}
132-
133-int mia::AndroidInputChannel::client_fd() const
134-{
135- return c_fd;
136-}
137-
138-int mia::AndroidInputChannel::server_fd() const
139-{
140- return s_fd;
141-}
142
143=== removed file 'src/server/input/android/android_input_channel.h'
144--- src/server/input/android/android_input_channel.h 2015-02-22 07:46:25 +0000
145+++ src/server/input/android/android_input_channel.h 1970-01-01 00:00:00 +0000
146@@ -1,59 +0,0 @@
147-/*
148- * Copyright © 2013 Canonical Ltd.
149- *
150- * This program is free software: you can redistribute it and/or modify it
151- * under the terms of the GNU General Public License version 3,
152- * as published by the Free Software Foundation.
153- *
154- * This program is distributed in the hope that it will be useful,
155- * but WITHOUT ANY WARRANTY; without even the implied warranty of
156- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
157- * GNU General Public License for more details.
158- *
159- * You should have received a copy of the GNU General Public License
160- * along with this program. If not, see <http://www.gnu.org/licenses/>.
161- *
162- * Authored by: Robert Carr <robert.carr@canonical.com>
163- */
164-
165-#ifndef MIR_INPUT_ANDROID_INPUT_CHANNEL_H_
166-#define MIR_INPUT_ANDROID_INPUT_CHANNEL_H_
167-
168-#include "mir/input/input_channel.h"
169-
170-namespace android
171-{
172-class InputChannel;
173-}
174-
175-namespace droidinput = android;
176-
177-namespace mir
178-{
179-namespace input
180-{
181-namespace android
182-{
183-
184-class AndroidInputChannel : public InputChannel
185-{
186-public:
187- explicit AndroidInputChannel();
188- virtual ~AndroidInputChannel();
189-
190- int client_fd() const;
191- int server_fd() const;
192-
193-protected:
194- AndroidInputChannel(AndroidInputChannel const&) = delete;
195- AndroidInputChannel& operator=(AndroidInputChannel const&) = delete;
196-
197-private:
198- int s_fd, c_fd;
199-};
200-
201-}
202-}
203-} // namespace mir
204-
205-#endif // MIR_INPUT_ANDROID_INPUT_CHANNEL_H_
206
207=== removed file 'src/server/input/android/input_channel_factory.cpp'
208--- src/server/input/android/input_channel_factory.cpp 2014-04-10 12:59:14 +0000
209+++ src/server/input/android/input_channel_factory.cpp 1970-01-01 00:00:00 +0000
210@@ -1,28 +0,0 @@
211-/*
212- * Copyright © 2014 Canonical Ltd.
213- *
214- * This program is free software: you can redistribute it and/or modify it
215- * under the terms of the GNU General Public License version 3,
216- * as published by the Free Software Foundation.
217- *
218- * This program is distributed in the hope that it will be useful,
219- * but WITHOUT ANY WARRANTY; without even the implied warranty of
220- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
221- * GNU General Public License for more details.
222- *
223- * You should have received a copy of the GNU General Public License
224- * along with this program. If not, see <http://www.gnu.org/licenses/>.
225- *
226- * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
227- */
228-
229-#include "input_channel_factory.h"
230-#include "android_input_channel.h"
231-
232-namespace mi = mir::input;
233-namespace mia = mi::android;
234-
235-std::shared_ptr<mi::InputChannel> mia::InputChannelFactory::make_input_channel()
236-{
237- return std::make_shared<mia::AndroidInputChannel>();
238-}
239
240=== removed file 'src/server/input/android/input_channel_factory.h'
241--- src/server/input/android/input_channel_factory.h 2014-04-10 12:59:14 +0000
242+++ src/server/input/android/input_channel_factory.h 1970-01-01 00:00:00 +0000
243@@ -1,44 +0,0 @@
244-/*
245- * Copyright © 2014 Canonical Ltd.
246- *
247- * This program is free software: you can redistribute it and/or modify it
248- * under the terms of the GNU General Public License version 3,
249- * as published by the Free Software Foundation.
250- *
251- * This program is distributed in the hope that it will be useful,
252- * but WITHOUT ANY WARRANTY; without even the implied warranty of
253- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
254- * GNU General Public License for more details.
255- *
256- * You should have received a copy of the GNU General Public License
257- * along with this program. If not, see <http://www.gnu.org/licenses/>.
258- *
259- * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
260- */
261-
262-#ifndef MIR_INPUT_ANDROID_INPUT_CHANNEL_FACTORY_H_
263-#define MIR_INPUT_ANDROID_INPUT_CHANNEL_FACTORY_H_
264-
265-#include "mir/input/input_channel_factory.h"
266-
267-namespace mir
268-{
269-namespace input
270-{
271-namespace android
272-{
273-class InputChannelFactory : public mir::input::InputChannelFactory
274-{
275-public:
276- std::shared_ptr<mir::input::InputChannel> make_input_channel() override;
277-
278- InputChannelFactory() = default;
279- InputChannelFactory(InputChannelFactory const&) = delete;
280- InputChannelFactory& operator=(InputChannelFactory const&) = delete;
281-};
282-
283-}
284-}
285-} // namespace mir
286-
287-#endif
288
289=== added file 'src/server/input/channel.cpp'
290--- src/server/input/channel.cpp 1970-01-01 00:00:00 +0000
291+++ src/server/input/channel.cpp 2016-04-05 19:30:54 +0000
292@@ -0,0 +1,64 @@
293+/*
294+ * Copyright © 2013-2016 Canonical Ltd.
295+ *
296+ * This program is free software: you can redistribute it and/or modify it
297+ * under the terms of the GNU General Public License version 3,
298+ * as published by the Free Software Foundation.
299+ *
300+ * This program is distributed in the hope that it will be useful,
301+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
302+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303+ * GNU General Public License for more details.
304+ *
305+ * You should have received a copy of the GNU General Public License
306+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
307+ *
308+ * Authored by: Robert Carr <robert.carr@canonical.com>
309+ * Brandon Schaefer <brandon.schaefer@canonical.com>
310+ */
311+
312+#include <system_error>
313+#include <sys/types.h>
314+#include <sys/socket.h>
315+
316+#include "channel.h"
317+
318+#include <boost/throw_exception.hpp>
319+
320+namespace mi = mir::input;
321+
322+namespace
323+{
324+// Default is 128KB which is larger then we need. Use a smaller size.
325+int const buffer_size{32 * 1024};
326+}
327+
328+mi::Channel::Channel()
329+{
330+ int sockets[2];
331+ if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets)) {
332+ BOOST_THROW_EXCEPTION(std::system_error(
333+ errno,
334+ std::system_category(),
335+ "Could not create socket pair."));
336+ }
337+
338+ int size = buffer_size;
339+ setsockopt(sockets[0], SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
340+ setsockopt(sockets[0], SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
341+ setsockopt(sockets[1], SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
342+ setsockopt(sockets[1], SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
343+
344+ server_fd_ = mir::Fd(sockets[0]);
345+ client_fd_ = mir::Fd(sockets[1]);
346+}
347+
348+int mi::Channel::server_fd() const
349+{
350+ return server_fd_;
351+}
352+
353+int mi::Channel::client_fd() const
354+{
355+ return client_fd_;
356+}
357
358=== added file 'src/server/input/channel.h'
359--- src/server/input/channel.h 1970-01-01 00:00:00 +0000
360+++ src/server/input/channel.h 2016-04-05 19:30:54 +0000
361@@ -0,0 +1,48 @@
362+/*
363+ * Copyright © 2013-2016 Canonical Ltd.
364+ *
365+ * This program is free software: you can redistribute it and/or modify it
366+ * under the terms of the GNU General Public License version 3,
367+ * as published by the Free Software Foundation.
368+ *
369+ * This program is distributed in the hope that it will be useful,
370+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
371+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
372+ * GNU General Public License for more details.
373+ *
374+ * You should have received a copy of the GNU General Public License
375+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
376+ *
377+ * Authored by: Robert Carr <robert.carr@canonical.com>
378+ * Brandon Schaefer <brandon.schaefer@canonical.com>
379+ */
380+
381+#ifndef MIR_INPUT_CHANNEL_H_
382+#define MIR_INPUT_CHANNEL_H_
383+
384+#include "mir/fd.h"
385+#include "mir/input/input_channel.h"
386+
387+namespace mir
388+{
389+namespace input
390+{
391+
392+class Channel : public InputChannel
393+{
394+public:
395+ Channel();
396+ virtual ~Channel() override = default;
397+
398+ int client_fd() const override;
399+ int server_fd() const override;
400+
401+private:
402+ mir::Fd server_fd_;
403+ mir::Fd client_fd_;
404+};
405+
406+}
407+}
408+
409+#endif /* MIR_INPUT_CHANNEL_H_ */
410
411=== added file 'src/server/input/channel_factory.cpp'
412--- src/server/input/channel_factory.cpp 1970-01-01 00:00:00 +0000
413+++ src/server/input/channel_factory.cpp 2016-04-05 19:30:54 +0000
414@@ -0,0 +1,28 @@
415+/*
416+ * Copyright © 2014-2016 Canonical Ltd.
417+ *
418+ * This program is free software: you can redistribute it and/or modify it
419+ * under the terms of the GNU General Public License version 3,
420+ * as published by the Free Software Foundation.
421+ *
422+ * This program is distributed in the hope that it will be useful,
423+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
424+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
425+ * GNU General Public License for more details.
426+ *
427+ * You should have received a copy of the GNU General Public License
428+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
429+ *
430+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
431+ *
432+ */
433+
434+#include "channel.h"
435+#include "channel_factory.h"
436+
437+namespace mi = mir::input;
438+
439+std::shared_ptr<mi::InputChannel> mi::ChannelFactory::make_input_channel()
440+{
441+ return std::make_shared<mi::Channel>();
442+}
443
444=== added file 'src/server/input/channel_factory.h'
445--- src/server/input/channel_factory.h 1970-01-01 00:00:00 +0000
446+++ src/server/input/channel_factory.h 2016-04-05 19:30:54 +0000
447@@ -0,0 +1,43 @@
448+/*
449+ * Copyright © 2014-2016 Canonical Ltd.
450+ *
451+ * This program is free software: you can redistribute it and/or modify it
452+ * under the terms of the GNU General Public License version 3,
453+ * as published by the Free Software Foundation.
454+ *
455+ * This program is distributed in the hope that it will be useful,
456+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
457+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
458+ * GNU General Public License for more details.
459+ *
460+ * You should have received a copy of the GNU General Public License
461+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
462+ *
463+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
464+ *
465+ */
466+
467+#ifndef MIR_INPUT_CHANNEL_FACTORY_H_
468+#define MIR_INPUT_CHANNEL_FACTORY_H_
469+
470+#include "mir/input/input_channel_factory.h"
471+
472+namespace mir
473+{
474+namespace input
475+{
476+
477+class ChannelFactory : public InputChannelFactory
478+{
479+public:
480+ virtual std::shared_ptr<InputChannel> make_input_channel() override;
481+
482+ ChannelFactory() = default;
483+ ChannelFactory(ChannelFactory const&) = delete;
484+ ChannelFactory& operator=(ChannelFactory const&) = delete;
485+};
486+
487+}
488+}
489+
490+#endif /* MIR_INPUT_CHANNEL_FACTORY_H_ */
491
492=== modified file 'src/server/input/default_configuration.cpp'
493--- src/server/input/default_configuration.cpp 2016-03-23 06:39:56 +0000
494+++ src/server/input/default_configuration.cpp 2016-04-05 19:30:54 +0000
495@@ -19,10 +19,10 @@
496 #include "mir/default_server_configuration.h"
497
498 #include "android/input_sender.h"
499-#include "android/input_channel_factory.h"
500 #include "key_repeat_dispatcher.h"
501 #include "display_input_region.h"
502 #include "event_filter_chain_dispatcher.h"
503+#include "channel_factory.h"
504 #include "cursor_controller.h"
505 #include "touchspot_controller.h"
506 #include "null_input_manager.h"
507@@ -161,7 +161,7 @@
508 if (!options->get<bool>(options::enable_input_opt))
509 return std::make_shared<mi::NullInputChannelFactory>();
510 else
511- return std::make_shared<mia::InputChannelFactory>();
512+ return std::make_shared<mi::ChannelFactory>();
513 }
514
515 std::shared_ptr<mi::CursorListener>
516
517=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
518--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-03-29 03:41:45 +0000
519+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-04-05 19:30:54 +0000
520@@ -17,6 +17,7 @@
521 */
522
523 #include "src/client/input/android/android_input_receiver.h"
524+#include "src/server/input/channel.h"
525 #include "mir/input/null_input_receiver_report.h"
526 #include "mir/input/xkb_mapper.h"
527 #include "mir/events/event_private.h"
528@@ -40,6 +41,7 @@
529 namespace mircva = mircv::android;
530 namespace md = mir::dispatch;
531 namespace mt = mir::test;
532+namespace mi = mir::input;
533
534 namespace droidinput = android;
535
536@@ -130,24 +132,13 @@
537 class AndroidInputReceiverSetup : public testing::Test
538 {
539 public:
540- AndroidInputReceiverSetup()
541- {
542- auto status = droidinput::InputChannel::openInputFdPair(server_fd, client_fd);
543- EXPECT_EQ(droidinput::OK, status);
544- }
545- ~AndroidInputReceiverSetup()
546- {
547- close(server_fd);
548- close(client_fd);
549- }
550-
551 void flush_channels()
552 {
553- fsync(server_fd);
554- fsync(client_fd);
555+ fsync(channel.server_fd());
556+ fsync(channel.client_fd());
557 }
558
559- int server_fd, client_fd;
560+ mi::Channel channel;
561
562 static std::chrono::milliseconds const next_event_timeout;
563 std::function<void(MirEvent*)> event_handler{[](MirEvent*){}};
564@@ -159,7 +150,7 @@
565 TEST_F(AndroidInputReceiverSetup, receiver_receives_key_events)
566 {
567 MirKeyboardEvent last_event;
568- mircva::InputReceiver receiver{client_fd,
569+ mircva::InputReceiver receiver{channel.client_fd(),
570 std::make_shared<mircv::XKBMapper>(),
571 [&last_event](MirEvent* ev)
572 {
573@@ -169,7 +160,7 @@
574 }
575 },
576 std::make_shared<mircv::NullInputReceiverReport>()};
577- TestingInputProducer producer{server_fd};
578+ TestingInputProducer producer{channel.server_fd()};
579
580 producer.produce_a_key_event();
581
582@@ -184,11 +175,11 @@
583
584 TEST_F(AndroidInputReceiverSetup, receiver_handles_events)
585 {
586- mircva::InputReceiver receiver{client_fd,
587+ mircva::InputReceiver receiver{channel.client_fd(),
588 std::make_shared<mircv::XKBMapper>(),
589 event_handler,
590 std::make_shared<mircv::NullInputReceiverReport>()};
591- TestingInputProducer producer(server_fd);
592+ TestingInputProducer producer(channel.server_fd());
593
594 producer.produce_a_key_event();
595 flush_channels();
596@@ -203,12 +194,12 @@
597
598 TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events)
599 {
600- mircva::InputReceiver receiver{client_fd,
601+ mircva::InputReceiver receiver{channel.client_fd(),
602 std::make_shared<mircv::XKBMapper>(),
603 event_handler,
604 std::make_shared<mircv::NullInputReceiverReport>()};
605
606- TestingInputProducer producer(server_fd);
607+ TestingInputProducer producer(channel.server_fd());
608
609 // Produce 3 motion events before client handles any.
610 producer.produce_a_pointer_event(0, 0, std::chrono::nanoseconds(0));
611@@ -235,7 +226,7 @@
612 std::unique_ptr<MirEvent> ev;
613 bool handler_called{false};
614
615- mircva::InputReceiver receiver{client_fd,
616+ mircva::InputReceiver receiver{channel.client_fd(),
617 std::make_shared<mircv::XKBMapper>(),
618 [&ev, &handler_called](MirEvent* event)
619 {
620@@ -247,7 +238,7 @@
621 {
622 return t;
623 }};
624- TestingInputProducer producer(server_fd);
625+ TestingInputProducer producer(channel.server_fd());
626
627 nanoseconds const one_frame = duration_cast<nanoseconds>(1s) / 60;
628
629@@ -293,9 +284,9 @@
630 {
631 bool handler_called = false;
632
633- TestingInputProducer producer(server_fd);
634+ TestingInputProducer producer(channel.server_fd());
635 mircva::InputReceiver receiver{
636- client_fd,
637+ channel.client_fd(),
638 std::make_shared<mircv::XKBMapper>(),
639 [&handler_called, &producer](MirEvent*)
640 {
641@@ -322,7 +313,7 @@
642
643 int frames_triggered = 0;
644
645- mircva::InputReceiver receiver{client_fd,
646+ mircva::InputReceiver receiver{channel.client_fd(),
647 std::make_shared<mircv::XKBMapper>(),
648 [&frames_triggered](MirEvent*)
649 {
650@@ -333,7 +324,7 @@
651 {
652 return t;
653 }};
654- TestingInputProducer producer(server_fd);
655+ TestingInputProducer producer(channel.server_fd());
656
657 std::chrono::nanoseconds const device_sample_interval = duration_cast<nanoseconds>(1s) / 250;
658 std::chrono::nanoseconds const frame_interval = duration_cast<nanoseconds>(1s) / 60;
659@@ -375,12 +366,12 @@
660 std::chrono::nanoseconds t;
661
662 mircva::InputReceiver receiver{
663- client_fd,
664+ channel.client_fd(),
665 std::make_shared<mircv::XKBMapper>(),
666 event_handler,
667 std::make_shared<mircv::NullInputReceiverReport>(),
668 };
669- TestingInputProducer producer(server_fd);
670+ TestingInputProducer producer(channel.server_fd());
671
672 std::chrono::nanoseconds const one_millisecond = std::chrono::nanoseconds(1000000ULL);
673 std::chrono::nanoseconds const one_second = 1000 * one_millisecond;
674
675=== modified file 'tests/unit-tests/input/CMakeLists.txt'
676--- tests/unit-tests/input/CMakeLists.txt 2016-03-23 06:39:56 +0000
677+++ tests/unit-tests/input/CMakeLists.txt 2016-04-05 19:30:54 +0000
678@@ -7,6 +7,7 @@
679 ${CMAKE_CURRENT_SOURCE_DIR}/test_cursor_controller.cpp
680 ${CMAKE_CURRENT_SOURCE_DIR}/test_xcursor_loader.cpp
681 ${CMAKE_CURRENT_SOURCE_DIR}/test_touchspot_controller.cpp
682+ ${CMAKE_CURRENT_SOURCE_DIR}/test_input_channel_factory.cpp
683 ${CMAKE_CURRENT_SOURCE_DIR}/test_input_event.cpp
684 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_builders.cpp
685 ${CMAKE_CURRENT_SOURCE_DIR}/test_default_device.cpp
686
687=== modified file 'tests/unit-tests/input/android/CMakeLists.txt'
688--- tests/unit-tests/input/android/CMakeLists.txt 2016-03-23 06:39:56 +0000
689+++ tests/unit-tests/input/android/CMakeLists.txt 2016-04-05 19:30:54 +0000
690@@ -1,6 +1,5 @@
691 list(APPEND UNIT_TEST_SOURCES
692 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_lexicon.cpp
693- ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_channel_factory.cpp
694 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_communication_package.cpp
695 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_sender.cpp
696 ${CMAKE_CURRENT_SOURCE_DIR}/test_input_consumer.cpp
697
698=== modified file 'tests/unit-tests/input/android/test_android_communication_package.cpp'
699--- tests/unit-tests/input/android/test_android_communication_package.cpp 2014-03-06 06:05:17 +0000
700+++ tests/unit-tests/input/android/test_android_communication_package.cpp 2016-04-05 19:30:54 +0000
701@@ -16,7 +16,7 @@
702 * Authored by: Robert Carr <robert.carr@canonical.com>
703 */
704
705-#include "src/server/input/android/android_input_channel.h"
706+#include "src/server/input/channel.h"
707
708 #include <gtest/gtest.h>
709 #include <gmock/gmock.h>
710@@ -24,14 +24,13 @@
711 #include <unistd.h>
712 #include <fcntl.h>
713
714-namespace droidinput = android;
715-namespace mia = mir::input::android;
716+namespace mi = mir::input;
717
718-TEST(AndroidInputChannel, packages_own_valid_fds)
719+TEST(InputChannel, packages_own_valid_fds)
720 {
721 int server_fd, client_fd;
722 {
723- mia::AndroidInputChannel package;
724+ mi::Channel package;
725
726 server_fd = package.server_fd();
727 client_fd = package.client_fd();
728
729=== modified file 'tests/unit-tests/input/android/test_android_input_sender.cpp'
730--- tests/unit-tests/input/android/test_android_input_sender.cpp 2016-03-23 06:39:56 +0000
731+++ tests/unit-tests/input/android/test_android_input_sender.cpp 2016-04-05 19:30:54 +0000
732@@ -18,7 +18,7 @@
733
734 #include "mir/events/event_private.h"
735
736-#include "src/server/input/android/android_input_channel.h"
737+#include "src/server/input/channel.h"
738 #include "src/server/input/android/input_sender.h"
739 #include "src/server/input/default_event_builder.h"
740 #include "src/server/report/null_report_factory.h"
741@@ -44,7 +44,6 @@
742
743 #include <boost/exception/all.hpp>
744
745-//#include <algorithm>
746 #include <cstring>
747
748 namespace mi = mir::input;
749@@ -140,7 +139,7 @@
750 fake_scene.observer->surface_removed(&stub_surface);
751 }
752
753- std::shared_ptr<mi::InputChannel> channel = std::make_shared<mia::AndroidInputChannel>();
754+ std::shared_ptr<mi::InputChannel> channel = std::make_shared<mi::Channel>();
755 mtd::StubSceneSurface stub_surface{channel->server_fd()};
756 droidinput::sp<droidinput::InputChannel> client_channel{new droidinput::InputChannel(droidinput::String8("test"), channel->client_fd())};
757 droidinput::InputConsumer consumer{client_channel};
758
759=== modified file 'tests/unit-tests/input/android/test_input_consumer.cpp'
760--- tests/unit-tests/input/android/test_input_consumer.cpp 2016-03-23 06:39:56 +0000
761+++ tests/unit-tests/input/android/test_input_consumer.cpp 2016-04-05 19:30:54 +0000
762@@ -18,7 +18,7 @@
763
764 #include "androidfw/Input.h"
765 #include "androidfw/InputTransport.h"
766-#include "src/server/input/android/android_input_channel.h"
767+#include "src/server/input/channel.h"
768 #include "mir/input/android/event_conversion_helpers.h"
769 #include "mir/input/android/android_input_lexicon.h"
770 #include "mir/geometry/displacement.h"
771@@ -32,6 +32,7 @@
772
773 using namespace std::literals::chrono_literals;
774 namespace mia = mir::input::android;
775+namespace mi = mir::input;
776 namespace geom = mir::geometry;
777
778 namespace
779@@ -58,7 +59,7 @@
780 mir::cookie::Blob default_cookie;
781 EventFactory events;
782 std::chrono::milliseconds current_frame_time = 0ms;
783- mia::AndroidInputChannel channel;
784+ mi::Channel channel;
785 geom::Displacement no_move{0,0};
786 geom::Displacement no_scroll{0,0};
787 geom::Point origin{0,0};
788
789=== renamed file 'tests/unit-tests/input/android/test_android_input_channel_factory.cpp' => 'tests/unit-tests/input/test_input_channel_factory.cpp'
790--- tests/unit-tests/input/android/test_android_input_channel_factory.cpp 2015-06-17 05:20:42 +0000
791+++ tests/unit-tests/input/test_input_channel_factory.cpp 2016-04-05 19:30:54 +0000
792@@ -16,20 +16,20 @@
793 * Authored by: Robert Carr <robert.carr@canonical.com>
794 */
795
796-#include "src/server/input/android/android_input_channel.h"
797-#include "src/server/input/android/input_channel_factory.h"
798+#include "src/server/input/channel.h"
799+#include "src/server/input/channel_factory.h"
800
801 #include <gtest/gtest.h>
802 #include <gmock/gmock.h>
803
804 #include <initializer_list>
805
806-namespace mia = mir::input::android;
807+namespace mi = mir::input;
808
809-TEST(AndroidInputChannelFactory, channel_factory_returns_input_channel_with_fds)
810+TEST(InputChannelFactory, channel_factory_returns_input_channel_with_fds)
811 {
812- mia::InputChannelFactory factory;
813+ mi::ChannelFactory factory;
814
815 auto package = factory.make_input_channel();
816- EXPECT_NE(nullptr, std::dynamic_pointer_cast<mia::AndroidInputChannel>(package));
817+ EXPECT_NE(nullptr, std::dynamic_pointer_cast<mi::Channel>(package));
818 }

Subscribers

People subscribed via source and target branches