[mob][photos] Trigger send logs if app is stuck in spalsh screen for >= 15 seconds (#1796)
This commit is contained in:
parent
eac142025d
commit
e203a8378e
2 changed files with 38 additions and 4 deletions
|
@ -51,6 +51,7 @@ import 'package:photos/services/user_service.dart';
|
|||
import 'package:photos/ui/tools/app_lock.dart';
|
||||
import 'package:photos/ui/tools/lock_screen.dart';
|
||||
import 'package:photos/utils/crypto_util.dart';
|
||||
import "package:photos/utils/email_util.dart";
|
||||
import 'package:photos/utils/file_uploader.dart';
|
||||
import 'package:photos/utils/local_settings.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -180,6 +181,16 @@ void _headlessTaskHandler(HeadlessTask task) {
|
|||
}
|
||||
|
||||
Future<void> _init(bool isBackground, {String via = ''}) async {
|
||||
bool initComplete = false;
|
||||
Future.delayed(const Duration(seconds: 15), () {
|
||||
if (!initComplete && !isBackground) {
|
||||
sendLogsForInit(
|
||||
"support@ente.io",
|
||||
"Stuck on splash screen for >= 15 seconds",
|
||||
null,
|
||||
);
|
||||
}
|
||||
});
|
||||
_isProcessRunning = true;
|
||||
_logger.info("Initializing... inBG =$isBackground via: $via");
|
||||
final SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
|
@ -254,6 +265,7 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
|||
preferences,
|
||||
);
|
||||
|
||||
initComplete = true;
|
||||
_logger.info("Initialization done");
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import 'package:path_provider/path_provider.dart';
|
|||
import 'package:photos/core/configuration.dart';
|
||||
import 'package:photos/core/error-reporting/super_logging.dart';
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/ui/common/progress_dialog.dart";
|
||||
import 'package:photos/ui/components/buttons/button_widget.dart';
|
||||
import 'package:photos/ui/components/dialog_widget.dart';
|
||||
import 'package:photos/ui/components/models/button_type.dart';
|
||||
|
@ -122,9 +123,28 @@ Future<void> _sendLogs(
|
|||
}
|
||||
}
|
||||
|
||||
Future<String> getZippedLogsFile(BuildContext context) async {
|
||||
final dialog = createProgressDialog(context, S.of(context).preparingLogs);
|
||||
await dialog.show();
|
||||
Future<void> sendLogsForInit(
|
||||
String toEmail,
|
||||
String? subject,
|
||||
String? body,
|
||||
) async {
|
||||
final String zipFilePath = await getZippedLogsFile(null);
|
||||
final Email email = Email(
|
||||
recipients: [toEmail],
|
||||
subject: subject ?? '',
|
||||
body: body ?? '',
|
||||
attachmentPaths: [zipFilePath],
|
||||
isHTML: false,
|
||||
);
|
||||
await FlutterEmailSender.send(email);
|
||||
}
|
||||
|
||||
Future<String> getZippedLogsFile(BuildContext? context) async {
|
||||
late final ProgressDialog dialog;
|
||||
if (context != null) {
|
||||
dialog = createProgressDialog(context, S.of(context).preparingLogs);
|
||||
await dialog.show();
|
||||
}
|
||||
final logsPath = (await getApplicationSupportDirectory()).path;
|
||||
final logsDirectory = Directory(logsPath + "/logs");
|
||||
final tempPath = (await getTemporaryDirectory()).path;
|
||||
|
@ -134,7 +154,9 @@ Future<String> getZippedLogsFile(BuildContext context) async {
|
|||
encoder.create(zipFilePath);
|
||||
await encoder.addDirectory(logsDirectory);
|
||||
encoder.close();
|
||||
await dialog.hide();
|
||||
if (context != null) {
|
||||
await dialog.hide();
|
||||
}
|
||||
return zipFilePath;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue