SlideShare a Scribd company logo
Know thy codeFramework
Know thy code ???.*What we wont know after this talkCode review secrets Know my code What we will learn from it ( Hopefully )How to make better use of framework sourceHow to make new components from the frameworkFramework
Android – Open Source Android has been available under a free software/open source license since October, 21 2008Google published the entire source code (including network and telephony stacks) under an Apache License.
Android – Open SourceSource available at source.android.com.Source is a bunch of git projects.Google built repo on top of git.Souce is ~3GB , needs ~10GB to build.Currently only builds on Linux and Mac
What code will we be seeing
Framework source in eclipseSource code from major release-specific branches can be downloaded like this:http://android.git.kernel.org/?p=platform/frameworks/base.git;a=snapshot;h=refs/heads/froyo;sf=tgzYou can get other versions by changing the branch name (froyo) in the link above (to donut, gingerbread, etc.)Links : https://bitly.com/bundles/rvyas/1
Framework source in eclipseExtract the android folder from <tarball>/core/java/ into android-sdk/platforms/<platform version>/sources/Make sure the platform-version is the same as the android version of the tarball.Refresh project in eclipse To test press Alt + Shift + T to check if you can view the activity class Source : http://kmansoft.wordpress.com/2011/01/27/android-sources-for-debugging/
Know thy code
Alternate “cloud” source viewerChrome extension : bit.ly/andsrcchrome	Adds an 'ad' command to the Chrome Omnibox
Alternate “cloud” source viewer
Getting hands dirty
Getting hands dirtypublicclassSeekBarextendsAbsSeekBarpublicabstractclassAbsSeekBarextendsProgressBarmThumbOffset= thumb.getIntrinsicWidth() / 2;setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE);setThumbPos(w, thumb, scale, 0);Modified code : http://bit.ly/andvsb
Getting hands dirtyStory : HTTP Requests
Getting hands dirtypublicabstractclassAsyncTask<Params, Progress, Result> {privatestaticfinal String LOG_TAG = "AsyncTask";privatestaticfinalintCORE_POOL_SIZE = 5;privatestaticfinalintMAXIMUM_POOL_SIZE = 128;privatestaticfinalintKEEP_ALIVE = 10;privatestaticfinalBlockingQueue<Runnable> sWorkQueue =newLinkedBlockingQueue<Runnable>(10);privatestaticfinalThreadFactorysThreadFactory = newThreadFactory() {privatefinalAtomicIntegermCount = newAtomicInteger(1);public Thread newThread(Runnable r) {returnnew Thread(r, "AsyncTask #" + mCount.getAndIncrement());        }    };
Performance examplespublicclassSQLiteDatabaseextendsSQLiteClosableAndroid implements locking in SQLiteDatabase- No point trying to hit the database from multiple threads- On the positive you don’t need to synchronize your 		  requests.
Questions?Thank you.

More Related Content

PPTX
Android v 1.1
PPTX
Android
PPTX
Flutter 1
PDF
Flutter app
PPTX
Code crunch
PDF
Development of Mobile Applications
PDF
C language in our world 2017
PDF
Firefox OS - Hive Pilani 2015
Android v 1.1
Android
Flutter 1
Flutter app
Code crunch
Development of Mobile Applications
C language in our world 2017
Firefox OS - Hive Pilani 2015

What's hot (19)

PDF
Android
PPTX
Android Application Development
DOCX
Fuchsia operating system by google document
PPTX
ANDROID TECHNOLOGY
PDF
Android Things Latest News / Aug 25, 2017
PDF
01 02 - introduction - adroid stack
PPT
Android and android versions
PPTX
Alternatives to Java for Android development
ODP
Future of android - Fuchsia OS
PPTX
Presentation2
PPT
Versions of android
PDF
Tizen, Firefox OS and the Future of Android
PPTX
Google Fuchsia
PPTX
Silverlight
PDF
Embedded Recipes 2019 - Overview of Fuchsia, a new operating system
ODP
The evolution of android from os 1.0 to lollipop
PPTX
Android Versions
PDF
Developing FOSDEM Companion
PDF
Introduction to Android (Jeudis du libre)
Android
Android Application Development
Fuchsia operating system by google document
ANDROID TECHNOLOGY
Android Things Latest News / Aug 25, 2017
01 02 - introduction - adroid stack
Android and android versions
Alternatives to Java for Android development
Future of android - Fuchsia OS
Presentation2
Versions of android
Tizen, Firefox OS and the Future of Android
Google Fuchsia
Silverlight
Embedded Recipes 2019 - Overview of Fuchsia, a new operating system
The evolution of android from os 1.0 to lollipop
Android Versions
Developing FOSDEM Companion
Introduction to Android (Jeudis du libre)
Ad

Similar to Know thy code (20)

PDF
01 03 - introduction to android
PPT
PPT Companion to Android
PPT
Enhancing and modifying_the_core_android_os
PDF
Android Development in a Nutshell
PDF
First Steps with Android - An Exciting Introduction
PDF
Android development first steps
PPT
Introduction to android
PPSX
Android OS and its Features
PPTX
Seminar on android app development
PDF
Android dev o_auth
ODP
Enhancing and modifying_the_core_android_os
PDF
An Introduction To Android
PDF
Android dev o_auth
PPTX
Android 101 Session @thejunction32
PPTX
Data Transfer between Activities & Databases
PDF
Android_Architectuture pdf complete detail
PPTX
Android Architecture v2 presetnation extension
PDF
Android development - the basics, MFF UK, 2013
PDF
Domo Arigato Mr. Roboto - Open Source Bridge 2009
PPTX
Mobile Application Development
01 03 - introduction to android
PPT Companion to Android
Enhancing and modifying_the_core_android_os
Android Development in a Nutshell
First Steps with Android - An Exciting Introduction
Android development first steps
Introduction to android
Android OS and its Features
Seminar on android app development
Android dev o_auth
Enhancing and modifying_the_core_android_os
An Introduction To Android
Android dev o_auth
Android 101 Session @thejunction32
Data Transfer between Activities & Databases
Android_Architectuture pdf complete detail
Android Architecture v2 presetnation extension
Android development - the basics, MFF UK, 2013
Domo Arigato Mr. Roboto - Open Source Bridge 2009
Mobile Application Development
Ad

More from Ravi Vyas (6)

PDF
What Product Market Fit is not
PDF
Mobile Metrics and Analytics
PDF
Key User Lifecycle Metrics for Growth & Engagement
PDF
Android workshop
PDF
Why android first
PPTX
Creating apps that work on all screen sizes
What Product Market Fit is not
Mobile Metrics and Analytics
Key User Lifecycle Metrics for Growth & Engagement
Android workshop
Why android first
Creating apps that work on all screen sizes

Recently uploaded (20)

PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
Group 1 Presentation -Planning and Decision Making .pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
A comparative analysis of optical character recognition models for extracting...
Big Data Technologies - Introduction.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
Assigned Numbers - 2025 - Bluetooth® Document
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology

Know thy code

  • 2. Know thy code ???.*What we wont know after this talkCode review secrets Know my code What we will learn from it ( Hopefully )How to make better use of framework sourceHow to make new components from the frameworkFramework
  • 3. Android – Open Source Android has been available under a free software/open source license since October, 21 2008Google published the entire source code (including network and telephony stacks) under an Apache License.
  • 4. Android – Open SourceSource available at source.android.com.Source is a bunch of git projects.Google built repo on top of git.Souce is ~3GB , needs ~10GB to build.Currently only builds on Linux and Mac
  • 5. What code will we be seeing
  • 6. Framework source in eclipseSource code from major release-specific branches can be downloaded like this:http://android.git.kernel.org/?p=platform/frameworks/base.git;a=snapshot;h=refs/heads/froyo;sf=tgzYou can get other versions by changing the branch name (froyo) in the link above (to donut, gingerbread, etc.)Links : https://bitly.com/bundles/rvyas/1
  • 7. Framework source in eclipseExtract the android folder from <tarball>/core/java/ into android-sdk/platforms/<platform version>/sources/Make sure the platform-version is the same as the android version of the tarball.Refresh project in eclipse To test press Alt + Shift + T to check if you can view the activity class Source : http://kmansoft.wordpress.com/2011/01/27/android-sources-for-debugging/
  • 9. Alternate “cloud” source viewerChrome extension : bit.ly/andsrcchrome Adds an 'ad' command to the Chrome Omnibox
  • 12. Getting hands dirtypublicclassSeekBarextendsAbsSeekBarpublicabstractclassAbsSeekBarextendsProgressBarmThumbOffset= thumb.getIntrinsicWidth() / 2;setThumbPos(getWidth(), thumb, scale, Integer.MIN_VALUE);setThumbPos(w, thumb, scale, 0);Modified code : http://bit.ly/andvsb
  • 13. Getting hands dirtyStory : HTTP Requests
  • 14. Getting hands dirtypublicabstractclassAsyncTask<Params, Progress, Result> {privatestaticfinal String LOG_TAG = "AsyncTask";privatestaticfinalintCORE_POOL_SIZE = 5;privatestaticfinalintMAXIMUM_POOL_SIZE = 128;privatestaticfinalintKEEP_ALIVE = 10;privatestaticfinalBlockingQueue<Runnable> sWorkQueue =newLinkedBlockingQueue<Runnable>(10);privatestaticfinalThreadFactorysThreadFactory = newThreadFactory() {privatefinalAtomicIntegermCount = newAtomicInteger(1);public Thread newThread(Runnable r) {returnnew Thread(r, "AsyncTask #" + mCount.getAndIncrement()); } };
  • 15. Performance examplespublicclassSQLiteDatabaseextendsSQLiteClosableAndroid implements locking in SQLiteDatabase- No point trying to hit the database from multiple threads- On the positive you don’t need to synchronize your requests.

Editor's Notes

  • #2: Apologize
  • #5:  Repo unifies the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow. Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android. The repo command is an executable Python script that you can put anywhere in your path