📜 ⬆️ ⬇️

Dr. Tariff (tariffs and balance): How I began to help people save on mobile costs



Today I will tell you how Dr. Tarif was created. This is an assistant who analyzes the statistics of your conversations and selects the ideal tariff plan. Once launched, the application will examine in detail the history of your conversations and other costs to tell if you can spend less. For one week, we were on our own in the TOP-10 free applications under the heading "Finance".


Idea


It all started from the morning when I woke up and, looking at the negative balance in the account, I realized that over the last week I had spent about 1,000 rubles talking. “Somehow too famously” - I thought, and decided it was time to switch to a new tariff. Before that, I had to select the tariff twice on the sites of operators. Despite the mathematical turn of mind, I had to figure out for quite a long time what tariff to switch to. At this point, I had a question - why not an application that could do it for me and, besides, to bring all the analytics about conversations in the form of infographics.
')
I asked a friend to sketch the first interface design:



I’ve already twice died Nokia N8, and I chose between iOS and Android. On one side, simplicity and sophisticated design, on the other - widgets, a larger set of functions and many free applications. I preferred Android and was not mistaken. This is the only mobile operating system that gives full access to user data, which means it will be possible to implement all the planned functionality.

Research


It took a lot of time to learn how to implement all my ideas. For example, there were 4 options for determining the region of the user. First of all, we wanted to read this information from the SIM card, but only the operator and the country are sewn into them (and even then not always). The second was based on GPS data, but we did not find a complete map of the breakdown of the RF by region. And the location at a particular point in time is not directly related to the region of the SIM card, and, therefore, to the rates for communication. The third option is to use GSM cellular identifiers or Wi-Fi towers. It turned out that a complete base does not exist and they constantly “migrate”.

There was a fourth way - to determine the region by phone code (the first N digits after +79), which is uniquely associated with the region and the operator. But for this it was necessary to somehow contrive to determine the subscriber's phone number. A separate task was to find all the requests and exact answers of mobile operators in various regions. And here we were waiting for new surprises: Megaphone, for example, is divided into 7 branches, each of which has its own system of requests / responses. The blessing though * 100 # works across all Russia. In MTS * 100 # calls on some devices cascades of incoming SMS with balance, it turned out that # 100 # solves the problem.

It soon became clear that we need to learn how to read the pop-up USSD responses of operators to work with Beeline and Tele2. A quick overview of this task showed that there is no API for this function. And on the official developer forum, this question remains open for 4 years.

We have already decided to cut this part, but our new Android developer, Dmitry, still found a way to solve this problem (the well-known way drew from here ; unfortunately, not very reliable, but for lack of a better alternative, we had to use it). Later it turned out that competing apps with MobileFox and USSD checker balance widgets use the same method, only in violation of Google’s recommendations, they set the highest possible priority 2147483647 (instead of the recommended 1000). Because of this, our application with reading USSD always flew past the ticket office.

It was funny with priorities at all - the same competitors put a similar priority on receiving SMS, and everything would be fine if they didn’t manually add them to the incoming ones and didn’t interrupt the alert. In this regard, the parts of users continuously fell SMS in the incoming after each action.

And often there was a chain effect: the SMS request was sent, the SMS was added to the inbox, bypassing our application, the application detected a new incoming SMS and re-sent the request. Fortunately, we started with testing on the beta version of the application :)



Tariff Optimizer


What we are really proud of is the tariff optimizer. It seems to you that you speak little and pay a lot? The idea was to just one click to separate the user from the most favorable tariff for him. But behind this click there is a big hard work.

To calculate the cost of an outgoing call or SMS, you need to know which region and operator is with the other party. If the subscriber is in another region, not in where he is registered, he will pay for roaming, but for you the cost will remain the same. Phone number is enough to calculate the cost of a call / SMS on almost all rates. The exception is made by tariffs, where the price for calls to subscribers with a specific tariff plan is specified separately.

Information about the cost of calls / SMS is compiled manually for each tariff, based on the description from the sites of operators, and is stored in a text file. Further, it is translated into a suitable form for calculations.

To preserve the anonymity of the number of calls / SMS sent in a truncated form. To begin with, 5 digits were cut off and this worked in most cases. A more detailed analysis showed that some calls are not so determined and information about the operator or region is contained in the last digits, so the protocol has been changed, and now the last 3 digits are truncated.

Once, analyzing the logs, I noticed that one client had changed the phone model to some little-known one, and the manufacturer remained unchanged (Samsung). The subscriber's identification occurred according to the MD5 hash value from his IMEI (international mobile equipment identifier), and since it is unique, the data is tied to a strictly one device.

So I thought ... But it turned out that this is not quite so. Maintaining the uniqueness of IMEI rests on the shoulders of manufacturers, and at the state level is controlled only for certified devices. In Europe or the US, this is closely monitored. In Russia there is a huge market of so-called gray devices, which are intended for another country and are imported illegally. The reason for this is simple: you do not have to pay a fee, as a result of which the cost of the apparatus decreases by several thousand.

As a result, it is quite possible the simultaneous existence of several devices with one IMEI. A collision was detected when there were less than 1000 users in the database, so the problem is quite relevant. Both devices (GT-I9003, SHV-E150S) were made by Samsung, but the first model is international, and the second is designed for the Asian market. It seems that Samsung just decided to save the allocated numbers and creates devices with the same IMEI for different countries.

The problem was solved by changing the identifier to the MD5 value from the IMEI + device model. Let's hope that the manufacturers will not release the same model with the same IMEI.

The server is written in Python. The first time worked under Windows 7 on a home computer. When writing a multiprocessor (remember GIL) server, there was a problem with passing a socket to another process due to operating system limitations. Now the server is running on a separate server running Ubuntu. The database uses PostgreSQL.

Some interesting facts:



Other application features


A nice addition to Dr. Tariff are graphics. You will find out who you are most talking with and who you are most communicating by SMS. Call MTS or Beeline often. All charts can be customized "by yourself", as well as select the period for which statistics will be displayed.







In addition, you will have flexible widgets with current balance and cost statistics.
Now, with each call, Dr. Tariff will inform you about the operator and the region. In the settings you can change the location of the window, or disable this feature. Trifle, but nice:


Now we are actively collecting feedback and we are already working on redesigning the application taking Android standards into account. According to numerous requests from iPhone users, an application for iOS is planned to be released (if successful with Android). Due to the closeness of the operating system, data can only be obtained from a personal account, which will lead to some difficulties, but this is true due to the lack of alternatives.



Until May 31, we decided to make the application free. Download on Google Play .

Who does not work downloading from Google Play can try to download from the Yandex Store or. Apk file with w3bsit3-dns.com .

If you like the app, or you want to help the development project, join our group and tell your friends and friends about it:
vk.com/DrTariff
facebook.com/groups/DrTariff/
twitter.com/DrTariff
drtariff.com

PS In the near future we want to prepare an infographic on which tariffs the users spend least effectively on the most efficient operators earn money - is it interesting?

Source: https://habr.com/ru/post/179559/


All Articles