From d3d4cf2515c8a6273549a9392ed1d5e35f6ed0e2 Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Sat, 22 May 2021 23:27:20 +0530 Subject: [PATCH] Add a separate package for the independent track --- android/app/build.gradle | 10 +++++++++- lib/core/network.dart | 5 +++-- lib/services/update_service.dart | 12 +++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3675cf088..fe86dd975 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -59,7 +59,15 @@ android { storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } - } + } + + flavorDimensions "default" + productFlavors { + independent { + dimension "default" + applicationIdSuffix ".independent" + } + } buildTypes { release { diff --git a/lib/core/network.dart b/lib/core/network.dart index 8ec5f4a7b..64f88b9f3 100644 --- a/lib/core/network.dart +++ b/lib/core/network.dart @@ -9,10 +9,11 @@ class Network { Future init() async { await FlutterUserAgent.init(); - final version = await _getAppVersion(); + final packageInfo = await PackageInfo.fromPlatform(); _dio = Dio(BaseOptions(headers: { HttpHeaders.userAgentHeader: FlutterUserAgent.userAgent, - 'X-Client-Version': version, + 'X-Client-Version': packageInfo.version, + 'X-Package-Name': packageInfo.packageName, })); } diff --git a/lib/services/update_service.dart b/lib/services/update_service.dart index 46c61be4f..9f0925f94 100644 --- a/lib/services/update_service.dart +++ b/lib/services/update_service.dart @@ -1,5 +1,7 @@ import 'dart:io'; +import 'package:flutter/foundation.dart'; +import 'package:logging/logging.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:photos/core/network.dart'; @@ -10,12 +12,16 @@ class UpdateService { LatestVersionInfo _latestVersion; Future shouldUpdate() async { + final platform = await PackageInfo.fromPlatform(); + Logger("UpdateService").info(platform.packageName); if (Platform.isIOS) { return false; } + if (!kDebugMode && platform.packageName != "io.ente.photos.independent") { + return false; + } _latestVersion = await _getLatestVersionInfo(); - final currentVersionCode = - int.parse((await PackageInfo.fromPlatform()).buildNumber); + final currentVersionCode = int.parse(platform.buildNumber); return currentVersionCode < _latestVersion.code; } @@ -26,7 +32,7 @@ class UpdateService { Future _getLatestVersionInfo() async { final response = await Network.instance .getDio() - .get("https://android.ente.io/release-info.json"); + .get("https://ente-android-releases.netlify.app/release-info.json"); return LatestVersionInfo.fromMap(response.data["latestVersion"]); } }