Skip to content

Commit

Permalink
Merge pull request #33 from SmartDeviceLink-Examples/5.7.0_updates
Browse files Browse the repository at this point in the history
Update app for Android 14 and SDL Java Suite 5.7.0
  • Loading branch information
JulianKast authored Dec 20, 2023
2 parents 3fddfdf + 94c32eb commit 707d279
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
8 changes: 4 additions & 4 deletions MobileWeather/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 33
compileSdkVersion 34
defaultConfig {
applicationId "com.sdl.mobileweather"
minSdkVersion 16
targetSdkVersion 33
versionCode 27
targetSdkVersion 34
versionCode 28
versionName "1.7.15"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
Expand Down Expand Up @@ -37,7 +37,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.smartdevicelink:sdl_android:5.6.0'
implementation 'com.smartdevicelink:sdl_android:5.7.0'
implementation 'net.hockeyapp.android:HockeySDK:5.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
2 changes: 2 additions & 0 deletions MobileWeather/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
tools:targetApi="31"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"
tools:targetApi="33"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE"
tools:targetApi="34"/>
<!-- Required for weather data -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Required to check if WiFi is enabled -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.smartdevicelink.transport.SdlBroadcastReceiver;
import com.smartdevicelink.transport.SdlRouterService;
import com.smartdevicelink.transport.TransportConstants;
import com.smartdevicelink.util.AndroidTools;

public class SdlReceiver extends SdlBroadcastReceiver {

Expand Down Expand Up @@ -48,6 +49,11 @@ public void onSdlEnabled(Context context, Intent intent) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (intent.getParcelableExtra(TransportConstants.PENDING_INTENT_EXTRA) != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
if (!AndroidTools.hasForegroundServiceTypePermission(context)) {
return;
}
}
PendingIntent pendingIntent = (PendingIntent) intent.getParcelableExtra(TransportConstants.PENDING_INTENT_EXTRA);
try {
//Here we are allowing the RouterService that is in the Foreground to start the SdlService on our behalf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,22 @@ private void checkSoftButtonStates() {
@SuppressLint("NewApi")
private void enterForeground() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("MobileWeather", "SmartDeviceLink", NotificationManager.IMPORTANCE_DEFAULT);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
Notification serviceNotification = new Notification.Builder(this, channel.getId())
.setContentTitle("SmartDeviceLink")
.setSmallIcon(R.drawable.ic_sdl)
.setTicker("SmartDeviceLink")
.build();
startForeground(FOREGROUND_SERVICE_ID, serviceNotification);
try {
NotificationChannel channel = new NotificationChannel("MobileWeather", "SmartDeviceLink", NotificationManager.IMPORTANCE_DEFAULT);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
Notification serviceNotification = new Notification.Builder(this, channel.getId())
.setContentTitle("SmartDeviceLink")
.setSmallIcon(R.drawable.ic_sdl)
.setTicker("SmartDeviceLink")
.build();
startForeground(FOREGROUND_SERVICE_ID, serviceNotification);
}
} catch (Exception e) {
// This should only occur when using TCP connections on Android 14+ due to needing
// specific connected devices for permissions regarding ForegroundServiceType
// ConnectedDevice where a TCP connection doesn't apply
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion MobileWeather/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:7.4.2'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion MobileWeather/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

0 comments on commit 707d279

Please sign in to comment.