From baac741ef80af06dca9c314911e95371af1da5be Mon Sep 17 00:00:00 2001 From: Martin Williams Date: Wed, 24 Jul 2024 16:47:38 +0100 Subject: [PATCH] Target android14 (#74) * targetSdk 34 * Declare DfuService foreground type * onPause/Resume don't signal back/forground * Fix call to LayoutInflater; add StrictMode logging * Fix screen update after DFU error --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 7 ++-- .../main/java/com/samsung/microbit/MBApp.java | 35 +++++++++++++++++-- .../microbit/ui/activity/ProjectActivity.java | 2 ++ .../microbit/ui/adapter/ProjectAdapter.java | 2 +- pfLibrary | 2 +- 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index de9db653..a980f80a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ android { defaultConfig { applicationId "com.samsung.microbit" minSdkVersion 21 - targetSdk 33 + targetSdk 34 // When target SDK version is 30+, // requestLegacyExternalStorage will continue to work for 29 Android 10 } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a7fe46a7..e44aa26f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,7 @@ + @@ -167,7 +168,9 @@ + android:foregroundServiceType="connectedDevice" + android:enabled="true" + android:exported="false"/> + android:exported="false"/> = Build.VERSION_CODES.P) { +// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() +// .detectAll() +// .permitDiskReads() +// .penaltyLog() +// .penaltyListener(Executors.newSingleThreadExecutor(), new StrictMode.OnThreadViolationListener() { +// @Override +// public void onThreadViolation(Violation v) { +// } +// }) +// .build()); +// +// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() +// .detectAll() +// .penaltyLog() +// .penaltyListener(Executors.newSingleThreadExecutor(), new StrictMode.OnVmViolationListener() { +// @Override +// public void onVmViolation(Violation v) { +// } +// }) +// .build()); +// } +// } super.onCreate(); app = this; ProcessLifecycleOwner.get().getLifecycle().addObserver(this); @@ -96,16 +125,18 @@ public void onStart(@NonNull LifecycleOwner owner) { MBApp.getAppState().eventPairForeground(); } + //onPause & onResume occur when pairing confirmation dialogue shows + @Override public void onResume(@NonNull LifecycleOwner owner) { logi("onResume"); - MBApp.getAppState().eventPairForeground(); + //MBApp.getAppState().eventPairForeground(); } @Override public void onPause(@NonNull LifecycleOwner owner) { logi("onPause"); - MBApp.getAppState().eventPairBackground(); + //MBApp.getAppState().eventPairBackground(); } @Override diff --git a/app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java b/app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java index 11d32ea3..3fce191b 100644 --- a/app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java +++ b/app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java @@ -2337,6 +2337,8 @@ public void onClick(View v) { final int errorType = intent.getIntExtra(DfuBaseService.EXTRA_ERROR_TYPE, 0); String error_message = ""; + PopUp.hide(); + switch (errorType) { case DfuBaseService.ERROR_TYPE_COMMUNICATION_STATE: if ( errorCode == 0x0085) { diff --git a/app/src/main/java/com/samsung/microbit/ui/adapter/ProjectAdapter.java b/app/src/main/java/com/samsung/microbit/ui/adapter/ProjectAdapter.java index 4de63203..5976f45c 100644 --- a/app/src/main/java/com/samsung/microbit/ui/adapter/ProjectAdapter.java +++ b/app/src/main/java/com/samsung/microbit/ui/adapter/ProjectAdapter.java @@ -361,7 +361,7 @@ public View getView(int position, View convertView, ViewGroup parent) { Project project = mProjects.get(position); if(convertView == null) { - LayoutInflater inflater = LayoutInflater.from(MBApp.getApp()); + LayoutInflater inflater = LayoutInflater.from( mProjectActivity); convertView = inflater.inflate(R.layout.project_items, null); } diff --git a/pfLibrary b/pfLibrary index adfc960c..f41d4240 160000 --- a/pfLibrary +++ b/pfLibrary @@ -1 +1 @@ -Subproject commit adfc960c7973bf6a598e6618057111e0f37aa01e +Subproject commit f41d4240507f906f869b36d16c34230f78301b27