-
public class SipToolbox
-
-
Field Summary
Fields Modifier and Type Field Description public final static PatternTRANSLATED_EMAIL_ADDRESS
-
Method Summary
Modifier and Type Method Description static longgetResourceChecksum(Context context)Calculates a checksum for the application's resources based on its package name.This method generates a checksum by taking the hash code of the application's package nameand performing a bitwise AND operation with 0xFFFFFFFFL. static booleanisAlreadyTranslatedEmail(String probableEmail)Checks if the given string is an already translated email address. static booleanisValidNumber(String number)Validates a given number string. static booleanisValidEmail(String emailId)Checks if the provided email ID is valid.This method uses the Android's built-in email validation pattern to determine the validity of the email ID. static StringgetInternationalNumber(String phoneNumber, int countryCode)Converts a phone number to its international format.This method takes a phone number and a country code as input, and attempts to convert the phone numberto its international format. static longgetIntFromIp(String ip)Converts an IPv4 address string to a long integer representation.This method takes an IPv4 address string in dotted-decimal notation (e.g., "192.168.1.1")and converts it into a 32-bit integer representation. static synchronized StringgetDeviceId(Context context)Gets a unique device ID.This method generates a unique ID for the device. static StringgetPersistentDeviceID(Context context)Retrieves a persistent device ID using the Android ID.This method uses the `Settings.Secure.ANDROID_ID` to retrieve a unique identifier for the device.The Android ID is a 64-bit number (as a hex string) that is randomly generated on the device'sfirst boot and should remain constant for the lifetime of the device. static StringgetProvisioningFileName(String operatorCode, int netType)Generates the file name for storing provisioning information.The file name is constructed using the following pattern:"lastProvisioningInfo_operatorCode[_netType].dat"where:- lastProvisioningInfo is a constant prefix.- operatorCode is the code of the mobile network operator.- netType is the network type (optional). static StringgetDialerInfo(Context context, String userName)Retrieves dialer information for the current device and user.This method collects information about the device, OS, and SIM card(s),formatting it into a comma-separated string. static booleanisSimCardAvailable(Context context)Checks if a SIM card is available on the device.This method retrieves SIM card information using the `PopulateDeviceInfo` classand checks if at least one SIM card is detected. -
-
Method Detail
-
getResourceChecksum
static long getResourceChecksum(Context context)
Calculates a checksum for the application's resources based on its package name.This method generates a checksum by taking the hash code of the application's package nameand performing a bitwise AND operation with 0xFFFFFFFFL. This checksum can be usedto detect changes in the application's resources.
Note: This implementation uses a simple hash of the package name and isnot a robust checksum. It is primarily intended for basic change detection.
- Parameters:
context- The application context.
-
isAlreadyTranslatedEmail
static boolean isAlreadyTranslatedEmail(String probableEmail)
Checks if the given string is an already translated email address.An email address is considered already translated if it:- Is not empty- Contains an underscore "_"- Matches the regex pattern defined in TRANSLATED_EMAIL_ADDRESS (likely checking for a specific format)This likely identifies emails that have undergone a translation process,possibly involving language adaptations or anonymization.
- Parameters:
probableEmail- The string to be checked.
-
isValidNumber
static boolean isValidNumber(String number)
Validates a given number string.A number is considered valid if it meets the following criteria:
- It is not null.
- It does not contain any letters (a-z, A-Z).
- Its length is between 7 and 16 characters, inclusive.
- Parameters:
number- The number string to validate.
-
isValidEmail
static boolean isValidEmail(String emailId)
Checks if the provided email ID is valid.This method uses the Android's built-in email validation pattern to determine the validity of the email ID.
- Parameters:
emailId- The email ID to validate.
-
getInternationalNumber
static String getInternationalNumber(String phoneNumber, int countryCode)
Converts a phone number to its international format.This method takes a phone number and a country code as input, and attempts to convert the phone numberto its international format. It uses the libphonenumber library to parse and format the phone number.If the phone number is valid, it is formatted according to the international standard (E.164) andreturned. If the phone number is invalid or an error occurs during processing, the original phone numberis returned.
- Parameters:
phoneNumber- The phone number to convert.countryCode- The country code associated with the phone number.
-
getIntFromIp
static long getIntFromIp(String ip)
Converts an IPv4 address string to a long integer representation.This method takes an IPv4 address string in dotted-decimal notation (e.g., "192.168.1.1")and converts it into a 32-bit integer representation.
- Parameters:
ip- The IPv4 address string to convert.
-
getDeviceId
static synchronized String getDeviceId(Context context)
Gets a unique device ID.This method generates a unique ID for the device. If the ID has already been generated,it is retrieved from shared preferences. Otherwise, a new ID is generated and storedin shared preferences.The ID is generated based on a persistent device identifier, such as the Android ID,IMEI, or serial number. This ensures that the ID remains consistent across appinstallations and data clears.The ID is hashed using SHA1 to protect user privacy.
- Parameters:
context- The application context.
-
getPersistentDeviceID
static String getPersistentDeviceID(Context context)
Retrieves a persistent device ID using the Android ID.This method uses the `Settings.Secure.ANDROID_ID` to retrieve a unique identifier for the device.The Android ID is a 64-bit number (as a hex string) that is randomly generated on the device'sfirst boot and should remain constant for the lifetime of the device. However, it can be null orunreliable on certain devices or Android versions.**Note:** Using the Android ID for unique identification is not recommended for security-sensitiveapplications as it can be reset on factory reset or in some cases, be altered by malicious software.For more robust identification, consider using other methods like Instance ID or a combination ofidentifiers.
- Parameters:
context- The application context.
-
getProvisioningFileName
static String getProvisioningFileName(String operatorCode, int netType)
Generates the file name for storing provisioning information.The file name is constructed using the following pattern:"lastProvisioningInfo_operatorCode[_netType].dat"where:- lastProvisioningInfo is a constant prefix.- operatorCode is the code of the mobile network operator.- netType is the network type (optional). If provided, it is appended to the file name.
- Parameters:
operatorCode- The code of the mobile network operator.netType- The network type.
-
getDialerInfo
static String getDialerInfo(Context context, String userName)
Retrieves dialer information for the current device and user.This method collects information about the device, OS, and SIM card(s),formatting it into a comma-separated string.The information collected includes:- User name (repeated twice)- OS type (ANDROID)- Android SDK version- Device model and brand- Device manufacturer- SIM card information (if available):- SIM card number- Mobile Country Code (MCC)- Mobile Network Code (MNC)
- Parameters:
context- The application context.userName- The name of the user.
-
isSimCardAvailable
static boolean isSimCardAvailable(Context context)
Checks if a SIM card is available on the device.This method retrieves SIM card information using the `PopulateDeviceInfo` classand checks if at least one SIM card is detected.
- Parameters:
context- The application context.
-
-
-
-