Mercurial > libervia-desktop-kivy
comparison cagou/core/platform_/android.py @ 370:1a12bbd80943
android: autoconnect profile using the new `profileAutoconnectGet` backend method:
thanks to this method, Cagou know which profile is started automatically in backend, and
can start it in frontend too.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jan 2020 21:17:08 +0100 |
parents | 4d3a0c4f2430 |
children | 1481f09c9175 |
comparison
equal
deleted
inserted
replaced
369:bbf992b0be0d | 370:1a12bbd80943 |
---|---|
78 | 78 |
79 def on_initFrontendState(self): | 79 def on_initFrontendState(self): |
80 # XXX: we use a separated socket instead of bridge because if we | 80 # XXX: we use a separated socket instead of bridge because if we |
81 # try to call a bridge method in on_pause method, the call data | 81 # try to call a bridge method in on_pause method, the call data |
82 # is not written before the actual pause | 82 # is not written before the actual pause |
83 s = self._frontend_status_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | 83 s = self._frontend_status_socket = socket.socket( |
84 socket.AF_UNIX, socket.SOCK_STREAM) | |
84 s.connect(os.path.join(SOCKET_DIR, SOCKET_FILE)) | 85 s.connect(os.path.join(SOCKET_DIR, SOCKET_FILE)) |
85 s.sendall(STATE_RUNNING) | 86 s.sendall(STATE_RUNNING) |
86 | 87 |
88 def profileAutoconnectGetCb(self, profile=None): | |
89 if profile is not None: | |
90 G.host.options.profile = profile | |
91 G.host.postInit() | |
92 | |
93 def profileAutoconnectGetEb(self, failure_): | |
94 log.error(f"Error while getting profile to autoconnect: {failure_}") | |
95 G.host.postInit() | |
96 | |
97 def do_postInit(self): | |
98 G.host.bridge.profileAutoconnectGet( | |
99 callback=self.profileAutoconnectGetCb, | |
100 errback=self.profileAutoconnectGetEb | |
101 ) | |
102 return False | |
103 | |
87 def onProfilePlugged(self, profile): | 104 def onProfilePlugged(self, profile): |
88 log.debug("ANDROID profilePlugged") | 105 log.debug("ANDROID profilePlugged") |
106 G.host.bridge.setParam( | |
107 "autoconnect_backend", C.BOOL_TRUE, "Connection", -1, profile, | |
108 callback=lambda: log.info(f"profile {profile} autonnection set"), | |
109 errback=lambda: log.error(f"can't set {profile} autonnection")) | |
89 for method, *args in self.cache: | 110 for method, *args in self.cache: |
90 method(*args) | 111 method(*args) |
91 del self.cache | 112 del self.cache |
92 G.host.removeListener("profilePlugged", self.onProfilePlugged) | 113 G.host.removeListener("profilePlugged", self.onProfilePlugged) |
93 | 114 |