2011년 2월 10일 목요일

[Android Course][English][Theme] - Android Market LVL(License Verification Library) Usage




※ LVL(License Verification Library) ?
: LVL basically your application from one device to another device with a light kind of piracy attacks makes
(Note> that even if piracy is to buy in to your account if your application can not run)
: If you use LVL in my application at runtime through the App Market was actually a purchase to determine if the application. If you are running a normal buyer.

1. "Market Licensing Package" Install
- "Window -> Android SDK and AVD Manager" through the installation
: "Available Packages" through the "Market Licensing Package" installation


- "Installed Packages" Package is installed through the check














2. "market_licensing" library Confirm Folder
: "Android-sdk-windows \ market_licensing \ library" when applied LVL future, Im required library.
: LVL to apply the library can be used in two ways.
  - a link to the reference project is the way
  - another one copy to the library source by the project will be put.
(Google Developer's Guide as a reference project to link recommended.)

3. Publisher Account Settings
: LVL want to use to obtain public key from the Android Market.
Android Market Account, select Edit Profile to access your personal information, such as setting screens coming out down below.
- "Test Accounts" field testing a Google account and put the address is
- "Public Key" field is a string that is used in the program, so in the future If you save it, and
- "Test response" values while the shape may be further tested in the license.

4. "LVL library Project" Create
: "LVL library Project" to create a reason, every time "LVL library Source" rather than copying it easy because when you add the reference.
- "Eclipse" from the "File> New> Android Project" by choosing and creating a new project.
(Contents column "Create project from existing source" to select, based on a copy of "LVL library" folder and checked)

- "Com_android_vending_licensing" project created.


















5. "LVL library" Apply
- "Test Android Project" to create
(ex : LVL_Test_App)








- "Eclipse - Project - Properties" by selecting additional library.






























































- "AndroidManifest.xml" Add permission settings
: LVL for permission to run with the following additional
<uses-permission android:name="com.android.vending.CHECK_LICENSE />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

- "LVL library" import
import android.telephony.TelephonyManager;
import com.android.vending.licensing.AESObfuscator;
import com.android.vending.licensing.LicenseChecker;
import com.android.vending.licensing.LicenseCheckerCallback;
import com.android.vending.licensing.ServerManagedPolicy;

- "LicenseCheckerCallback" Implementation
    private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
        @Override
        public void allow() {
            if (isFinishing()) {
                return;
            }
            // "License Authentication" Success
        }
        @Override
        public void applicationError(ApplicationErrorCode errorCode) {
         // "License Authentication" Error
        }
        @Override
        public void dontAllow() {
            if (isFinishing()) {
                return;
            }
         // "License Authentication" Fail
        }
    }

- "License Authentication" Initialization and Run
public class main extends Activity {

    // public key
    private static final String BASE64_PUBLIC_KEY = "public key ... ";
   
    // Random byte
    private static final byte[] SALT = {-6, 35, 50, -118, -13, -5, 73, -24, 11, 82, -15,
                         -12, 27, -17, -4, -113, -13, 42, -54, 79};
    private LicenseCheckerCallback m_LicenseCheckerCallback;
    private LicenseChecker m_Checker;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        // "LicenseCheckerCallback" Initialize
        m_LicenseCheckerCallback = new MyLicenseCheckerCallback();
        // "Devices ID" Obtain
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String deviceId = tm.getDeviceId();
        // "LicenseChecker" Initialize
        m_Checker = new LicenseChecker( this,
                   new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)),
                   BASE64_PUBLIC_KEY);
        // "License Validation" Exe
        m_Checker.checkAccess(m_LicenseCheckerCallback);
    }
    ...
}

6. APK Test
: "LVL" to test the "Android Market" will be up to the fee.
: "Publish" does not need to do to, "save" are worth LVL can test release.


In addition, inquiries, or questions, please contact us.
(joonryang@gmail.com)

댓글 없음:

댓글 쓰기