Merge "Add dismissFlow callback to SlicePurchaseWebInterface" into udc-qpr-dev
This commit is contained in:
@@ -75,5 +75,11 @@
|
||||
Notify purchase failed
|
||||
</button>
|
||||
<p id="purchase_failed"></p>
|
||||
|
||||
<h2>Dismiss flow</h2>
|
||||
<button type="button" onclick="testDismissFlow()">
|
||||
Dismiss flow
|
||||
</button>
|
||||
<p id="dismiss_flow"></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -31,3 +31,9 @@ function testNotifyPurchaseFailed(failure_code = 0, failure_reason = "unknown")
|
||||
document.getElementById("purchase_failed").innerHTML =
|
||||
"Notified purchase failed.";
|
||||
}
|
||||
|
||||
function testDismissFlow() {
|
||||
DataBoostWebServiceFlow.dismissFlow();
|
||||
document.getElementById("dismiss_flow").innerHTML =
|
||||
"Called dismiss flow.";
|
||||
}
|
||||
|
||||
@@ -88,4 +88,21 @@ public class DataBoostWebServiceFlow {
|
||||
@Nullable String failureReason) {
|
||||
mActivity.onPurchaseFailed(failureCode, failureReason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface method allowing the carrier website to notify the slice purchase application that
|
||||
* the service flow ended prematurely. This can be due to user action, an error in the
|
||||
* web sheet logic, or an error on the network side.
|
||||
*
|
||||
* This can be called using the JavaScript below:
|
||||
* <script type="text/javascript">
|
||||
* function dismissFlow() {
|
||||
* DataBoostWebServiceFlow.dismissFlow();
|
||||
* }
|
||||
* </script>
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void dismissFlow() {
|
||||
mActivity.onDismissFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,14 @@ public class SlicePurchaseActivity extends Activity {
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
|
||||
protected void onDismissFlow() {
|
||||
logd("onDismissFlow: Dismiss flow called while purchasing premium capability "
|
||||
+ TelephonyManager.convertPremiumCapabilityToString(mCapability));
|
||||
SlicePurchaseBroadcastReceiver.sendSlicePurchaseAppResponse(
|
||||
mIntent, SlicePurchaseController.EXTRA_INTENT_REQUEST_FAILED);
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
|
||||
// Pressing back in the WebView will go to the previous page instead of closing
|
||||
|
||||
@@ -55,6 +55,7 @@ public class SlicePurchaseActivityTest extends ActivityUnitTestCase<SlicePurchas
|
||||
@Mock PendingIntent mPendingIntent;
|
||||
@Mock PendingIntent mSuccessfulIntent;
|
||||
@Mock PendingIntent mCanceledIntent;
|
||||
@Mock PendingIntent mRequestFailedIntent;
|
||||
@Mock CarrierConfigManager mCarrierConfigManager;
|
||||
@Mock NotificationManager mNotificationManager;
|
||||
@Mock PersistableBundle mPersistableBundle;
|
||||
@@ -112,6 +113,11 @@ public class SlicePurchaseActivityTest extends ActivityUnitTestCase<SlicePurchas
|
||||
doReturn(true).when(mSuccessfulIntent).isBroadcast();
|
||||
doReturn(mSuccessfulIntent).when(spiedIntent).getParcelableExtra(
|
||||
eq(SlicePurchaseController.EXTRA_INTENT_SUCCESS), eq(PendingIntent.class));
|
||||
doReturn(TelephonyManager.PHONE_PROCESS_NAME).when(mRequestFailedIntent)
|
||||
.getCreatorPackage();
|
||||
doReturn(true).when(mRequestFailedIntent).isBroadcast();
|
||||
doReturn(mRequestFailedIntent).when(spiedIntent).getParcelableExtra(
|
||||
eq(SlicePurchaseController.EXTRA_INTENT_REQUEST_FAILED), eq(PendingIntent.class));
|
||||
|
||||
mSlicePurchaseActivity = startActivity(spiedIntent, null, null);
|
||||
}
|
||||
@@ -124,7 +130,7 @@ public class SlicePurchaseActivityTest extends ActivityUnitTestCase<SlicePurchas
|
||||
|
||||
@Test
|
||||
public void testOnPurchaseFailed() throws Exception {
|
||||
int failureCode = SlicePurchaseController.FAILURE_CODE_SERVER_UNREACHABLE;
|
||||
int failureCode = SlicePurchaseController.FAILURE_CODE_CARRIER_URL_UNAVAILABLE;
|
||||
String failureReason = "Server unreachable";
|
||||
mSlicePurchaseActivity.onPurchaseFailed(failureCode, failureReason);
|
||||
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
@@ -141,4 +147,10 @@ public class SlicePurchaseActivityTest extends ActivityUnitTestCase<SlicePurchas
|
||||
mSlicePurchaseActivity.onDestroy();
|
||||
verify(mCanceledIntent).send();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnDismissFlow() throws Exception {
|
||||
mSlicePurchaseActivity.onDismissFlow();
|
||||
verify(mRequestFailedIntent).send();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user