bug report system info includes installer package
This commit is contained in:
parent
f929ade864
commit
834531c731
3 changed files with 36 additions and 2 deletions
|
@ -33,10 +33,12 @@ import deckers.thibault.aves.utils.LogUtils
|
||||||
import io.flutter.plugin.common.MethodCall
|
import io.flutter.plugin.common.MethodCall
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.SupervisorJob
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class AppAdapterHandler(private val context: Context) : MethodCallHandler {
|
class AppAdapterHandler(private val context: Context) : MethodCallHandler {
|
||||||
|
@ -46,6 +48,7 @@ class AppAdapterHandler(private val context: Context) : MethodCallHandler {
|
||||||
when (call.method) {
|
when (call.method) {
|
||||||
"getPackages" -> ioScope.launch { safe(call, result, ::getPackages) }
|
"getPackages" -> ioScope.launch { safe(call, result, ::getPackages) }
|
||||||
"getAppIcon" -> ioScope.launch { safeSuspend(call, result, ::getAppIcon) }
|
"getAppIcon" -> ioScope.launch { safeSuspend(call, result, ::getAppIcon) }
|
||||||
|
"getAppInstaller" -> ioScope.launch { safe(call, result, ::getAppInstaller) }
|
||||||
"copyToClipboard" -> ioScope.launch { safe(call, result, ::copyToClipboard) }
|
"copyToClipboard" -> ioScope.launch { safe(call, result, ::copyToClipboard) }
|
||||||
"edit" -> safe(call, result, ::edit)
|
"edit" -> safe(call, result, ::edit)
|
||||||
"open" -> safe(call, result, ::open)
|
"open" -> safe(call, result, ::open)
|
||||||
|
@ -161,6 +164,23 @@ class AppAdapterHandler(private val context: Context) : MethodCallHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getAppInstaller(@Suppress("unused_parameter") call: MethodCall, result: MethodChannel.Result) {
|
||||||
|
val packageName = context.packageName
|
||||||
|
val pm = context.packageManager
|
||||||
|
try {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
val info = pm.getInstallSourceInfo(packageName)
|
||||||
|
result.success(info.initiatingPackageName ?: info.installingPackageName)
|
||||||
|
} else {
|
||||||
|
@Suppress("deprecation")
|
||||||
|
result.success(pm.getInstallerPackageName(packageName))
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
result.error("getAppInstaller-exception", "failed to get installer for packageName=$packageName", e.message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun copyToClipboard(call: MethodCall, result: MethodChannel.Result) {
|
private fun copyToClipboard(call: MethodCall, result: MethodChannel.Result) {
|
||||||
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
|
val uri = call.argument<String>("uri")?.let { Uri.parse(it) }
|
||||||
val label = call.argument<String>("label")
|
val label = call.argument<String>("label")
|
||||||
|
|
|
@ -14,6 +14,8 @@ abstract class AndroidAppService {
|
||||||
|
|
||||||
Future<Uint8List> getAppIcon(String packageName, double size);
|
Future<Uint8List> getAppIcon(String packageName, double size);
|
||||||
|
|
||||||
|
Future<String?> getAppInstaller();
|
||||||
|
|
||||||
Future<bool> copyToClipboard(String uri, String? label);
|
Future<bool> copyToClipboard(String uri, String? label);
|
||||||
|
|
||||||
Future<bool> edit(String uri, String mimeType);
|
Future<bool> edit(String uri, String mimeType);
|
||||||
|
@ -73,6 +75,16 @@ class PlatformAndroidAppService implements AndroidAppService {
|
||||||
return Uint8List(0);
|
return Uint8List(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String?> getAppInstaller() async {
|
||||||
|
try {
|
||||||
|
return await platform.invokeMethod('getAppInstaller');
|
||||||
|
} on PlatformException catch (e, stack) {
|
||||||
|
await reportService.recordError(e, stack);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> copyToClipboard(String uri, String? label) async {
|
Future<bool> copyToClipboard(String uri, String? label) async {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -158,6 +158,7 @@ class _BugReportState extends State<BugReport> with FeedbackMixin {
|
||||||
Future<String> _getInfo(BuildContext context) async {
|
Future<String> _getInfo(BuildContext context) async {
|
||||||
final packageInfo = await PackageInfo.fromPlatform();
|
final packageInfo = await PackageInfo.fromPlatform();
|
||||||
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||||
|
final installer = await androidAppService.getAppInstaller();
|
||||||
final hasPlayServices = await availability.hasPlayServices;
|
final hasPlayServices = await availability.hasPlayServices;
|
||||||
final flavor = context.read<AppFlavor>().toString().split('.')[1];
|
final flavor = context.read<AppFlavor>().toString().split('.')[1];
|
||||||
return [
|
return [
|
||||||
|
@ -169,6 +170,7 @@ class _BugReportState extends State<BugReport> with FeedbackMixin {
|
||||||
'Google Play services: ${hasPlayServices ? 'ready' : 'not available'}',
|
'Google Play services: ${hasPlayServices ? 'ready' : 'not available'}',
|
||||||
'System locales: ${WidgetsBinding.instance!.window.locales.join(', ')}',
|
'System locales: ${WidgetsBinding.instance!.window.locales.join(', ')}',
|
||||||
'Aves locale: ${settings.locale ?? 'system'} -> ${settings.appliedLocale}',
|
'Aves locale: ${settings.locale ?? 'system'} -> ${settings.appliedLocale}',
|
||||||
|
'Installer: $installer',
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue