Skip to content

Commit

Permalink
[deep link] Distinguish IosDomainError and AndroidDomainError. (#7892)
Browse files Browse the repository at this point in the history
* 1

* lint

* word

* resolve comments

* Update validation_details_view.dart
  • Loading branch information
hannah-hyj authored Jun 6, 2024
1 parent 8824098 commit cef4bd7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import 'deep_links_services.dart';
typedef _DomainAndPath = ({String? domain, String? path});

const domainAssetLinksJsonFileErrors = {
DomainError.existence,
DomainError.appIdentifier,
DomainError.fingerprints,
AndroidDomainError.existence,
AndroidDomainError.appIdentifier,
AndroidDomainError.fingerprints,
};
const domainHostingErrors = {
DomainError.contentType,
DomainError.httpsAccessibility,
DomainError.nonRedirect,
DomainError.hostForm,
const domainAndroidHostingErrors = {
AndroidDomainError.contentType,
AndroidDomainError.httpsAccessibility,
AndroidDomainError.nonRedirect,
AndroidDomainError.hostForm,
};

/// The phase of the deep link page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class CommonError {

class DomainError extends CommonError {
const DomainError(super.title, super.explanation, super.fixDetails);
}

class AndroidDomainError extends DomainError {
const AndroidDomainError(super.title, super.explanation, super.fixDetails);

/// Existence of an asset link file.
static const existence = DomainError(
Expand Down Expand Up @@ -117,6 +121,18 @@ class DomainError extends CommonError {
static const other = DomainError('Check failed', '', '');
}

class IosDomainError extends DomainError {
const IosDomainError(super.title, super.explanation, super.fixDetails);
// TODO: Add domain errors for iOS.

/// Existence of an Apple-App-Site-Association file.
static const existence = DomainError(
'Apple-App-Site-Association file does not exist',
'',
'',
);
}

/// There are currently two types of path errors, errors from intent filters and path format errors.
class PathError extends CommonError {
const PathError(super.title, super.explanation, super.fixDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ const String _generatedContentKey = 'generatedContent';
const int _domainBatchSize = 500;

const Map<String, DomainError> checkNameToDomainError = {
'EXISTENCE': DomainError.existence,
'APP_IDENTIFIER': DomainError.appIdentifier,
'FINGERPRINT': DomainError.fingerprints,
'CONTENT_TYPE': DomainError.contentType,
'HTTPS_ACCESSIBILITY': DomainError.httpsAccessibility,
'NON_REDIRECT': DomainError.nonRedirect,
'HOST_FORMED_PROPERLY': DomainError.hostForm,
'OTHER_CHECKS': DomainError.other,
'EXISTENCE': AndroidDomainError.existence,
'APP_IDENTIFIER': AndroidDomainError.appIdentifier,
'FINGERPRINT': AndroidDomainError.fingerprints,
'CONTENT_TYPE': AndroidDomainError.contentType,
'HTTPS_ACCESSIBILITY': AndroidDomainError.httpsAccessibility,
'NON_REDIRECT': AndroidDomainError.nonRedirect,
'HOST_FORMED_PROPERLY': AndroidDomainError.hostForm,
'OTHER_CHECKS': AndroidDomainError.other,
};

class GenerateAssetLinksResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ class _DomainCheckTable extends StatelessWidget {
_CheckExpansionTile(
initiallyExpanded: !fingerprintExists,
checkName: 'Digital assets link file',
status:
_CheckStatusText(hasError: linkData.domainErrors.isNotEmpty),
status: _CheckStatusText(
hasError:
linkData.domainErrors.any((e) => e is AndroidDomainError),
),
children: <Widget>[
_Fingerprint(controller: controller),
// The following checks are only displayed if a fingerprint exists.
Expand Down Expand Up @@ -226,7 +228,7 @@ class _HostingIssues extends StatelessWidget {
@override
Widget build(BuildContext context) {
final errors = controller.selectedLink.value!.domainErrors
.where((error) => domainHostingErrors.contains(error))
.where((error) => domainAndroidHostingErrors.contains(error))
.toList();
return ExpansionTile(
controlAffinity: ListTileControlAffinity.leading,
Expand Down Expand Up @@ -562,7 +564,7 @@ class _CrossCheckTable extends StatelessWidget {
// TODO (hangyujin): Update this bool to actually check if aasa file exists.
const hasIosAasaFile = true;
final hasAndroidAssetLinksFile =
!linkData.domainErrors.contains(DomainError.existence);
!linkData.domainErrors.contains(AndroidDomainError.existence);

final missingIos = hasIosAasaFile && !linkData.os.contains(PlatformOS.ios);
final missingAndroid =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final domainErrorlinkData = LinkData(
domain: 'www.google.com',
path: '/',
os: {PlatformOS.android, PlatformOS.ios},
domainErrors: [DomainError.existence],
domainErrors: [AndroidDomainError.existence],
);

final pathErrorlinkData = LinkData(
Expand Down Expand Up @@ -427,7 +427,7 @@ void main() {
domain: 'www.domain1.com',
path: '/',
os: {PlatformOS.android},
domainErrors: [DomainError.existence],
domainErrors: [AndroidDomainError.existence],
),
LinkData(
domain: 'www.domain2.com',
Expand Down Expand Up @@ -499,7 +499,7 @@ void main() {
domain: 'www.domain2.com',
path: '/path',
os: {PlatformOS.ios},
domainErrors: [DomainError.existence],
domainErrors: [AndroidDomainError.existence],
),
LinkData(
domain: 'www.google.com',
Expand Down Expand Up @@ -631,7 +631,7 @@ void main() {
domain: 'www.domain1.com',
path: '/path1',
os: {PlatformOS.android},
domainErrors: [DomainError.existence],
domainErrors: [AndroidDomainError.existence],
),
LinkData(
domain: 'www.domain2.com',
Expand Down

0 comments on commit cef4bd7

Please sign in to comment.