Powered by Blogger.

The Programming Blog



Running Systrace for android

Measuring time taken by app to launch

Go to verbose of logacat in Android monitor
Select no filters
Search for Displayed
Run your app
Time taken for every Activity to draw and display will be provoded in ms

1. Method Tracing

To run Method Tracing do following -

1. Pre requisite -

Tools > Android > Enable ADB Integration
  • Android Device Monitor can’t be running. (Android Monitor is different thing , don't mix up)
  • set your app debuggable in build.gradle file (app)
  • 2. Now use Android Monitor as -
  • View > Tool Windows > Android Monitor.
  • Go to monitor Tab - to shift between the log and monitor tab , see on the right top, a icon is present that allows you to do so as given here - https://developer.android.com/images/tools/am-imaxlogcat.png
  • Connect your device 
  • Click a clock to start method tracing just after starting your app. Click clock again to stop method tracing, You will get Result in the editor tab (where tabs of xml/java files are present). Click the tab and in bottom section you will find all the methods along with their inclusive and exclusive time. Click inclusive tab to sort them by highest or lowest time.
  • Thus you can see the methods taking most of your time.





2. Systrace Tool

Pre - You must have systrace enabled in your android device - go to Settings -> Dev Options -> Monitoring -> Profile GPU rendering - in adb.....
->Enable opengl traces - systrace

To run this - You should have pip installed - So I installed pip and using pip installed

sudo easy_install pip
pip install pyserial
- Using Command Line 

After this - Run the following command -

 cd  Users/sachinaggarwal/Library/Android/sdk/platform-tools/systrace
python systrace.py --time=10 -o mynewtrace.html sched gfx view wm
If you get error that Is adb on your path - You need to add adb to your environment variables as -

echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile
In place of ${USER} enter your username
After this you need to quit the terminal and reopen it to see the effect.
Open Terminal, Connect your device and reenter the following commands
cd  Users/sachinaggarwal/Library/Android/sdk/platform-tools/systrace
python systrace.py --time=10 -o mynewtrace1.html sched gfx view wm
Your inline trace will be saved in mynewtrace.html. Open it and analyze


2nd Option - Run in Android Studio in Android Device Monitor -

Additional prereq - For ADM to run, you must have ADB integration disabled. (disabled by defualt so no problem)

Prob - You may find that you are enable to run your project (it will ask you to enable adb integration). This is because instant run requires adb integration. SO -> Go to Settings and disable instant run -> You will be now able to run your app as well as ADM.
In ADM, open devices tab and select your device and on it select systrace icon to start taking systrace.






Analysing trace file -

To analyse the trace file you can click any of red part in trace but the easiest way is to Go to Right -> Choose alerts tab -> you will see all the problems by choosing any alert and also get video links or android doc suggestions about your problem - thats how easy it is

You may look at traceview in future - https://developer.android.com/studio/profile/traceview.html









Share
Tweet
Pin
Share
No comments
Hackathons are always awesome !! You build a product, interact with other hackers and overdose yourself off caffeine. And if we get unlimited RedBull, then it's just 10X Awesomeness.

My team was selected into the finals of Smart India Hackathon. We were selected for the Indian Space Research Organisation category.

Problem Statement: Novel Solution for preventing a breach of the confidential file from the organization other than already available methods in networking. The solution should also prevent uploading of data to the internet.

Solution: Our idea for this was a client-side solution: On every employee system, we will partition the system volume into two parts: Public and Confidential. Public Volume contains all the data that can go outside organization without any concern. Confidential Area contains all the confidential data deployed by system admin into this volume.

The Confidential Area will be completely isolated i.e. None of the following can be done on files of this area: Cut, Copy, Send To, Save As, Paste, Delete, Drag and Drop and many more commands. This ensures that none of the files from the confidential area can move to the public area or external drives.

What about uploading to Internet/Mail/Backend Script ?? How can we stop this ??

Our solution to this problem was: When the user wants to open confidential area, the user has to use our File Viewer tool to open the files.
At all other times, all the permission on file of the Confidential area will be revoked. This means that if the user tries to upload a file, it will be corrupt. The user may try bash script, program or any other way, it will not work because file simply does not exist without permissions.

File permissions will only be granted when the user opens the confidential file in File Viewer. Also, during this time (when File Viewer is opened), we are checking that FileViewer is in focus. Because the user can open File Viewer and then take advantage of granted file permissions.

We also handled a lot of other edge cases and were able to develop 60% of our product (Isolation part was done completely using a combination of registry modification, clipboard listeners to clear clipboard when copied data comes in, etc).

The further product development will be carried on after instructions from Indian Space Research Organisation.




Share
Tweet
Pin
Share
No comments
This was my first Hackathon. And I bet, more are coming.

My friend Anirudh called me to join him in the InOut Hackathon, NIT Surat. I wasn't so sure as this would had been my first hackathon. But then, there is always the first time.

Hackthons are awesome. We both interacted with so many developers. It was amazing to hear so many crazy ideas from people. Every interaction ended with a WOW feeling. There were Games, Photo Sessions, Tweet Competitions, Redbulls, and whatnot. It was like we were invited to have fun.

As for our product, it didn't went well. We wasted most of our time brainstorming the idea. The product was not completed on time and we failed miserably in demo. 

But, we realised that hackathon is not a competition. Its fun. That night we didn't sleep. We and group of some other participants played cards, LAN games, and discussed about each others' college culture. We made new friends, from different parts of country.

It was fun but challenging at the same time. I realised the amount of talent out there. It is a good motivation for me and I will participate in more hackathons now.




Share
Tweet
Pin
Share
No comments
Many times Android Studio just wouldn't work. You will see some weird errors while building and stackoverflow will also fail you on this.

Well, this usually always solve my buggy Android Studio -

1. Restart Android Studio.

2. Try Again. If it still fails, go to Build -> Clean Project. Try Again.

3. If it still doesn't work, go to File -> Invalidate Cache and restart. Try Again.

4. If it still fails, close Android Studio. Go to your sdk location -> find a folder called "build-tools". Delete that folder. For a safe side, don't delete it permanently. Try Again.

5. Help yourself. Even God can't help you on this now. 
Share
Tweet
Pin
Share
No comments
Its 4.30 in the night (or just call it morning) and here I am discussing interesting issue I came across in PowerUp Game a couple of days back.

It happened to me for the second time that app crashed with a message "Power Up has stopped working". I didn't had my phone connected when the crash happened. So Bad. Or maybe not. I learned a couple of new things because of this. That's what I love about Open Source.

So,  I thought of applying a trick I found sometime back while going through StackOverflow questions. Here it goes,

1. Open your terminal or Command Prompt and connect your device on which crash happened.

2. Now we need to go to the location of adb. How to find it ?

Go to your Android Studio -> File -> Other Settings ->  Default Project Structure

You can find the location of sdk there.

3. Now we will recover the log cat. Come back to terminal.

cd sdk_location_you_copied
cd platform-tools                            
adb logcat AndroidRuntime:E  *:S 

You will see all the log cats. In case its running infinitely, just press Ctrl + C.

4. Now that you have your logcat, search for your package name in it. I searched "power" and was able to find all the crash that happened in Power Up recently on my device. 

I will be telling about how I handled the issue I found #234 in my next post.
Share
Tweet
Pin
Share
No comments
Winning the 4th Edition of Discover Thinking Contest by CSI

"Best Things Happens Unexpectedly"

- Secured a rank in National 50 in DTC CSI and got invite to 51st Annual Convention of CSI, 2016 , Coimbatore with full cost coverage.

From last few months, most of my days are being spent contributing to Open Source Projects. One such day, I came across Discover Thinking Contest by CSI. It was a while since I did competitive programming and had no mood to participate in this contest.

The contest participation was open for a whole day of 11th Jan, 2017. It was in the night, when I was getting really bored, I decided to give this contest a try. (Better than sitting idle huh !!)

It was a 3 hour contest with 5 questions. The contest was do or die contest. You can't go to next question until you answer the current question. The judge supported most of the programming languages out there, so it was not a problem for anyone.

 The questions were the tricky one with each question a blend of Data Structures, File Handling, and Algorithms. None of the question could have been done if you don't have strong understanding of  File Handling in your respective language.

 The question demanded to read a input.txt file that could be anywhere in the target directory , execute your code on that input in given time complexity and save your output in specified format (was different for every question) in output.txt which should be saved in the same directory as target directory.

To further add to this, the question needed a good understanding of Data Structures. I remember a question in which I had to make my own Data Structure using Java Class, use HashMap, use Queue and a Linked List. The solution got so big that I was sometimes lost in my own code.

Well, I ended up answering all five of them in just time. Given my previous failures in competitive programming I had no hope whatsoever that I will win this out of 11000 participants from all over the country.

But I did !! Coming back from college, I got a mail which congratulated me. I was dumbstruck for few minutes. I convinced myself that it must be a prank but it wasn't. I won it.

The prize was a full cost coverage to attend the 51st Annual Convention of CSI at Coimbatore, Tamil Nadu. 

My First Flight !!
  
Le Meridien Hotel, Coimbatore !!

Awarded by CSI Head !!




It was a 3 day convention with eminent speakers from all over the world. I got to meet several professors from IIT's, Researchers, professionals from top notch industries like Adobe, Microsoft, KPMG, etc. There was so much to learn in just 3 days.

What I loved the most was the cultural diversity. People from different parts of country, from girls to boys,  students to professionals, startups to big IT players, all of them a part of technology. 


Share
Tweet
Pin
Share
No comments
Newer Posts
Older Posts

About me

I am Sachin Aggarwal, Android Developer and Designer pursuing my B.Tech at MAIT, Delhi. I love to explore new things and spend time contributing to Open Source.

Categories

  • Android
  • Competitive Programming
  • Experiences
  • Extras

Blog Archive

  • ▼  2017 (6)
    • ▼  October (1)
      • Android Systrace and Method Tracing
    • ►  April (1)
      • Smart India Hackathon
    • ►  March (2)
      • InOut Hackathon, NIT Surat
      • Buggy Android Studio
    • ►  February (2)
      • Recover Crash Logs
      • Winning the 4th Edition of Discover Thinking Conte...
  • ►  2016 (4)
    • ►  September (1)
    • ►  July (1)
    • ►  February (1)
    • ►  January (1)

Created with by ThemeXpose | Distributed By Gooyaabi Templates