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

Have Companion Create a unique ID

Have the Companion create a unique “InstallationId” which it reports to
the Rendezvous Server. This will help us keep track of how many
Companions are out there and what version of Android (and the Companion)
they are running on.

Note: The id is generated by the ACRA Library and is persistent across
upgrades of the Companion. However it will be re-created if the
Companion is uninstalled and then re-installed. It is not related in any
way to any Android provided identifier, which minimizes the privacy
impact of this identifier.

Change-Id: I7b85afe1451f4d44b4e0d412b3f37904425e3112
parent 3abb556f
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
<field name="COMPONENT_SELECTOR">Web1</field> <field name="COMPONENT_SELECTOR">Web1</field>
<value name="ARG0"> <value name="ARG0">
<block type="lists_create_with" id="17" inline="false"> <block type="lists_create_with" id="17" inline="false">
<mutation items="7"></mutation> <mutation items="8"></mutation>
<value name="ADD0"> <value name="ADD0">
<block type="lists_create_with" id="18" inline="false"> <block type="lists_create_with" id="18" inline="false">
<mutation items="2"></mutation> <mutation items="2"></mutation>
...@@ -206,6 +206,22 @@ ...@@ -206,6 +206,22 @@
</value> </value>
</block> </block>
</value> </value>
<value name="ADD7">
<block type="lists_create_with" id="3?x|P8JB#okUP8#oa5~o">
<mutation items="2"></mutation>
<value name="ADD0">
<block type="text" id="dh=0y=Jn`kt,SG-ksVd[">
<field name="TEXT">aid</field>
</block>
</value>
<value name="ADD1">
<block type="component_method" id="`g:@(vs,TD%uU%D1d+q/">
<mutation component_type="PhoneStatus" method_name="InstallationId" is_generic="false" instance_name="PhoneStatus1"></mutation>
<field name="COMPONENT_SELECTOR">PhoneStatus1</field>
</block>
</value>
</block>
</value>
</block> </block>
</value> </value>
</block> </block>
...@@ -215,7 +231,7 @@ ...@@ -215,7 +231,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="27" x="0" y="818"> <block type="component_event" id="27" x="0" y="870">
<mutation component_type="PhoneStatus" instance_name="PhoneStatus1" event_name="OnSettings"></mutation> <mutation component_type="PhoneStatus" instance_name="PhoneStatus1" event_name="OnSettings"></mutation>
<field name="COMPONENT_SELECTOR">PhoneStatus1</field> <field name="COMPONENT_SELECTOR">PhoneStatus1</field>
<statement name="DO"> <statement name="DO">
...@@ -249,6 +265,19 @@ ...@@ -249,6 +265,19 @@
<field name="PROCNAME">getRendezvousServer</field> <field name="PROCNAME">getRendezvousServer</field>
</block> </block>
</value> </value>
<next>
<block type="component_set_get" id="DCo==NX_F-`kld}S2ug5">
<mutation component_type="Label" set_or_get="set" property_name="Text" is_generic="false" instance_name="aidLabel"></mutation>
<field name="COMPONENT_SELECTOR">aidLabel</field>
<field name="PROP">Text</field>
<value name="VALUE">
<block type="component_method" id="awb}a`]zKxjK^VB@~G$}">
<mutation component_type="PhoneStatus" method_name="InstallationId" is_generic="false" instance_name="PhoneStatus1"></mutation>
<field name="COMPONENT_SELECTOR">PhoneStatus1</field>
</block>
</value>
</block>
</next>
</block> </block>
</next> </next>
</block> </block>
...@@ -256,7 +285,7 @@ ...@@ -256,7 +285,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="47" x="0" y="962"> <block type="component_event" id="47" x="0" y="1040">
<mutation component_type="Button" instance_name="ConnectButton" event_name="Click"></mutation> <mutation component_type="Button" instance_name="ConnectButton" event_name="Click"></mutation>
<field name="COMPONENT_SELECTOR">ConnectButton</field> <field name="COMPONENT_SELECTOR">ConnectButton</field>
<statement name="DO"> <statement name="DO">
...@@ -281,7 +310,7 @@ ...@@ -281,7 +310,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="procedures_defnoreturn" id="34" x="0" y="1105"> <block type="procedures_defnoreturn" id="34" x="0" y="1183">
<field name="NAME">checkWiFi</field> <field name="NAME">checkWiFi</field>
<statement name="STACK"> <statement name="STACK">
<block type="controls_if" id="35" inline="false"> <block type="controls_if" id="35" inline="false">
...@@ -344,7 +373,7 @@ ...@@ -344,7 +373,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="procedures_defreturn" id="51" inline="false" x="0" y="1402"> <block type="procedures_defreturn" id="51" inline="false" x="0" y="1480">
<field name="NAME">getRendezvousServer</field> <field name="NAME">getRendezvousServer</field>
<value name="RETURN"> <value name="RETURN">
<block type="component_method" id="52" inline="false"> <block type="component_method" id="52" inline="false">
...@@ -363,7 +392,7 @@ ...@@ -363,7 +392,7 @@
</block> </block>
</value> </value>
</block> </block>
<block type="procedures_defreturn" id="55" inline="false" x="0" y="1542"> <block type="procedures_defreturn" id="55" inline="false" x="0" y="1620">
<mutation> <mutation>
<arg name="input"></arg> <arg name="input"></arg>
</mutation> </mutation>
...@@ -394,7 +423,7 @@ ...@@ -394,7 +423,7 @@
</block> </block>
</value> </value>
</block> </block>
<block type="component_event" id="61" x="0" y="1668"> <block type="component_event" id="61" x="0" y="1746">
<mutation component_type="Notifier" instance_name="Notifier1" event_name="AfterChoosing"></mutation> <mutation component_type="Notifier" instance_name="Notifier1" event_name="AfterChoosing"></mutation>
<field name="COMPONENT_SELECTOR">Notifier1</field> <field name="COMPONENT_SELECTOR">Notifier1</field>
<statement name="DO"> <statement name="DO">
...@@ -426,7 +455,7 @@ ...@@ -426,7 +455,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="procedures_defnoreturn" id="67" x="0" y="1835"> <block type="procedures_defnoreturn" id="67" x="0" y="1913">
<mutation> <mutation>
<arg name="x"></arg> <arg name="x"></arg>
</mutation> </mutation>
...@@ -523,7 +552,7 @@ ...@@ -523,7 +552,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="S~hQs_KH8?5y90Ie^-Ok" x="0" y="2208"> <block type="component_event" id="S~hQs_KH8?5y90Ie^-Ok" x="0" y="2312">
<mutation component_type="CheckBox" instance_name="CheckBox1" event_name="Changed"></mutation> <mutation component_type="CheckBox" instance_name="CheckBox1" event_name="Changed"></mutation>
<field name="COMPONENT_SELECTOR">CheckBox1</field> <field name="COMPONENT_SELECTOR">CheckBox1</field>
<statement name="DO"> <statement name="DO">
...@@ -545,7 +574,7 @@ ...@@ -545,7 +574,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="procedures_defreturn" id="79" inline="false" x="0" y="2300"> <block type="procedures_defreturn" id="79" inline="false" x="0" y="2404">
<mutation> <mutation>
<arg name="code"></arg> <arg name="code"></arg>
</mutation> </mutation>
...@@ -645,7 +674,7 @@ ...@@ -645,7 +674,7 @@
</block> </block>
</value> </value>
</block> </block>
<block type="procedures_defnoreturn" id="98" x="0" y="2673"> <block type="procedures_defnoreturn" id="98" x="0" y="2777">
<field name="NAME">resetRendezvousServer</field> <field name="NAME">resetRendezvousServer</field>
<statement name="STACK"> <statement name="STACK">
<block type="lexical_variable_set" id="99" inline="false"> <block type="lexical_variable_set" id="99" inline="false">
...@@ -669,7 +698,7 @@ ...@@ -669,7 +698,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="103" x="0" y="2816"> <block type="component_event" id="103" x="0" y="2920">
<mutation component_type="Button" instance_name="ResetRendezvousServer" event_name="Click"></mutation> <mutation component_type="Button" instance_name="ResetRendezvousServer" event_name="Click"></mutation>
<field name="COMPONENT_SELECTOR">ResetRendezvousServer</field> <field name="COMPONENT_SELECTOR">ResetRendezvousServer</field>
<statement name="DO"> <statement name="DO">
...@@ -703,7 +732,7 @@ ...@@ -703,7 +732,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="109" x="0" y="2960"> <block type="component_event" id="109" x="0" y="3064">
<mutation component_type="Button" instance_name="ScanButton" event_name="Click"></mutation> <mutation component_type="Button" instance_name="ScanButton" event_name="Click"></mutation>
<field name="COMPONENT_SELECTOR">ScanButton</field> <field name="COMPONENT_SELECTOR">ScanButton</field>
<statement name="DO"> <statement name="DO">
...@@ -713,7 +742,7 @@ ...@@ -713,7 +742,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="111" x="0" y="3052"> <block type="component_event" id="111" x="0" y="3156">
<mutation component_type="Form" instance_name="Screen1" event_name="Initialize"></mutation> <mutation component_type="Form" instance_name="Screen1" event_name="Initialize"></mutation>
<field name="COMPONENT_SELECTOR">Screen1</field> <field name="COMPONENT_SELECTOR">Screen1</field>
<statement name="DO"> <statement name="DO">
...@@ -893,7 +922,7 @@ ...@@ -893,7 +922,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="procedures_defnoreturn" id="139" x="0" y="3561"> <block type="procedures_defnoreturn" id="139" x="0" y="3665">
<mutation> <mutation>
<arg name="value"></arg> <arg name="value"></arg>
<arg name="permanent"></arg> <arg name="permanent"></arg>
...@@ -937,7 +966,7 @@ ...@@ -937,7 +966,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="component_event" id="147" x="0" y="3769"> <block type="component_event" id="147" x="0" y="3873">
<mutation component_type="Button" instance_name="SetRenzvousServer" event_name="Click"></mutation> <mutation component_type="Button" instance_name="SetRenzvousServer" event_name="Click"></mutation>
<field name="COMPONENT_SELECTOR">SetRenzvousServer</field> <field name="COMPONENT_SELECTOR">SetRenzvousServer</field>
<statement name="DO"> <statement name="DO">
...@@ -992,7 +1021,7 @@ ...@@ -992,7 +1021,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="procedures_defnoreturn" id="156" x="0" y="3990"> <block type="procedures_defnoreturn" id="156" x="0" y="4094">
<field name="NAME">startdirectconnect</field> <field name="NAME">startdirectconnect</field>
<statement name="STACK"> <statement name="STACK">
<block type="local_declaration_statement" id="157" inline="false"> <block type="local_declaration_statement" id="157" inline="false">
...@@ -1040,7 +1069,7 @@ ...@@ -1040,7 +1069,7 @@
</block> </block>
</statement> </statement>
</block> </block>
<block type="global_declaration" id="164" inline="false" x="0" y="4197"> <block type="global_declaration" id="164" inline="false" x="0" y="4327">
<field name="NAME">rendezvousServer</field> <field name="NAME">rendezvousServer</field>
<value name="VALUE"> <value name="VALUE">
<block type="text" id="165"> <block type="text" id="165">
...@@ -1048,5 +1077,5 @@ ...@@ -1048,5 +1077,5 @@
</block> </block>
</value> </value>
</block> </block>
<yacodeblocks ya-version="173" language-version="22"></yacodeblocks> <yacodeblocks ya-version="176" language-version="23"></yacodeblocks>
</xml> </xml>
\ No newline at end of file
...@@ -6,7 +6,7 @@ $Source $Yail ...@@ -6,7 +6,7 @@ $Source $Yail
(require <com.google.youngandroid.runtime>) (require <com.google.youngandroid.runtime>)
(def (p$badversion ) (set-and-coerce-property! 'ErrorLabel 'Text "The version of App Inventor you are using is not compatible with this Companion app. " 'text)) (def (p$badversion ) (set-and-coerce-property! 'ErrorLabel 'Text "The version of App Inventor you are using is not compatible with this Companion app. " 'text))
(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") ) '(any any any any any any any ) "make a list")) '(list))) '(text))) (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") ) '(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$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$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) (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) "="))
...@@ -38,10 +38,10 @@ $Source $Yail ...@@ -38,10 +38,10 @@ $Source $Yail
(add-component Screen1 com.google.appinventor.components.runtime.VerticalArrangement SettingsPanel (add-component Screen1 com.google.appinventor.components.runtime.VerticalArrangement SettingsPanel
(set-and-coerce-property! 'SettingsPanel 'AlignHorizontal 3 'number) (set-and-coerce-property! 'SettingsPanel 'AlignHorizontal 3 'number)
(set-and-coerce-property! 'SettingsPanel 'Width -2 'number)
(set-and-coerce-property! 'SettingsPanel 'Visible #f 'boolean) (set-and-coerce-property! 'SettingsPanel 'Visible #f 'boolean)
(set-and-coerce-property! 'SettingsPanel 'Width -2 'number)
) )
;;; settingsintro ;;; settingsintro
...@@ -97,6 +97,11 @@ $Source $Yail ...@@ -97,6 +97,11 @@ $Source $Yail
(define-event ResetRendezvousServer Click()(set-this-form) (define-event ResetRendezvousServer Click()(set-this-form)
((get-var p$resetRendezvousServer) )(set-and-coerce-property! 'SettingsPanel 'Visible #f 'boolean)(set-and-coerce-property! 'MainPanel 'Visible #t 'boolean)) ((get-var p$resetRendezvousServer) )(set-and-coerce-property! 'SettingsPanel 'Visible #f 'boolean)(set-and-coerce-property! 'MainPanel 'Visible #t 'boolean))
;;; aidLabel
(add-component SettingsPanel com.google.appinventor.components.runtime.Label aidLabel
)
;;; MainPanel ;;; MainPanel
(add-component Screen1 com.google.appinventor.components.runtime.VerticalArrangement MainPanel (add-component Screen1 com.google.appinventor.components.runtime.VerticalArrangement MainPanel
...@@ -129,12 +134,12 @@ $Source $Yail ...@@ -129,12 +134,12 @@ $Source $Yail
(add-component MainPanel com.google.appinventor.components.runtime.Label ErrorLabel (add-component MainPanel com.google.appinventor.components.runtime.Label ErrorLabel
(set-and-coerce-property! 'ErrorLabel 'HasMargins #f 'boolean) (set-and-coerce-property! 'ErrorLabel 'HasMargins #f 'boolean)
(set-and-coerce-property! 'ErrorLabel 'Width -2 'number)
(set-and-coerce-property! 'ErrorLabel 'TextAlignment 1 'number) (set-and-coerce-property! 'ErrorLabel 'TextAlignment 1 'number)
(set-and-coerce-property! 'ErrorLabel 'TextColor #xFFFF0000 'number) (set-and-coerce-property! 'ErrorLabel 'TextColor #xFFFF0000 'number)
(set-and-coerce-property! 'ErrorLabel 'Width -2 'number)
) )
;;; PhonePanel ;;; PhonePanel
...@@ -225,14 +230,14 @@ $Source $Yail ...@@ -225,14 +230,14 @@ $Source $Yail
(set-and-coerce-property! 'CodeBox 'FontTypeface 1 'number) (set-and-coerce-property! 'CodeBox 'FontTypeface 1 'number)
(set-and-coerce-property! 'CodeBox 'Width -2 'number)
(set-and-coerce-property! 'CodeBox 'Hint "Six Character Code" 'text) (set-and-coerce-property! 'CodeBox 'Hint "Six Character Code" 'text)
(set-and-coerce-property! 'CodeBox 'MultiLine #t 'boolean) (set-and-coerce-property! 'CodeBox 'MultiLine #t 'boolean)
(set-and-coerce-property! 'CodeBox 'TextAlignment 1 'number) (set-and-coerce-property! 'CodeBox 'TextAlignment 1 'number)
(set-and-coerce-property! 'CodeBox 'Width -2 'number)
) )
;;; Label8 ;;; Label8
...@@ -361,7 +366,7 @@ $Source $Yail ...@@ -361,7 +366,7 @@ $Source $Yail
) )
(define-event PhoneStatus1 OnSettings()(set-this-form) (define-event PhoneStatus1 OnSettings()(set-this-form)
(set-and-coerce-property! 'MainPanel 'Visible #f 'boolean)(set-and-coerce-property! 'SettingsPanel 'Visible #t 'boolean)(set-and-coerce-property! 'rendezvoustextbox 'Text ((get-var p$getRendezvousServer) ) 'text)) (set-and-coerce-property! 'MainPanel 'Visible #f 'boolean)(set-and-coerce-property! 'SettingsPanel 'Visible #t 'boolean)(set-and-coerce-property! 'rendezvoustextbox 'Text ((get-var p$getRendezvousServer) ) 'text)(set-and-coerce-property! 'aidLabel 'Text (call-component-method 'PhoneStatus1 'InstallationId (*list-for-runtime*) '()) 'text))
;;; Web1 ;;; Web1
(add-component MainPanel com.google.appinventor.components.runtime.Web Web1 (add-component MainPanel com.google.appinventor.components.runtime.Web Web1
......
...@@ -318,6 +318,11 @@ public class PhoneStatus extends AndroidNonvisibleComponent implements Component ...@@ -318,6 +318,11 @@ public class PhoneStatus extends AndroidNonvisibleComponent implements Component
} }
} }
@SimpleFunction(description = "Return the ACRA Installation ID")
public String InstallationId() {
return org.acra.util.Installation.id(Form.getActiveForm());
}
/* Static context way to get the useWebRTC flag */ /* Static context way to get the useWebRTC flag */
public static boolean getUseWebRTC() { public static boolean getUseWebRTC() {
return useWebRTC; return useWebRTC;
......
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