Search code examples
androidandroid-sourceandroid-locationandroid-gps

Can not get GPS location in Android-5.0.2_r1


I have installed AOSP android-5.0.2_r1 on an Nexus 7. I wrote a simple app to retrieve location data from the GPS sensor, but the onLocationChanged method is never invoked. Below is the logcat, can anyone spot what is wrong??

D/PbdTest ( 2356): into Oncreate method
D/PbdTest ( 2356): GPS provider enabled
D/OpenGLRenderer( 2356): Render dirty regions requested: true
D/Atlas   ( 2356): Validating map...
I/Adreno-EGL( 2356): <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/28/14, c33033c, Ia6306ec328
I/OpenGLRenderer( 2356): Initialized EGL, version 1.4
D/OpenGLRenderer( 2356): Enabling debug mode 0
I/ActivityManager(  606): Displayed com.example.pbdtest/.MainActivity: +426ms
V/GpsLocationProvider(  606): AGpsStatus is V2+: 96
V/GpsLocationProvider(  606): AGPS IP is v4: ffffffff
V/GpsLocationProvider(  606): Passing AGPS IP addr: size 0
V/GpsLocationProvider(  606): Received SUPL IP addr[]: null
D/ConnectivityManager(  606): Looking for legacyRequest for netCap with hash: [ Transports: CELLULAR Capabilities: SUPL&NOT_RESTRICTED&TRUSTED&NOT_VPN] (57351)
D/ConnectivityManager(  606): sLegacyRequests has:
D/ConnectivityService(  606): requestNetwork for NetworkRequest [ id=5, legacyType=3, [ Transports: CELLULAR Capabilities: SUPL&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
D/ConnectivityManager(  606): sending expire msg with seqNum 0 and delay 60000
D/ConnectivityManager(  606): starting startUsingNetworkFeature for request NetworkRequest [ id=5, legacyType=3, [ Transports: CELLULAR Capabilities: SUPL&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
D/ConnectivityService(  606): handleRegisterNetworkRequest checking NetworkAgentInfo [MOBILE (LTE) - 100]
D/ConnectivityService(  606): apparently satisfied.  currentScore=50
D/ConnectivityService(  606): using NetworkAgentInfo [MOBILE (LTE) - 100]
D/CSLegacyTypeTracker(  606): Sending connected broadcast for type 3 NetworkAgentInfo [MOBILE (LTE) - 100] isDefaultNetwork=true
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null](  606): ValidatedState{ when=-1ms what=532481 target=com.android.internal.util.StateMachine$SmHandler }
D/ConnectivityService(  606): sendStickyBroadcast: action=android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE
D/ConnectivityService(  606): sending new NetworkRequest to factories
D/Ethernet(  606): got request NetworkRequest [ id=5, legacyType=3, [ Transports: CELLULAR Capabilities: SUPL&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
D/ConnectivityManager.CallbackHandler(  606): CM callback handler got msg 524290
D/ConnectivityManager(  606): startUsingNetworkFeature got Network:100
D/TelephonyNetworkFactory(  956): got request NetworkRequest [ id=5, legacyType=3, [ Transports: CELLULAR Capabilities: SUPL&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
D/WIFI    (  606): got request NetworkRequest [ id=5, legacyType=3, [ Transports: CELLULAR Capabilities: SUPL&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null](  606): Validated
D/ConnectivityService(  606): Validated NetworkAgentInfo [MOBILE (LTE) - 100]
D/ConnectivityService(  606): rematching NetworkAgentInfo [MOBILE (LTE) - 100]
D/ConnectivityService(  606): Network NetworkAgentInfo [MOBILE (LTE) - 100] was already satisfying request 5. No change.
D/ConnectivityService(  606): Network NetworkAgentInfo [MOBILE (LTE) - 100] was already satisfying request 1. No change.
D/ConnectivityService(  606): notifyType AVAILABLE for NetworkAgentInfo [MOBILE (LTE) - 100]
D/ConnectivityManager.CallbackHandler(  748): CM callback handler got msg 524290
D/ConnectivityManager.CallbackHandler(  606): CM callback handler got msg 524290
D/ConnectivityManager(  606): startUsingNetworkFeature got Network:100
W/NetworkPolicy(  606): shared quota unsupported; generating rule for each iface
D/audio_hw_primary(  190): disable_audio_route: reset and update mixer path: low-latency-playback
D/audio_hw_primary(  190): disable_snd_device: snd_device(2: speaker)
D/ConnectivityService(  606): sendStickyBroadcast: action=android.net.conn.CONNECTIVITY_CHANGE
D/Tethering(  606): MasterInitialState.processMessage what=3
E/        (  187): invalid crash request of size 4 (from pid=2327 uid=0)
W/qcom_sensors_hal(  606): hal_sensor1_data_cb: SENSOR1_MSG_TYPE_BROKEN_PIPE
E/Sensors ( 2441): sns_fsa_la.c(386):fsa: fflush failed, 9
E/Sensors ( 2441): sns_fsa_la.c(386):fsa: fflush failed, 9
W/Sensors ( 2441): sns_smr_la.c(446):smr_la: smr_apps_la_thread_main is starting, fd=12, sns_smr.en_rx_msg_ptr=b6fe29d0
W/Sensors ( 2441): sns_sam_app.c(6827):sns_sam_reg_algo: Registering algo service 16, err 0
E/Sensors ( 2441): sns_debug_main.c(565):Debug Config File missing in EFS!

Below is the code for my app:

public class MainActivity extends Activity {

//private PbdLocationManager pbdLocManager;
//private PbdDeviceManager pbdDevManager;
private final String TAG = "PbdTest";
//private MyReceiver receiver;

private int noLocations = 2;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.d(TAG, "into Oncreate method");


    // Testing the LocationManager functions
    LocationManager locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    final MyLocationListener listener = new MyLocationListener();

    locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 0, listener);

}

private final class MyLocationListener implements LocationListener{
    @Override
    public void onLocationChanged(Location location){
        try{
            double lat = location.getLatitude();
            double lon = location.getLongitude();
            String l = "LocationManager Longitude: " + lon + " Latitude: " + lat;
            Toast.makeText(getApplicationContext(), l ,Toast.LENGTH_SHORT).show();
            Log.d(TAG, "SUCCESS to call function");

        }
        catch (Exception e){
            Log.d(TAG, "FAILED to call function");
            e.printStackTrace();
        }
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras){}
    @Override
    public void onProviderEnabled(String provider){}
    @Override 
    public void onProviderDisabled(String provider){}
}

Solution

  • Check if there possible to have GPS signal from physical point of view.