Skip to content

Commit baac741

Browse files
authored
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
1 parent 8626caa commit baac741

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55
defaultConfig {
66
applicationId "com.samsung.microbit"
77
minSdkVersion 21
8-
targetSdk 33
8+
targetSdk 34
99
// When target SDK version is 30+,
1010
// requestLegacyExternalStorage will continue to work for 29 Android 10
1111
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
3434
<uses-permission android:name="android.permission.CAMERA"/>
3535
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
36+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
3637

3738
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30"/>
3839
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
@@ -167,7 +168,9 @@
167168

168169
<service
169170
android:name=".service.DfuService"
170-
android:enabled="true"/>
171+
android:foregroundServiceType="connectedDevice"
172+
android:enabled="true"
173+
android:exported="false"/>
171174

172175
<service
173176
android:name=".service.PluginService"
@@ -189,7 +192,7 @@
189192
android:name=".service.PartialFlashingService"
190193
android:enabled="true"
191194
android:launchMode="singleInstance"
192-
/>
195+
android:exported="false"/>
193196

194197
<activity
195198
android:name=".ui.activity.SplashScreenActivity"

app/src/main/java/com/samsung/microbit/MBApp.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import android.app.Application;
66
import android.graphics.Typeface;
7+
import android.os.Build;
8+
import android.os.StrictMode;
9+
import android.os.strictmode.Violation;
710
import android.util.Log;
811

912
import androidx.annotation.NonNull;
@@ -13,6 +16,8 @@
1316

1417
import com.samsung.microbit.MBAppState;
1518

19+
import java.util.concurrent.Executors;
20+
1621
/**
1722
* Represents a custom class of the app.
1823
* Provides some resources that use along app modules,
@@ -39,6 +44,30 @@ public void logi(String message) {
3944

4045
@Override
4146
public void onCreate() {
47+
// if (DEBUG) {
48+
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
49+
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
50+
// .detectAll()
51+
// .permitDiskReads()
52+
// .penaltyLog()
53+
// .penaltyListener(Executors.newSingleThreadExecutor(), new StrictMode.OnThreadViolationListener() {
54+
// @Override
55+
// public void onThreadViolation(Violation v) {
56+
// }
57+
// })
58+
// .build());
59+
//
60+
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
61+
// .detectAll()
62+
// .penaltyLog()
63+
// .penaltyListener(Executors.newSingleThreadExecutor(), new StrictMode.OnVmViolationListener() {
64+
// @Override
65+
// public void onVmViolation(Violation v) {
66+
// }
67+
// })
68+
// .build());
69+
// }
70+
// }
4271
super.onCreate();
4372
app = this;
4473
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
@@ -96,16 +125,18 @@ public void onStart(@NonNull LifecycleOwner owner) {
96125
MBApp.getAppState().eventPairForeground();
97126
}
98127

128+
//onPause & onResume occur when pairing confirmation dialogue shows
129+
99130
@Override
100131
public void onResume(@NonNull LifecycleOwner owner) {
101132
logi("onResume");
102-
MBApp.getAppState().eventPairForeground();
133+
//MBApp.getAppState().eventPairForeground();
103134
}
104135

105136
@Override
106137
public void onPause(@NonNull LifecycleOwner owner) {
107138
logi("onPause");
108-
MBApp.getAppState().eventPairBackground();
139+
//MBApp.getAppState().eventPairBackground();
109140
}
110141

111142
@Override

app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,8 @@ public void onClick(View v) {
23372337
final int errorType = intent.getIntExtra(DfuBaseService.EXTRA_ERROR_TYPE, 0);
23382338
String error_message = "";
23392339

2340+
PopUp.hide();
2341+
23402342
switch (errorType) {
23412343
case DfuBaseService.ERROR_TYPE_COMMUNICATION_STATE:
23422344
if ( errorCode == 0x0085) {

app/src/main/java/com/samsung/microbit/ui/adapter/ProjectAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
361361

362362
Project project = mProjects.get(position);
363363
if(convertView == null) {
364-
LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
364+
LayoutInflater inflater = LayoutInflater.from( mProjectActivity);
365365
convertView = inflater.inflate(R.layout.project_items, null);
366366
}
367367

0 commit comments

Comments
 (0)