I have app A which is free. I have app B which is a donation app. I know people rather pay 4 bucks for coffee and get my app for free via other channels but oh well.
I want to enable more features in app A if app B is legit and from the market and paid for.
So I was curious if I just change the package name in the Market License code in order to check for app B even though app A is executing it.
For example, this line is from the lvl library code:
mChecker = new LicenseChecker(ctx, new ServerManagedPolicy(ctx,
new AESObfuscator(SALT, ctx.getPackageName(), deviceId)),
BASE64_PUBLIC_KEY);
I would like to replace ctx.getPackageName() with 开发者_运维百科the package name from app B, which of course is my app and I know. For example:
mChecker = new LicenseChecker(ctx, new ServerManagedPolicy(ctx,
new AESObfuscator(SALT, com.something.app.b, deviceId)),
BASE64_PUBLIC_KEY);
Does anyone have experience with this?
Changing the arguments to the obfuscator constructor isn't going to do what you want. The package that is checked is determined by the LicenseChecker constructor from the first argument. It might work to define a new constructor for LicenseChecker that takes a package name and version code for package B.
If app A also wants to check its own license, you'll need to extend ServerManagedPolicy as well so that it keeps separate cache data for each app in app A's preferences file.
Note that even if this works, it will break if you update app B in the market, because you will need to wire in a specific version code into app A.
精彩评论