Re: [Dev] [EMM][Android] OTA firmware upgrade support

2016-03-30 Thread Kasun Dananjaya Delgolla
Hi Gayan,

Server get an ack when the process starts. But we can change status type at
any point. OTA logic is done in a way that the update package gets deleted
once the process is complete. So it's already handled. If the test passes
the download process and goes to the verify state, that means the logic
works well. After that point, upgrade will be handled by OS inbuilt upgrade
process.

Thanks
On Mar 30, 2016 11:36 PM, "Gayan Yalpathwala"  wrote:

> Hi Kasun,
>
> Following problems were encountered while completing the OTA upgrade
> process.
>
> 03-30 22:50:16.534 12103-12116/org.wso2.emm.system.service E/OTA_SM:
> Update package file retrieval error.java.io.IOException: open failed:
> EACCES (Permission denied)
> - This was due to using /cache/update.zip as the OTA package location.
> This location was changed to /mnt/sdcard/update.zip in order to read the
> file successfully.
> - Also added following read and write permissions for the system app.
>  android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
> 
>  android:name="android.permission.READ_EXTERNAL_STORAGE" />
>
> checkURL() method in OTAServerManager.java hangs while checking the
> existence of the URL.
> - This implementation is currently invalid since we have a static URL
> implementation, therefore the method was made to return true.
>
> Other than that, I have noticed that the server is ACKed even when the OTA
> upgrade fails on the device end.
> Is there a mechanism to clear the OTA package from the device's file
> location once installed? If not, this will lead to a memory overflow.
>
> Thanks,
>
>
>
>
>
> On Tue, Mar 29, 2016 at 9:11 PM, Kasun Dananjaya Delgolla  > wrote:
>
>> Hi Gayan,
>>
>> Seems like OTA process downloads the firmware package. After this, did
>> you see logs when the system app tries to trigger the build?
>>
>> Thanks
>>
>> On Tue, Mar 29, 2016 at 7:38 PM, Gayan Yalpathwala 
>> wrote:
>>
>>> Hi Kasun et al,
>>>
>>> I have implemented this operation and tested on a rooted device with the
>>> system app in place.
>>>
>>> OTA Server
>>> =
>>> A file server which serves build.prop and the particular upgrade pack
>>> was used as the OTA server. These files need to be added under a
>>> sub-directory in the name of the device.
>>> Ex:-
>>> Device name: c1ktt
>>> Files: http://10.10.10.227:8000/c1ktt/build.prop and
>>> http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip
>>>
>>> build.prop
>>> 
>>> Attached is a sample build.prop. Key field to be changed is as follows.
>>> ro.build.version.release=x.x.x (This version has to be greater than the
>>> previous version of the firmware for an upgrade to happen)
>>>
>>> Server side configurations
>>> 
>>> Following constants need to be changed accordingly
>>> in org/wso2/emm/system/service/utils/Constants.java. These configs which
>>> are related to the OTA server, will be moved out to an external config file.
>>>   public static final String DEFAULT_OTA_SERVER_ADDRESS =
>>> "10.10.10.227";
>>> public static final String DEFAULT_OTA_SERVER_PROTOCOL = "http";
>>> public static final int DEFAULT_OTA_SERVER_PORT = 8000;
>>>
>>> Logs from system app
>>> =
>>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>>> D/EMMSystemService: Entered onHandleIntent of the Command Runner Service.
>>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>>> D/EMMSystemService: EMM agent has sent a command.
>>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>>> D/EMMSystemService: The operation code is: UPGRADE_FIRMWARE
>>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>>> I/EMMSystemService: Will now executing the command ...UPGRADE_FIRMWARE
>>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>>> D/EMMSystemService: Do task triggered. Code = UPGRADE_FIRMWARE
>>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>>> I/EMMSystemService: An upgrade has been requested
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
>>>  checkMirrorLinkEnabled returns : false
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
>>> showing allowed
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
>>> Loading configuration from file /data/system/ota.conf for product c1ktt
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service E/OTA_SC:
>>> Build property file does not meet required
>>> specification.java.io.FileNotFoundException: /data/system/ota.conf: open
>>> failed: ENOENT (No such file or directory)
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service I/OTA_SC:
>>> Loading default configuration for product c1ktt.
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
>>> create a new server config: package url
>>> http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip:8000
>>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
>>> 

Re: [Dev] [EMM][Android] OTA firmware upgrade support

2016-03-30 Thread Gayan Yalpathwala
Hi Kasun,

Following problems were encountered while completing the OTA upgrade
process.

03-30 22:50:16.534 12103-12116/org.wso2.emm.system.service E/OTA_SM: Update
package file retrieval error.java.io.IOException: open failed: EACCES
(Permission denied)
- This was due to using /cache/update.zip as the OTA package location. This
location was changed to /mnt/sdcard/update.zip in order to read the file
successfully.
- Also added following read and write permissions for the system app.




checkURL() method in OTAServerManager.java hangs while checking the
existence of the URL.
- This implementation is currently invalid since we have a static URL
implementation, therefore the method was made to return true.

Other than that, I have noticed that the server is ACKed even when the OTA
upgrade fails on the device end.
Is there a mechanism to clear the OTA package from the device's file
location once installed? If not, this will lead to a memory overflow.

Thanks,





On Tue, Mar 29, 2016 at 9:11 PM, Kasun Dananjaya Delgolla 
wrote:

> Hi Gayan,
>
> Seems like OTA process downloads the firmware package. After this, did you
> see logs when the system app tries to trigger the build?
>
> Thanks
>
> On Tue, Mar 29, 2016 at 7:38 PM, Gayan Yalpathwala 
> wrote:
>
>> Hi Kasun et al,
>>
>> I have implemented this operation and tested on a rooted device with the
>> system app in place.
>>
>> OTA Server
>> =
>> A file server which serves build.prop and the particular upgrade pack was
>> used as the OTA server. These files need to be added under a sub-directory
>> in the name of the device.
>> Ex:-
>> Device name: c1ktt
>> Files: http://10.10.10.227:8000/c1ktt/build.prop and
>> http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip
>>
>> build.prop
>> 
>> Attached is a sample build.prop. Key field to be changed is as follows.
>> ro.build.version.release=x.x.x (This version has to be greater than the
>> previous version of the firmware for an upgrade to happen)
>>
>> Server side configurations
>> 
>> Following constants need to be changed accordingly
>> in org/wso2/emm/system/service/utils/Constants.java. These configs which
>> are related to the OTA server, will be moved out to an external config file.
>>   public static final String DEFAULT_OTA_SERVER_ADDRESS = "10.10.10.227";
>> public static final String DEFAULT_OTA_SERVER_PROTOCOL = "http";
>> public static final int DEFAULT_OTA_SERVER_PORT = 8000;
>>
>> Logs from system app
>> =
>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>> D/EMMSystemService: Entered onHandleIntent of the Command Runner Service.
>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>> D/EMMSystemService: EMM agent has sent a command.
>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>> D/EMMSystemService: The operation code is: UPGRADE_FIRMWARE
>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>> I/EMMSystemService: Will now executing the command ...UPGRADE_FIRMWARE
>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>> D/EMMSystemService: Do task triggered. Code = UPGRADE_FIRMWARE
>> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
>> I/EMMSystemService: An upgrade has been requested
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
>>  checkMirrorLinkEnabled returns : false
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
>> showing allowed
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
>> Loading configuration from file /data/system/ota.conf for product c1ktt
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service E/OTA_SC:
>> Build property file does not meet required
>> specification.java.io.FileNotFoundException: /data/system/ota.conf: open
>> failed: ENOENT (No such file or directory)
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service I/OTA_SC:
>> Loading default configuration for product c1ktt.
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
>> create a new server config: package url
>> http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip:8000
>> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
>> build.prop URL:http://10.10.10.227:8000/c1ktt/build.prop
>> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM:
>> Start download: http://10.10.10.227:8000/c1ktt/build.prop to buffer
>> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM:
>> wrote 1024 into byte output stream
>> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM:
>> wrote 1024 into byte output stream
>> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM:
>> wrote 1024 into byte output stream
>> 03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_SM:
>> wrote 166 into byte output stream
>> 03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_SM:
>> Download finished: 

Re: [Dev] [EMM][Android] OTA firmware upgrade support

2016-03-29 Thread Kasun Dananjaya Delgolla
Hi Gayan,

Seems like OTA process downloads the firmware package. After this, did you
see logs when the system app tries to trigger the build?

Thanks

On Tue, Mar 29, 2016 at 7:38 PM, Gayan Yalpathwala  wrote:

> Hi Kasun et al,
>
> I have implemented this operation and tested on a rooted device with the
> system app in place.
>
> OTA Server
> =
> A file server which serves build.prop and the particular upgrade pack was
> used as the OTA server. These files need to be added under a sub-directory
> in the name of the device.
> Ex:-
> Device name: c1ktt
> Files: http://10.10.10.227:8000/c1ktt/build.prop and
> http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip
>
> build.prop
> 
> Attached is a sample build.prop. Key field to be changed is as follows.
> ro.build.version.release=x.x.x (This version has to be greater than the
> previous version of the firmware for an upgrade to happen)
>
> Server side configurations
> 
> Following constants need to be changed accordingly
> in org/wso2/emm/system/service/utils/Constants.java. These configs which
> are related to the OTA server, will be moved out to an external config file.
>   public static final String DEFAULT_OTA_SERVER_ADDRESS = "10.10.10.227";
> public static final String DEFAULT_OTA_SERVER_PROTOCOL = "http";
> public static final int DEFAULT_OTA_SERVER_PORT = 8000;
>
> Logs from system app
> =
> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
> D/EMMSystemService: Entered onHandleIntent of the Command Runner Service.
> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
> D/EMMSystemService: EMM agent has sent a command.
> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
> D/EMMSystemService: The operation code is: UPGRADE_FIRMWARE
> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
> I/EMMSystemService: Will now executing the command ...UPGRADE_FIRMWARE
> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
> D/EMMSystemService: Do task triggered. Code = UPGRADE_FIRMWARE
> 03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
> I/EMMSystemService: An upgrade has been requested
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
>  checkMirrorLinkEnabled returns : false
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
> showing allowed
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
> Loading configuration from file /data/system/ota.conf for product c1ktt
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service E/OTA_SC: Build
> property file does not meet required
> specification.java.io.FileNotFoundException: /data/system/ota.conf: open
> failed: ENOENT (No such file or directory)
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service I/OTA_SC:
> Loading default configuration for product c1ktt.
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
> create a new server config: package url
> http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip:8000
> 03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
> build.prop URL:http://10.10.10.227:8000/c1ktt/build.prop
> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: Start
> download: http://10.10.10.227:8000/c1ktt/build.prop to buffer
> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
> 1024 into byte output stream
> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
> 1024 into byte output stream
> 03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
> 1024 into byte output stream
> 03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
> 166 into byte output stream
> 03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_SM:
> Download finished: 3238 bytes downloaded
> 03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_BPP:
> tmpDir:/data/data/org.wso2.emm.system.service/files
>
> Thanks,
>
>
>
>
> On Wed, Feb 10, 2016 at 7:22 PM, Kasun Dananjaya Delgolla  > wrote:
>
>> Hi,
>>
>> I have implemented the android layer implementation of the above
>> functionality. How it works is, when the admin sends the upgrade command
>> from the UI/REST API, android agent app talks to the system service
>> (implemented as a separate component, since these features require system
>> level/root access). Then, the system service will invoke the firmware
>> upgrade following the below steps.
>>
>> 1. System app will first downloads the OTA upgrade package's
>> configuration file "ota.conf" from the OTA server (server URL and ports
>> have to be configured in the system app)
>> 2. Then it parses the config file downloaded to read the necessary
>> configs (ex: upgrade package version, size etc)
>> 3. System app compares the upgrade package version with the device
>> existing firmware version.
>> 4. If the firmware version is greater than the available version, it
>> downloads 

Re: [Dev] [EMM][Android] OTA firmware upgrade support

2016-03-29 Thread Gayan Yalpathwala
Hi Kasun et al,

I have implemented this operation and tested on a rooted device with the
system app in place.

OTA Server
=
A file server which serves build.prop and the particular upgrade pack was
used as the OTA server. These files need to be added under a sub-directory
in the name of the device.
Ex:-
Device name: c1ktt
Files: http://10.10.10.227:8000/c1ktt/build.prop and
http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip

build.prop

Attached is a sample build.prop. Key field to be changed is as follows.
ro.build.version.release=x.x.x (This version has to be greater than the
previous version of the firmware for an upgrade to happen)

Server side configurations

Following constants need to be changed accordingly
in org/wso2/emm/system/service/utils/Constants.java. These configs which
are related to the OTA server, will be moved out to an external config file.
  public static final String DEFAULT_OTA_SERVER_ADDRESS = "10.10.10.227";
public static final String DEFAULT_OTA_SERVER_PROTOCOL = "http";
public static final int DEFAULT_OTA_SERVER_PORT = 8000;

Logs from system app
=
03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
D/EMMSystemService: Entered onHandleIntent of the Command Runner Service.
03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
D/EMMSystemService: EMM agent has sent a command.
03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
D/EMMSystemService: The operation code is: UPGRADE_FIRMWARE
03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
I/EMMSystemService: Will now executing the command ...UPGRADE_FIRMWARE
03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
D/EMMSystemService: Do task triggered. Code = UPGRADE_FIRMWARE
03-29 18:46:40.114 23424-17321/org.wso2.emm.system.service
I/EMMSystemService: An upgrade has been requested
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast:
 checkMirrorLinkEnabled returns : false
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/Toast: showing
allowed
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
Loading configuration from file /data/system/ota.conf for product c1ktt
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service E/OTA_SC: Build
property file does not meet required
specification.java.io.FileNotFoundException: /data/system/ota.conf: open
failed: ENOENT (No such file or directory)
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service I/OTA_SC:
Loading default configuration for product c1ktt.
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC: create
a new server config: package url
http://10.10.10.227:8000/c1ktt/c1ktt.ota.zip:8000
03-29 18:46:40.119 23424-17321/org.wso2.emm.system.service D/OTA_SC:
build.prop URL:http://10.10.10.227:8000/c1ktt/build.prop
03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: Start
download: http://10.10.10.227:8000/c1ktt/build.prop to buffer
03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
1024 into byte output stream
03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
1024 into byte output stream
03-29 18:46:40.214 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
1024 into byte output stream
03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_SM: wrote
166 into byte output stream
03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_SM:
Download finished: 3238 bytes downloaded
03-29 18:46:40.219 23424-17321/org.wso2.emm.system.service D/OTA_BPP:
tmpDir:/data/data/org.wso2.emm.system.service/files

Thanks,




On Wed, Feb 10, 2016 at 7:22 PM, Kasun Dananjaya Delgolla 
wrote:

> Hi,
>
> I have implemented the android layer implementation of the above
> functionality. How it works is, when the admin sends the upgrade command
> from the UI/REST API, android agent app talks to the system service
> (implemented as a separate component, since these features require system
> level/root access). Then, the system service will invoke the firmware
> upgrade following the below steps.
>
> 1. System app will first downloads the OTA upgrade package's configuration
> file "ota.conf" from the OTA server (server URL and ports have to be
> configured in the system app)
> 2. Then it parses the config file downloaded to read the necessary configs
> (ex: upgrade package version, size etc)
> 3. System app compares the upgrade package version with the device
> existing firmware version.
> 4. If the firmware version is greater than the available version, it
> downloads the upgrade package from the server.
> 5. System app triggers the OTA upgrade.
>
> Thanks
>
> On Wed, Feb 10, 2016 at 6:41 PM, Gayan Yalpathwala 
> wrote:
>
>> Hi,
>>
>> I am adding the above function to the REST API layer and to the jaggery
>> UI of EMM. With the introduction of this, a privileged user can remotely
>> force a firmware upgrade on the device. This facility will only be