Research on Application Development of GPS Beidou dual-mode technology-Research on Application Data Interaction and gps Development

Source: Internet
Author: User

Research on Application Development of GPS Beidou dual-mode technology-Research on Application Data Interaction and gps Development

 

Research on Application Development of GPS Beidou dual-mode technology-Application Data Interaction

 

The Android development principle is that anyone who is interested in which data can listen through the listener. This is certainly the case for Locating data over there. I am not prepared to bother with location reporting, there are a lot of articles on the Internet. Next we will talk about the dual-mode related Beidou gps satellite star chart trigger data reporting and customization of private protocols.

In locationmanager, there is an interface addGpsStatusListener, which is used in the application to transmit the listen. There are many processes in the process, and the listener is stored in the location provider, in the middle, it is switched by the service, but the service directly uses the addGpsStatusListener of the provider. The following describes the addGpsStatusListener interface in the service:

    public boolean addGpsStatusListener(IGpsStatusListener listener, String packageName) {        if (mGpsStatusProvider == null) {            return false;        }        int allowedResolutionLevel = getCallerAllowedResolutionLevel();        checkResolutionLevelIsSufficientForProviderUse(allowedResolutionLevel,                LocationManager.GPS_PROVIDER);        final int uid = Binder.getCallingUid();        final long ident = Binder.clearCallingIdentity();        try {            if (!checkLocationAccess(uid, packageName, allowedResolutionLevel)) {                return false;            }        } finally {            Binder.restoreCallingIdentity(ident);        }        try {            mGpsStatusProvider.addGpsStatusListener(listener);        } catch (RemoteException e) {            Slog.e(TAG, "mGpsStatusProvider.addGpsStatusListener failed", e);            return false;        }        return true;    }

Register now. This is equivalent to mounting a hook in the provider. Once new data is updated, it can be directly transferred to the application, of course, it is not difficult to understand the code of those hands that are interested in the listener. Let's take a look at the satellite sv status report, which directly triggers the onSvStatusChanged interface of listener, as shown below:

    private void reportSvStatus() {        int svCount = native_read_sv_status(mSvs, mSnrs, mSvElevations, mSvAzimuths, mSvMasks);        synchronized (mListeners) {            int size = mListeners.size();            for (int i = 0; i < size; i++) {                Listener listener = mListeners.get(i);                try {                    listener.mListener.onSvStatusChanged(svCount, mSvs, mSnrs,                            mSvElevations, mSvAzimuths, mSvMasks[EPHEMERIS_MASK],                            mSvMasks[ALMANAC_MASK], mSvMasks[USED_FOR_FIX_MASK],                            mSvMasks[BD_SVS_NUM], mSvMasks[BD_EPHEMERIS_MASK],                            mSvMasks[BD_ALMANAC_MASK],mSvMasks[BD_USED_FOR_FIX_MASK]);                } catch (RemoteException e) {                    Log.w(TAG, "RemoteException in reportSvInfo");                    mListeners.remove(listener);                    // adjust for size of list changing                    size--;                }            }        }

In this way, the onSvStatusChanged in GpsStatusListenerTransport is called. here we need to click the next article, and it will send a GpsStatus. GPS_EVENT_SATELLITE_STATUS message, but there is no parameter, I will take advantage of the two parameters, the number of one gps storage, the number of one Beidou storage. After the message is sent, it will be converted once in the handle.

        private final Handler mGpsHandler = new Handler() {            @Override            public void handleMessage(Message msg) {                if (msg.what == NMEA_RECEIVED) {                    synchronized (mNmeaBuffer) {                        int length = mNmeaBuffer.size();                        for (int i = 0; i < length; i++) {                            Nmea nmea = mNmeaBuffer.get(i);                            mNmeaListener.onNmeaReceived(nmea.mTimestamp, nmea.mNmea);                        }                        mNmeaBuffer.clear();                    }                } else {                    // synchronize on mGpsStatus to ensure the data is copied atomically.                    synchronized(mGpsStatus) {                    if(GpsStatus.GPS_EVENT_SATELLITE_STATUS == msg.what){int pri_event ;pri_event = 0x77 + (msg.arg1<<8) + (msg.arg2<<16);//Log.d(TAG, "LM: msg.arg1 "+msg.arg1 +" msg.arg2 "+msg.arg2+ " pri "+pri_event);                        mListener.onGpsStatusChanged(pri_event);                    }                        mListener.onGpsStatusChanged(msg.what);                    }                }            }
Therefore, when forwarding messages, perform special processing to synthesize a special message, and carry our gps number to the Beidou number. Nothing else is special, third-party applications can also receive sv changes, but do not know the specific number of gps and Beidou. There are no other differences.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.