Android Wifi scanning too slow - android

I am at the beginning stage on developing an application, which needs scan the wifi APs per second. The scanning part works well on one HTC hero, however, it takes 6 seconds for my galaxy tab to finish one scan.
I write a very simple program, scanning wifi continuously and note down how long it takes for one scan. (from wifi.startScan() to receiver get results). In HTC phone, it's 500 ms, but in Samsung tab, it takes 6s on average. I wonder if anyone can help me to solve this problem. Is it because Samsung changed the os or because the hardware's problem?
the program is as follows:
import java.util.Date;
import java.util.List;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class wifiScan extends Activity {
private class WifiReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context c, Intent intent) {
List<ScanResult> results = wifi.getScanResults();
Date tempDate=new Date();
String info=testNumber+" "+(tempDate.getTime()-testDate.getTime())+" "+results.size();
Log.i("wifiScan", info);
wifiText.setText(info);
testNumber++;
testDate=new Date();
wifi.startScan();
}
}
private TextView wifiText;
private WifiManager wifi;
private WifiReceiver receiver;
private Date testDate;
private static int testNumber=0;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
testNumber=0;
wifiText = (TextView) findViewById(R.id.wifiText);
receiver=new WifiReceiver();
registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
wifi =(WifiManager)getSystemService(Context.WIFI_SERVICE);
if(!wifi.isWifiEnabled()){
wifi.setWifiEnabled(true);
}
startScan();
}
#Override
public void onStop(){
super.onStop();
finish();
}
public void startScan(){
testDate=new Date();
wifi.startScan();
}
}
The log info is as follows:
02-16 15:42:22.600: WARN/PowerManagerService(2484): Timer 0x1->0x0|0x1
02-16 15:42:22.600: ERROR/PowerManagerService(2484): CurLock p:3 mPS:1
02-16 15:42:22.600: WARN/PowerManagerService(2484): type=SCREEN_DIM_WAKE_LOCK 'StayOnWhilePluggedIn Screen Dim' active (minState=1) activeT=1257228
02-16 15:42:22.607: WARN/PowerManagerService(2484): type=PARTIAL_WAKE_LOCK 'StayOnWhilePluggedIn Partial' active (minState=0) activeT=1257228
02-16 15:42:24.005: DEBUG/dalvikvm(3374): GC_EXPLICIT freed 790 objects / 55536 bytes in 143ms
02-16 15:42:24.775: DEBUG/AndroidRuntime(4056): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
02-16 15:42:24.775: DEBUG/AndroidRuntime(4056): CheckJNI is OFF
02-16 15:42:24.784: DEBUG/AndroidRuntime(4056): setted country_code = SINGAPORE
02-16 15:42:24.784: DEBUG/AndroidRuntime(4056): setted sales_code = XSP
02-16 15:42:24.784: DEBUG/AndroidRuntime(4056): found sales_code tag = <XSP>, </XSP>
02-16 15:42:24.792: DEBUG/dalvikvm(4056): creating instr width table
02-16 15:42:24.822: DEBUG/AndroidRuntime(4056): --- registering native functions ---
02-16 15:42:24.904: DEBUG/LibQmg_native(4056): register_android_app_LibQmg
02-16 15:42:24.986: DEBUG/AndroidRuntime(4056): Shutting down VM
02-16 15:42:24.986: DEBUG/dalvikvm(4056): Debugger has detached; object registry had 1 entries
02-16 15:42:24.993: INFO/AndroidRuntime(4056): NOTE: attach of thread 'Binder Thread #2' failed
02-16 15:42:25.169: DEBUG/AndroidRuntime(4064): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
02-16 15:42:25.169: DEBUG/AndroidRuntime(4064): CheckJNI is OFF
02-16 15:42:25.176: DEBUG/AndroidRuntime(4064): setted country_code = SINGAPORE
02-16 15:42:25.176: DEBUG/AndroidRuntime(4064): setted sales_code = XSP
02-16 15:42:25.176: DEBUG/AndroidRuntime(4064): found sales_code tag = <XSP>, </XSP>
02-16 15:42:25.184: DEBUG/dalvikvm(4064): creating instr width table
02-16 15:42:25.212: DEBUG/AndroidRuntime(4064): --- registering native functions ---
02-16 15:42:25.286: DEBUG/LibQmg_native(4064): register_android_app_LibQmg
02-16 15:42:25.368: INFO/ActivityManager(2484): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=nus.master.test/.wifiScan }
02-16 15:42:25.376: INFO/Launcher(3211): onPause()
02-16 15:42:25.411: DEBUG/AndroidRuntime(4064): Shutting down VM
02-16 15:42:25.411: DEBUG/dalvikvm(4064): Debugger has detached; object registry had 1 entries
02-16 15:42:25.419: INFO/AndroidRuntime(4064): NOTE: attach of thread 'Binder Thread #2' failed
02-16 15:42:25.450: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:25.450: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:25.454: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:25.454: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:25.454: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:42:25.611: INFO/Launcher(3211): onWindowFocusChanged(false)
02-16 15:42:30.724: DEBUG/dalvikvm(3200): GC_EXPLICIT freed 4001 objects / 233800 bytes in 118ms
02-16 15:42:30.892: INFO/WifiMonitor(2484): Event [ SCAN-RESULTS ]
02-16 15:42:30.892: INFO/wpa_supplicant(3810): WPS-AP-AVAILABLE
02-16 15:42:30.892: INFO/wpa_supplicant(3810): CTRL-EVENT-NO-CONNECTION
02-16 15:42:30.896: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00
02-16 15:42:30.900: INFO/WifiMonitor(2484): Event [WPS-AP-AVAILABLE ]
02-16 15:42:30.900: INFO/WifiMonitor(2484): Event [CTRL-EVENT-NO-CONNECTION]
02-16 15:42:30.900: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00]
02-16 15:42:30.947: INFO/wpa_supplicant(3810): SAN_RESULTS : [34]
02-16 15:42:30.958: INFO/wpa_supplicant(3810): SAN_RESULTS : [34]
02-16 15:42:30.970: VERBOSE/WifiStateTracker(2484): Changing supplicant state: SCANNING ==> INACTIVE
02-16 15:42:30.970: DEBUG/NetworkStateTracker(2484): setDetailed state, old =SCANNING and new state=IDLE
02-16 15:42:30.970: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/IDLE
02-16 15:42:31.009: INFO/NetworkStatusReceiver(2935): action: android.net.wifi.SHOW_AP_LIST_DIALOG
02-16 15:42:31.021: ERROR/WifiManager(2935): showApDialog
02-16 15:42:31.025: INFO/WifiService(2484): isShowingAccessPointListDialog():false
02-16 15:42:31.029: INFO/WifiService(2484): setShowAccessPointListDialog():false
02-16 15:42:31.060: INFO/wifiScan(4009): 0 5609 21
02-16 15:42:31.064: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:31.064: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:31.068: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:31.068: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:31.068: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:42:36.536: INFO/WifiMonitor(2484): Event [ SCAN-RESULTS ]
02-16 15:42:36.536: INFO/wpa_supplicant(3810): WPS-AP-AVAILABLE
02-16 15:42:36.536: INFO/wpa_supplicant(3810): CTRL-EVENT-NO-CONNECTION
02-16 15:42:36.540: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00
02-16 15:42:36.544: INFO/WifiMonitor(2484): Event [WPS-AP-AVAILABLE ]
02-16 15:42:36.544: INFO/WifiMonitor(2484): Event [CTRL-EVENT-NO-CONNECTION]
02-16 15:42:36.544: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00]
02-16 15:42:36.587: INFO/wpa_supplicant(3810): SAN_RESULTS : [35]
02-16 15:42:36.611: INFO/wpa_supplicant(3810): SAN_RESULTS : [35]
02-16 15:42:36.634: VERBOSE/WifiStateTracker(2484): Changing supplicant state: SCANNING ==> INACTIVE
02-16 15:42:36.634: DEBUG/NetworkStateTracker(2484): setDetailed state, old =SCANNING and new state=IDLE
02-16 15:42:36.661: INFO/NetworkStatusReceiver(2935): action: android.net.wifi.SHOW_AP_LIST_DIALOG
02-16 15:42:36.665: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/IDLE
02-16 15:42:36.665: ERROR/WifiManager(2935): showApDialog
02-16 15:42:36.669: INFO/WifiService(2484): isShowingAccessPointListDialog():false
02-16 15:42:36.669: INFO/WifiService(2484): setShowAccessPointListDialog():false
02-16 15:42:36.724: INFO/wifiScan(4009): 1 5662 22
02-16 15:42:36.728: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:36.728: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:36.732: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:36.732: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:36.736: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:42:41.247: DEBUG/BatteryService(2484): update start
02-16 15:42:41.275: DEBUG/BatteryService(2484): updateBattery level:83 scale:100 status:4 health:2 present:true voltage: 4051 temperature: 330 technology: Li-ion AC powered:false USB powered:true icon:17302421
02-16 15:42:41.314: DEBUG/CorePlayerService(3270): mSystemReceiver:onReceive(action=android.intent.action.BATTERY_CHANGED) is called
02-16 15:42:41.357: DEBUG/WifiService(2484): ACTION_BATTERY_CHANGED pluggedType: 2
02-16 15:42:42.177: INFO/WifiMonitor(2484): Event [ SCAN-RESULTS ]
02-16 15:42:42.177: INFO/wpa_supplicant(3810): WPS-AP-AVAILABLE
02-16 15:42:42.181: INFO/wpa_supplicant(3810): CTRL-EVENT-NO-CONNECTION
02-16 15:42:42.181: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00
02-16 15:42:42.185: INFO/WifiMonitor(2484): Event [WPS-AP-AVAILABLE ]
02-16 15:42:42.189: INFO/WifiMonitor(2484): Event [CTRL-EVENT-NO-CONNECTION]
02-16 15:42:42.193: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00]
02-16 15:42:42.216: INFO/wpa_supplicant(3810): SAN_RESULTS : [36]
02-16 15:42:42.240: INFO/wpa_supplicant(3810): SAN_RESULTS : [36]
02-16 15:42:42.240: VERBOSE/WifiStateTracker(2484): Changing supplicant state: SCANNING ==> INACTIVE
02-16 15:42:42.240: DEBUG/NetworkStateTracker(2484): setDetailed state, old =SCANNING and new state=IDLE
02-16 15:42:42.247: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/IDLE
02-16 15:42:42.271: INFO/NetworkStatusReceiver(2935): action: android.net.wifi.SHOW_AP_LIST_DIALOG
02-16 15:42:42.271: ERROR/WifiManager(2935): showApDialog
02-16 15:42:42.275: INFO/WifiService(2484): isShowingAccessPointListDialog():false
02-16 15:42:42.282: INFO/WifiService(2484): setShowAccessPointListDialog():false
02-16 15:42:42.314: INFO/wifiScan(4009): 2 5588 21
02-16 15:42:42.322: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:42.322: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:42.326: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:42.329: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:42.329: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:42:43.255: DEBUG/BatteryService(2484): update start
02-16 15:42:43.294: DEBUG/BatteryService(2484): updateBattery level:83 scale:100 status:4 health:2 present:true voltage: 4080 temperature: 320 technology: Li-ion AC powered:false USB powered:true icon:17302421
02-16 15:42:43.384: DEBUG/WifiService(2484): ACTION_BATTERY_CHANGED pluggedType: 2
02-16 15:42:43.388: DEBUG/CorePlayerService(3270): mSystemReceiver:onReceive(action=android.intent.action.BATTERY_CHANGED) is called
02-16 15:42:47.783: INFO/WifiMonitor(2484): Event [ SCAN-RESULTS ]
02-16 15:42:47.786: INFO/wpa_supplicant(3810): WPS-AP-AVAILABLE
02-16 15:42:47.786: INFO/wpa_supplicant(3810): CTRL-EVENT-NO-CONNECTION
02-16 15:42:47.786: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00
02-16 15:42:47.798: INFO/WifiMonitor(2484): Event [WPS-AP-AVAILABLE ]
02-16 15:42:47.798: INFO/WifiMonitor(2484): Event [CTRL-EVENT-NO-CONNECTION]
02-16 15:42:47.814: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00]
02-16 15:42:47.826: INFO/wpa_supplicant(3810): SAN_RESULTS : [38]
02-16 15:42:47.853: INFO/wpa_supplicant(3810): SAN_RESULTS : [38]
02-16 15:42:47.872: VERBOSE/WifiStateTracker(2484): Changing supplicant state: SCANNING ==> INACTIVE
02-16 15:42:47.872: DEBUG/NetworkStateTracker(2484): setDetailed state, old =SCANNING and new state=IDLE
02-16 15:42:47.904: INFO/NetworkStatusReceiver(2935): action: android.net.wifi.SHOW_AP_LIST_DIALOG
02-16 15:42:47.919: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/IDLE
02-16 15:42:47.923: ERROR/WifiManager(2935): showApDialog
02-16 15:42:47.927: INFO/WifiService(2484): isShowingAccessPointListDialog():false
02-16 15:42:47.931: INFO/WifiService(2484): setShowAccessPointListDialog():false
02-16 15:42:47.970: INFO/wifiScan(4009): 3 5652 26
02-16 15:42:47.974: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:47.974: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:47.986: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:47.986: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:47.986: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:42:53.423: INFO/WifiMonitor(2484): Event [ SCAN-RESULTS ]
02-16 15:42:53.427: INFO/wpa_supplicant(3810): WPS-AP-AVAILABLE
02-16 15:42:53.427: INFO/wpa_supplicant(3810): CTRL-EVENT-NO-CONNECTION
02-16 15:42:53.427: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00
02-16 15:42:53.435: INFO/WifiMonitor(2484): Event [WPS-AP-AVAILABLE ]
02-16 15:42:53.439: INFO/WifiMonitor(2484): Event [CTRL-EVENT-NO-CONNECTION]
02-16 15:42:53.439: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00]
02-16 15:42:53.462: INFO/wpa_supplicant(3810): SAN_RESULTS : [37]
02-16 15:42:53.482: INFO/wpa_supplicant(3810): SAN_RESULTS : [37]
02-16 15:42:53.493: VERBOSE/WifiStateTracker(2484): Changing supplicant state: SCANNING ==> INACTIVE
02-16 15:42:53.497: DEBUG/NetworkStateTracker(2484): setDetailed state, old =SCANNING and new state=IDLE
02-16 15:42:53.525: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/IDLE
02-16 15:42:53.529: INFO/NetworkStatusReceiver(2935): action: android.net.wifi.SHOW_AP_LIST_DIALOG
02-16 15:42:53.529: ERROR/WifiManager(2935): showApDialog
02-16 15:42:53.532: INFO/WifiService(2484): isShowingAccessPointListDialog():false
02-16 15:42:53.532: INFO/WifiService(2484): setShowAccessPointListDialog():false
02-16 15:42:53.575: INFO/wifiScan(4009): 4 5602 24
02-16 15:42:53.579: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:53.579: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:53.591: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:53.591: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:53.595: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:42:59.040: INFO/WifiMonitor(2484): Event [ SCAN-RESULTS ]
02-16 15:42:59.040: INFO/wpa_supplicant(3810): WPS-AP-AVAILABLE
02-16 15:42:59.044: INFO/wpa_supplicant(3810): CTRL-EVENT-NO-CONNECTION
02-16 15:42:59.048: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00
02-16 15:42:59.048: INFO/WifiMonitor(2484): Event [WPS-AP-AVAILABLE ]
02-16 15:42:59.056: INFO/WifiMonitor(2484): Event [CTRL-EVENT-NO-CONNECTION]
02-16 15:42:59.075: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=1 BSSID=00:00:00:00:00:00]
02-16 15:42:59.091: INFO/wpa_supplicant(3810): SAN_RESULTS : [38]
02-16 15:42:59.115: INFO/wpa_supplicant(3810): SAN_RESULTS : [38]
02-16 15:42:59.122: VERBOSE/WifiStateTracker(2484): Changing supplicant state: SCANNING ==> INACTIVE
02-16 15:42:59.122: DEBUG/NetworkStateTracker(2484): setDetailed state, old =SCANNING and new state=IDLE
02-16 15:42:59.138: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/IDLE
02-16 15:42:59.142: INFO/NetworkStatusReceiver(2935): action: android.net.wifi.SHOW_AP_LIST_DIALOG
02-16 15:42:59.154: ERROR/WifiManager(2935): showApDialog
02-16 15:42:59.158: INFO/WifiService(2484): isShowingAccessPointListDialog():false
02-16 15:42:59.161: INFO/WifiService(2484): setShowAccessPointListDialog():false
02-16 15:42:59.204: INFO/wifiScan(4009): 5 5626 22
02-16 15:42:59.204: INFO/wpa_supplicant(3810): CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00
02-16 15:42:59.204: INFO/WifiMonitor(2484): Event [CTRL-EVENT-STATE-CHANGE id=-1 state=2 BSSID=00:00:00:00:00:00]
02-16 15:42:59.208: VERBOSE/WifiStateTracker(2484): Changing supplicant state: INACTIVE ==> SCANNING
02-16 15:42:59.208: DEBUG/NetworkStateTracker(2484): setDetailed state, old =IDLE and new state=SCANNING
02-16 15:42:59.208: DEBUG/ConnectivityService(2484): Dropping ConnectivityChange for WIFI: DISCONNECTED/SCANNING
02-16 15:43:00.025: VERBOSE/AlarmManager(2484): set: Alarm{47dfb360 type 1 android}

I would guess that what you see is the difference between passive and active scan.
If you scan passively you have to stay at least 100ms on each channel (probably
closer to 200ms in practice) while with an active scan you can scan a lot quicker.
Presumably the 6s scan is passive while the 500ms scan is active.
With regulatory domain the device is not allowed to transmit unless it can figure
out which channels are allowed so it must scan passively until it gets the information
it needs. After that it should be able to switch to active scanning.

If you want active scan, you can call wifi.startScanActive().

Related

Silent APK installation by the device owner doesn't work on MIUI 11

I have a "device owner" Android app which silently installs APK using PackageInstaller (see the code, for example, here).
This code works perfectly on all Android 7+ devices except Xiaomi Redmi 7A (running MIUI 11). The installation fails, here's the related logcat output:
01-16 00:43:21.494 1488 2892 I InstallationStatistic: beginInstallSession: 417086238
01-16 00:43:21.600 1488 1658 D com.android.server.pm.PackageManagerServiceInjector: Package verify start
01-16 00:43:21.601 1488 1538 D CompatibilityInfo: mCompatibilityFlags - 0
01-16 00:43:21.601 1488 1538 D CompatibilityInfo: applicationDensity - 320
01-16 00:43:21.601 1488 1538 D CompatibilityInfo: applicationScale - 1.0
01-16 00:43:21.611 24382 24395 D GuardProvider: start parse apk : /data/app/vmdl417086238.tmp
01-16 00:43:21.618 24382 24395 E i.guardprovide: Invalid ID 0x00000000.
01-16 00:43:21.638 4434 24418 D PackageVerifyedRecevier: verify package /data/app/vmdl417086238.tmp info: PackageInfo{45d0d6b com.hmdm.sendphoto}
01-16 00:43:21.638 4434 24418 D PackageVerifyedRecevier: verify package /data/app/vmdl417086238.tmp finish true
01-16 00:43:21.639 1488 1658 I com.android.server.pm.PackageManagerServiceInjector: MIUILOG- Install Reject uid: 10161 pkg : com.hmdm.launcher
01-16 00:43:21.639 1488 1658 E PackageInstaller: Commit of session 417086238 failed: Permission Denied
Package ID of the installer (device owner) is com.hmdm.launcher. Package ID of the app being installed is com.hmdm.sendphoto.
I tried to add the "Install unknown apps" permission but this didn't help.
Looks like the app must request MIUI OS for some special (undocumented) permissions?
The device owner rights were granted to the application by QR code based enrollment.
Also with MIUI 10.3 some apps are refused to install/update.
For instance, I cannot install a Threema update the usual way (and just get a silly error 'not installed'). logcat shows that com.miui.global.packageinstaller.action.verifypackage called by com.android.server.pm.PackageManagerServiceInjector fails:
02-16 11:29:05.809 1271 1853 D com.android.server.pm.PackageManagerServiceInjector: Package verify start
02-16 11:29:05.810 1271 1317 D CompatibilityInfo: mCompatibilityFlags - 0
02-16 11:29:05.810 1271 1317 D CompatibilityInfo: applicationDensity - 440
02-16 11:29:05.810 1271 1317 D CompatibilityInfo: applicationScale - 1.0
02-16 11:29:05.812 1271 6228 W ActivityManager: Sending non-protected broadcast com.miui.global.packageinstaller.action.verifypackage from system 3440:com.miui.securitycenter.remote/1000 pkg com.miui.securitycenter. Callers=
02-16 11:29:05.816 3440 25765 E ActivityThread: Failed to find provider info for guard
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: parseApk
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: java.lang.IllegalArgumentException: Unknown URI content://guard
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at android.content.ContentResolver.call(Unknown Source:63)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at com.miui.permcenter.install.q.doInBackground(Unknown Source:17)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at com.miui.permcenter.install.q.doInBackground(Unknown Source:2)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at android.os.AsyncTask$2.call(Unknown Source:20)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
02-16 11:29:05.817 3440 25765 E PackageVerifyedRecevier: at java.lang.Thread.run(Thread.java:764)
02-16 11:29:05.817 3440 25765 D PackageVerifyedRecevier: verify package /data/app/vmdl216836998.tmp info: null
02-16 11:29:05.818 3440 25765 D PackageVerifyedRecevier: verify package /data/app/vmdl216836998.tmp finish false
02-16 11:29:05.818 1271 1853 I com.android.server.pm.PackageManagerServiceInjector: MIUILOG- INSTALL_FAILED_VERIFICATION_FAILURE uid: 10026 pkg : com.google.android.packageinstaller
What worked for me was to move the apk file to /data/local/tmp/
and then call as root
pm install -r file.apk

Android Studio JSon HTTP Application crash

I am using the latest version of android studio. 6.0 does not have the apache libraries but i have added them in the gradle. My application works but it doesnt get the data. I've added the log cat below including my mainactivity:
public class MainActivity extends AppCompatActivity {
private TextView responseTextView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.responseTextView = (TextView) this.findViewById(R.id.responseTextView);
new GetAllLecturesTask().execute(new ApiConnector());
}
public void setTextToTextView(JSONArray jsonArray)
{
String s = "";
for (int i=0; i<jsonArray.length();i++){
JSONObject json = null;
try{
json = jsonArray.getJSONObject(i);
s = s +
"Name : "+json.getString("Name")+
"EmailAddress : "+json.getString("EmailAddress")+"\n"+
"PhoneNo : "+json.getString("PhoneNo")+"\n\n";
}catch (JSONException e){
e.printStackTrace();
}
}
}
private class GetAllLecturesTask extends AsyncTask<ApiConnector,Long,JSONArray>
{
#Override
protected JSONArray doInBackground(ApiConnector... params){
return params[0].GetAllLectures();
}
#Override
protected void onPostExecute(JSONArray jsonArray){
setTextToTextView(jsonArray);
}
}
}
Logcat:
02-16 20:55:57.690 2304-2304/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
02-16 20:55:57.690 2304-2304/? D/AndroidRuntime: CheckJNI is ON
02-16 20:55:57.710 2304-2304/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
02-16 20:55:57.740 2304-2304/? E/memtrack: Couldn't load memtrack module (No such file or directory)
02-16 20:55:57.740 2304-2304/? E/android.os.Debug: failed to load memtrack module: -2
02-16 20:55:57.740 2304-2304/? I/Radio-JNI: register_android_hardware_Radio DONE
02-16 20:55:57.750 2304-2304/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
02-16 20:55:57.760 1357-1368/? I/ActivityManager: Force stopping com.example.jahanara.externaldatabase appid=10066 user=0: from pid 2304
02-16 20:55:57.760 1357-1368/? I/ActivityManager: Killing 2275:com.example.jahanara.externaldatabase/u0a66 (adj 0): stop com.example.jahanara.externaldatabase
02-16 20:55:57.770 1357-1393/? W/InputDispatcher: channel '3605d7 com.example.jahanara.externaldatabase/com.example.jahanara.externaldatabase.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
02-16 20:55:57.770 1357-1393/? E/InputDispatcher: channel '3605d7 com.example.jahanara.externaldatabase/com.example.jahanara.externaldatabase.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
02-16 20:55:57.770 1357-1369/? D/GraphicsStats: Buffer count: 2
02-16 20:55:57.770 1357-1369/? I/WindowState: WIN DEATH: Window{3605d7 u0 com.example.jahanara.externaldatabase/com.example.jahanara.externaldatabase.MainActivity}
02-16 20:55:57.770 1357-1369/? W/InputDispatcher: Attempted to unregister already unregistered input channel '3605d7 com.example.jahanara.externaldatabase/com.example.jahanara.externaldatabase.MainActivity (server)'
02-16 20:55:57.800 1357-1368/? W/ActivityManager: Force removing ActivityRecord{999f3d u0 com.example.jahanara.externaldatabase/.MainActivity t135}: app died, no saved state
02-16 20:55:57.810 1357-1803/? W/ActivityManager: Spurious death for ProcessRecord{966925c 0:com.example.jahanara.externaldatabase/u0a66}, curProc for 2275: null
02-16 20:55:57.810 2304-2304/? D/AndroidRuntime: Shutting down VM
02-16 20:55:58.050 1697-1828/? W/EGL_emulation: eglSurfaceAttrib not implemented
02-16 20:55:58.050 1697-1828/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f690c260840, error=EGL_SUCCESS
02-16 20:55:58.100 1005-1005/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
02-16 20:55:58.600 2313-2313/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
02-16 20:55:58.600 2313-2313/? D/AndroidRuntime: CheckJNI is ON
02-16 20:55:58.620 2313-2313/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
02-16 20:55:58.690 2313-2313/? E/memtrack: Couldn't load memtrack module (No such file or directory)
02-16 20:55:58.690 2313-2313/? E/android.os.Debug: failed to load memtrack module: -2
02-16 20:55:58.690 2313-2313/? I/Radio-JNI: register_android_hardware_Radio DONE
02-16 20:55:58.700 2317-2317/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
02-16 20:55:58.700 2317-2317/? D/AndroidRuntime: CheckJNI is ON
02-16 20:55:58.710 2313-2313/? D/AndroidRuntime: Calling main entry com.android.commands.wm.Wm
02-16 20:55:58.720 2317-2317/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
02-16 20:55:58.740 2317-2317/? E/memtrack: Couldn't load memtrack module (No such file or directory)
02-16 20:55:58.740 2317-2317/? E/android.os.Debug: failed to load memtrack module: -2
02-16 20:55:58.740 2317-2317/? I/Radio-JNI: register_android_hardware_Radio DONE
02-16 20:55:58.750 2317-2317/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
02-16 20:55:58.760 1357-1803/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.jahanara.externaldatabase/.MainActivity} from uid 0 on display 0
02-16 20:55:59.120 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 360ms
02-16 20:55:59.270 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 440ms
02-16 20:55:59.570 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:55:59.730 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 460ms
02-16 20:55:59.900 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 480ms
02-16 20:56:00.050 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 480ms
02-16 20:56:00.220 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 490ms
02-16 20:56:00.240 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 340ms
02-16 20:56:00.380 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 330ms
02-16 20:56:00.530 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 310ms
02-16 20:56:00.680 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 440ms
02-16 20:56:00.830 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:00.990 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 460ms
02-16 20:56:01.150 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 470ms
02-16 20:56:01.300 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 470ms
02-16 20:56:01.600 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:01.750 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:01.910 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 460ms
02-16 20:56:02.070 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 470ms
02-16 20:56:02.210 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 460ms
02-16 20:56:02.360 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:02.510 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 440ms
02-16 20:56:02.660 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:02.810 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:02.960 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 450ms
02-16 20:56:02.980 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 320ms
02-16 20:56:03.120 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 310ms
02-16 20:56:03.120 1357-1726/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowManagerService$H.handleMessage(android.os.Message) from WindowManagerService.java:8000 waiters=2 for 160ms
02-16 20:56:03.120 1357-1803/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowAnimator$1.doFrame(long) from WindowAnimator.java:121 waiters=2 for 140ms
02-16 20:56:03.120 2313-2313/? D/AndroidRuntime: Shutting down VM
02-16 20:56:03.290 1357-1849/? W/art: Long monitor contention event with owner method=void com.android.server.wm.WindowManagerService$H.handleMessage(android.os.Message) from WindowManagerService.java:7820 waiters=2 for 160ms
02-16 20:56:03.290 1357-1371/? W/art: Long monitor contention event with owner method=int com.android.server.am.ActivityStackSupervisor.startActivityMayWait(android.app.IApplicationThread, int, java.lang.String, android.content.Intent, java.lang.String, android.service.voice.IVoiceInteractionSession, com.android.internal.app.IVoiceInteractor, android.os.IBinder, java.lang.String, int, int, android.app.ProfilerInfo, android.app.IActivityManager$WaitResult, android.content.res.Configuration, android.os.Bundle, boolean, int, android.app.IActivityContainer, com.android.server.am.TaskRecord) from ActivityStackSupervisor.java:946 waiters=0 for 4.470s
02-16 20:56:03.290 2317-2317/? D/AndroidRuntime: Shutting down VM
02-16 20:56:03.290 1357-1388/? W/art: Long monitor contention event with owner method=int com.android.server.am.ActivityStackSupervisor.startActivityMayWait(android.app.IApplicationThread, int, java.lang.String, android.content.Intent, java.lang.String, android.service.voice.IVoiceInteractionSession, com.android.internal.app.IVoiceInteractor, android.os.IBinder, java.lang.String, int, int, android.app.ProfilerInfo, android.app.IActivityManager$WaitResult, android.content.res.Configuration, android.os.Bundle, boolean, int, android.app.IActivityContainer, com.android.server.am.TaskRecord) from ActivityStackSupervisor.java:946 waiters=1 for 3.280s
02-16 20:56:03.290 1357-1429/? W/art: Long monitor contention event with owner method=int com.android.server.am.ActivityStackSupervisor.startActivityMayWait(android.app.IApplicationThread, int, java.lang.String, android.content.Intent, java.lang.String, android.service.voice.IVoiceInteractionSession, com.android.internal.app.IVoiceInteractor, android.os.IBinder, java.lang.String, int, int, android.app.ProfilerInfo, android.app.IActivityManager$WaitResult, android.content.res.Configuration, android.os.Bundle, boolean, int, android.app.IActivityContainer, com.android.server.am.TaskRecord) from ActivityStackSupervisor.java:946 waiters=2 for 2.440s
02-16 20:56:03.320 1357-1849/? W/InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 2275 uid 10066
02-16 20:56:03.330 1697-1697/? I/Choreographer: Skipped 310 frames! The application may be doing too much work on its main thread.
02-16 20:56:03.790 1357-1371/? W/ActivityManager: Activity pause timeout for ActivityRecord{d0412ba u0 com.android.launcher3/.Launcher t132}
02-16 20:56:03.800 2332-2332/? I/art: Not late-enabling -Xcheck:jni (already on)
02-16 20:56:03.810 1357-1371/? I/ActivityManager: Start proc 2332:com.example.jahanara.externaldatabase/u0a66 for activity com.example.jahanara.externaldatabase/.MainActivity
02-16 20:56:03.810 2332-2332/? W/System: ClassLoader referenced unknown path: /data/app/com.example.jahanara.externaldatabase-2/lib/x86_64
02-16 20:56:03.910 1005-1122/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
02-16 20:56:03.910 2332-2347/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-16 20:56:04.190 1697-1697/? I/Choreographer: Skipped 51 frames! The application may be doing too much work on its main thread.
02-16 20:56:04.310 2332-2347/? I/OpenGLRenderer: Initialized EGL, version 1.4
02-16 20:56:05.450 1697-1697/? I/Choreographer: Skipped 73 frames! The application may be doing too much work on its main thread.
02-16 20:56:05.740 2332-2347/? W/EGL_emulation: eglSurfaceAttrib not implemented
02-16 20:56:05.740 2332-2347/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f691ce988c0, error=EGL_SUCCESS
02-16 20:56:07.210 2332-2345/? E/Entity Response  :: [{"ID":"1","Name":"James Shuttleworth","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07591231231","Department":"Computing","AvailabilityID":"1000"},{"ID":"2","Name":"Mike Morgan","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07594422281","Department":"Computing","AvailabilityID":"1001"},{"ID":"3","Name":"Parveen Samra","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07594423333","Department":"Environment","AvailabilityID":"1002"},{"ID":"4","Name":"Vasile Constantin","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07598811337","Department":"Engineering","AvailabilityID":"1003"},{"ID":"5","Name":"George William","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07897211290","Department":"Engineering","AvailabilityID":"1004"},{"ID":"6","Name":"Amanda Brooks","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07335115226","Department":"Environment","AvailabilityID":"1005"},{"ID":"7","Name":"Sandy Taramonli","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07777222311","Department":"Computing","AvailabilityID":"1006"},{"ID":"8","Name":"Mark Bennett","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07747222441","Department":"Environment","AvailabilityID":"1007"},{"ID":"9","Name":"Amritpal Slaich","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07747722141","Department":"Engineering","AvailabilityID":"1008"},{"ID":"10","Name":"Harminder Kaur","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07669931771","Department":"Engineering","AvailabilityID":"1009"},{"ID":"11","Name":"Leon Smalov","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07734541236","Department":"Computing","AvailabilityID":"1010"},{"ID":"12","Name":"Mark Tyers","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07734529936","Department":"Computing","AvailabilityID":"1011"},{"ID":"13","Name":"Farzana Aslam","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07414622990","Department":"Engineering","AvailabilityID":"1012"},{"ID":"14","Name":"Yih-Ling Hedley","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410090","Department":"Engineering","AvailabilityID":"1013"},{"ID":"15","Name":"Abdullahi Ahmed","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410091","Department":"Engineering","AvailabilityID":"1014"},{"ID":"16","Name":"Carl Mills","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410092","Department":"Design","AvailabilityID":"1015"},{"ID":"17","Name":"Una Malone","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410093","Department":"Engineering","AvailabilityID":"1016"},{"ID":"18","Name":"Reda Al Bodour","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410094","Department":"Computing","AvailabilityID":"1017"},{"ID":"19","Name":"Phillip Smith","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410095","Department":"Computing","AvailabilityID":"1018"},{"ID":"20","Name":"Erik Barrow","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410096","Department":"Computing","AvailabilityID":"1019"},{"ID":"21","Name":"Luke Hicks","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410097","Department":"Computing","AvailabilityID":"1020"},{"ID":"22","Name":"Ateya Asgar","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410098","Department":"Engineering","AvailabilityID":"1021"},{"ID":"23","Name":"Xiang Fei","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410099","Department":"Computing","AvailabilityID":"1022"},{"ID":"24","Name":"Zahir Ahmad","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410100","Department":"Engineering","AvailabilityID":"1023"},{"ID":"25","Name":"Carey Pridgeon","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410101","Department":"Computing","AvailabilityID":"1024"},{"ID":"26","Name":"Hong Guo","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410102","Department":"Computing","AvailabilityID":"1025"},{"ID":"27","Name":"Richard Lane","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410103","Department":"Environment","AvailabilityID":"1026"},{"ID":"28","Name":"Bill Dunn","EmailAddress":"eduardhanu#yahoo.com","PhoneNo":"07552410104","Department":"E
02-16 20:56:07.930 1357-1376/? I/ActivityManager: Displayed com.example.jahanara.externaldatabase/.MainActivity: +4s140ms
02-16 20:56:08.130 1697-1828/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f690cc1d750
Your setTextToTextView method is called by the onPostExecute method.
But this method simply set a variable s concatenating the value of the json objects.
It doesn't set the value in the responseTextView (the TextView) defined in the onCreate method.
You have to call somenthing like:
responseTextView.setText(s);

Android MediaCodec decode h264 raw data latency issue

I have tried to use MediaCodec to decode 1080p h264 raw data.
But I found the latency is between 45ms~65ms with my SONY Z3(5.1.1).
Is possible to reduce the latency?
My frame is IPPP and GOP is 15, Have any h264 sps flag will effect the latency?
And I have another question, how to change the orientation of surface let the frame show in 90,180 or 270 degree.
I put my test project source in following google drive link.
And the h264 raw data is in test_code\res\raw .
https://drive.google.com/file/d/0B688fdS1LxF4REtra0YteDh6TkE/view?usp=sharing
02-16 18:05:52.804: I/Process(10590): Sending signal. PID: 10590 SIG: 9
02-16 18:05:54.618: W/ResourceType(10706): Found multiple library tables, ignoring...
02-16 18:05:54.677: D/OpenGLRenderer(10706): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-16 18:05:54.684: D/Atlas(10706): Validating map...
02-16 18:05:54.717: I/Adreno-EGL(10706): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030_msm8974_LA.BF.1.1.1_RB1__release_AU ()
02-16 18:05:54.717: I/Adreno-EGL(10706): OpenGL ES Shader Compiler Version: E031.25.03.06
02-16 18:05:54.717: I/Adreno-EGL(10706): Build Date: 07/13/15 Mon
02-16 18:05:54.717: I/Adreno-EGL(10706): Local Branch: mybranch11906725
02-16 18:05:54.717: I/Adreno-EGL(10706): Remote Branch: quic/LA.BF.1.1.1_rb1.26
02-16 18:05:54.717: I/Adreno-EGL(10706): Local Patches: NONE
02-16 18:05:54.717: I/Adreno-EGL(10706): Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030 + 6151be1 + a1e0343 + 002d7d6 + 7d0e3f7 + NOTHING
02-16 18:05:54.718: I/OpenGLRenderer(10706): Initialized EGL, version 1.4
02-16 18:05:54.733: D/OpenGLRenderer(10706): Enabling debug mode 0
02-16 18:05:54.800: I/Timeline(10706): Timeline: Activity_idle id: android.os.BinderProxy#1970952c time:27341192
02-16 18:05:56.804: I/OMXClient(10706): Using client-side OMX mux.
02-16 18:05:56.819: D/MediaCodec(10706): MediaCodec[kWhatConfigure]: video-output-protection: 00000000, audio-output-protection: 00000000
02-16 18:05:56.821: I/ACodec(10706): [OMX.qcom.video.decoder.avc] DRC Mode: Dynamic Buffer Mode
02-16 18:05:56.827: I/ExtendedCodec(10706): Decoder will be in frame by frame mode
02-16 18:05:56.830: D/ACodec(10706): Found video-output-protection flags set to 00000000
02-16 18:05:56.845: E/(10706): inputBuffers.size:4
02-16 18:05:56.845: E/(10706): outputBuffers.size:23
02-16 18:05:56.858: E/DecodeActivity(10706): dequeueOutputBuffer timed out!
02-16 18:05:56.870: E/DecodeActivity(10706): dequeueOutputBuffer timed out!
02-16 18:05:56.883: E/DecodeActivity(10706): dequeueOutputBuffer timed out!
02-16 18:05:56.884: E/DecodeActivity(10706): INFO_OUTPUT_BUFFERS_CHANGED
02-16 18:05:56.892: E/DecodeActivity(10706): New format {mime=video/raw, crop-top=0, crop-right=1919, slice-height=1088, color-format=2141391876, height=1088, width=1920, what=1869968451, crop-bottom=1079, crop-left=0, stride=1920}
02-16 18:05:56.898: E/DecodeActivity(10706): Receive first decode frame after 51 ms
I see in your code that you set 10000 uS as the timeout to receive input data. That's a short amount of time.
while (!Thread.interrupted()) {
if (!isEOS) {
int inIndex = decoder.dequeueInputBuffer(10000);
In dequeueInputBuffer, put a very long timeout, like ten seconds (10000000). It will allow waiting longer. Setting -1 as the timeout will block until data is received.
You should maybe handle connectivity problems outside of your feeding loop, and have your own helper to buffer the initial data before launching the feeding loop.

Hit a button on Android and takes a long response time

First, I use a System.Out.print to output something but I don't see that in the console or logcat, where does it display?
Then when hit the button, it takes long time to respond. I log the files from logcat and have No idea what the OS is doing behind which took so long.
02-16 13:01:07.859: WARN/WindowManager(51): Key dispatching timed out sending to com.test.finalapp/com.test.finalapp.tab.FeaturedActivity
02-16 13:01:08.101: WARN/WindowManager(51): Dispatch state: {{KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to Window{44dcd868 com.test.finalapp/com.test.finalapp.MyAccount1_1Activity paused=false} # 1329425383564
lw=Window{44dcd868 com.test.finalapp/com.test.finalapp.MyAccount1_1Activity paused=false} lb=android.os.BinderProxy#44e756f0 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{44e2b0a0 com.test.finalapp/com.test.finalapp.games.slotMachine paused=false}}}
02-16 13:01:08.119: WARN/WindowManager(51): Current state: {{null to Window{44e2c788 com.test.finalapp/com.test.finalapp.tab.FeaturedActivity paused=false} # 1329426068120 lw=Window{44e2c788 com.test.finalapp/com.test.finalapp.tab.FeaturedActivity paused=false} lb=android.os.BinderProxy#44e2c5a0 fin=true gfw=true ed=true tts=0 wf=false fp=false mcf=Window{44e2b0a0 com.test.finalapp/com.test.finalapp.games.slotMachine paused=false}}}
02-16 13:01:08.240: INFO/ActivityManager(51): ANR in process: com.test.finalapp (last in com.test.finalapp)
02-16 13:01:08.240: INFO/ActivityManager(51): Annotation: keyDispatchingTimedOut
02-16 13:01:08.240: INFO/ActivityManager(51): CPU usage:
02-16 13:01:08.240: INFO/ActivityManager(51): Load: 0.37 / 0.37 / 0.38
02-16 13:01:08.240: INFO/ActivityManager(51): CPU usage from 8216ms to 81ms ago:
02-16 13:01:08.240: INFO/ActivityManager(51): system_server: 4% = 3% user + 1% kernel / faults: 4 minor
02-16 13:01:08.240: INFO/ActivityManager(51): obango.finalapp: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): qemud: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): logcat: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): events/0: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): TOTAL: 5% = 4% user + 1% kernel
02-16 13:01:08.251: INFO/ActivityManager(51): Removing old ANR trace file from /data/anr/traces.txt
02-16 13:01:09.081: INFO/Process(51): Sending signal. PID: 239 SIG: 3
02-16 13:01:09.239: INFO/dalvikvm(239): threadid=7: reacting to signal 3
02-16 13:01:09.458: INFO/Process(51): Sending signal. PID: 51 SIG: 3
02-16 13:01:09.486: INFO/dalvikvm(51): threadid=7: reacting to signal 3
02-16 13:01:10.457: INFO/dalvikvm(239): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:12.037: INFO/dalvikvm(51): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:12.055: INFO/Process(51): Sending signal. PID: 223 SIG: 3
02-16 13:01:12.269: INFO/dalvikvm(223): threadid=7: reacting to signal 3
02-16 13:01:12.358: INFO/Process(51): Sending signal. PID: 213 SIG: 3
02-16 13:01:12.375: INFO/dalvikvm(213): threadid=7: reacting to signal 3
02-16 13:01:12.608: INFO/Process(51): Sending signal. PID: 154 SIG: 3
02-16 13:01:12.885: INFO/Process(51): Sending signal. PID: 146 SIG: 3
02-16 13:01:12.905: INFO/dalvikvm(213): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:13.113: INFO/Process(51): Sending signal. PID: 189 SIG: 3
02-16 13:01:13.348: INFO/Process(51): Sending signal. PID: 181 SIG: 3
02-16 13:01:13.602: INFO/Process(51): Sending signal. PID: 170 SIG: 3
02-16 13:01:13.816: INFO/dalvikvm(146): threadid=7: reacting to signal 3
02-16 13:01:13.976: INFO/dalvikvm(189): threadid=7: reacting to signal 3
02-16 13:01:14.084: INFO/Process(51): Sending signal. PID: 103 SIG: 3
02-16 13:01:14.144: INFO/dalvikvm(103): threadid=7: reacting to signal 3
02-16 13:01:14.342: INFO/Process(51): Sending signal. PID: 106 SIG: 3
02-16 13:01:16.950: INFO/dalvikvm(170): threadid=7: reacting to signal 3
02-16 13:01:18.814: INFO/dalvikvm(181): threadid=7: reacting to signal 3
02-16 13:01:23.204: WARN/MediaPlayer(239): info/warning (1, 44)
02-16 13:01:23.578: DEBUG/AudioSink(30): bufferCount (4) is too small and increased to 12
02-16 13:01:24.137: WARN/AudioFlinger(30): write blocked for 76 msecs, 2 delayed writes, thread 0xb388
02-16 13:01:24.385: DEBUG/dalvikvm(239): GC freed 4564 objects / 281416 bytes in 77ms
02-16 13:01:24.914: INFO/MediaPlayer(239): Info (1,44)
02-16 13:01:25.537: INFO/dalvikvm(106): threadid=7: reacting to signal 3
02-16 13:01:26.370: INFO/dalvikvm(103): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:26.435: INFO/dalvikvm(223): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:27.350: INFO/dalvikvm(170): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:27.611: INFO/dalvikvm(181): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:28.074: INFO/ActivityManager(51): Starting activity: Intent { cmp=com.test.finalapp/.Leaderboard1 (has extras) }
02-16 13:01:28.934: INFO/ActivityManager(51): Displayed activity com.test.finalapp/.Leaderboard1: 754 ms (total 754 ms)
02-16 13:01:29.889: INFO/dalvikvm(189): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:30.152: INFO/dalvikvm(146): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:30.375: INFO/dalvikvm(154): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:31.183: INFO/dalvikvm(106): Wrote stack trace to '/data/anr/traces.txt'
You should give us the code that is executed and, if you just call a method, give us the code of the method, too. Yous system.out will be printed in the logcat, just check for the tag System.
Even without your code, I can start a educated guess: Your button probably trigger a long taking operation and blocks the UI thread as the touchlistener runs on the UI Thread.
You should also consider moving it into an AsyncTask that is meant to be used for long term operations like internet access or calculations. You can update your UI easily from the AsyncTask, too.

Download large file in Android

I have an app that downloads a very large file (over 50MB). Unfortunately I'm getting reports that the download fails.
Below is the logcat of one such failure, which ends with a java.net.SocketException: The operation timed out. In-between it has various messages from the WifiMonitor. I don't know how to interpret these messages.
Is there something special that I should do to download a large file, or is this simply a connection problem?
09-02 16:41:19.925 I/ActivityManager( 646): Displayed activity com.example/com.example.sp.MainActivity: 1110 ms (total 3786 ms)
09-02 16:41:21.935 W/InputManagerService( 646): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#45133d08
09-02 16:41:23.495 I/global ( 7345): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
09-02 16:41:23.895 D/dalvikvm( 7345): GC freed 5348 objects / 307096 bytes in 160ms
09-02 16:41:25.885 D/dalvikvm( 7345): GC freed 15282 objects / 713544 bytes in 124ms
09-02 16:41:27.405 D/dalvikvm( 7345): GC freed 11775 objects / 524576 bytes in 131ms
09-02 16:41:28.982 I/wpa_supplicant( 7284): CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys
09-02 16:41:28.985 V/WifiMonitor( 646): Event [CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys]
09-02 16:41:28.985 V/WifiStateTracker( 646): New network state is DISCONNECTED
09-02 16:41:28.985 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=0
09-02 16:41:28.985 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=0]
09-02 16:41:28.995 V/WifiStateTracker( 646): Changing supplicant state: COMPLETED ==> DISCONNECTED
09-02 16:41:29.086 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=2
09-02 16:41:29.086 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=2]
09-02 16:41:29.086 V/WifiStateTracker( 646): Changing supplicant state: DISCONNECTED ==> SCANNING
09-02 16:41:29.086 W/wpa_supplicant( 7284): Failed to initiate AP scan.
09-02 16:41:29.095 I/wpa_supplicant( 7284): CTRL-EVENT-SCAN-RESULTS Ready
09-02 16:41:29.095 I/wpa_supplicant( 7284): Trying to associate with 00:1c:f0:6e:2a:56 (SSID='WLANR' freq=2412 MHz)
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=3
09-02 16:41:29.105 V/WifiMonitor( 646): Event [Trying to associate with 00:1c:f0:6e:2a:56 (SSID='WLANR' freq=2412 MHz)]
09-02 16:41:29.105 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=3]
09-02 16:41:29.125 V/WifiStateTracker( 646): Changing supplicant state: SCANNING ==> ASSOCIATING
09-02 16:41:29.825 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=4
09-02 16:41:29.825 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=4]
09-02 16:41:29.825 V/WifiStateTracker( 646): Changing supplicant state: ASSOCIATING ==> ASSOCIATED
09-02 16:41:29.825 I/wpa_supplicant( 7284): Associated with 00:1c:f0:6e:2a:56
09-02 16:41:29.825 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=7
09-02 16:41:29.825 I/wpa_supplicant( 7284): CTRL-EVENT-CONNECTED - Connection to 00:1c:f0:6e:2a:56 completed (reauth) [id=0 id_str=]
09-02 16:41:29.825 I/wpa_supplicant( 7284): wpa_supplicant - IPC_EVENT_AUTH_SUCC
09-02 16:41:29.825 V/WifiMonitor( 646): Event [Associated with 00:1c:f0:6e:2a:56]
09-02 16:41:29.825 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=7]
09-02 16:41:29.845 V/WifiStateTracker( 646): Changing supplicant state: ASSOCIATED ==> COMPLETED
09-02 16:41:29.855 V/WifiMonitor( 646): Event [CTRL-EVENT-CONNECTED - Connection to 00:1c:f0:6e:2a:56 completed (reauth) [id=0 id_str=]]
09-02 16:41:29.855 V/WifiStateTracker( 646): New network state is CONNECTED
09-02 16:41:29.865 D/WifiStateTracker( 646): Deconfiguring interface and stopping DHCP
09-02 16:41:29.865 E/wpa_supplicant( 7284): prepare_filter_struct: type=5
09-02 16:41:29.945 E/FileUtils( 7345): Download failed
09-02 16:41:29.945 E/FileUtils( 7345): java.net.SocketException: The operation timed out
The phone disconnects from Wi-Fi when going into sleep mode, which I guess was the cause here? Take a look at WifiManager's WifiLock to see how you can prevent it.

Categories

Resources