diff options
author | RHenigan <heniganr1@gmail.com> | 2020-07-30 14:53:59 -0400 |
---|---|---|
committer | RHenigan <heniganr1@gmail.com> | 2020-07-30 14:53:59 -0400 |
commit | 63315096b3b5e9e36bfa38270977d7f980a34c60 (patch) | |
tree | bc54c11930130ffebc9d42e1e862d5849f55b7e2 | |
parent | 7f12aef2f619380fc625cb72bfa1a1948d425181 (diff) | |
download | sdl_android-feature/0193_MinAndroidSDK.tar.gz |
Update Min SDK and Android API Checksfeature/0193_MinAndroidSDK
13 files changed, 58 insertions, 124 deletions
diff --git a/android/hello_sdl_android/build.gradle b/android/hello_sdl_android/build.gradle index da649cbbb..6124ae700 100755 --- a/android/hello_sdl_android/build.gradle +++ b/android/hello_sdl_android/build.gradle @@ -4,7 +4,7 @@ android { compileSdkVersion 29 defaultConfig { applicationId "com.sdl.hellosdlandroid" - minSdkVersion 14 + minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" diff --git a/android/sdl_android/build.gradle b/android/sdl_android/build.gradle index bdc46218d..e55054278 100644 --- a/android/sdl_android/build.gradle +++ b/android/sdl_android/build.gradle @@ -5,7 +5,7 @@ import org.apache.tools.ant.taskdefs.condition.Os android { compileSdkVersion 29 defaultConfig { - minSdkVersion 8 + minSdkVersion 16 targetSdkVersion 29 versionCode 14 versionName new File(projectDir.path, ('/../../VERSION')).text.trim() diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java index 86488cca0..91cde0e3c 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java @@ -32,7 +32,6 @@ package com.smartdevicelink.SdlConnection;
import android.annotation.SuppressLint;
-import android.os.Build;
import android.view.Surface;
import com.smartdevicelink.encoder.SdlEncoder;
@@ -216,12 +215,7 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList @SuppressLint("NewApi")
public OutputStream startStream(SessionType sType, byte rpcSessionID) throws IOException {
OutputStream os = new PipedOutputStream();
- InputStream is = null;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
- is = new PipedInputStream((PipedOutputStream) os, BUFF_READ_SIZE);
- } else {
- is = new PipedInputStream((PipedOutputStream) os);
- }
+ InputStream is = new PipedInputStream((PipedOutputStream) os, BUFF_READ_SIZE);
if (sType.equals(SessionType.NAV))
{
// protocol is fixed to RAW
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java index 06b9abd7b..2b0b25931 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java @@ -34,7 +34,6 @@ package com.smartdevicelink.managers; import android.annotation.SuppressLint; import android.content.Context; -import android.os.Build; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; @@ -134,8 +133,7 @@ public class SdlManager extends BaseSdlManager { } else { this.videoStreamManager = null; } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN - && (getAppTypes().contains(AppHMIType.NAVIGATION) || getAppTypes().contains(AppHMIType.PROJECTION))) { + if (getAppTypes().contains(AppHMIType.NAVIGATION) || getAppTypes().contains(AppHMIType.PROJECTION)) { this.audioStreamManager = new AudioStreamManager(_internalInterface, context); } else { this.audioStreamManager = null; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java index bb78741c7..4e6ff7e9c 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java @@ -179,14 +179,6 @@ public class AudioStreamManager extends BaseAudioStreamManager { */
public AudioStreamManager(@NonNull ISdl internalInterface, @NonNull Context context) {
super(internalInterface);
- if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN){
- this.queue = null;
- this.context = null;
- this.serviceCompletionHandler = null;
- this.streamingStateMachine = null;
- transitionToState(ERROR);
- return;
- }
this.queue = new LinkedList<>();
this.context = new WeakReference<>(context);
this.serviceCompletionHandler = new Handler(Looper.getMainLooper());
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java index 9e63b9fb8..399165586 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java @@ -37,7 +37,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; -import android.os.Build; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -138,18 +137,16 @@ public class LockScreenManager extends BaseSubManager { deviceLogo = null; deviceIconUrl = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - try { - if (android.arch.lifecycle.ProcessLifecycleOwner.get() != null && lifecycleObserver != null) { - android.arch.lifecycle.ProcessLifecycleOwner.get().getLifecycle().removeObserver(lifecycleObserver); - } - } catch (Exception e) { - e.printStackTrace(); + try { + if (android.arch.lifecycle.ProcessLifecycleOwner.get() != null && lifecycleObserver != null) { + android.arch.lifecycle.ProcessLifecycleOwner.get().getLifecycle().removeObserver(lifecycleObserver); } - - lifecycleObserver = null; + } catch (Exception e) { + e.printStackTrace(); } + lifecycleObserver = null; + isApplicationForegrounded = false; super.dispose(); @@ -241,29 +238,25 @@ public class LockScreenManager extends BaseSubManager { } // Set up listener for Application Foreground / Background events - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - try { - lifecycleObserver = new android.arch.lifecycle.LifecycleObserver() { - @android.arch.lifecycle.OnLifecycleEvent(android.arch.lifecycle.Lifecycle.Event.ON_START) - public void onMoveToForeground() { - isApplicationForegrounded = true; - launchLockScreenActivity(); - } - - @android.arch.lifecycle.OnLifecycleEvent(android.arch.lifecycle.Lifecycle.Event.ON_STOP) - public void onMoveToBackground() { - isApplicationForegrounded = false; - } - }; + try { + lifecycleObserver = new android.arch.lifecycle.LifecycleObserver() { + @android.arch.lifecycle.OnLifecycleEvent(android.arch.lifecycle.Lifecycle.Event.ON_START) + public void onMoveToForeground() { + isApplicationForegrounded = true; + launchLockScreenActivity(); + } - if (android.arch.lifecycle.ProcessLifecycleOwner.get() != null) { - android.arch.lifecycle.ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleObserver); + @android.arch.lifecycle.OnLifecycleEvent(android.arch.lifecycle.Lifecycle.Event.ON_STOP) + public void onMoveToBackground() { + isApplicationForegrounded = false; } - } catch (Exception e) { - e.printStackTrace(); + }; + + if (android.arch.lifecycle.ProcessLifecycleOwner.get() != null) { + android.arch.lifecycle.ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleObserver); } - } else{ - isApplicationForegrounded = true; + } catch (Exception e) { + e.printStackTrace(); } mLockscreenDismissedReceiver = new BroadcastReceiver() { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index dff9efb0d..a15969d58 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -537,15 +537,11 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ private static boolean isBluetoothConnected() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if(bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - int a2dpState = bluetoothAdapter.getProfileConnectionState(BluetoothProfile.A2DP); - int headSetState = bluetoothAdapter.getProfileConnectionState(BluetoothProfile.HEADSET); - - return ((a2dpState == BluetoothAdapter.STATE_CONNECTED || a2dpState == BluetoothAdapter.STATE_CONNECTING) - && (headSetState == BluetoothAdapter.STATE_CONNECTED || headSetState == BluetoothAdapter.STATE_CONNECTING)); - }else{ - return true; - } + int a2dpState = bluetoothAdapter.getProfileConnectionState(BluetoothProfile.A2DP); + int headSetState = bluetoothAdapter.getProfileConnectionState(BluetoothProfile.HEADSET); + + return ((a2dpState == BluetoothAdapter.STATE_CONNECTED || a2dpState == BluetoothAdapter.STATE_CONNECTING) + && (headSetState == BluetoothAdapter.STATE_CONNECTED || headSetState == BluetoothAdapter.STATE_CONNECTING)); } return false; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java index 5168bf50b..24d5ec850 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java @@ -260,9 +260,7 @@ public class SdlRouterService extends Service{ registrationIntent.setAction(action); registrationIntent.putExtra(TransportConstants.BIND_LOCATION_PACKAGE_NAME_EXTRA, this.getPackageName()); registrationIntent.putExtra(TransportConstants.BIND_LOCATION_CLASS_NAME_EXTRA, this.getClass().getName()); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ - registrationIntent.setFlags((Intent.FLAG_RECEIVER_FOREGROUND)); - } + registrationIntent.setFlags((Intent.FLAG_RECEIVER_FOREGROUND)); return registrationIntent; } @@ -1401,9 +1399,6 @@ public class SdlRouterService extends Service{ } public void resetForegroundTimeOut(long delay){ - if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2){ - return; - } synchronized (FOREGROUND_NOTIFICATION_LOCK) { if (foregroundTimeoutHandler == null) { foregroundTimeoutHandler = new Handler(); @@ -1443,11 +1438,6 @@ public class SdlRouterService extends Service{ @SuppressWarnings("deprecation") private void enterForeground(String content, long chronometerLength, boolean ongoing) { DebugTool.logInfo(TAG, "Attempting to enter the foreground - " + System.currentTimeMillis()); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB){ - DebugTool.logWarning(TAG, "Unable to start service as foreground due to OS SDK version being lower than 11"); - isForeground = false; - return; - } Bitmap icon; int resourcesIncluded = getResources().getIdentifier("ic_sdl", "drawable", getPackageName()); @@ -1502,36 +1492,24 @@ public class SdlRouterService extends Service{ } synchronized (FOREGROUND_NOTIFICATION_LOCK) { Notification notification; - if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { - notification = builder.getNotification(); - - } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - //Now we need to add a notification channel - NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - if (notificationManager != null) { - NotificationChannel notificationChannel = new NotificationChannel(SDL_NOTIFICATION_CHANNEL_ID, SDL_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW); - notificationChannel.enableLights(false); - notificationChannel.enableVibration(false); - notificationManager.createNotificationChannel(notificationChannel); - } else { - DebugTool.logError(TAG, "Unable to retrieve notification Manager service"); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - safeStartForeground(FOREGROUND_SERVICE_ID, builder.build()); - stopSelf(); //A valid notification channel must be supplied for SDK 27+ - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + //Now we need to add a notification channel + NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + if (notificationManager != null) { + NotificationChannel notificationChannel = new NotificationChannel(SDL_NOTIFICATION_CHANNEL_ID, SDL_NOTIFICATION_CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW); + notificationChannel.enableLights(false); + notificationChannel.enableVibration(false); + notificationManager.createNotificationChannel(notificationChannel); + } else { + DebugTool.logError(TAG, "Unable to retrieve notification Manager service"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + safeStartForeground(FOREGROUND_SERVICE_ID, builder.build()); + stopSelf(); //A valid notification channel must be supplied for SDK 27+ } - - } - notification = builder.build(); - } - if (notification == null) { - safeStartForeground(FOREGROUND_SERVICE_ID, builder.build()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - stopSelf(); //A valid notification must be supplied for SDK 27+ } - return; + } + notification = builder.build(); safeStartForeground(FOREGROUND_SERVICE_ID, notification); isForeground = true; @@ -1785,9 +1763,7 @@ public class SdlRouterService extends Service{ startService.putExtra(TransportConstants.START_ROUTER_SERVICE_TRANSPORT_CONNECTED, record.getType().toString()); } - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); - } + startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); AndroidTools.sendExplicitBroadcast(getApplicationContext(),startService, null); @@ -2596,8 +2572,6 @@ public class SdlRouterService extends Service{ } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) private boolean removeAllSessionsWithAppId(String appId){ synchronized(SESSION_LOCK){ if(bluetoothSessionMap !=null){ diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java index 3629e883c..cc123d041 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java @@ -32,8 +32,6 @@ package com.smartdevicelink.transport;
import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.os.Build;
import android.os.NetworkOnMainThreadException;
import com.smartdevicelink.exception.SdlException;
@@ -141,7 +139,6 @@ public class TCPTransport extends SdlTransport { * @return True if data was sent successfully, False otherwise
*/
@SuppressLint("DefaultLocale")
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected boolean sendBytesOverTransport(SdlPacket packet) {
TCPTransportState currentState = getCurrentState();
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java index becbdcbb4..acf84462f 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java @@ -144,8 +144,7 @@ public class TransportBroker { } catch (RemoteException e) { e.printStackTrace(); //Let's check to see if we should retry - if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && e instanceof TransactionTooLargeException) - || (retryCount < 5 && routerServiceMessenger.getBinder().isBinderAlive() && routerServiceMessenger.getBinder().pingBinder())) { //We probably just failed on a small transaction =\ + if (e instanceof TransactionTooLargeException || retryCount < 5 && routerServiceMessenger.getBinder().isBinderAlive() && routerServiceMessenger.getBinder().pingBinder()) { //We probably just failed on a small transaction =\ try { Thread.sleep(100); } catch (InterruptedException e1) { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java index b74c7aac9..3e8a37661 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java @@ -173,12 +173,11 @@ public class MediaStreamingStatus { //False positive return false; } - if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH ){ - int state = adapter.getProfileConnectionState(BluetoothProfile.A2DP); - if(state != BluetoothAdapter.STATE_CONNECTING && state != BluetoothAdapter.STATE_CONNECTED){ - //False positive - return false; - } + + int state = adapter.getProfileConnectionState(BluetoothProfile.A2DP); + if(state != BluetoothAdapter.STATE_CONNECTING && state != BluetoothAdapter.STATE_CONNECTED){ + //False positive + return false; } return true; @@ -196,11 +195,7 @@ public class MediaStreamingStatus { private void setupBluetoothBroadcastReceiver(){ String[] actions = new String[4]; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - actions[0] = BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED; - }else{ - actions[0] = "android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED"; - } + actions[0] = BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED; actions[1] = BluetoothAdapter.ACTION_STATE_CHANGED; actions[2] = BluetoothDevice.ACTION_ACL_DISCONNECTED; actions[3] = BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java index 8dc481323..0a08a3f16 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java @@ -35,7 +35,6 @@ package com.smartdevicelink.util; import android.content.ComponentName; import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; -import android.os.Build; import android.os.Bundle; import java.util.Comparator; @@ -80,7 +79,7 @@ public class SdlAppInfo { } } - if(packageInfo != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD){ + if(packageInfo != null){ this.lastUpdateTime = packageInfo.lastUpdateTime; if(this.lastUpdateTime <= 0){ this.lastUpdateTime = packageInfo.firstInstallTime; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java index 5ce18165f..9265eb345 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java @@ -37,7 +37,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ResolveInfo; -import android.os.Build; import android.os.Handler; import android.os.Looper; @@ -163,9 +162,7 @@ public class ServiceFinder { Intent intent = new Intent(); intent.setAction(SdlRouterService.REGISTER_WITH_ROUTER_ACTION); intent.putExtra(SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME, receiverLocation); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); - } + intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); return intent; } |