Merge pull request #7538 from osmandapp/Huawei

drm-integration
This commit is contained in:
max-klaus 2019-09-11 13:49:00 +03:00 committed by GitHub
commit e861741fe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.huawei.android.sdk.drm"
android:versionCode="2"
android:versionName="2.0.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme" >
<activity
android:name="com.huawei.android.sdk.drm.DrmDialogActivity"
android:configChanges="screenSize|orientation|keyboardHidden"
android:exported="false"
android:theme="@android:style/Theme.Translucent" >
<meta-data
android:name="hwc-theme"
android:value="androidhwext:style/Theme.Emui.Translucent" />
</activity>
</application>
</manifest>

View file

@ -18,6 +18,8 @@ apply plugin: 'com.android.application'
// Less important
def huawei = (!System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+huawei"))
task printc {
configurations.each { if(it.isCanBeResolved()) println it.name }
}
@ -251,6 +253,13 @@ task downloadWorldMiniBasemap {
}
}
task downloadHuaweiDrm {
doLast {
ant.get(src: 'https://obs.cn-north-2.myhwclouds.com/hms-ds-wf/sdk/HwDRM_SDK_2.5.2.300_ADT.zip', dest: 'HwDRM_SDK_2.5.2.300_ADT.zip', skipexisting: 'true')
ant.unzip(src: 'HwDRM_SDK_2.5.2.300_ADT.zip', dest: 'libs/')
}
}
task collectVoiceAssets(type: Sync) {
from "../../resources/voice"
into "assets/voice"
@ -317,6 +326,10 @@ task collectExternalResources {
validateTranslate,
copyWidgetIcons,
downloadWorldMiniBasemap
if (huawei) {
downloadHuaweiDrm
}
}
// Legacy core build
@ -422,4 +435,8 @@ dependencies {
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
exclude group: 'com.android.support'
}
if (huawei) {
implementation files('libs/huawei-android-drm_v2.5.2.300.jar')
}
}

View file

@ -0,0 +1,38 @@
package net.osmand.plus;
import android.app.Activity;
import android.widget.Toast;
import com.huawei.android.sdk.drm.Drm;
import com.huawei.android.sdk.drm.DrmCheckCallback;
public class HuaweiDrmHelper {
private Activity activity;
private DrmCheckCallback callback;
//Copyright protection id
private static final String DRM_ID = "101048021";
//Copyright protection public key
private static final String DRM_PUBLIC_KEY = "e0a6c798fddfd0927bd509dfeafcef4b61c4408d7ea0ca9dfb4b7766b964f801";
public HuaweiDrmHelper(final Activity activity) {
this.activity = activity;
callback = new DrmCheckCallback() {
@Override
public void onCheckSuccess() { }
@Override
public void onCheckFailed() {
activity.finish();
}
};
}
public void check() {
Drm.check(getActivity(), getActivity().getPackageName(), DRM_ID, DRM_PUBLIC_KEY, callback);
}
public Activity getActivity() {
return this.activity;
}
}

View file

@ -25,6 +25,10 @@ public class Version {
return ctx.getString(R.string.versionFeatures).contains("+blackberry");
}
public static boolean isHuawei(OsmandApplication ctx) {
return ctx.getString(R.string.versionFeatures).contains("+huawei");
}
public static boolean isMarketEnabled(OsmandApplication ctx) {
return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx);
}

View file

@ -66,6 +66,7 @@ import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.HuaweiDrmHelper;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
@ -250,6 +251,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
trackDetailsMenu.setMapActivity(this);
super.onCreate(savedInstanceState);
if (Version.isHuawei(getMyApplication())) {
new HuaweiDrmHelper(this).check();
}
// Full screen is not used here
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);