commit
e861741fe6
5 changed files with 89 additions and 0 deletions
25
OsmAnd/AndroidManifest-huawei.xml
Normal file
25
OsmAnd/AndroidManifest-huawei.xml
Normal 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>
|
|
@ -18,6 +18,8 @@ apply plugin: 'com.android.application'
|
||||||
// Less important
|
// Less important
|
||||||
|
|
||||||
|
|
||||||
|
def huawei = (!System.getenv("APP_FEATURES") || System.getenv("APP_FEATURES").contains("+huawei"))
|
||||||
|
|
||||||
task printc {
|
task printc {
|
||||||
configurations.each { if(it.isCanBeResolved()) println it.name }
|
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) {
|
task collectVoiceAssets(type: Sync) {
|
||||||
from "../../resources/voice"
|
from "../../resources/voice"
|
||||||
into "assets/voice"
|
into "assets/voice"
|
||||||
|
@ -317,6 +326,10 @@ task collectExternalResources {
|
||||||
validateTranslate,
|
validateTranslate,
|
||||||
copyWidgetIcons,
|
copyWidgetIcons,
|
||||||
downloadWorldMiniBasemap
|
downloadWorldMiniBasemap
|
||||||
|
|
||||||
|
if (huawei) {
|
||||||
|
downloadHuaweiDrm
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy core build
|
// Legacy core build
|
||||||
|
@ -422,4 +435,8 @@ dependencies {
|
||||||
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
|
implementation ("com.github.HITGIF:TextFieldBoxes:1.3.5"){
|
||||||
exclude group: 'com.android.support'
|
exclude group: 'com.android.support'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (huawei) {
|
||||||
|
implementation files('libs/huawei-android-drm_v2.5.2.300.jar')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
38
OsmAnd/src/net/osmand/plus/HuaweiDrmHelper.java
Normal file
38
OsmAnd/src/net/osmand/plus/HuaweiDrmHelper.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,10 @@ public class Version {
|
||||||
return ctx.getString(R.string.versionFeatures).contains("+blackberry");
|
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) {
|
public static boolean isMarketEnabled(OsmandApplication ctx) {
|
||||||
return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx);
|
return isGooglePlayEnabled(ctx) || isAmazonEnabled(ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||||
import net.osmand.plus.AppInitializer.InitEvents;
|
import net.osmand.plus.AppInitializer.InitEvents;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
|
import net.osmand.plus.HuaweiDrmHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||||
|
@ -250,6 +251,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
trackDetailsMenu.setMapActivity(this);
|
trackDetailsMenu.setMapActivity(this);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if (Version.isHuawei(getMyApplication())) {
|
||||||
|
new HuaweiDrmHelper(this).check();
|
||||||
|
}
|
||||||
// Full screen is not used here
|
// Full screen is not used here
|
||||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
Loading…
Reference in a new issue