Class TelephonyCtrl

java.lang.Object
com.unitech.api.telephony.TelephonyCtrl

public class TelephonyCtrl extends Object
  • Field Details

  • Constructor Details

    • TelephonyCtrl

      public TelephonyCtrl(Context context)
  • Method Details

    • isSimCardExist

      public Bundle isSimCardExist()
      Checks if a SIM card exists.
      Returns:
      A Bundle containing the following:
      • int errorCode - The error code (1 for error, 0 for success)
      • String errorMsg - The error message, if any
      • boolean isSimCardExist - Whether a SIM card exists (default is false if not present)
      Usage example:
       
       int errorCode = bundle.getInt("errorCode");
       String errorMsg = bundle.getString("errorMsg");
       boolean isSimCardExist = bundle.getBoolean("isSimCardExist", false);
       
       
    • getNetworkDataUsageWithRange

      public Bundle getNetworkDataUsageWithRange(long timeRangeSeconds)
      Retrieves the network data usage from now to the past N second(s) range.
      Parameters:
      timeRangeSeconds - the past second(s) from now
      Returns:
      A Bundle containing the following:
      • int errorCode - error code (1 for error, 0 for success)
      • String errorMsg - error message
      • ArrayList<NetworkDataUsage> networkDataUsages - network data usage list, obtained via NetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage"))
      The possible values for mobileRx, mobileTx, wifiRx, and wifiTx are:
      • "0" - No data exists
      • "0 B" - Zero bytes transferred for specific Rx or Tx
      • "X B" - X bytes transferred for specific Rx or Tx (where B represents bytes)
      The units for data are:
      • B - Bytes
      • K - Kilobytes (KB)
      • M - Megabytes (MB)
      • G - Gigabytes (GB)
      • T - Terabytes (TB)
      • P - Petabytes (PB)
      • E - Exabytes (EB)
      Example usage:
       
       Bundle bundle = getNetworkDataUsage();
      
       // Retrieve the error code and message
       int errorCode = bundle.getInt("errorCode");
       String errorMsg = bundle.getString("errorMsg");
      
       // Handle error
       if (errorCode == 1) {
           Log.d("NetworkDataUsage", "Error: " + errorMsg);
       } else {
           // Convert the network data usage list
           ArrayList<NetworkDataUsage> networkDataUsages =
               NetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage"));
      
           // Process each usage data
           for (NetworkDataUsage usage : networkDataUsages) {
               Log.d("NetworkDataUsage", "Mobile Rx: " + usage.getMobileRx());
               Log.d("NetworkDataUsage", "Mobile Tx: " + usage.getMobileTx());
               Log.d("NetworkDataUsage", "WiFi Rx: " + usage.getWifiRx());
               Log.d("NetworkDataUsage", "WiFi Tx: " + usage.getWifiTx());
           }
       }
       
       
    • getNetworkDataUsage

      public Bundle getNetworkDataUsage()
      Retrieves the network data usage for the last 24 hours.
      Returns:
      A Bundle containing the following:
      • int errorCode - error code (1 for error, 0 for success)
      • String errorMsg - error message
      • ArrayList<NetworkDataUsage> networkDataUsages - network data usage list, obtained via NetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage"))
      The possible values for mobileRx, mobileTx, wifiRx, and wifiTx are:
      • "0" - No data exists
      • "0 B" - Zero bytes transferred for specific Rx or Tx
      • "X B" - X bytes transferred for specific Rx or Tx (where B represents bytes)
      The units for data are:
      • B - Bytes
      • K - Kilobytes (KB)
      • M - Megabytes (MB)
      • G - Gigabytes (GB)
      • T - Terabytes (TB)
      • P - Petabytes (PB)
      • E - Exabytes (EB)
      Example usage:
       
       Bundle bundle = getNetworkDataUsage();
      
       // Retrieve the error code and message
       int errorCode = bundle.getInt("errorCode");
       String errorMsg = bundle.getString("errorMsg");
      
       // Handle error
       if (errorCode == 1) {
           Log.d("NetworkDataUsage", "Error: " + errorMsg);
       } else {
           // Convert the network data usage list
           ArrayList<NetworkDataUsage> networkDataUsages =
               NetworkDataUsage.convertToUsageList(bundle.getStringArrayList("getNetworkDataUsage"));
      
           // Process each usage data
           for (NetworkDataUsage usage : networkDataUsages) {
               Log.d("NetworkDataUsage", "Mobile Rx: " + usage.getMobileRx());
               Log.d("NetworkDataUsage", "Mobile Tx: " + usage.getMobileTx());
               Log.d("NetworkDataUsage", "WiFi Rx: " + usage.getWifiRx());
               Log.d("NetworkDataUsage", "WiFi Tx: " + usage.getWifiTx());
           }
       }
       
       
    • downloadESimSubscription

      public Bundle downloadESimSubscription(String activateCode, boolean switchAfterDownload)
      Downloads an eSIM subscription.
      Parameters:
      activateCode - The activation code
      switchAfterDownload - Whether to switch to the downloaded eSIM subscription after download
      Returns:
      A bundle containing the error code and message
      int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
      String errorMsg = bundle.getString("errorMsg");
    • downloadESimSubscriptionWithNickName

      public Bundle downloadESimSubscriptionWithNickName(String activateCode, String nickName, boolean switchAfterDownload)
      Downloads an eSIM subscription and change nickname.
      Parameters:
      activateCode - The activation code
      nickName - The nickname of the eSIM subscription
      switchAfterDownload - Whether to switch to the downloaded eSIM subscription after download
      Returns:
      A bundle containing the error code and message
      int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
      String errorMsg = bundle.getString("errorMsg");
      *
    • deleteESimSubscriptionByName

      public Bundle deleteESimSubscriptionByName(String name)
      Deletes an eSIM subscription by name of ICCID or Display Name.
      Parameters:
      name - The display name of the eSIM to switch to
      Returns:
      A bundle containing the error code and message
      int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
      String errorMsg = bundle.getString("errorMsg");
    • switchESimByName

      public Bundle switchESimByName(String name)
      Switches to the eSIM with the specified display name or ICCID.
      Parameters:
      name - The display name of the eSIM to switch to
      Returns:
      A bundle containing the error code and message
      int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
      String errorMsg = bundle.getString("errorMsg");
    • getEID

      public Bundle getEID()
      Retrieves the eSIM ID.
      Returns:
      A bundle containing the error code and message
      int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
      String errorMsg = bundle.getString("errorMsg");
      String EID = bundle.getString("EID");
    • getSubscriptionInfo

      public Bundle getSubscriptionInfo()
      Retrieves the Subscription information.
      Returns:
      A bundle containing the error code and message
      int errorCode = bundle.getInt("errorCode"), (success=0, error:others)
      String errorMsg = bundle.getString("errorMsg");
      using keySet() to retrieve what keys are included in this bundle
    • updateDisplayNameByIccid

      public Bundle updateDisplayNameByIccid(String iccid, String displayName)