CheogramLicenseChecker.java

 1package com.cheogram.android;
 2
 3import android.content.Context;
 4import android.os.Handler;
 5import android.os.Looper;
 6import android.provider.Settings.Secure;
 7import android.util.Log;
 8
 9import com.google.android.vending.licensing.*;
10
11import eu.siacs.conversations.utils.BiConsumer;
12
13import eu.siacs.conversations.R;
14
15public class CheogramLicenseChecker implements LicenseCheckerCallback {
16	private final LicenseChecker mChecker;
17	private final BiConsumer mCallback;
18
19	public CheogramLicenseChecker(Context context, BiConsumer<String, String> callback) {
20		mChecker = new LicenseChecker(context, new StrictPolicy(), context.getResources().getString(R.string.licensePublicKey));
21		mCallback = callback;
22	}
23
24	public void checkLicense() {
25		mChecker.checkAccess(this);
26	}
27
28	@Override
29	public void dontAllow(int reason) {
30		Log.d("CheogramLicenseChecker", "dontAllow: " + reason);
31		mCallback.accept(null, null);
32	}
33
34	@Override
35	public void applicationError(int errorCode) {
36		Log.d("CheogramLicenseChecker", "applicationError: " + errorCode);
37		mCallback.accept(null, null);
38	}
39
40	@Override
41	public void allow(int reason, ResponseData data, String signedData, String signature) {
42		Log.d("CheogramLicenseChecker", "" + reason + "	/ " + data + " / " + signedData + " / " + signature);
43		mCallback.accept(signedData, signature);
44	}
45}