Exemplo n.º 1
0
 def openApp(self, pebbleConnection, uuid):
     AppStartService = AppMessageService(
         pebbleConnection, message_type=LegacyAppLaunchMessage)
     AppStartService.send_message(
         uuid, {
             LegacyAppLaunchMessage.Keys.RunState:
             Uint8(LegacyAppLaunchMessage.States.Running)
         })
     AppStartService.shutdown()
Exemplo n.º 2
0
    def _install_legacy2(self):
        metadata = self._bundle.get_app_metadata()
        app_uuid = metadata['uuid']

        # We don't really care if this worked; we're just waiting for it.
        self._pebble.send_and_read(
            LegacyAppInstallRequest(data=LegacyUpgradeAppUUID(uuid=app_uuid)),
            LegacyAppInstallResponse)

        # Find somewhere to install to.
        result = self._pebble.send_and_read(
            LegacyAppInstallRequest(data=LegacyBankInfoRequest()),
            LegacyAppInstallResponse).data
        assert isinstance(result, LegacyBankInfoResponse)
        first_free = 0
        for app in result.apps:
            assert isinstance(app, LegacyBankEntry)
            if app.bank_number == first_free:
                first_free += 1
        if first_free == result.bank_count:
            raise AppInstallError("No app banks free.")

        # Send the app over
        binary = self._bundle.zip.read(self._bundle.get_app_path())
        self._send_part_legacy2(PutBytesType.Binary, binary, first_free)

        if self._bundle.has_resources:
            resources = self._bundle.zip.read(self._bundle.get_resource_path())
            self._send_part_legacy2(PutBytesType.Resources, resources,
                                    first_free)

        if self._bundle.has_worker:
            worker = self._bundle.zip.read(self._bundle.get_worker_path())
            self._send_part_legacy2(PutBytesType.Worker, worker, first_free)

        # Mark it as available
        self._pebble.send_and_read(
            LegacyAppInstallRequest(
                data=LegacyAppAvailable(bank=first_free, vibrate=True)),
            LegacyAppInstallResponse)

        # Launch it (which is painful on 2.x).
        appmessage = AppMessageService(self._pebble,
                                       message_type=LegacyAppLaunchMessage)
        appmessage.send_message(
            app_uuid, {
                LegacyAppLaunchMessage.Keys.RunState:
                AMUint8(LegacyAppLaunchMessage.States.Running)
            })
        appmessage.shutdown()
Exemplo n.º 3
0
    def _install_legacy2(self):
        metadata = self._bundle.get_app_metadata()
        app_uuid = metadata['uuid']

        self._pebble.send_packet(LegacyAppInstallRequest(data=LegacyUpgradeAppUUID(uuid=app_uuid)))
        # We don't really care if this worked; we're just waiting for it.
        self._pebble.read_from_endpoint(LegacyAppInstallResponse)

        # Find somewhere to install to.
        self._pebble.send_packet(LegacyAppInstallRequest(data=LegacyBankInfoRequest()))
        result = self._pebble.read_from_endpoint(LegacyAppInstallResponse).data
        assert isinstance(result, LegacyBankInfoResponse)
        first_free = 0
        for app in result.apps:
            assert isinstance(app, LegacyBankEntry)
            if app.bank_number == first_free:
                first_free += 1
        if first_free == result.bank_count:
            raise AppInstallError("No app banks free.")

        # Send the app over
        binary = self._bundle.zip.read(self._bundle.get_app_path())
        self._send_part_legacy2(PutBytesType.Binary, binary, first_free)

        if self._bundle.has_resources:
            resources = self._bundle.zip.read(self._bundle.get_resource_path())
            self._send_part_legacy2(PutBytesType.Resources, resources, first_free)

        if self._bundle.has_worker:
            worker = self._bundle.zip.read(self._bundle.get_worker_path())
            self._send_part_legacy2(PutBytesType.Worker, worker, first_free)

        # Mark it as available
        self._pebble.send_packet(LegacyAppInstallRequest(data=LegacyAppAvailable(bank=first_free, vibrate=True)))
        self._pebble.read_from_endpoint(LegacyAppInstallResponse)

        # Launch it (which is painful on 2.x).
        appmessage = AppMessageService(self._pebble, message_type=LegacyAppLaunchMessage)
        appmessage.send_message(app_uuid, {
            LegacyAppLaunchMessage.Keys.RunState: AMUint8(LegacyAppLaunchMessage.States.Running)
        })
        appmessage.shutdown()