Commit a08f09c9 authored by Jeffrey I. Schiller's avatar Jeffrey I. Schiller Committed by Evan W. Patton

Permit Companion to install from https

When the Companion is used to scan a bar code, if it finds a string that
begins with http:// it calls the package installer (or in the case of
the Play Store version, it hands it off to the on-phone browser). This
functionality was added a while ago to deal with the case where people
used the Companion to scan the barcode resulting from a package
build. Basically people got confused between scanning a QR Code for
connection to the browser and scanning the QR code of a packaged app.

However it turns out that this was a useful feature because it lets
people use the Companion to install their created apk’s so they do not
have to have a separate bar code scanning app installed. This is
particularly useful in a school setting in that it reduces the amount of
work that staff have to do to setup devices.

This commit updates the code to also call the installer when the string
begins with https as well as http. Given that we will soon serve MIT App
Inventor over https, packaged URL’s will soon begin with https.

Change-Id: I5797f998749b1a309c9504088fa03d5aaf4eb06e
parent e5220480
......@@ -225,7 +225,6 @@
<value name="ADD8">
<block type="lists_create_with" id="}V;[y55Tf$v{NV$fLE!%">
<mutation items="2"></mutation>
<comment pinned="true" h="64" w="315">Indicates that we can accept iceServers from the Rendezvous server</comment>
<value name="ADD0">
<block type="text" id="M;4c#e*(tb{AT6CJfQ4x">
<field name="TEXT">r2</field>
......@@ -438,25 +437,54 @@
<field name="NAME">isAPK</field>
<field name="VAR0">input</field>
<value name="RETURN">
<block type="math_compare" id="56">
<field name="OP">EQ</field>
<block type="logic_or" id="?]t/mFK^K=,Isjx^C]-M">
<field name="OP">OR</field>
<value name="A">
<block type="text_starts_at" id="57">
<value name="TEXT">
<block type="lexical_variable_get" id="58">
<field name="VAR">input</field>
<block type="math_compare" id="56">
<field name="OP">EQ</field>
<value name="A">
<block type="text_starts_at" id="57">
<value name="TEXT">
<block type="lexical_variable_get" id="58">
<field name="VAR">input</field>
</block>
</value>
<value name="PIECE">
<block type="text" id="59">
<field name="TEXT">http://</field>
</block>
</value>
</block>
</value>
<value name="PIECE">
<block type="text" id="59">
<field name="TEXT">http://</field>
<value name="B">
<block type="math_number" id="60">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="60">
<field name="NUM">1</field>
<block type="math_compare" id="u1Q`jlIW}x?cXeN;dq^d">
<field name="OP">EQ</field>
<value name="A">
<block type="text_starts_at" id="UJMX]nVk^Yt60go#ImlD">
<value name="TEXT">
<block type="lexical_variable_get" id="089/L*vyb(*~k;0En;V]">
<field name="VAR">input</field>
</block>
</value>
<value name="PIECE">
<block type="text" id="p!*FO;,2Y+m*)7dL^pL3">
<field name="TEXT">https://</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="0%#Y4|NYw?_e3?3uJO*8">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
</block>
......@@ -1116,5 +1144,5 @@
</block>
</value>
</block>
<yacodeblocks ya-version="189" language-version="27"></yacodeblocks>
<yacodeblocks ya-version="204" language-version="30"></yacodeblocks>
</xml>
\ No newline at end of file
......@@ -9,7 +9,7 @@ $Source $Yail
(def (p$callrendezvous $code) (set-and-coerce-property! 'Web1 'Url (call-yail-primitive string-append (*list-for-runtime* "http://" (get-var g$rendezvousServer) "/rendezvous/" ) '(text text text ) "join") 'text)(call-component-method 'Web1 'PostText (*list-for-runtime* (call-component-method 'Web1 'BuildRequestData (*list-for-runtime* (call-yail-primitive make-yail-list (*list-for-runtime* (call-yail-primitive make-yail-list (*list-for-runtime* "key" (lexical-value $code) ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "ipaddr" (call-component-method 'PhoneStatus1 'GetWifiIpAddress (*list-for-runtime*) '()) ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "port" "9987" ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "webrtc" (call-yail-primitive yail-not (*list-for-runtime* (get-property 'CheckBox1 'Checked)) '(boolean) "not") ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "version" (call-component-method 'PhoneStatus1 'GetVersionName (*list-for-runtime*) '()) ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "api" (call-component-method 'PhoneStatus1 'SdkLevel (*list-for-runtime*) '()) ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "installer" (call-component-method 'PhoneStatus1 'GetInstaller (*list-for-runtime*) '()) ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "aid" (call-component-method 'PhoneStatus1 'InstallationId (*list-for-runtime*) '()) ) '(any any ) "make a list") (call-yail-primitive make-yail-list (*list-for-runtime* "r2" #t ) '(any any ) "make a list") ) '(any any any any any any any any any ) "make a list")) '(list))) '(text)))
(def (p$checkWiFi ) (if (call-yail-primitive yail-equal? (*list-for-runtime* 1 (call-yail-primitive string-starts-at (*list-for-runtime* (call-component-method 'PhoneStatus1 'GetWifiIpAddress (*list-for-runtime*) '()) "Error") '(text text) "starts at")) '(any any) "=") (begin (call-component-method 'Notifier1 'ShowChooseDialog (*list-for-runtime* "Your Device does not appear to have a WiFi Connection" "No WiFi" "Continue without WiFi" "Exit" #f) '(text text text text boolean)))))
(def (p$getRendezvousServer ) (call-component-method 'TinyDB1 'GetValue (*list-for-runtime* "rendezvousServer" (get-var g$rendezvousServer)) '(text any)))
(def (p$isAPK $input) (call-yail-primitive yail-equal? (*list-for-runtime* (call-yail-primitive string-starts-at (*list-for-runtime* (lexical-value $input) "http://") '(text text) "starts at") 1) '(any any) "="))
(def (p$isAPK $input) (or-delayed (call-yail-primitive yail-equal? (*list-for-runtime* (call-yail-primitive string-starts-at (*list-for-runtime* (lexical-value $input) "http://") '(text text) "starts at") 1) '(any any) "=") (call-yail-primitive yail-equal? (*list-for-runtime* (call-yail-primitive string-starts-at (*list-for-runtime* (lexical-value $input) "https://") '(text text) "starts at") 1) '(any any) "=")))
(def (p$processcode $x) (if ((get-var p$isAPK) (lexical-value $x)) (begin (call-component-method 'PhoneStatus1 'installURL (*list-for-runtime* (lexical-value $x)) '(text))) (begin (set-and-coerce-property! 'PhoneStatus1 'WebRTC (call-yail-primitive yail-not (*list-for-runtime* (get-property 'CheckBox1 'Checked)) '(boolean) "not") 'boolean)((get-var p$callrendezvous) (call-component-method 'PhoneStatus1 'setHmacSeedReturnCode (*list-for-runtime* ((get-var p$extractRendezvousServer) (lexical-value $x)) (get-var g$rendezvousServer)) '(text text)))(call-component-method 'PhoneStatus1 'startHTTPD (*list-for-runtime* #f) '(boolean)))))
(def (p$extractRendezvousServer $code) (if (call-yail-primitive string-contains (*list-for-runtime* (lexical-value $code) ";") '(text text) "contains") (let ( ($codes (call-yail-primitive string-split (*list-for-runtime* (lexical-value $code) ";") '(text text) "split")) ) (begin ((get-var p$setRendezvousServer) (call-yail-primitive yail-list-get-item (*list-for-runtime* (lexical-value $codes) 1) '(list number) "select list item") #f) (call-yail-primitive yail-list-get-item (*list-for-runtime* (lexical-value $codes) 2) '(list number) "select list item")) ) (lexical-value $code)))
(def (p$resetRendezvousServer ) (set-var! g$rendezvousServer "rendezvous.appinventor.mit.edu")(call-component-method 'TinyDB1 'ClearTag (*list-for-runtime* "rendezvousServer") '(text)))
......@@ -397,4 +397,4 @@ $Source $Yail
(add-component Screen1 com.google.appinventor.components.runtime.TinyDB TinyDB1
)
(init-runtime)
(init-runtime)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment