Skip to content

Commit

Permalink
Merge pull request #1327 from dji-sdk/sdk_releases/4.18
Browse files Browse the repository at this point in the history
release for 4.18
  • Loading branch information
Hoker- authored Oct 24, 2024
2 parents da95568 + b3b5e7c commit 37afa62
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 47 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MSDK V5 Supported Product:
* [M30 Series](https://www.dji.com/matrice-30?site=brandsite&from=nav)
* [M300 RTK](https://www.dji.com/matrice-300?site=brandsite&from=nav)

# DJI Mobile SDK V4 for Android Latest Version 4.17
# DJI Mobile SDK V4 for Android Latest Version 4.18

## What Is This?

Expand All @@ -19,21 +19,21 @@ Declare dependency via Maven:
<dependency>
<groupId>com.dji</groupId>
<artifactId>dji-sdk</artifactId>
<version>4.17</version>
<version>4.18</version>
</dependency>

<dependency>
<groupId>com.dji</groupId>
<artifactId>dji-sdk-provided</artifactId>
<version>4.17</version>
<version>4.18</version>
</dependency>
~~~

or Gradle:

~~~groovy
compile 'com.dji:dji-sdk:4.17'
provided 'com.dji:dji-sdk-provided:4.17'
compile 'com.dji:dji-sdk:4.18'
provided 'com.dji:dji-sdk-provided:4.18'
~~~

For further detail on how to integrate the DJI Android SDK into your Android Studio project, please check the [Integrate SDK into Application](http://developer.dji.com/mobile-sdk/documentation/application-development-workflow/workflow-integrate.html#import-maven-dependency) tutorial.
Expand Down
12 changes: 6 additions & 6 deletions Sample Code/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ repositories {
}

android {
compileSdkVersion 31
buildToolsVersion '31.0.0'
compileSdkVersion 33
useLibrary 'org.apache.http.legacy'

defaultConfig {
applicationId "com.dji.sdk.sample"
minSdkVersion 23
targetSdkVersion 31
targetSdkVersion 34
multiDexEnabled true
versionCode 1
ndk {
// On x86 devices that run Android API 23 or above, if the application is targeted with API 23 or
// above, FFmpeg lib might lead to runtime crashes or warnings.
abiFilters 'armeabi-v7a', 'arm64-v8a'
abiFilters 'armeabi-v7a','arm64-v8a'
}
}

//需要直接使用appbundle的话,需要强制配置shrinkResources为false
buildTypes {
release {
shrinkResources false
Expand Down Expand Up @@ -77,7 +77,7 @@ android {
dependencies {
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.squareup:otto:1.3.8'
implementation('com.dji:dji-sdk:4.17', {
implementation('com.dji:dji-sdk:4.18', {
/**
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
Expand All @@ -87,7 +87,7 @@ dependencies {
exclude module: 'library-anti-distortion'
//exclude module: 'fly-safe-database'
})
compileOnly 'com.dji:dji-sdk-provided:4.17'
compileOnly 'com.dji:dji-sdk-provided:4.18'

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.core:core:1.0.0'
Expand Down
2 changes: 1 addition & 1 deletion Sample Code/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

-keep class sun.misc.Unsafe { *; }

-keep class com.secneo.** { *; }
-keep class com.cySdkyc.** { *; }

-keep class org.greenrobot.eventbus.**{*;}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static Bus getEventBus() {
protected void attachBaseContext(Context paramContext) {
super.attachBaseContext(paramContext);
MultiDex.install(this);
com.secneo.sdk.Helper.install(this);
com.cySdkyc.clx.Helper.install(this);
app = this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,7 @@
public class MainContent extends RelativeLayout {

public static final String TAG = MainContent.class.getName();
private static final String[] REQUIRED_PERMISSION_LIST = new String[] {
Manifest.permission.VIBRATE, // Gimbal rotation
Manifest.permission.INTERNET, // API requests
Manifest.permission.ACCESS_WIFI_STATE, // WIFI connected products
Manifest.permission.ACCESS_COARSE_LOCATION, // Maps
Manifest.permission.ACCESS_NETWORK_STATE, // WIFI connected products
Manifest.permission.ACCESS_FINE_LOCATION, // Maps
Manifest.permission.CHANGE_WIFI_STATE, // Changing between WIFI and USB connection
Manifest.permission.WRITE_EXTERNAL_STORAGE, // Log files
Manifest.permission.BLUETOOTH, // Bluetooth connected products
Manifest.permission.BLUETOOTH_ADMIN, // Bluetooth connected products
Manifest.permission.READ_EXTERNAL_STORAGE, // Log files
Manifest.permission.READ_PHONE_STATE, // Device UUID accessed upon registration
Manifest.permission.RECORD_AUDIO // Speaker accessory
};
private String[] permissionArrays;
private static final int REQUEST_PERMISSION_CODE = 12345;
private AtomicBoolean isRegistrationInProgress = new AtomicBoolean(false);
private int lastProcess = -1;
Expand Down Expand Up @@ -125,9 +111,42 @@ public void onConnectivityChange(boolean isConnected) {
private AppActivationState.AppActivationStateListener appActivationStateListener;
private boolean isregisterForLDM = false;
private Context mContext;

public MainContent(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
permissionArrays = new String[]{
Manifest.permission.VIBRATE, // Gimbal rotation
Manifest.permission.INTERNET, // API requests
Manifest.permission.ACCESS_WIFI_STATE, // WIFI connected products
Manifest.permission.ACCESS_COARSE_LOCATION, // Maps
Manifest.permission.ACCESS_NETWORK_STATE, // WIFI connected products
Manifest.permission.ACCESS_FINE_LOCATION, // Maps
Manifest.permission.CHANGE_WIFI_STATE, // Changing between WIFI and USB connection
Manifest.permission.BLUETOOTH, // Bluetooth connected products
Manifest.permission.BLUETOOTH_ADMIN, // Bluetooth connected products
Manifest.permission.READ_PHONE_STATE, // Device UUID accessed upon registration
Manifest.permission.RECORD_AUDIO,// Speaker accessory
};
} else {//兼容Android 12
permissionArrays = new String[]{
Manifest.permission.VIBRATE, // Gimbal rotation
Manifest.permission.INTERNET, // API requests
Manifest.permission.ACCESS_WIFI_STATE, // WIFI connected products
Manifest.permission.ACCESS_COARSE_LOCATION, // Maps
Manifest.permission.ACCESS_NETWORK_STATE, // WIFI connected products
Manifest.permission.ACCESS_FINE_LOCATION, // Maps
Manifest.permission.CHANGE_WIFI_STATE, // Changing between WIFI and USB connection
Manifest.permission.WRITE_EXTERNAL_STORAGE, // Log files
Manifest.permission.BLUETOOTH, // Bluetooth connected products
Manifest.permission.BLUETOOTH_ADMIN, // Bluetooth connected products
Manifest.permission.READ_EXTERNAL_STORAGE, // Log files
Manifest.permission.READ_PHONE_STATE, // Device UUID accessed upon registration
Manifest.permission.RECORD_AUDIO // Speaker accessory
};
}
}

@Override
Expand Down Expand Up @@ -292,7 +311,7 @@ public void run() {
}

private void sendDelayMsg(int msg, long delayMillis) {
if (mHandler == null){
if (mHandler == null) {
return;
}

Expand Down Expand Up @@ -328,7 +347,7 @@ private void updateVersion() {
if (TextUtils.isEmpty(version)) {
mTextModelAvailable.setText("Firmware version:N/A"); //Firmware version:
} else {
mTextModelAvailable.setText("Firmware version:"+version); //"Firmware version: " +
mTextModelAvailable.setText("Firmware version:" + version); //"Firmware version: " +
removeFirmwareVersionListener();
}
}
Expand All @@ -348,7 +367,7 @@ public void run() {
private void refreshSDKRelativeUI() {
mProduct = DJISampleApplication.getProductInstance();
Log.d(TAG, "mProduct: " + (mProduct == null ? "null" : "unnull"));
if (null != mProduct ) {
if (null != mProduct) {
if (mProduct.isConnected()) {
mBtnOpen.setEnabled(true);
String str = mProduct instanceof Aircraft ? "DJIAircraft" : "DJIHandHeld";
Expand All @@ -363,7 +382,7 @@ private void refreshSDKRelativeUI() {
} else {
mTextProduct.setText(R.string.product_information);
}
} else if (mProduct instanceof Aircraft){
} else if (mProduct instanceof Aircraft) {
Aircraft aircraft = (Aircraft) mProduct;
if (aircraft.getRemoteController() != null && aircraft.getRemoteController().isConnected()) {
mTextConnectionStatus.setText(R.string.connection_only_rc);
Expand Down Expand Up @@ -395,7 +414,7 @@ public void run() {
};
firmwareKey = ProductKey.create(ProductKey.FIRMWARE_PACKAGE_VERSION);
if (KeyManager.getInstance() != null) {
KeyManager.getInstance().addListener(firmwareKey, firmwareVersionUpdater );
KeyManager.getInstance().addListener(firmwareKey, firmwareVersionUpdater);
}
hasStartedFirmVersionListener = true;
}
Expand Down Expand Up @@ -465,7 +484,7 @@ public void onFailure(DJIError djiError) {
private void checkAndRequestPermissions() {
// Check for permissions
List<String> missingPermission = new ArrayList<>();
for (String eachPermission : REQUIRED_PERMISSION_LIST) {
for (String eachPermission : permissionArrays) {
if (ContextCompat.checkSelfPermission(mContext, eachPermission) != PackageManager.PERMISSION_GRANTED) {
missingPermission.add(eachPermission);
}
Expand Down Expand Up @@ -495,7 +514,7 @@ public void run() {
DJISDKManager.getInstance().getLDMManager().setModuleNetworkServiceEnabled(new LDMModule.Builder().moduleType(
LDMModuleType.FIRMWARE_UPGRADE).enabled(false).build());
}
if(isregisterForLDM) {
if (isregisterForLDM) {
DJISDKManager.getInstance().registerAppForLDM(mContext.getApplicationContext(), new DJISDKManager.SDKManagerCallback() {
@Override
public void onRegister(DJIError djiError) {
Expand All @@ -509,11 +528,13 @@ public void onRegister(DJIError djiError) {
Log.v(TAG, djiError.getDescription());
hideProcess();
}

@Override
public void onProductDisconnect() {
Log.d(TAG, "onProductDisconnect");
notifyStatusChange();
}

@Override
public void onProductConnect(BaseProduct baseProduct) {
Log.d(TAG, String.format("onProductConnect newProduct:%s", baseProduct));
Expand All @@ -532,8 +553,7 @@ public void onComponentChange(BaseProduct.ComponentKey componentKey,
if (newComponent != null) {
newComponent.setComponentListener(mDJIComponentListener);

if(componentKey == BaseProduct.ComponentKey.FLIGHT_CONTROLLER)
{
if (componentKey == BaseProduct.ComponentKey.FLIGHT_CONTROLLER) {
showDBVersion();
}
}
Expand All @@ -559,9 +579,9 @@ public void onDatabaseDownloadProgress(long current, long total) {
}
lastProcess = process;
showProgress(process);
if (process % 25 == 0){
if (process % 25 == 0) {
ToastUtils.setResultToToast("DB load process : " + process);
}else if (process == 0){
} else if (process == 0) {
ToastUtils.setResultToToast("DB load begin");
}
}
Expand All @@ -581,11 +601,13 @@ public void onRegister(DJIError djiError) {
Log.v(TAG, djiError.getDescription());
hideProcess();
}

@Override
public void onProductDisconnect() {
Log.d(TAG, "onProductDisconnect");
notifyStatusChange();
}

@Override
public void onProductConnect(BaseProduct baseProduct) {
Log.d(TAG, String.format("onProductConnect newProduct:%s", baseProduct));
Expand All @@ -604,8 +626,7 @@ public void onComponentChange(BaseProduct.ComponentKey componentKey,
if (newComponent != null) {
newComponent.setComponentListener(mDJIComponentListener);

if(componentKey == BaseProduct.ComponentKey.FLIGHT_CONTROLLER)
{
if (componentKey == BaseProduct.ComponentKey.FLIGHT_CONTROLLER) {
showDBVersion();
}
}
Expand All @@ -631,9 +652,9 @@ public void onDatabaseDownloadProgress(long current, long total) {
}
lastProcess = process;
showProgress(process);
if (process % 25 == 0){
if (process % 25 == 0) {
ToastUtils.setResultToToast("DB load process : " + process);
}else if (process == 0){
} else if (process == 0) {
ToastUtils.setResultToToast("DB load begin");
}
}
Expand All @@ -645,7 +666,7 @@ public void onDatabaseDownloadProgress(long current, long total) {
}
}

private void showProgress(final int process){
private void showProgress(final int process) {
mHander.post(new Runnable() {
@Override
public void run() {
Expand All @@ -655,7 +676,7 @@ public void run() {
});
}

private void showDBVersion(){
private void showDBVersion() {
mHander.postDelayed(new Runnable() {
@Override
public void run() {
Expand All @@ -672,10 +693,10 @@ public void onFailure(DJIError djiError) {
}
});
}
},3000);
}, 3000);
}

private void hideProcess(){
private void hideProcess() {
mHander.post(new Runnable() {
@Override
public void run() {
Expand Down

0 comments on commit 37afa62

Please sign in to comment.