How should I implement a circular buffer of debug messages? - android

I am using ACRA as a crash and error reporting lib in my Android app.
It offers an option to send the content of LogCat along with the error reports, but I do not wish to use this feature as it requires a READ_LOGS permission, that may represent a threat to some users.
I am essentially interested in sending my own application debug logs along with the error reports I send using ACRA. Of course there needs to be a maximum size of this debug history (e.g. only the last 20 messages would be saved and sent). And I could store messages by simply calling something like storeLog("User has clicked button 1").
To achieve this, I would need either:
a circular buffer, storing (Timestamp t, String message) pairs. Drawback of this option: need to pass this buffer between classes, loss of history on application exit (unless if I save it to a file or SharedPreferences)
a rolling file.
Which option is to be preferred, and how can it be implemented (especially the "rolling" behavior) ?

Related

Firebase Crash Reporting - uploading custom files

Is there a way to attach complete logcats to crashes using Firebase Crash Reporting? I did notice that the Firebase SDK has some log functions, but those have to be specifically invoked. My app already does a ton of logging to logcat using our own custom loggger (not Android logger) anyways, so I would hate to have to duplicate the log calls to Firebase.
For example, I would need to do:
MyLogger.d(TAG, "my log message");
Firebase.log("my log message");
Sending a complete logcat isn't really possible because modern Android permissions don't allow apps to access that any more (as logs could easily and accidentally contain sensitive information). You will need to invoke the logging API to get logs attached. It's advisable to hook your existing logging infrastructure to make this happen without duplication at every location.

Firebase RemoteConfig used for showing a message on app start

I am thinking of using RemoteConfig for these 2 purposes:
Have on the server a parameter minVersion of the app that should function. So for instance if v1.5 is broken and I release an update on Google Play as v1.6 I want to block access to 1.5 and older and force the user to update to 1.6 in order to use the app.
Have on the server, a parameter to store a message to display in the app. So for instance have a message like "We are having server maintenance, please wait a while". On app start, if the message parameter is not empty, show a dialog with it in the app.
Of course, in this case, on each app start I need to fetch the remote config values and check them.
Why use RemoteConfig? Because it's easy, it's free, it's convenient and I don't need to have another separate server for these 2 simple jobs.
So is this a valid use case?
Yes these are both valid cases.
For point 1, you can quite easily determine the users app version. I created a video detailing how to do it
https://youtu.be/McP11kcrMtk

Possible to only use certain characters of a line to authenticate with remote database?

I'm looking to set up a remote database for user data for an Android application I am developing, but I don't want to use a server to handle the queries. Instead, I am looking to see if there is a way to make either the database recieve or the app only send parts of a generated code for each user.
This is my thought process on how it would work:
User opens app for first time ->
app generates and stores on device specific code for user and visible to user->
example of User Code: MG0CG094CF08352FBZS3042C0890432 ->
when user inputs data on app ->
data stored on device and sent to database when connection available ->
database receives only M0045328 for user identification for data input
The idea would be registration with the database without having to handle emails, passwords, etc., just the 8 digit user identification code. The purpose of the 32 character app generated code would be for security and the user in the event they they get a new device or delete the app.
The security measure I'm thinking of instead of a server is for the database to only handle certain characters of the user code or for the app to only send certain characters.
User sees this in app: MG0CG094CF08352FBZS3042C0890432
Application only sends: Mx0xx0x4xxxxx5xxxxx3xx2xxx8xxxxx
Database reads: M0045328
Obviously I don't want it to read like that in the source, so I need some discrete way for the app to exclude characters when sending information. Problem is that I can't think of some way that it's possible to code it like that. I essentially want the app to encrypt itself and only decrypt when it's sending information. I obviously also don't want each code to decrypt the same way, so maybe the 32 character code could also include which characters to send?
Anyone have some idea about how to do this or would simply a server solution be easier? Keep in mind I would prefer for it to handle it this way more than to use a server.
For all your pseudo code, in the end you are trying to achieve a DRM structure. DRM is not feasible for devices that you have no control over. So you can only obfuscate things a bit. Trying to hide code is not likely to work; it's better to try and hide some kind of data to make that more difficult to find.

Get logs from android when app is app store

Currently we can use logcat or ask other testers to send logcat files. But What i want as to see logs when app is on play store. So let's say if any request contact us for some problem that he is facing. Then it would be easier for us to see that user's device logs and figure out the issue. Because some issues are not easily reproducible.
Is there a way I can get the logs of device which i don't have a physically access to using some tool when the app is on play store?
EDIT
I don't want use in a way where user has to upload logs files and manually send it to our team. It should display live log on a website or provider's console.
You can track logs with Google Analytics. Just send trackers to analytics on the places you usually send logs.(You must initialize tracker first. See link below)
Example :
Tracker defaultTracker = GoogleAnalytics.getInstance(this).getDefaultTracker();
defaultTracker.send(MapBuilder.createEvent("Logger", "Log_Tag",
"Log_msg", null).build());
And you will get a event group in the Behaviour section of google analytics called Logger that has list of Log_Tags that has List of Log_msg
It is pretty easy to implement. See this link on how to add Google Analytics to your app https://developers.google.com/analytics/devguides/collection/android/v3/
Hope this helps you.
You need a custom Log service to store the important logs/errors
From your app if any crashes or important Logs you send it Log server for future reference.
Click Here
You should try Crashlytics
Crashlytics for Android delivers real-time crash reporting across all devices. We perform a deep analysis of each stack trace to identify the most important frames and we break down every bug by device model and version so you can spend less time finding and more time fixing issues.
What if "NETWORK" is not available when your app crashed on users device to update/send a crash report to you.
For me,
1.) I will get Crash Reports when User hits "Report to developer" at the time of crash.
2.) I use Google Analytics, to get the description of the app with location(which line of code) of error from "Crashes and Exceptions" under "Behaviour" tab.
Also, by modifying/adding your Google Analytics Code, as mentioned here: Crashes & Exceptions
Try your Luck!
You can use Log4j library in android.
What is Log4j library?
It is an logger library in java. And it allow the application to write logs in to your file, email when caught exceptions and can send logs in background to your server or any else. So that you can see the logs of every individual device and track the issues.
download it from the below link:
Log4j for android
Hope it will help you.
Currently I'm using ACRA.
The official link contains all details you need and offers different way of "User interaction mode", "Reports destination" and "Reports content".
If you implement it very well on your app, you can have a full report of what is happening.
Keeping in mind few things u can do it :-
create log files.
store them in your applications private area and not in sdcard ( to avoid deletion by user
or if on sdcard then use . before directory to hide it from user )
keep a service running at the background.
start uploading the document after every hour or when app moves in the background or the
file size increase >10 kb etc... depends upon choice. and remember to upload all files
in this directory.
if uploads successfully delete dat file else leave it which will be uploaded next time.
try to implement zip to make single file if file count is gr8er then 5 suppose.
In a nutshell :-
a. record.
b. zip
c. upload
c. delete.
this is my view remember

Filtering SMS messages that only pertain to my application

So I've gotten some great information from people on here pertaining to how to allow my application to receive text messages before the native messaging app catches them.
However, I'm looking for a little more specifics on how I can mold this to fit the needs of my application
What I'm ultimately looking to do, is to only have text messages pertaining to my application be the ones that are caught by my application before the native messaging app, while all other text messages just head to the normal spot
Is there any way to add extra data to a text message, or some sort of port, where text messages can be filtered into my app as opposed to the native messaging app, without losing out on my 160 character max? I'm really not looking for my application to replace the native messaging app for all text messages, and would only like to have it deal with text messages that are pertaining to my application, as it seems right now to be much easier to have them come into the application from an end-user standpoint, as there's no good way (at least on hTC phones) to copy or import individual text messages from the native messaging application to be brought into the application.
Any help would be very very appreciated... and if there's any wording in there that is hard to understand (as I'm sure it might be somewhat difficult to follow), please let me know and I will try to clarify! Thanks!
The answer is probably no, assuming you have a filter set up before your native messaging app to do some regex (regular expression) filtering on the message content, you will have to use up some of your character limit - or make sure your application is extended to handle multi-sms messages (i.e. one message using 2,3 or more sms's).
The best, easiest to read description of the inner details of an sms I know of is this, SMS and the PDU format, short of going through the official ITU-T protocol documents. There are other fields in the SMS there, but I doubt you could reliably hijack one of them for your purposes. But then again, if you did a whole bunch of trial & error, you might find a way.

Categories

Resources