本文整理汇总了Java中com.google.android.vending.licensing.Policy类的典型用法代码示例。如果您正苦于以下问题:Java Policy类的具体用法?Java Policy怎么用?Java Policy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Policy类属于com.google.android.vending.licensing包,在下文中一共展示了Policy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dontAllow
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
public void dontAllow(int policyReason) {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
displayResult(getString(R.string.dont_allow));
// Should not allow access. In most cases, the app should assume
// the user has access unless it encounters this. If it does,
// the app should inform the user of their unlicensed ways
// and then either shut down the app or limit the user to a
// restricted set of features.
// In this example, we show a dialog that takes the user to Market.
// If the reason for the lack of license is that the service is
// unavailable or there is another problem, we display a
// retry button on the dialog and a different message.
displayDialog(policyReason == Policy.RETRY);
}
示例2: testExtraDataParsed
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that extra data is parsed correctly on a LICENSED resopnse..
*/
public void testExtraDataParsed() {
String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
"ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=11>=22&GR=33" +
"&FILE_URL1=http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLj4GVlGU5oyW6y3FsXrJiQqMunTGw9B" +
"&FILE_NAME1=main.3.com.example.android.market.licensing.obb&FILE_SIZE1=687801613" +
"&FILE_URL2=http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLsdSDjefsdfEKdVaseEsfaMeifTek9B" +
"&FILE_NAME2=patch.3.com.example.android.market.licensing.obb&FILE_SIZE2=204233";
p.processServerResponse(Policy.LICENSED,
ResponseData.parse(sampleResponse));
assertEquals(11l, p.getValidityTimestamp());
assertEquals(22l, p.getRetryUntil());
assertEquals(33l, p.getMaxRetries());
assertEquals(2, p.getExpansionURLCount());
assertEquals("main.3.com.example.android.market.licensing.obb",p.getExpansionFileName(0));
assertEquals(687801613l,p.getExpansionFileSize(0));
assertEquals("http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLj4GVlGU5oyW6y3FsXrJiQqMunTGw9B",
p.getExpansionURL(0));
assertEquals("patch.3.com.example.android.market.licensing.obb",p.getExpansionFileName(1));
assertEquals(204233,p.getExpansionFileSize(1));
assertEquals("http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLsdSDjefsdfEKdVaseEsfaMeifTek9B",
p.getExpansionURL(1));
}
示例3: testRetryCountsCleared
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that retry counts are cleared after getting a NOT_LICENSED response.
*/
public void testRetryCountsCleared() {
String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
"ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1>=2&GR=3";
p.processServerResponse(Policy.LICENSED,
ResponseData.parse(sampleResponse));
// Sanity test
assertTrue(0l != p.getValidityTimestamp());
assertTrue(0l != p.getRetryUntil());
assertTrue(0l != p.getMaxRetries());
// Actual test
p.processServerResponse(Policy.NOT_LICENSED, null);
assertEquals(0l, p.getValidityTimestamp());
assertEquals(0l, p.getRetryUntil());
assertEquals(0l, p.getMaxRetries());
}
示例4: testRetryCountsCleared
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that retry counts are cleared after getting a NOT_LICENSED response.
*/
public void testRetryCountsCleared() {
String sampleResponse = "0|1579380448|org.mobiletrial.simplesample|1|" +
"ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1>=2&GR=3";
p.processServerResponse(Policy.LICENSED,
ResponseData.parse(sampleResponse));
// Sanity test
assertTrue(0l != p.getValidityTimestamp());
assertTrue(0l != p.getRetryUntil());
assertTrue(0l != p.getMaxRetries());
// Actual test
p.processServerResponse(Policy.NOT_LICENSED, null);
assertEquals(0l, p.getValidityTimestamp());
assertEquals(0l, p.getRetryUntil());
assertEquals(0l, p.getMaxRetries());
}
示例5: LicenseChecker
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* @param context a Context
* @param policy implementation of Policy
* @param encodedPublicKey Base64-encoded RSA public key
* @param serviceUrl a URL to the licensing server
* @param accountType a instance of IAccountType to determine Android Account
* @throws IllegalArgumentException if encodedPublicKey is invalid
*/
public LicenseChecker(Context context,
Policy policy,
String encodedPublicKey,
URL serviceUrl,
IAccountType accountType) {
mPolicy = policy;
mPublicKey = null;
mPublicKey = generatePublicKey(encodedPublicKey);
mContext = context;
mPackageName = mContext.getPackageName();
mVersionCode = getVersionCode(context, mPackageName);
HandlerThread handlerThread = new HandlerThread("background thread");
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());
mAccountType = accountType;
mServiceUrl = serviceUrl;
}
示例6: dontAllow
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
@Override
public void dontAllow(int reason) {
switch (reason){
case Policy.NOT_LICENSED:
sendBroadcast(false);
break;
default:
sendBroadcast(true);
}
Logger.d(TAG, "dontAllow, reason=" + reason);
}
示例7: checkLicense
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
private void checkLicense() {
mHandler = new Handler();
Policy policy = PolicyFactory.createPolicy(this, getPackageName());
mChecker = new LicenseChecker(this, policy, Key.BASE_64_PUBLIC_KEY);
mCallBack = new CheckLicenseCallBack();
mChecker.checkAccess(mCallBack);
}
示例8: dontAllow
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
@Override
public void dontAllow(int reason) {
if (isFinishing()) {
return;
}
if (reason == Policy.NOT_LICENSED) {
handleCracked();
}
}
示例9: dontAllow
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
public void dontAllow(int reason) {
if (((Activity) delegate).isFinishing()) { return; }
if (reason == Policy.RETRY) {
delegate.onLicenceRetry(reason);
} else {
delegate.onLicenceInvalid(reason);
}
}
示例10: testNoFailureOnEncodedExtras
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
public void testNoFailureOnEncodedExtras() {
String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
"ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1&test=hello%20world%20%26" +
"%20friends>=2&GR=3";
p.processServerResponse(Policy.LICENSED,
ResponseData.parse(sampleResponse));
assertEquals(1l, p.getValidityTimestamp());
assertEquals(2l, p.getRetryUntil());
assertEquals(3l, p.getMaxRetries());
}
示例11: testLicensedResonse
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that after receiving a LICENSED response, the policy grants
* access.
*/
public void testLicensedResonse() {
StrictPolicy p = new StrictPolicy();
p.processServerResponse(Policy.LICENSED, null);
boolean result = p.allowAccess();
assertTrue(result);
}
示例12: testNotLicensedResponse
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that after receiving a NOT_LICENSED response, the policy denies
* access.
*/
public void testNotLicensedResponse() {
StrictPolicy p = new StrictPolicy();
p.processServerResponse(Policy.NOT_LICENSED, null);
boolean result = p.allowAccess();
assertFalse(result);
}
示例13: testRetryResponse
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that after receiving a RETRY response, the policy denies
* access.
*/
public void testRetryResponse() {
StrictPolicy p = new StrictPolicy();
p.processServerResponse(Policy.RETRY, null);
boolean result = p.allowAccess();
assertFalse(result);
}
示例14: testExtraDataParsed
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that extra data is parsed correctly on a LICENSED resopnse..
*/
public void testExtraDataParsed() {
String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
"ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=11>=22&GR=33";
p.processServerResponse(Policy.LICENSED,
ResponseData.parse(sampleResponse));
assertEquals(11l, p.getValidityTimestamp());
assertEquals(22l, p.getRetryUntil());
assertEquals(33l, p.getMaxRetries());
}
示例15: testExtraDataParsed
import com.google.android.vending.licensing.Policy; //导入依赖的package包/类
/**
* Verify that extra data is parsed correctly on a LICENSED resopnse..
*/
public void testExtraDataParsed() {
String sampleResponse = "0|1579380448|org.mobiletrial.simplesample|1|" +
"ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=11>=22&GR=33";
p.processServerResponse(Policy.LICENSED,
ResponseData.parse(sampleResponse));
assertEquals(11l, p.getValidityTimestamp());
assertEquals(22l, p.getRetryUntil());
assertEquals(33l, p.getMaxRetries());
}