Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2018 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 package android.telephony.euicc.cts;
     18 
     19 import android.app.Activity;
     20 import android.app.PendingIntent;
     21 import android.telephony.euicc.EuiccManager;
     22 
     23 /**
     24  * A dummy activity which simulates a resolution activity. Returns {@link Activity#RESULT_OK} to
     25  * caller if 1) {@link Activity#onResume()} is called (as proof that the activity has been
     26  * successfully started), and 2) the callback intent is verified.
     27  */
     28 public class EuiccResolutionActivity extends Activity {
     29 
     30     @Override
     31     protected void onResume() {
     32         super.onResume();
     33 
     34         // verify callback intent
     35         // TODO: verify callback intent's action matches
     36         // EuiccTestResolutionActivity.ACTION_START_RESOLUTION_ACTIVITY
     37         PendingIntent callbackIntent =
     38                 getIntent()
     39                         .getParcelableExtra(
     40                                 EuiccManager
     41                                         .EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT);
     42         if (callbackIntent != null) {
     43             setResult(RESULT_OK);
     44         } else {
     45             setResult(RESULT_CANCELED);
     46         }
     47 
     48         // Resolution activity has successfully started, return result & finish
     49         finish();
     50     }
     51 }
     52