CloudPOS SDK
  • CloudPOS SDK
    • EMV Develop Spec
    • Scanning Service Usage
    • API Specification
    • CloudPOS SDK AAR
    • Java API Samples
    • Permissions
    • Error code
    • MDB Communication Protocal
  • POS_Specs
  • FAQ
    • SDK Error Collection
      • Printer
      • PINPAD
      • Contactless Card
      • IC Card
      • MSR Card
    • Hardware/Repair
      • Recover a Tampered Terminal
      • Learning Tampered Events
      • Remotely Reactivate from Tamper
      • TF (Micro SD) Card Suggestion
      • Understand Tamper Reason
    • Printer
      • Verify Terminal Printer Status
      • Print Unsupported Character Sets
      • Use Terminal Bluetooth Printer
      • Print Images
      • Print QR Codes
      • Evaluate HTML Print Performance
      • Evaluate Print Performance
      • Print with TM T88IV
      • Replace HTML Print Font
      • Java API Printer Operations
      • Understanding Image Print Gaps
      • Print with JavaScript
      • Verify Printer Paper Status
    • USB/Serial Port
      • Install Terminal USB Drivers
      • Install UU Cable Driver
      • Reinstall Production Serial Drivers
      • Linux Serial Driver Installation
      • Serial Port Development
      • Add Linux Udev Rules
      • ReOpen Serial after Wake-up
      • Close Serial after Disconnect
      • Connect Accessory Mode
      • Detect UU Cable Connnected
      • Control Fan via Serial Port
      • List Connected USB Devices
      • Accessory Agent Service D22/Q3
    • Firmware
      • Update Firmware
      • Understand Firmware Naming
      • Compare Engineer/User Modes
      • Configure POS Home Settings
      • Configure POS System Settings
      • Prevent Accidental App Uninstallation
      • Troubleshoot "Agent Stopped" Error
      • Resolve Forgotten Lock Password
      • Utilize Q1 Buttons
      • Adapt Q1 4G
      • Customize Boot Logo/Animation
      • Set Wallpaper
      • Activate Startup Special Mode
      • Install Browsers
      • Understand Firmware External Access
      • Get Terminal Firmware Modes
      • Write Customer Serial Numbers
      • Enable Touch Screen Wake-Up
      • Set User System Properties
      • Enable and Disable MTP
      • Update POS WebView
      • Disable File Explorer for TF/Pendrives
      • Manage Screen On/Off
      • Disable notification badges
      • Scheduled Terminal Reboot Setup
    • Settings Menu
      • Perform Factory Data Reset
      • Understand Settings Menus
      • View Terminal Certificate List
      • Understand Merchant Self Test
      • Use Network Self-Test
      • Change System Language
      • Log in as Administrator
      • Change Administrator's Login Password
      • Update Terminal Time
      • Update Terminal Time Zone
      • Update Time Zone from IP
      • Enable Settings Menu Role Control
      • Update Role Passwords API
      • Disable Bluetooth/Wi Fi
      • Enable/Disable Auto Time Zone
      • Enable/Disable Automatic Time
      • Set Display Sleep
      • Grant Accessibility Permission Automatically
      • Disable Security Lock
      • Access Settings Sub Menu
      • Set Language API
    • Battery/Power
      • Understand Special Charging Indicator
      • Preserve Terminal Battery Life
      • Understand Q2 Low-voltage Shutdown
      • Understand Terminal Battery Performance
      • Understand Counter Mode
      • Turn Off Terminal API
    • SIM/Ethenet/WIFI
      • Disable POS Hotspot
      • Activate POS Hotspot
      • Retrieve Terminal IMEI Number
      • Retrieve Terminal MEID Number
      • Understand Modem Bands
      • Troubleshoot Terminal SIM Signal
      • Resolve SIM Network Issues
      • Troubleshoot Network Search Error
      • Check eSIM Status
      • Ethernet Connectivity Usage
      • Set Communication Mode
      • Troubleshoot USSD Issues
      • Set Preferred Network Type API
      • Add APN API
      • Set Static Ethernet API
      • Enable/Disable Mobile Data API
      • Set Network Operators API
      • Activate eSIM
      • Enable/Disable Ethernet
    • Certificate
      • Apply App Certificates
      • Renew App Certificate
      • App Installation Controls
      • Install CA Certificates
      • Clear Terminal Certificates
      • Understand Certificate Visibility
    • Card
      • Contactless Card Distance
      • NFC Buffer Size Understanding
      • Use Contactless CPU Card
      • Use Felica Card
      • Use Mifare Card
      • Understand PSAM Card Exceptions
      • Optimal Tap Positioning Guide
    • FingerPrint
      • Fingerprint Module Usage Guide
      • Fingerprint DPI Specifications
      • Fingerprint Data Formats
    • Other Development
      • New Android Studio Versions
      • Setup ANDROID HOME
      • App Signing Process
      • Install POS Applications
      • Create First Android App
      • Retrieve Terminal Logs
      • Resolve APK Signature Conflict
      • Obtain Unfiltered Full Log
      • Obtain Terminal Current Location
      • Use Terminal Camera
      • Get Test APKs
      • Learn ADB Commands
      • Get Advanced Demos
      • Import Java SDK in C
      • Obtain Signal Strength
      • Get D3 Demos
      • Learn Kiosk Mode
      • Block Status Bar API
      • Display Full-Screen API
      • Display Full Screen Android API
      • Disable Home Key
      • Capture Power Button API
      • Retrieve Terminal Info
      • Save Files Locally
      • Set Default Launcher
      • Get Firmware Version
      • Get Firmware&EMV Version
      • Implement TLSv1.3
      • Auto-Run Post-Install
      • Understand Secure Connections
      • Use AnyDesk
      • Export Database to SD
      • Migrate App to Q2Premium
      • Auto-Run App Post-Boot
      • Integrate Java SDK in Flutter
      • Call AIDL Interface
      • Connect wirelessly
      • Get POS SN
      • UPT development-related
      • Q3 PDA Terminal Barcode Scanner
    • Key Injection
      • Inject Test Keys Remotely
      • Understand DUKPT
      • Understand Master&Session Keys
      • Use TMK KeyLoader POS
      • Understand Remote Key Injection
      • Resolve Serial Timeout
      • Import TMK Error: 74496
    • PINPAD
      • PINPAD Configuration Summary
      • Customize PINPAD GUI
    • TMS/Wizarview
      • TMS Overview
      • TMS User Guide
      • Register Terminal to WizarView
      • Accept TMS File Downloads
      • Handle User Locked Status
      • Apply WizarView Account
      • Batch Import Terminals
      • Unbind App Configuration
      • Remove App via TMS
      • Understand Agent Error Codes
      • Understand TMS IP Ports
      • Understand Update Scenarios
      • Understand App Binding Types
      • Apply RMA Maintenance Account
      • Update Firmware Remotely
      • Push APK to Specific Device
      • Set Agent Working Mode
      • Manage APK Prompt Installation
      • Network Control in Agent
      • Push Apps Using Tags
      • Deploy AID/CAPK via TMS
    • EMV
      • What's Tag91
      • What's CAPK
      • Set Issuer Scripts
      • Resolve Detection Priority Conflict
  • Wizarview Open API
Powered by GitBook
On this page
  • Permission
  • Description
  • Sample code
  1. FAQ
  2. SIM/Ethenet/WIFI

Set Network Operators API

Permission

The application declares the following permissions in the manifest:

 android.permission.CLOUDPOS_SET_CELLULAR_NETWORK_OPERATOR

Description

  • Bind Service

bindService(new Intent().setClassName("com.smartpos.phone.settings", "com.smartpos.phone.settings.RadioQueryService"), mQueryRadioNetworkConnection, Context.BIND_AUTO_CREATE);
  • Use the IBinder returned by the service to construct the communication Messenger

private ServiceConnection mQueryRadioNetworkConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
  • Define a Client Messenger associated with the Handler to receive the return from the server:

/** Target we publish for clients to send messages to IncomingHandler.
*/
final Messenger mMessenger = new Messenger(new IncomingHandler());

/* * Start cellular network operator querying. * @param event the event you want to start, can be one of following: * 1 - EVENT_NETWORK_SCAN * 2 - EVENT_NETWORK_SELECT * @return mMessenger which associated with Handler.
*/
Message msg = Message.obtain(null, 1 / event /, 0 / slot */, 0);
msg.replyTo = mMessenger;
mService.send(msg);

/** Receive the return of the network operator's search interface:*/
final String[] scanInfo = msg.getData().getStringArray("result");
for (int i = 0; i < scanInfo.length; i++) {
String item[] = scanInfo[i].split(",");
String operatorAlphaLong = scanInfo0; // such as 'CHN-UNICOM'
String operatorAlphaShort = scanInfo1; // such as 'UNICOM'
String operatorNumeric = scanInfo2; // such as '46001'
String stateString = scanInfo3; // such as 'available/forbidden'
}

/** Set cellular network operator. * @param event the event you want to start, can be one of following: * 1 - EVENT_NETWORK_SCAN * 2 - EVENT_NETWORK_SELECT * @return mMessenger which associated with Handler.
*/
Bundle bundle = new Bundle();
bundle.putString("operatorAlphaLong", operatorAlphaLong);
bundle.putString("operatorAlphaShort", operatorAlphaShort);
bundle.putString("operatorNumeric", operatorNumeric);
bundle.putString("stateString", stateString);
Message msg = Message.obtain(null, 2 / event /, 0 / slot */, 0, bundle);
msg.replyTo = mMessenger;
mService.send(msg);

/** Return of the interface set:*/
String responce = "Registration Done";
switch (msg.arg1) {
case -1:
responce = "Not Allowed";
break;
case -2:
responce = "Please connect later";
break;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
// Messenger for communicating with service
Messenger mService = new Messenger(service);
}
};

Sample code

public class QueryRadioActivity extends Activity {
	private static final String TAG = "QueryRadioActivity";
	// static events
    private static final int EVENT_NETWORK_SCAN = 1;
    private static final int EVENT_NETWORK_SELECT = 2;
    private static final int EVENT_NETWORK_SCAN_COMPLETED = 3;
    private static final int EVENT_NETWORK_SELECTION_DONE = 4;
    private static final int QUERY_OK = 0;
    private static final int QUERY_PARTIAL = 1;
    private static final int QUERY_IS_RUNNING = -2;
    private static final int SELECT_OK = 0;
    private static final int SELECT_DENIED = -1;
    private static final int SELECT_BUSY = -2;
	private ProgressDialog mProgressDialog;
	//map of RAT type values to user understandable strings
    private HashMap<String, String> mRatMap = new HashMap<String, String>();
	
	private ServiceConnection mQueryRadioNetworkConnection = new ServiceConnection() {
		
		@Override
		public void onServiceDisconnected(ComponentName name) {
			mService = null;
		}
		
		@Override
		public void onServiceConnected(ComponentName name, IBinder service) {
			mService = new Messenger(service);
		}
	};
	
	/**
     * Handler of incoming messages from service.
     */
    class IncomingHandler extends Handler {
		@Override
		public void handleMessage(Message msg) {
			mProgressDialog.dismiss();
			String responce = "Unknown response";
			switch (msg.what) {
			case EVENT_NETWORK_SCAN_COMPLETED: // Querying done.
				switch (msg.arg1) {
                case QUERY_OK:
                case QUERY_PARTIAL:
                	responce = "Query response is OK!";
                	final String[] scanInfo = msg.getData().getStringArray("result");
                    AlertDialog.Builder builder = new AlertDialog.Builder(QueryRadioActivity.this);
                    // emmmmmmmmmmmmm
                    String[] items = new String[scanInfo.length];
                    String operatorNumeric;
                    int operatorNumericIndexOf;
                    String item[];
                    for (int i = 0; i < scanInfo.length; i++) {
                    	item = scanInfo[i].split(",");
                    	operatorNumeric = item[2];
                    	operatorNumericIndexOf = operatorNumeric.indexOf("+") + 1;
                    	operatorNumeric = operatorNumeric.substring(0, operatorNumericIndexOf) + " " + mRatMap.get(operatorNumeric.substring(operatorNumericIndexOf, operatorNumeric.length()));
                    	items[i] = item[0] + " " + operatorNumeric + " " + item[3];
                    }
                    
                    builder.setItems(items, new OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        	try {
                        		Bundle bundle = new Bundle();
                        		String item[] = scanInfo[which].split(",");
                        	    bundle.putString("operatorAlphaLong", item[0]); // such as 'CHN-UNICOM'
                        	    bundle.putString("operatorAlphaShort", item[1]); // such as 'UNICOM'
                        	    bundle.putString("operatorNumeric", item[2]); // such as '46001'+14(RIL_RADIO_TECHNOLOGY_LTE)
                        	    bundle.putString("stateString", item[3]); // such as 'available/forbidden'
                        		Message msg = Message.obtain(null, EVENT_NETWORK_SELECT, 0 /* slot */, 0, bundle);
                				msg.replyTo = mMessenger;
                				mService.send(msg);
                				mProgressDialog = ProgressDialog.show(QueryRadioActivity.this, "", "Selecting, please wait..", true, true);
    						} catch (RemoteException e) {
    							e.printStackTrace();
    						}
                        }
                    });
                    builder.show();
                	break;
                case QUERY_IS_RUNNING:
                	responce = "Query is running, please retry later!";
                	break;
            	default:
            		/* In case of one of following:
					 *        int QUERY_EXCEPTION = -1;
					 *        int QUERY_ABORT = 2;
					 *        int QUERY_REJ_IN_RLF = 3;
            	     */
            		responce = "Busy, please query later!";
            		break;
				}
				break;

			case EVENT_NETWORK_SELECTION_DONE: // Select done.
				switch (msg.arg1) {
				case SELECT_OK:
					responce = "Registration Done";
					break;
				case SELECT_DENIED:
					responce = "Not Allowed";
					break;
				case SELECT_BUSY:
					responce = "Please connect later!";
					break;
				}
				break;
			}
			Toast.makeText(QueryRadioActivity.this, responce, Toast.LENGTH_LONG).show();
		}
	};
	
	/** Messenger for communicating with service. */
    Messenger mService = null;
	
	/**
     * Target we publish for clients to send messages to IncomingHandler.
     */
    final Messenger mMessenger = new Messenger(new IncomingHandler());
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.query_radio);
		mRatMap.put("0" /* RIL_RADIO_TECHNOLOGY_UNKNOWN */, "Unknown");
	    mRatMap.put("1" /* RIL_RADIO_TECHNOLOGY_GPRS */, "2G");
	    mRatMap.put("2" /* RIL_RADIO_TECHNOLOGY_EDGE */, "2G");
	    mRatMap.put("3" /* RIL_RADIO_TECHNOLOGY_UMTS */, "3G");
	    mRatMap.put("4" /* RIL_RADIO_TECHNOLOGY_IS95A */, "2G");
	    mRatMap.put("5" /* RIL_RADIO_TECHNOLOGY_IS95B */, "2G");
	    mRatMap.put("6" /* RIL_RADIO_TECHNOLOGY_1xRTT */, "2G");
	    mRatMap.put("7" /* RIL_RADIO_TECHNOLOGY_EVDO_0 */, "3G");
	    mRatMap.put("8" /* RIL_RADIO_TECHNOLOGY_EVDO_A */, "3G");
	    mRatMap.put("9" /* RIL_RADIO_TECHNOLOGY_HSDPA */, "3G");
	    mRatMap.put("10" /* RIL_RADIO_TECHNOLOGY_HSUPA */, "3G");
	    mRatMap.put("11" /* RIL_RADIO_TECHNOLOGY_HSPA */, "3G");
	    mRatMap.put("12" /* RIL_RADIO_TECHNOLOGY_EVDO_B */, "3G");
	    mRatMap.put("13" /* RIL_RADIO_TECHNOLOGY_EHRPD */, "3G");
	    mRatMap.put("14" /* RIL_RADIO_TECHNOLOGY_LTE */, "4G");
	    mRatMap.put("19" /* RIL_RADIO_TECHNOLOGY_LTE_CA */, "4G");
	    mRatMap.put("15" /* RIL_RADIO_TECHNOLOGY_HSPAP */, "3G");
	    mRatMap.put("16" /* RIL_RADIO_TECHNOLOGY_GSM */, "2G");
	    mRatMap.put("17" /* RIL_RADIO_TECHNOLOGY_TD_SCDMA */, "3G");
		findViewById(R.id.query_radio_network).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if (mService == null) {
					Log.w(TAG, "Query failed, could't bind service.");
					Toast.makeText(QueryRadioActivity.this, "Query failed, could't bind service.", Toast.LENGTH_LONG).show();
					return;
				}
				try {
					Message msg = Message.obtain(null, EVENT_NETWORK_SCAN /* event */, 0 /* slot */, 0);
					msg.replyTo = mMessenger;
					mService.send(msg);
					mProgressDialog = ProgressDialog.show(QueryRadioActivity.this, "", "Querying, please wait..", true, true);
				} catch (RemoteException e) {
					e.printStackTrace();
				}
			}
		});
		bindService(new Intent().setClassName("com.smartpos.phone.settings", "com.smartpos.phone.settings.RadioQueryService"), mQueryRadioNetworkConnection, Context.BIND_AUTO_CREATE);
	}
	
	@Override
    protected void onDestroy() {
        super.onDestroy();
        unbindService(mQueryRadioNetworkConnection);
    }
}
PreviousEnable/Disable Mobile Data APINextActivate eSIM

Last updated 1 year ago