Retire the classic flight screen and stop the start-up location grant being dropped
MainActivity now makes the app's only start-up permission request and tells Dart when it finishes; the phone-location stream waits for that instead of asking in parallel, which made Android drop the location grant. The P3 simulator run passed, so the pre-P2 FlightControlPage, the pages only it used and its Settings toggle are gone. The app smoke test checks the home screen again instead of the login gate removed in July. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
63acacced7
commit
2db557a3b4
11 files changed
+50
-1088
No files matched your search
@@ -198,6 +198,15 @@ class DjiSdkBridge(
|
||||
mainHandler.post { eventSink?.success(event) }
|
||||
}
|
||||
|
||||
/**
|
||||
* MainActivity's start-up permission request finished. Dart must not ask for
|
||||
* location itself while that dialog is up (Android allows one request at a
|
||||
* time and drops the other's grant), so it waits for this event instead.
|
||||
*/
|
||||
fun onPermissionsResult(locationGranted: Boolean) {
|
||||
emit(mapOf("type" to "permissions", "location" to locationGranted))
|
||||
}
|
||||
|
||||
// ── DJI SDK registration & product lifecycle ─────────────────────────────────
|
||||
|
||||
private fun registerApp() {
|
||||
|
||||
@@ -31,7 +31,9 @@ class MainActivity : FlutterFragmentActivity() {
|
||||
/**
|
||||
* The DJI SDK needs these dangerous permissions granted before it can connect
|
||||
* to / communicate with a product. We request them up front from the host
|
||||
* Activity so the Flutter UI can stay focused on the SDK flow.
|
||||
* Activity so the Flutter UI can stay focused on the SDK flow. This is the
|
||||
* app's only start-up permission request: Dart waits for the result (see
|
||||
* [DjiSdkBridge.onPermissionsResult]) rather than asking in parallel.
|
||||
*/
|
||||
private fun requestDjiPermissions() {
|
||||
val missing = REQUIRED_PERMISSIONS.filter {
|
||||
@@ -42,6 +44,17 @@ class MainActivity : FlutterFragmentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode != PERMISSION_REQUEST_CODE) return
|
||||
val location = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
|
||||
PackageManager.PERMISSION_GRANTED ||
|
||||
ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) ==
|
||||
PackageManager.PERMISSION_GRANTED
|
||||
bridge?.onPermissionsResult(location)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PERMISSION_REQUEST_CODE = 12321
|
||||
|
||||
|
||||
Reference in new issue
Block a user