-
Notifications
You must be signed in to change notification settings - Fork 38
increase security of in-app billing & fixing bugs #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
import android.content.Intent; | ||
import android.content.IntentSender.SendIntentException; | ||
import android.content.ServiceConnection; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.ResolveInfo; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.IBinder; | ||
|
@@ -218,7 +220,12 @@ public void onServiceDisconnected(ComponentName name) { | |
public void onServiceConnected(ComponentName name, IBinder service) { | ||
if (mDisposed) return; | ||
logDebug("Billing service connected."); | ||
mService = IInAppBillingService.Stub.asInterface(service); | ||
if (!"com.farsitel.bazaar".equals(name.getPackageName())) { | ||
logDebug("can't find bazaar app!"); | ||
return; | ||
} else { | ||
mService = IInAppBillingService.Stub.asInterface(service); | ||
} | ||
String packageName = mContext.getPackageName(); | ||
try { | ||
logDebug("Checking for in-app billing 3 support."); | ||
|
@@ -264,7 +271,9 @@ public void onServiceConnected(ComponentName name, IBinder service) { | |
|
||
Intent serviceIntent = new Intent("ir.cafebazaar.pardakht.InAppBillingService.BIND"); | ||
serviceIntent.setPackage("com.farsitel.bazaar"); | ||
if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line will cause a null pointer exception to be thrown if bazaar client is not installed |
||
PackageManager pm=mContext.getPackageManager(); | ||
List<ResolveInfo> intentServices = pm.queryIntentServices(serviceIntent, 0); | ||
if (intentServices != null && !intentServices.isEmpty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this new approach will fix the app crashing issue |
||
// service available to handle that Intent | ||
mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); | ||
} | ||
|
@@ -287,7 +296,7 @@ public void onServiceConnected(ComponentName name, IBinder service) { | |
public void dispose() { | ||
logDebug("Disposing."); | ||
mSetupDone = false; | ||
if (mServiceConn != null) { | ||
if (mServiceConn != null && mService!=null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, we should check if the service is not null |
||
logDebug("Unbinding from service."); | ||
if (mContext != null) mContext.unbindService(mServiceConn); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the part that we check for the authenticity of target app.