原文:http://android.eoe.cn/topic/android_sdkandroid
Table 1 lists all of the source files in the License Verification Library (LVL) available through the Android SDK. All of the files are part of the com.android.vending.licensing package.算法
表一列出了經過AndroidSDK能夠得到的許可認證庫(LVL)的源代碼文件。這些文件都是com.android.vending.licensing這包的一部分。
Table 1. Summary of LVL library classes and interfaces.express
表一:LVL庫的類文件和接口promise
<!-- 表格開始 -->
{|style="border-spacing: 0px;margin: 4px 4px; width: 90%; border-left:1px solid #ccc;border-top:1px solid #ccc; "緩存
<!-- 這段是表頭 -->
|-style="background:#DEE8F1; "
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Category目錄
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Name名字
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Description描述服務器
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
License check and result許可查看和結果
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
LicenseChecker
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Class that you instantiate (or subclass) to initiate a license check.一個您實例化或者子類話的類,這個類用來開始一個許可檢查。網絡
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |app
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
LicenseCheckerCallback
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Interface that you implement to handle result of the license check.您能夠經過實現這個接口來處理許可檢查的結果。less
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
Policy策略
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Policy
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Interface that you implement to determine whether to allow access to the application, based on the license response.經過實現這個接口您能夠決定是否容許經過許可反饋來訪問應用異步
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ServerManagedPolicy
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Default Policy implementation. Uses settings provided by the licensing server to manage local storage of license data, license validity, retry.默認的Policy接口。使用許可服務器提供的設置來管理本地的存儲數據,許可合法性和嘗試。
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
StrictPolicy
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Alternative Policy implementation. Enforces licensing based on a direct license response from the server only. No caching or request retry.本地Policy接口。強制許可基於來自服務器的直接的許可響應。不緩存也不請求重試。
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
Data obfuscation(optional)
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Obfuscator
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Interface that you implement if you are using a Policy (such as ServerManagedPolicy) that caches license response data in a persistent store. Applies an obfuscation algorithm to encode and decode data being written or read.
若是您使用Policy(比ServerManagedPolicy),您將繼承這個接口。這個接口把許可響應數據緩存在一個持久存儲區裏。在被讀寫的時候,它使用模糊算法來編碼和解碼。
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
AESObfuscator
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Default Obfuscator implementation that uses AES encryption/decryption algorithm to obfuscate/unobfuscate data.使用AES加密/解密算法來混淆/反混淆數據的默認算法接口。
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
Device limitation(optional)
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
DeviceLimiter
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Interface that you implement if you want to restrict use of an application to a specific device.
實現這個接口,您能夠限制應用在特定設備上的使用。Called from LicenseValidator. 調用來自LicenseValidator。
Implementing DeviceLimiter is not recommended for most applications because it requires a backend server and may cause the user to lose access to licensed applications, unless designed with care.
對於大多數應用,咱們不推薦繼承DeviceLimiter接口,它他須要一個後臺服務器而且它可能致使用戶和許可的應用失去聯繫,除非在設計的時候認真的考慮了。
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
NullDeviceLimiter
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Default DeviceLimiter implementation that is a no-op (allows access to all devices).默認的DeviceLimiter接口,這個接口容許訪問任何設備。
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
Library core, no integration needed
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ResponseData
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Class that holds the fields of a license response.這個類控制一個許可響應的區域
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
LicenseValidator
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Class that decrypts and verifies a response received from the licensing server.這個類用來解密並驗證從許可服務器發來的響應
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ValidationException
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Class that indicates errors that occur when validating the integrity of data managed by an Obfuscator.這個類指出在驗證Obfuscator管理的數據的完整性時出現的錯誤
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
PreferenceObfuscator
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Utility class that writes/reads obfuscated data to the system's SharedPreferences store.這個工具類用於讀寫混淆數據存儲到系統的Sharedpreferences
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:0px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ILicensingService
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
One-way IPC interface over which a license check request is passed to the Google Play client.單向的進程間通信接口,這個接口的許可檢查請求來自google play客戶端
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ILicenseResultListener
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
One-way IPC callback implementation over which the application receives an asynchronous response from the licensing server.單向進程間通信調用的實現,這個實現基於應用收到的來自許可服務器的異步響應
|}
<!-- 表格結束 -->
Table 2 lists all of the license response codes supported by the licensing server. In general, an application should handle all of these response codes. By default, the LicenseValidator class in the LVL provides all of the necessary handling of these response codes for you.
表二列出了許可服務器所支持的全部許可返回碼. 通常的,一個應用應該處理全部的這些返回碼.默認的, LVL中的LicenseValidator(許可校驗碼)類提供全部須要處理的響應代碼
Table 2. Summary of response codes returned by the Google Play server in a license response.
表二 google play商店服務器以許可響應的形式返回的響應代碼
<!-- 表格開始 -->
{|style="border-spacing: 0px;margin: 4px 4px; width: 90%; border-left:1px solid #ccc;border-top:1px solid #ccc; "
<!-- 這段是表頭 -->
|-style="background:#DEE8F1; "
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Response Code返回碼
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Description描述
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Signed? 是否簽名?
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Extras 值
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Comments 評價
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
LICENSED
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The application is licensed to the user. The user has purchased the application or the application only exists as a draft.
這個應用被受權給這個用戶,這個用戶購買了這個應用,或者這個應用僅僅是一個草稿版本(已經上傳,可是沒有發佈).
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Yes是
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
VT, GT,GR
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Allow access according to Policy constraints通過Policy驗證後運行使用應用
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
LICENSED_OLD_KEY
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The application is licensed to the user, but there is an updated application version available that is signed with a different key.
這個應用被受權給這個用戶,這個應用有升級版,可是升級版的簽名和當前的應用不一樣
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Yes是
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
VT, GT,GR, UT
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Optionally allow access according to Policyconstraints.
Can indicate that the key pair used by the installed application version is invalid or compromised. The application can allow access if needed or inform the user that an upgrade is available and limit further use until upgrade.
有選擇性的容許使用應用.能夠代表已安裝的應用所使用的密鑰不存在或者已經被損壞.若是須要應用能夠被容許使用或者通知用戶須要進行升級才能使用
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
NOT_LICENSED
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The application is not licensed to the user.
這個應用沒有受權給這個用戶
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
No
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Do not allow access.不容許使用該應用
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ERROR_CONTACTING_SERVER
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The application is not licensed to the user.
Local error — the Google Play application was not able to reach the licensing server, possibly because of network availability problems.
本地錯誤—google play 應用不能鏈接到許可服務器,多是由於網絡鏈接問題
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
No
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
according toPolicy retry limits.試用次數取決於Policy
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ERROR_SERVER_FAILURE
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Server error — the server could not load the publisher account's key pair for licensing.
服務器錯誤—服務器不能獲取發佈者的密鑰來進行許可操做
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
No
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Retry the license check according toPolicy retry limits.根據Policy的使用次數從新進行許可檢查
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ERROR_INVALID_PACKAGE_NAME
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Local error — the application requested a license check for a package that is not installed on the device.
本地錯誤,這個應用須要一個許可證來對包進行許可檢查,可是這個許可證沒有安裝在設備上
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
No
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Retry the license check according toPolicy retry limits.根據Policy的使用次數從新進行許可檢查
Do not retry the license check.Typically caused by a development error.不要進行許可堅持,通常是因爲應用開發錯誤.
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ERROR_NON_MATCHING_UID
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Local error — the application requested a license check for a package whose UID (package, user ID pair) does not match that of the requesting application.
本地錯誤---這個應用須要一個許可證來對安裝包進行檢查,可是這個許可證的UID(包,用戶ID)和當前的請求應用不相吻合.
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
No
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Do not retry the license check.Typically caused by a development error. 不要進行許可檢查,通常是因爲應用開發錯誤
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
ERROR_NOT_MARKET_MANAGED
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Server error — the application (package name) was not recognized by Google Play.
服務器錯誤 應用(包名)沒有被google play識別.
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
No
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Do not retry the license check.
Can indicate that the application was not published through Google Play or that there is an development error in the licensing implementation.
不要進行許可檢查,能夠代表應用沒有在google play上發佈或者在開發中許可實現的時候存在錯誤
|}
<!-- 表格結束 -->
Note: As documented in Setting Up The Testing Environment, the response code can be manually overridden for the application developer and any registered test users via the Google Play publisher site.
注意:就像在設置測試環境一張描述的那樣,相應碼能夠手動被google play的註冊開發者或者測試者重寫.
Additionally, as noted above, applications that are in draft mode (in other words, applications that have been uploaded but have never been published) will return LICENSED for all users, even if not listed as a test user. Since the application has never been offered for download, it is assumed that any users running it must have obtained it from an authorized channel for testing purposes.
除此以外,如上所述,在」草稿」狀態的應用(這個應用已經上傳,可是從未發佈)將會返回LICENSED 給全部的用戶,即便這些用戶不是列出的測試用戶.因爲這個應用歷來沒有提供下載,因此這個應用被視爲從一個受權渠道拿來作測試之用的
To assist your application in managing access to the application across the application refund period and provide other information, The licensing server includes several pieces of information in the license responses. Specifically, the service provides recommended values for the application's license validity period, retry grace period, maximum allowable retry count, and other settings. If your application uses APK expansion files, the response also includes the file names, sizes, and URLs. The server appends the settings as key-value pairs in the license response "extras" field.
爲了幫助您的應用管理用戶在退款期間的使用並提供其餘信息,許可服務器包含了幾組許可返回信息.具體來講,服務器提供應用許可證有效期期間的建議值,重試寬限期,容許的最大重試次數,以及其餘設置。若是您的應用使用了apk’擴充文件,那返回值也包括文件名,文件大小,URL等.服務器在許可響應的」額外」領域做爲鍵值對追加設置項.
Any Policy implementation can extract the extras settings from the license response and use them as needed.
任何Policy類的繼承能夠從許可返回信息中提取設置的值,在須要的時候使用他們.
The LVL default Policy implementation, ServerManagedPolicy, serves as a working implementation and an illustration of how to obtain, store, and use the settings.
LVL的默認Policy類默認繼承 ServerManagedPolicy,實現功能,說明怎麼獲取,存儲,使用這些設置.
Table 3. Summary of license-management settings supplied by the Google Play server in a license response.
表3 google play服務器以一個許可響應的形式提供的許可管理設置
<!-- 表格開始 -->
{|style="border-spacing: 0px;margin: 4px 4px; width: 90%; border-left:1px solid #ccc;border-top:1px solid #ccc; "
<!-- 這段是表頭 -->
|-style="background:#DEE8F1; "
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Extra
! style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px" | Description
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
VT
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
License validity timestamp. Specifies the date/time at which the current (cached) license response expires and must be rechecked on the licensing server. See the section below about License validity period.
許可有效期時間戳.指定了當前(或是緩存的)許可響應已通過期,必須去許可服務器上覆查. 有關許可證有效期,請參閱下文
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
GT
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Grace period timestamp. Specifies the end of the period during which a Policy may allow access to the application, even though the response status is RETRY.寬限期的時間戳.指定在許可響應信號是RETRY的時候容許應用使用的最後日期.
The value is managed by the server, however a typical value would be 5 or more days. See the section below about Retry period and maximum retry count.這個值是由服務器管理的,通常這個值是5天或者更多.參閱下面的使用期限和最大使用次數
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
GR
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Maximum retries count. Specifies how many consecutive RETRY license checks the Policyshould allow, before denying the user access to the application.
最大使用次數,指定在禁止用戶使用應用前,Policy能夠容許多少次連續的RETRY許可檢查信號.
The value is managed by the server, however a typical value would be "10" or higher. See the section below about Retry period and maximum retry count.
這個值也是由服務器管理,通常是」10」或者更大,參閱下面的使用期限和最大使用次數
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
UT
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
Update timestamp. Specifies the day/time when the most recent update to this application was uploaded and published.更新時間戳.指定應用新版本上傳或發佈的日期和時間.
The server returns this extra only for LICENSED_OLD_KEYS responses, to allow the Policyto determine how much time has elapsed since an update was published with new licensing keys before denying the user access to the application.服務器只返回LICENSED_OLD_KEYS的響應來容許Policy決定一個含有新的許可信息的更新版本發佈後還有多少時間來禁止用戶使用舊版本
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
FILE_URL1orFILE_URL2
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The URL for an expansion file (1 is for the main file, 2 is the patch file). Use this to download the file over HTTP.擴展文件的URL(1表明主文件,2是補丁文件).使用這個URL來從HTTP上下載文件.
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
FILE_NAME1orFILE_NAME2
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The expansion file's name (1 is for the main file, 2 is the patch file). You must use this name when saving the file on the device.
擴展文件的名字(1是主文件,2是補丁文件).在設備上保存這個文件時,您必須使用這個名字
<!-- 這段是表格 -->
|- style=" vertical-align:top;"
| style=" border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
FILE_SIZE1orFILE_SIZE2
| style="border-right:1px solid #ccc;border-bottom:1px solid #ccc; padding:5px 15px; " |
The size of the file in bytes (1 is for the main file, 2 is the patch file). Use this to assist with downloading and to ensure that enough space is available on the device's shared storage location before downloading.
文件的大小,以字節爲單位(1是主文件,2是補丁文件).使用他來輔助下載並在下載前確保設備的存儲空間足夠.
|}
<!-- 表格結束 -->
The Google Play licensing server sets a license validity period for all downloaded applications.
Google play許可服務器對全部的下載了的應用設置了一個有效期.
The period expresses the interval of time over which an application's license status should be considered as unchanging and cacheable by a licensing Policy in the application.
這個階段在表述時,一個應用許可狀態的時間間隔應該做爲沒有在變化和能夠經過應用中的Policy許可證被緩存來考慮.
The licensing server includes the validity period in its response to all license checks, appending an end-of-validity timestamp to the response as an extra under the key VT.
許可服務器在他的對全部許可檢查響應中包含了有效期,這個操做經過在響應中追加有效期結束時間戳做爲VT鍵下額外的數值來實現的.
A Policy can extract the VT key value and use it to conditionally allow access to the application without rechecking the license, until the validity period expires.
一個Policy能夠把VT的鍵提取出來而後使用它來在不從新檢查許可證的狀況下使用應用,直到有效時間結束.
The license validity signals to a licensing Policy when it must recheck the licensing status with the licensing server.
當一個許可證必須使用許可服務器從新檢查許可狀態的時候, 許可證向一個許可Policy發一個有效性信號
It is not intended to imply whether an application is actually licensed for use.
他不是想要去暗示這個應用是否被許可可使用.
That is, when an application's license validity period expires, this does not mean that the application is no longer licensed for use — rather, it indicates only that the Policy must recheck the licensing status with the server.
而是,當一個應用的許可過時了,這不意味着這個應用不再能被許可以使用了—而是,他暗示只有Policy必須從新使用服務器檢查許可狀態.
It follows that, as long as the license validity period has not expired, it is acceptable for the Policy to cache the initial license status locally and return the cached license status instead of sending a new license check to the server.
只要許可有效期沒有過時,他就能夠被Policy接受並緩存最初的尚未過時的許可狀態到本地,而後返回緩存的許可狀態而不是向服務器發送一個新的許可檢查.
The licensing server manages the validity period as a means of helping the application properly enforce licensing across the refund period offered by Google Play for paid applications. It sets the validity period based on whether the application was purchased and, if so, how long ago. Specifically, the server sets a validity period as follows:
做爲一種輔助在google play上的付費應用恰當的強制許可的方式,許可服務器會管理該應用的許可有效時間.他判斷是否這個應用是付費的,若是是,容許使用多長時間 , 經過這個來設置許可的有效時間.具體來講,服務器設置有效期的方法以下:
• For a paid application, the server sets the initial license validity period so that the license response remains valid for as long as the application is refundable. A licensing Policy in the application may cache the result of the initial license check and does not need to recheck the license until the validity period has expired.
• 對於一個付費的應用,服務器經過設置最初的許可有效期來使許可響應保持有效.只要應用在退還期.一個在應用中的許可Policy可能緩存最初許可證的檢查結果,而不須要從新檢查許可直到有效期結束.
• When an application is no longer refundable, the server sets a longer validity period — typically a number of days.
• 當一個應用再也不能夠退還,服務器會設置一個比較長的有效期,一般是不少天.
• For a free application, the server sets the validity period to a very high value (long.MAX_VALUE). This ensures that, provided the Policy has cached the validity timestamp locally, it will not need to recheck the license status of the application in the future.
• 對於一個免費的應用,服務器設置有效期爲一個很是大的數值(long.MAX_VALUE).這樣能夠確保Policy已經在本地緩存了一個有效的時間戳,他在未來不須要從新檢查許可狀態.
The ServerManagedPolicy implementation uses the extracted timestamp (mValidityTimestamp) as a primary condition for determining whether to recheck the license status with the server before allowing the user access to the application.
ServerManagedPolicy (服務管理策略)的實現使用了提取到的時間戳(mValidityTimestamp)來做爲基本的判斷是否須要在容許用戶使用該應用以前經過服務器從新檢查許可狀態的條件
In some cases, system or network conditions can prevent an application's license check from reaching the licensing server, or prevent the server's response from reaching the Google Play client application. For example, the user might launch an application when there is no cell network or data connection available—such as when on an airplane—or when the network connection is unstable or the cell signal is weak.
在一些狀況下,系統或網絡條件可能阻止應用經過許可服務器進行許可檢查或者阻止來自google play客戶端的服務器響應.例如,用戶可能在沒有基站網絡或者數據鏈接的環境下啓動應用—好比在飛機上—或者,基站信號很弱或者網絡部穩定.
When network problems prevent or interrupt a license check, the Google Play client notifies the application by returning a RETRY response code to the Policy's processServerResponse() method. In the case of system problems, such as when the application is unable to bind with Google Play's ILicensingServiceimplementation, the LicenseChecker library itself calls the Policy processServerResonse() method with aRETRY response code.
當網絡問題阻止或者中斷了許可檢查,googleplay客戶端會經過返回一個RRTRY響應碼給Policy的processServerResponse() 方法來通知應用這個狀況.在系統問題狀況下,好比當應用不能和google play的 ILicensingService服務綁定, LicenseChecker庫會使用RETRY響應碼來調用processServerResonse()方法.
In general, the RETRY response code is a signal to the application that an error has occurred that has prevented a license check from completing.
通常的,RETRY響應碼通常代表應用存在一個錯誤致使不能完成許可檢查.
The Google Play server helps an application to manage licensing under error conditions by setting a retry "grace period" and a recommended maximum retries count. The server includes these values in all license check responses, appending them as extras under the keys GT and GR.
Google play服務器經過設置一個」寬限期」並設置最多使用次數來幫助應用在存在錯誤的狀況下處理許可.服務器在全部的許可檢查響應中包含這些值,他們被做爲GT和GR的追加值.
The application Policy can extract the GT and GR extras and use them to conditionally allow access to the application, as follows:
應用的Policy能夠提取GT和GR值並使用它們來有條件容許用戶使用應用程序:
• For a license check that results in a RETRY response, the Policy should cache the RETRY response code and increment a count of RETRY responses.
• 若是許可檢查返回RETRY響應,Policy應該緩存RETRY響應碼並記錄,並不斷增長RETRY的響應次數
• The Policy should allow the user to access the application, provided that either the retry grace period is still active or the maximum retries count has not been reached.
The ServerManagedPolicy uses the server-supplied GT and GR values as described above. The example below shows the conditional handling of the retry responses in the allow() method. The count of RETRY responses is maintained in the processServerResponse() method, not shown.
若是試用的」寬限期」還沒到或者最大使用次數還沒到,那Policy應該容許用戶訪問應用. ServerManagedPolicy使用服務器提供的GT和GR值.下面的例子在allow()方法中展現了怎麼處理使用時的響應.RETRY的數量在processServerResponse()方法中保存,在這裏沒有展現.
public boolean allowAccess() {long ts = System.currentTimeMillis();if (mLastResponse == LicenseResponse.LICENSED) {// Check if the LICENSED response occurred within the validity timeout.if (ts <= mValidityTimestamp) {// Cached LICENSED response is still valid.return true;}} else if (mLastResponse == LicenseResponse.RETRY &&ts < mLastResponseTime + MILLIS_PER_MINUTE) {// Only allow access if we are within the retry period or we haven't used up our// max retries.return (ts