Home | History | Annotate | Download | only in activation
      1 /*
      2  * Copyright (C) 2015 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 com.android.services.telephony.activation;
     18 
     19 import android.app.PendingIntent;
     20 import android.telephony.TelephonyManager;
     21 
     22 /**
     23  * Handles SIM activation requests and runs the appropriate activation process until it completes
     24  * or fails. When done, sends back a response if needed.
     25  */
     26 public class SimActivationManager {
     27     public static final class Triggers {
     28         public static final int SYSTEM_START = 1;
     29         public static final int EXPLICIT_REQUEST = 2;
     30     }
     31 
     32     public interface Response {
     33         /**
     34          * @param status See {@link android.telephony.TelephonyManager} for SIM_ACTIVATION_RESULT_*
     35          *               constants.
     36          */
     37         void onResponse(int status);
     38     }
     39 
     40     public void runActivation(int trigger, Response response) {
     41         Activator activator = selectActivator(trigger);
     42 
     43         activator.onActivate();
     44 
     45         // TODO: Specify some way to determine if activation is even necessary.
     46 
     47         // TODO: specify some way to return the result.
     48 
     49         if (response != null) {
     50             response.onResponse(TelephonyManager.SIM_ACTIVATION_RESULT_COMPLETE);
     51         }
     52     }
     53 
     54     private Activator selectActivator(int trigger) {
     55         // TODO: Select among all activator types
     56 
     57         // For now, pick a do-nothing activator
     58         return new Activator() {
     59 
     60             /** ${inheritDoc} */
     61                 @Override
     62             public void onActivate() {
     63                 // do something
     64             }
     65         };
     66     }
     67 }
     68