diff --git a/src/Helpers/Build.php b/src/Helpers/Build.php index e873d837b7269e8effc75ac0301d80303c31ed28..937582b0783f9bad3ffe2546ed6da30d395f2183 100644 --- a/src/Helpers/Build.php +++ b/src/Helpers/Build.php @@ -71,12 +71,12 @@ LINEAGE => [SIGNED] (ex. signed) ) */ - preg_match_all('/(cm|lineage|eelo|e)-([0-9\.]+)-\D?-?([\d_]+)?-([\w+]+)-([A-Za-z0-9]+)?-?([\w+]+)?/', $fileName, $tokens); + preg_match_all('/(e)-([0-9\.]+)-?((alpha|beta|rc)(\.\d)?)?-\D-?([\d_]+)?-([\w+]+)-([A-Za-z0-9]+)?-?([\w+]+)?/', $fileName, $tokens); $this->filePath = (substr($physicalPath, -1) === '/') ? $physicalPath . $fileName : $physicalPath . '/' . $fileName; $tokens = $this->formatTokens($tokens); $this->migrationFilePath = $physicalPath . '/migration_paths.json'; - $this->channel = $this->_getChannel(str_replace(range(0, 9), '', $tokens[4]), $tokens[1], $tokens[2]); + $this->channel = $this->_getChannel(str_replace(range(0, 9), '', $tokens[7]), $tokens[1], $tokens[2]); $this->filename = $fileName; // Try to load the build.prop from two possible paths: @@ -88,7 +88,7 @@ $this->timestamp = intval($this->getBuildPropValue('ro.build.date.utc') ?? filemtime($this->filePath)); $this->incremental = $this->getBuildPropValue('ro.build.version.incremental') ?? ''; $this->apiLevel = $this->getBuildPropValue('ro.build.version.sdk') ?? ''; - $this->model = $this->getBuildPropValue('ro.lineage.device') ?? $this->getBuildPropValue('ro.cm.device') ?? ($tokens[1] == 'cm' ? $tokens[6] : $tokens[5]); + $this->model = $this->getBuildPropValue('ro.lineage.device') ?? $this->getBuildPropValue('ro.cm.device') ?? ($tokens[1] == 'cm' ? $tokens[9] : $tokens[8]); $this->version = $tokens[2]; $this->displayVersion = $this->getBuildPropValue('ro.cm.display.version') ?? $this->getBuildPropValue('ro.lineage.display.version') ?? ''; $this->androidVersion = $this->getBuildPropValue('ro.build.version.release') ?? ''; @@ -172,7 +172,7 @@ return $ret; } - + /** * Check version of current build against given build(returns false if lesser version) * @param object An object representing current build @@ -183,7 +183,7 @@ if (empty($currentBuild)) { return true; } // Valid build if no current build specified - + if ($currentBuild->getTimestamp() >= $this->getTimestamp()) { return false; // Invalid build if timestamp older or equal(same build invalid) } @@ -230,7 +230,7 @@ return $this->size; } - + /** * Get isUpgradeSupported parameter * @return boolean @@ -246,7 +246,7 @@ } */ public function getIsUpgradeSupported($compareVersion) - { + { $thisMajorVersion = explode(".", $this->androidVersion)[0]; $compareMajorVersion = explode(".", $compareVersion)[0]; $isSameVersion = boolval(!strcmp($thisMajorVersion, $compareMajorVersion)); // Check if Android version is same @@ -254,18 +254,18 @@ if($isSameVersion) { return true; } - + else if(file_exists($this->migrationFilePath)) { $migrationContents = file_get_contents($this->migrationFilePath); if (!empty($migrationContents)) { $migrations = json_decode($migrationContents, true); // Contains migration rules - + if (!empty($migrations[$compareMajorVersion]) && is_array($migrations[$compareMajorVersion])) { return in_array(intval($thisMajorVersion), $migrations[$compareMajorVersion]); } } } - + return false; } /** @@ -557,4 +557,4 @@ } return TRUE; } - } \ No newline at end of file + }