@@ -14,7 +14,7 @@ var serviceName = "org.webosbrew.hyperion.ng.loader.service";
14
14
var servicePath = "/media/developer/apps/usr/palm/services/" + serviceName ;
15
15
var autostartFilepath = servicePath + "/autostart.sh" ;
16
16
var linkPath = "/var/lib/webosbrew/init.d/90-start_hyperiond" ;
17
- var elevationCommand = "/media/developer/apps/usr/palm/services/org.webosbrew.hbchannel.service/elevate-service " + serviceName ;
17
+ var elevationCommand = "/media/developer/apps/usr/palm/services/org.webosbrew.hbchannel.service/elevate-service " + serviceName + " && killall -9 loader_service" ;
18
18
19
19
var not = function ( x ) { return ! x } ;
20
20
var yes_no_bool = function ( x ) {
@@ -89,6 +89,8 @@ module.exports = kind({
89
89
hyperionVersionText : 'unknown' ,
90
90
resultText : 'unknown' ,
91
91
92
+ initDone : false ,
93
+
92
94
bindings : [
93
95
{ from : "autostartEnabled" , to : '$.autostart.checked' } ,
94
96
{ from : "serviceElevated" , to : '$.startButton.disabled' , transform : not } ,
@@ -103,11 +105,21 @@ module.exports = kind({
103
105
create : function ( ) {
104
106
this . inherited ( arguments ) ;
105
107
console . info ( "Application created" ) ;
106
- // At first, elevate the native service
107
- // It does not do harm if service is elevated already
108
- this . elevate ( ) ;
109
- this . set ( 'resultText' , 'Checking service status...' ) ;
110
- this . $ . serviceStatus . send ( { } ) ;
108
+ this . set ( 'resultText' , 'Waiting for startup...' ) ;
109
+ // Spawn startup routine after 2 seconds, so UI has time to load
110
+ var self = this ;
111
+ setTimeout ( function ( ) {
112
+ self . doStartup ( ) ;
113
+ } , 3000 ) ;
114
+ } ,
115
+ // Spawned from this.create() with a little delay
116
+ doStartup : function ( ) {
117
+ this . set ( 'resultText' , 'Startup routine started...' ) ;
118
+ var self = this ;
119
+ // Start to continuosly poll service status
120
+ setInterval ( function ( ) {
121
+ self . $ . serviceStatus . send ( { } ) ;
122
+ } , 2000 ) ;
111
123
} ,
112
124
// Elevates the native service - this enables hyperion.ng.loader.service to run as root by default
113
125
elevate : function ( ) {
@@ -161,15 +173,24 @@ module.exports = kind({
161
173
onServiceStatus : function ( sender , evt ) {
162
174
console . info ( "onServiceStatus" ) ;
163
175
console . info ( sender , evt ) ;
176
+
177
+ if ( ! evt . returnValue ) {
178
+ console . info ( 'Service status call failed!' ) ;
179
+ return ;
180
+ }
181
+
164
182
this . set ( 'serviceElevated' , evt . elevated ) ;
165
183
this . set ( 'daemonRunning' , evt . running ) ;
166
- this . set ( 'resultText' , 'Service status received..' ) ;
167
- if ( this . serviceElevated ) {
184
+ if ( this . serviceElevated && ! this . initDone ) {
185
+ this . set ( 'resultText' , 'Startup routine finished!' ) ;
186
+ this . initDone = true ;
168
187
this . checkAutostart ( ) ;
169
188
this . fetchVersion ( ) ;
170
- } else {
171
- this . set ( 'resultText' , 'Restarting native service to elevate...' ) ;
172
- this . terminate ( ) ;
189
+ } else if ( ! this . serviceElevated ) {
190
+ // Elevate the native service
191
+ // Eventually the next service status callback will report elevation
192
+ this . set ( 'resultText' , 'Trying to elevate...' ) ;
193
+ this . elevate ( ) ;
173
194
}
174
195
} ,
175
196
onAutostartCheck : function ( sender , evt ) {
0 commit comments