Android xposed Frame---Modify the system position information to realize the hidden function instance _android

Source: Internet
Author: User

First, the preface

This article mainly introduces a practical case is how to modify the geographic information of the system through this framework to realize the hidden function, in today's development of social tools, especially micro-letters, he has a real-time location sharing function, then for those who are not single dog students may have some egg pain, which day daughter-in-law to Zhagang send location, The result is that you are not in her desired position at this time is awkward, and the circle of friends in the sharing of content can choose the current position, some cock silk as I do not have money but also want to travel, then we can be a full of the seriousness of the force.

Second, positioning principle

See above said so much, feel this function must be done, the benefits are too much, the following we began to operate, but before this must be familiar with the xposed framework of the use of rules, not understand the students can go here to see: xposed framework of the use of rules In this article we learned that we only need to do the blocking in the callback method in the class that implements the Ixposedhookloadpackage interface Handleloadpackage. But here we have to do one thing first, and that is the knowledge of positioning systems in Android, and we know that there are many ways in which mobile phones are positioned:

First, satellite positioning

GPS (Global Positioning System) that is, is the United States to establish a satellite navigation positioning system, the use of the system, users can achieve all-weather, continuous, real-time three-dimensional navigation positioning and speed, in addition, the use of the system, The user is also able to perform high precision time transfer and high-precision positioning.

Second, base station positioning

The mobile phone measures the downlink pilot signal of different base stations, obtains TOA (arrival moment) or TDOA (arrival time difference) of the downlink pilot frequency of different base stations, according to the measurement result and combined with the base station coordinates, generally uses the triangle Formula estimation algorithm, can calculate the mobile phone position. The actual position estimation algorithm needs to consider the position of multiple base stations (3 or 3), so the algorithm is much more complicated. Generally speaking, the higher the number of base stations measured by mobile stations, the higher the measurement precision and the more obvious the improvement of positioning performance.

Third, WiFi location

Each wireless AP (router) has a globally unique MAC address, and the wireless AP is generally not mobile for a period of time;
When the device is turned on Wi-Fi, the wireless router defaults to the SSID broadcast (unless the user manually configures the function to turn off the feature), including the MAC address of the router in the broadcast frame; Upload this information to the server, after the calculation of the server, saved as "mac-latitude" mapping, when the information gathered enough time on the server set up a huge WiFi information network;

When a device is in a network like this, the collected data can be sent to the location server, the server retrieves the location of each AP, combines the strength of each signal, calculates the location of the device and returns it to the user device, which is calculated in the same way as the base station location. Also uses the three point localization or the localization technology, the position service provider must unceasingly update, supplements own database, guarantees the data accuracy. When some WiFi information is not in the database, the location information of the unknown WiFi can be inferred from the other nearby WiFi location information and uploaded to the server.

Four, aGPS positioning

AGPS (ASSISTEDGPS: Auxiliary Global Positioning System) is a combination of GSM/GPRS and traditional satellite positioning, the use of Base station to send auxiliary satellite information to reduce the GPS chip acquisition of satellite signal delay time, the covered room can also borrow base station signal to make up, Reduce the reliance of GPS chips on satellites. aGPS use of mobile phone base station signal, supplemented by remote location server to download satellite Ephemeris (English: Almanac Data), and then with the traditional GPS satellite receiver, so that positioning faster. is a combination of network base station information and GPS information to the mobile station positioning technology, not only the global Positioning System GPS, but also using mobile base station to solve the problem of GPS coverage, can be in the 2 generation of G, C Network and 3G network use.

There are specific ways to invoke these kinds of positioning in Android. So if you want to modify the positioning of the system, then you must first understand these several calling methods, in a previous article also said that the hook is the most critical point is to find the hook of the place, this need to read the source to find. The general acquisition of location information in Android involves several of the following classes and methods:

First: Using base station location information

Android.telephony.TelephonyManager
+getcelllocation
+getphonecount
+getneighboringcellinfo
+getallcellinfo

Android.telephony.PhoneStateListener
+oncelllocationchanged
+oncellinfochanged

Second: Use WiFi location information

Android.NET.wifi.WifiManager
+getscanresults
+getwifistate
+iswifienabled

Android.Net.wifi.WifiInfo
+getmacaddress
+getssid
+getbssid

Android.net.NetworkInfo
+gettypename
+isconnectedorconnecting
+isconnected
+isavailable

Android.telephony.CellInfo
+isregistered

Third: Using GPS positioning

Android.location.LocationManager
+getgpsstatus
+getlastlocation
+getlastknownlocation
+getproviders
+getbestprovider
+addgpsstatuslistener
+addnmealistener

Third, interception operation

With these methods and classes, it's time to intercept the operation, but this is the way to intercept, because after many tests, it is found that most of Android's location apps are based on the base station +gps+wifi three hybrid methods to locate, But if we're going to intercept these three ways it's too strenuous, so here we do, only to intercept the operation of GPS positioning, and the other two ways to intercept after the return value of all set empty, so that the system to force the use of GPS positioning, why use GPS positioning this way? Because the other two ways after intercepting to construct false data is a bit troublesome, and for GPs this way we only need to construct a fake location object on it, the operation is very convenient. Here we have the idea, the following to begin operation:

First of all, we put other positioning mode information to intercept all return null value, so you can force the system to use GPS positioning data, and then began to intercept GPS data, because I dream to visit Taiwan May days, so here on the construction of a false Taipei data:
Construct a fake location object directly, then set it as a parameter, because the location object here is passed back through the callback, so you need to modify the parameter instead of the return value. Here if some students want to go to other places, and do not know the specific latitude and longitude information, how to do? This can use the Baidu map of the picker function:

Click here to select the location:

When selected, you can see the latitude and longitude information, in the upper right corner can assign value information:

All right, here we go. Modified the location of the system information, and then we began to run, the operation steps are very simple, first run the module, and then the Xposedinstaller tool will prompt the module update or have a new module to activate, click to activate or update the tool, Then reboot the device to take effect.

Iv. demonstration of Operation result

When we restart again, open Baidu Map surprised to find no data? This is not our intercept error, but we are indoors, so GPS positioning may fail, so if you want to see the data need to go outside operation can, below is my Baidu map screenshot:
With this map, we are about to start the real outfit force, first search the vicinity of the beautiful ha:
Haha, see, this forced me unprepared, I almost believe, see the location of the information click to see is also true, and not what we have seen: "The location by the user defined by themselves," Here we are the force is installed successfully.

Project Source: Source Download

V. Summary

This article mainly introduces the xposed frame of a practical use case, is to modify the location of equipment information, let oneself install a force, this article used to modify the geographical location of the weekend to achieve a trip to Taipei's desire to function, the above is the entire content of this article, I hope that the study of everyone to help We also hope that we can support the cloud-dwelling community.

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.