Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Workaround Amazon crash on Lollipop devices. #433
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanZhilich committed Feb 5, 2015
1 parent ff15aae commit 0ca10de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
minSdkVersion project.minSdkVersion
targetSdkVersion project.targetSdkVersion
versionCode 10
versionName '0.9.8.2'
versionName '0.9.8.5-SNAPSHOT'
}

lintOptions {
Expand Down
33 changes: 27 additions & 6 deletions library/src/main/java/org/onepf/oms/OpenIabHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
Expand Down Expand Up @@ -273,7 +274,27 @@ public Appstore get() {
@NotNull
@Override
public Appstore get() {
return new AmazonAppstore(context);
return new AmazonAppstore(new ContextWrapper(context.getApplicationContext()){
@Override
public Context getApplicationContext() {
return this;
}

@Override
public ComponentName startService(final Intent intent) {
final List<ResolveInfo> infos = getPackageManager().queryIntentServices(intent, 0);
if (infos.isEmpty()) {
return super.startService(intent);
}
final ResolveInfo serviceInfo = infos.get(0);
final String packageName = serviceInfo.serviceInfo.packageName;
final String className = serviceInfo.serviceInfo.name;
final ComponentName component = new ComponentName(packageName, className);
final Intent explicitIntent = new Intent(intent);
explicitIntent.setComponent(component);
return super.startService(explicitIntent);
}
});
}
});

Expand Down Expand Up @@ -1148,11 +1169,11 @@ private void checkFortumo() {

private void checkAmazon() {
// As of Amazon In-App 2.0.1 PurchasingService.getUserData() crashes on Android API 21
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Logger.d("checkAmazon() Android Lollipop not supported, ignoring amazon wrapper.");
appStoreFactoryMap.remove(NAME_AMAZON);
return;
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Logger.d("checkAmazon() Android Lollipop not supported, ignoring amazon wrapper.");
// appStoreFactoryMap.remove(NAME_AMAZON);
// return;
// }

boolean amazonAvailable = false;
try {
Expand Down

0 comments on commit 0ca10de

Please # to comment.