Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1481464f authored by Romain Hunault's avatar Romain Hunault
Browse files

Return the update based on the same Android version of the current build

parent 2087061a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
.git
Dockerfile
builds/delta/*/*/*.zip
builds/full/*/*/*.zip
+23 −0
Original line number Diff line number Diff line
@@ -14,6 +14,29 @@ Got a question? Not sure where it should be made? See [CONTRIBUTING](CONTRIBUTIN

## How to use

### Test

```
$ sudo docker stop lineageota \
    && sudo docker build -t e/lineageota . \
    && sudo docker run \
        -d \
        -p 80:80 \
        --rm \
        -v "${PWD}/builds/full:/var/www/html/builds/full" \
        --name lineageota \
        e/lineageota \
```

Access to API via http://localhost/api/v1/\<device\>/\<channel\>

Get logs with

```
$ sudo docker exec -ti lineageota tail -f LineageOTA.log
```


### Composer

```shell
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
    $protocol = 'https://';

    $logger = new Logger('main');
    $logger->pushHandler(new StreamHandler('LineageOTA.log', Logger::WARNING));
    $logger->pushHandler(new StreamHandler('LineageOTA.log', Logger::INFO));

    $app = new CmOta($logger);
    $app
+14 −5
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@

        // This will contain the build list based on the current request
    	private $builds = array();

      private $postData = array();
      private $logger = null;
      private $currentBuild = null;

        /**
         * Constructor of the Builds class.
@@ -61,8 +61,12 @@

            foreach ( $this->builds as $build ) {

                // TODO look into incremental
                // TODO look into android_version
                if (!is_null($this->currentBuild) && strcmp($this->currentBuild->getAndroidVersion(), $build->getAndroidVersion()) != 0) {
                  $this->logger->info($build->getIncremental().' ignored as Android version is not the same');
                  continue;
                }

                $this->logger->info($build->getIncremental().' is a new update');

                array_push( $ret, array(
                    // CyanogenMod
@@ -175,6 +179,11 @@

                            if ( $build->isValid( $this->postData['params'] ) ) {
                                array_push( $this->builds , $build );

                                if (strcmp($this->postData['params']['source_incremental'], $build->getIncremental()) == 0) {
                                  $this->currentBuild = $build;
                                  $this->logger->info($build->getIncremental().' is the current build');
                                }
                            }
                        }
                    }