Skip to content

Commit

Permalink
Some IrssiNotifier Plus licensing fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
murgo committed Nov 12, 2018
1 parent 9478a02 commit 65d0f99
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ protected void onCreate(Bundle savedInstanceState) {
tv.setText(getString(R.string.welcome_thanks_for_support) + " " + tv.getText());
}

if (LicenseHelper.bothEditionsInstalled(this)) {
MessageBox.Show(this, null, getString(R.string.both_versions_installed), null);
}

whatNext(0);
}

Expand Down Expand Up @@ -163,7 +159,16 @@ private void checkLicense() {
public void doStuff(LicenseCheckingTask.LicenseCheckingMessage result) {
switch (result.licenseCheckingStatus) {
case Allow:
continueStateMachine();
if (LicenseHelper.bothEditionsInstalled(InitialSettingsActivity.this)) {
MessageBox.Show(InitialSettingsActivity.this, null, getString(R.string.both_versions_installed), new Callback<Void>() {
@Override
public void doStuff(Void param) {
continueStateMachine();
}
});
} else {
continueStateMachine();
}
break;
case Disallow:
preferences.setLicenseCount(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,19 @@ protected LicenseCheckingMessage doInBackground(Void... params) {
private LicenseCheckingMessage checkLicense(int nonce) {
Intent intent = new Intent("com.android.vending.licensing.ILicensingService");
intent.setPackage("com.android.vending");
boolean bindResult = activity.bindService(intent,
new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder s) {
service = ILicensingService.Stub.asInterface(s);
}

@Override
public void onServiceDisconnected(ComponentName name) {
Log.w(TAG, "Service unexpectedly disconnected.");
service = null;
}
},
Context.BIND_AUTO_CREATE);
ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder s) {
service = ILicensingService.Stub.asInterface(s);
}

@Override
public void onServiceDisconnected(ComponentName name) {
Log.w(TAG, "Service unexpectedly disconnected.");
service = null;
}
};
boolean bindResult = activity.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);

if (!bindResult) {
Log.e(TAG, "Could not bind to service.");
Expand Down Expand Up @@ -155,6 +154,8 @@ public void verifyLicense(int responseCode, String signedData, String signature)
return new LicenseCheckingMessage("Could not check license from licensing service in time");
}

activity.unbindService(serviceConnection);

/* Response codes:
private static final int LICENSED = 0x0;
private static final int NOT_LICENSED = 0x1;
Expand Down

0 comments on commit 65d0f99

Please sign in to comment.