RandeeCao / marketbilling

Automatically exported from code.google.com/p/marketbilling
1 stars 0 forks source link

IabHelper: disconnection from the billing service is strangely handled #172

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Actually IabHelper contains method to handle it

  mServiceConn = new ServiceConnection() {
            @Override
            public void onServiceDisconnected(ComponentName name) {
                logDebug("Billing service disconnected.");
                mService = null;
            }

            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                logDebug("Billing service connected.");
                mService = getServiceFromBinder(service);
                componentName = name;
                String packageName = mContext.getPackageName();
                try {
...

and inside it mService it set to null.

But mService is a widely used field. There are several async methods that use 
mService.  And there is no synchronization, no null-checking.
Could you please explain why it was made so? 
I have this question due to a lot of npe reports from my users. I'm not sure 
that mService became null after disconnect but there is a possibility of it.

Original issue reported on code.google.com by Anastasi...@gmail.com on 16 Jan 2014 at 9:57

GoogleCodeExporter commented 8 years ago
Because it is "sample code" :(

Original comment by marko.st...@outfit7.com on 5 Feb 2014 at 10:54