1
Tech Talk
AndroidWrapper for JamaicaVM
Antonio Cesarano,
aicas GmbH
9 September 2013
2
Agenda
– Goal
– Issues
– Structure of Android applications
– Incompatibilities with JamaicaVM
– Proposed solution
– AndroidWrapper
3
Goal
Execute the source code of Android applications on the
JamaicaVM.
Goal
4
Main question
– Why is not already possible?
Android applications are based on Java but they use own
APIs, that are not compilable by JamaicaVM.
javax.swing.JCompone
nt android.view.View
?
Issues
5
Java code execution
– Windows, Linux and other OS
HARDWARE
(Intel, AMD, ARM)
Operating System
(Windows, Linux, QNX)
Jamaica Runtime Environment
Java API
Class
Jamaica
Virtual
Machine
public class Hello
{
   public static void main(String 
args[])
   {
      System.out.println(“Hello World”);
   }
}
Issues
6
Java code execution
– Android
HARDWARE
(Intel, ARM)
Linux Kernel
Android API
Class
Dalvik
Virtual
Machine
public class MainActivity extends Activity 
{  
    @Override
    protected void onCreate(Bundle bundle) 
    {
        super.onCreate(savedInstanceState);  
        TextView textView = (TextView) 
findViewById(R.id.textView1);
        textView.setText("Hello World");
    }
}
Android Runtime Environment
Issues
7
Android applications
Main components
– activity_main.xml
– R.java
– MainActivity.java
Structure of Android Application
8
activity_main.xml
<LinearLayout
 
xmlns:tools="http://schemas.android.com/tools
"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".MainActivity" 
>
     <TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" 
      />
</LinearLayout>
Simple example
Structure of Android Application
9
activity_main.xml
<LinearLayout
 
xmlns:tools="http://schemas.android.com/tools
"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".MainActivity" 
>
     <TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" 
      />
</LinearLayout>
Simple example
Structure of Android Application
10
R.java
public final class R {
public static final class id {
        public static final int textView1=0x7f080000;
    }
    public static final class layout {
        public static final int activity_main=0x7f030000;
    }
}
The R.java file is auto-generated by the Android Resource Manager and
contains references to all resources of the app.
Structure of Android Application
11
MainActivity.java
public class MainActivity extends Activity 
{  
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);  
        TextView 
textView=(TextView)findViewById(R.id.textView1);
        textView.setText("Hello, World!");
    }
}
Hello World example:
Structure of Android Application
12
Some incompatibilities to solve
Incompatibilities with JamaicaVM
13
Incompatibilities - 1
javax.swing
java.awt
java.tools
java.rmi
...
java.io
java.tools
java.util
java.lang
android.app
android.graphics
android.os
android.content
Android API
Jamaica API
Incompatibilities with JamaicaVM
14
Incompatibilities - 2
public static void main(String args[])
protected void onCreate(Bundle bundle)
Incompatibilities with JamaicaVM
15
Incompatibilities - 3
Graphics components are not created in the source code but are
declared in the activity_main.xml file.
Incompatibilities with JamaicaVM
16
Proposed Solution
Adapter Design Pattern
– Adapter pattern (also known as Wrapper) allows classes that normally
could not work together, because of incompatible interfaces, to work
together.
Proposed Solution
17
Different APIs
android.app
android.graphics
android.os
android.content
Android API
...
Adaptee classes
android.app
android.graphics
...
Proposed Solution
Android classes for JamaicaRE
18
main() method non-existent
Wrapper
 onCreate()
 {
  doSomething();
 }
Android code
 public static void main()
     {
        onCreate();
     }
Adaptee classes
android.app
android.view
...
Proposed Solution
19
Get graphic components from XML file
1 - Parse the xml file
2 – Map objects into graphic components
3 – Draw graphic components
1
3
1
2
Proposed Solution
20
Android Wrapper
XML Parser
●TreeGraphicNode
●GraphicNodeParser
Graphic manager
●GraphicDrawer
Wrapper
●Activity
●AndroidWrapper
Adaptee classes
AndroidWrapper Solution
21
TreeGraphicNode
String androidID
String graphicElement
String marginLeft
...
...
List<TreeGraphicNode>
TreeGraphicNode
Attributes
Children
Parent
AndroidWrapper Solution – XML Parser
22
GraphicNodeParser
Linear
Layout
Edit
Text
Button Radio
Group
Radio
Button
Radio
Button
DOM parent = null;
AndroidID = layout1;
GraphicElement = LinearLayout;
Children = 0x7fff9465a02f;
Parent = 0x7fff9575c05f; 
AndroidID = text1;
GraphicElement = TextView;
Children = null;
Parent = 0x7fff9575c05f; 
AndroidID = button1;
GraphicElement = Button;
Children = null;
Parent = 0x7fff9575c05f; 
AndroidID = group1;
GraphicElement = RadioGroup;
Children = 0x7fff4711b09f;
Parent = 0x7fff2311d01f, 
AndroidID = radio1;
GraphicElement = RadioButton;
Children = null;
Parent = 0x7fff2311d01f; 
AndroidID = radio2;
GraphicElement = RadioButton;
Children = null;
AndroidWrapper Solution – XML Parser
What it does?
● Create an instance of TreeGraphicnode from the DOM
23
Android Wrapper
XML Parser
●TreeGraphicNode
●GraphicNodeParser
Graphic manager
●GraphicDrawer
Wrapper
●Activity
●AndroidWrapper
Adaptee classes
24
GraphicDrawer
Twomain tasks:
1. Createthescreen surface
2. Draw graphic componentsinto thescreen
AndroidWrapper solution - Graphic manager
25
Create the screen surface
➢ Createthemain frame
➢ Createthecommand panel
➢ Createtheactivity panel
MainFrame
CommandPanel
ActivityPanel
AndroidWrapper solution - Graphic manager
26
Draw graphic components into the screen
Two phases:
➢Draw graphic components written in the xml
➢Add components to the screen
AndroidWrapper solution - Graphic manager
27
Draw components
parent = null;
AndroidID = layout1;
GraphicElement = LinearLayout;
Children = 0x7fff9465a02f;
Parent = 0x7fff9575c05f; 
AndroidID = text1;
GraphicElement = TextView;
Children = null;
Parent = 0x7fff9575c05f; 
AndroidID = button1;
GraphicElement = Button;
Children = null;
Parent = 0x7fff9575c05f; 
AndroidID = group1;
GraphicElement = RadioGroup;
Children = 0x7fff4711b09f;
Parent = 0x7fff2311d01f, 
AndroidID = radio1;
GraphicElement = RadioButton;
Children = null;
Parent = 0x7fff2311d01f; 
AndroidID = radio2;
GraphicElement = RadioButton;
Children = null;
button1button1
radio1
radio2
group1
text1
layout1
drawComponent(nod
e)
Graphic manager – Draw components into the screen
 Key
layout1
text1
button1
group1
radio1
radio2
Value
componentsMap
28
Add components to the screen
parent = null;
AndroidID = layout1;
GraphicElement = LinearLayout;
Children = 0x7fff9465a02f;
 Key
layout1
text1
button1
group1
radio1
radio2
Value
componentsMap
layout1
layout1
Graphic manager – Draw components into the screen
29
Android Wrapper
XML Parser
●TreeGraphicNode
●GraphicNodeParser
Graphic manager
●GraphicDrawer
Wrapper
●Activity
●AndroidWrapperer
Adaptee classes
AndroidWrapper solution
30
MainActivity.java
public class MainActivity extends Activity 
{  
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);  
        TextView 
textView=(TextView)findViewById(R.id.textView1);
        textView.setText("Hello World");
    }
}
Hello World example:
AndroidWrapper solution - Wrapper
31
Activity
The Activity adaptee class is responsible to instantiate a
GraphicDrawer and get the graphic from it.
protected void onCreate(Bundle bundle)
{
graphicDrawer = new GraphicDrawer(bundle);
graphicDrawer.generateGraphic();
}
layout1
button1button1
radio1
radio2
text1
group1
AndroidWrapper solution - Wrapper
32
AndroidWrapper
Two simple tasks:
1. Class R = 
Class mainActivity = 
File xmlFile  =
R.java
activity_main.xml
MainActivity.java
2. public static void main(String arg[])
   {
     mainActivity.onCreate(new 
Bundle(R,xmlFile))
   }
AndroidWrapper solution - Wrapper
33
Android Wrapper
XML Parser
●TreeGraphicNode
●GraphicNodeParser
Graphic manager
●GraphicDrawer
Wrapper
●Activity
●AndroidWrapper
Adaptee classes
AndroidWrapper solution
34
Adaptee classes
To work correctly, the Adapter must find the JamaicaVM version of the
classes requested by the MainActivity.
JamaicaRE
android.app.Activity
android.widget.TextView
...
   MainActivity.java
import android.app.Activity;
import android.widget.TextView;
....
public void onCreate()
{
       ......
.....
}
.....
AndroidWrapper solution
35
Adaptee classes
Solution:
– Write all Android classes ad-hoc for JamaicaVM
Positive aspect Negative aspect
AndroidWrapper solution
36
Positive aspect
Maximum compatibility with JamaicaVM
– Classes written ad-hoc for JamaivcaVM
AndroidWrapper solution
37
Negative aspect
Reproduce the whole Android Runtime Environment:
● The number of the classes is very enormous
● The complexity is not always low
AndroidWrapper solution – Adaptee classes
38
– not always:
Three scenarios:
1) Need to write the class from zero
2) Wrap the class with an equivalent one
3) Use the original class
Adaptee classes - complexity
AndroidWrapper solution
39
 Mercury
Adaptee classes
1) Write a class from zero
Example: android.widget.ListView
 Venus
 Earth
 Mars
 ....
JPanel JScrollBar
JLabel
AndroidWrapper solution
40
Adaptee classes
2) Wrap the class with an equivalent one
Example: android.widget.Button
public Class Button extends 
JButton
{
   public Button(String text)
   {
      super(text);
   }
   ....
}
AndroidWrapper solution
41
Adaptee classes
3) Use the original class
- When Android classes use only objects of Java
e.g android.util.TextUtils
AndroidWrapper solution
javax.swing
java.awt
java.tools
java.rmi
...
java.io
java.tools
java.util
java.lang
android.app
android.graphics
android.os
android.content
Android API
Java API
42
Summary: full route
AndroidWrapper solution
43
44
DEMO
45
Questions?
46
Thank you
47
Adaptee classes
Complexity for reproduce the whole Android Runtime Environment
Complexity
Activity
Classes
Textutils Button TextView
low
medium
high
Parcelable Resources
Use original class
Wrap with equivalent class
Write from zero
average 
complexity
...
AndroidWrapper solution
48
Sequence diagram
AndroidWrapper solution - Wrapper

More Related Content

PPTX
Wf ms cloud evaluation 4caast
PPT
P2p cdn
PDF
Getting Started with Android - OSSPAC 2009
PDF
Begining Android Development
PPTX
JS digest. February 2017
PPTX
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
PDF
Introduction to Android - Mobile Portland
PDF
Android workshop material
Wf ms cloud evaluation 4caast
P2p cdn
Getting Started with Android - OSSPAC 2009
Begining Android Development
JS digest. February 2017
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
Introduction to Android - Mobile Portland
Android workshop material

Similar to Tech Talk Project Work (20)

PDF
Hacking the Codename One Source Code - Part IV - Transcript.pdf
PPTX
Code Obfuscation for Android & WP7
PDF
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
PDF
PT GTUG 1st Technical Tession - Android
PDF
Workshop su Android Kernel Hacking
PDF
An Introduction To Android
PPTX
Android Performance Tips & Tricks
PPTX
Сергей Жук "Android Performance Tips & Tricks"
PDF
Profiling Android Applications
PDF
[Android] Introduction to Android Programming
PPTX
Wayland: Is It Ready Yet?
ODP
PPTX
Ii 1300-java essentials for android
PDF
Android Attacks
PDF
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
PDF
React Native
PPT
Synapseindia android apps application
PDF
[Android] Multiple Background Threads
PPTX
Languor
PDF
Inside Android's UI at AnDevCon V
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Code Obfuscation for Android & WP7
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
PT GTUG 1st Technical Tession - Android
Workshop su Android Kernel Hacking
An Introduction To Android
Android Performance Tips & Tricks
Сергей Жук "Android Performance Tips & Tricks"
Profiling Android Applications
[Android] Introduction to Android Programming
Wayland: Is It Ready Yet?
Ii 1300-java essentials for android
Android Attacks
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
React Native
Synapseindia android apps application
[Android] Multiple Background Threads
Languor
Inside Android's UI at AnDevCon V
Ad

More from Antonio Cesarano (8)

PDF
Inspire JSON Merger
PPTX
Erasmus Traineeship Report @ RedHat
PPTX
Lost John - Mobile Game Development
PPT
Pitch ItLosers - TechGarage 2014
PDF
Project Proposal - Project Management
PDF
Project management - Final Report
PPTX
Threads and multi threading
PPTX
Cluster based storage - Nasd and Google file system - advanced operating syst...
Inspire JSON Merger
Erasmus Traineeship Report @ RedHat
Lost John - Mobile Game Development
Pitch ItLosers - TechGarage 2014
Project Proposal - Project Management
Project management - Final Report
Threads and multi threading
Cluster based storage - Nasd and Google file system - advanced operating syst...
Ad

Recently uploaded (20)

PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
Website Design Services for Small Businesses.pdf
PDF
DNT Brochure 2025 – ISV Solutions @ D365
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
most interesting chapter in the world ppt
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PDF
E-Commerce Website Development Companyin india
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PPTX
Computer Software - Technology and Livelihood Education
PDF
Guide to Food Delivery App Development.pdf
PDF
Visual explanation of Dijkstra's Algorithm using Python
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Introduction to Windows Operating System
PPTX
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Website Design Services for Small Businesses.pdf
DNT Brochure 2025 – ISV Solutions @ D365
How to Use SharePoint as an ISO-Compliant Document Management System
Salesforce Agentforce AI Implementation.pdf
Topaz Photo AI Crack New Download (Latest 2025)
most interesting chapter in the world ppt
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
E-Commerce Website Development Companyin india
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Full-Stack Developer Courses That Actually Land You Jobs
Wondershare Recoverit Full Crack New Version (Latest 2025)
Computer Software - Technology and Livelihood Education
Guide to Food Delivery App Development.pdf
Visual explanation of Dijkstra's Algorithm using Python
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Introduction to Windows Operating System
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx

Tech Talk Project Work