1<!-- 2 ~ Copyright (C) 2022 The Android Open Source Project 3 ~ 4 ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 ~ you may not use this file except in compliance with the License. 6 ~ You may obtain a copy of the License at 7 ~ 8 ~ http://www.apache.org/licenses/LICENSE-2.0 9 ~ 10 ~ Unless required by applicable law or agreed to in writing, software 11 ~ distributed under the License is distributed on an "AS IS" BASIS, 12 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 ~ See the License for the specific language governing permissions and 14 ~ limitations under the License. 15 --> 16 17<!DOCTYPE html> 18<html lang="en"> 19<head> 20 <meta charset="UTF-8"> 21 <meta name="description" content=" 22 This is a HTML page that calls and verifies responses from the @JavascriptInterface functions of 23 DataBoostWebServiceFlow. Test slice purchase application behavior using ADB shell commands and 24 the APIs below: 25 26 FROM TERMINAL: 27 Allow device to override carrier configs: 28 $ adb root 29 Set PREMIUM_CAPABILITY_PRIORITIZE_LATENCY enabled: 30 $ adb shell cmd phone cc set-value -p supported_premium_capabilities_int_array 34 31 Set the carrier purchase URL to this test HTML file: 32 $ adb shell cmd phone cc set-value -p premium_capability_purchase_url_string \ 33 file:///android_asset/slice_purchase_test.html 34 OPTIONAL: Allow premium capability purchase on LTE: 35 $ adb shell cmd phone cc set-value -p premium_capability_supported_on_lte_bool true 36 OPTIONAL: Override ServiceState to fake a NR SA connection: 37 $ adb shell am broadcast -a com.android.internal.telephony.TestServiceState --ei data_rat 20 38 39 FROM TEST ACTIVITY: 40 TelephonyManager tm = getApplicationContext().getSystemService(TelephonyManager.class) 41 tm.isPremiumCapabilityAvailable(TelephonyManager.PREMIUM_CAPABILITY_PRIORITIZE_LATENCY); 42 LinkedBlockingQueue<Integer> purchaseRequests = new LinkedBlockingQueue<>(); 43 tm.purchasePremiumCapability(TelephonyManager.PREMIUM_CAPABILITY_PRIORITIZE_LATENCY, 44 this.getMainExecutor(), request::offer); 45 46 When the test application starts, this HTML will be loaded into the WebView along with the 47 associated JavaScript functions in file:///android_asset/slice_purchase_test.js. 48 Click on the buttons in the HTML to call the corresponding @JavascriptInterface APIs. 49 50 RESET DEVICE STATE: 51 Clear carrier configurations that were set: 52 $ adb shell cmd phone cc clear-values 53 Clear ServiceState override that was set: 54 $ adb shell am broadcast -a com.android.internal.telephony.TestServiceState --es action reset 55 "> 56 <title>Test SlicePurchaseActivity</title> 57 <script type="text/javascript" src="slice_purchase_test.js"></script> 58</head> 59<body> 60 <h1>Test SlicePurchaseActivity</h1> 61 <h2>Get requested premium capability</h2> 62 <button type="button" onclick="testGetRequestedCapability()"> 63 Get requested premium capability 64 </button> 65 <p id="requested_capability"></p> 66 67 <h2>Notify purchase successful</h2> 68 <button type="button" onclick="testNotifyPurchaseSuccessful()"> 69 Notify purchase successful 70 </button> 71 <p id="purchase_successful"></p> 72 73 <h2>Notify purchase failed</h2> 74 <button type="button" onclick="testNotifyPurchaseFailed(2, 'FAILURE_CODE_SERVER_UNREACHABLE')"> 75 Notify purchase failed 76 </button> 77 <p id="purchase_failed"></p> 78 79 <h2>Dismiss flow</h2> 80 <button type="button" onclick="testDismissFlow()"> 81 Dismiss flow 82 </button> 83 <p id="dismiss_flow"></p> 84 85 <h2>Test <a href="http://www.google.com">hyperlink</a></h2> 86</body> 87</html> 88