470 likes | 504 Views
Business Cards Application for Android Final presentation. Prepared By: Eyal Segal Koren Shoval Advisor: Nathaniel Azuelos. Presentation Overview. Project Goals About the Application Working Environment Android SDK About Android Framework Class Diagrams Business card application
E N D
Business Cards Application for AndroidFinal presentation Prepared By: Eyal Segal Koren Shoval Advisor: Nathaniel Azuelos
Presentation Overview • Project Goals • About the Application • Working Environment • Android SDK • About Android • Framework • Class Diagrams • Business card application • Edit • Use Cases & Class Diagrams • Browse • Use Cases & Class Diagrams • Bluetooth & Encryption • Use Cases, Sequence Diagrams & Class Diagrams • Memory considerations • UI Demo
Project Goals • Create an application for managing business cards • Learn and use Android API • Build a graphical user interface • Examine data exchange on mobile devices • Communication via Bluetooth • Considering encryption & authentication
About the Application • Design your own business cards • Use your own pictures as backgrounds • Customize fonts, colors and layout • Browse, search and organize your business cards collection • Two browsing styles • Manage custom folders • Share your business cards with your colleagues using bluetooth • Supports secured transmission
Working Environment • Operating system • Windows Vista x86 • Development tools • Eclipse IDE for java • Android SDK • Android emulators • Eclipse memory analyzer • Android devices • HTC desire, HTC magic • Android 2.2 (Froyo)
Application block diagram • Our code is based on 3 layers Business card application Framework Android SDK
About Android • Operating System for mobile devices • Open source • Developed by Google • Uses a modified version of the Linux kernel • Allows developers to write code in Java language • Android API • We are using API level 8 (version 2.2)
Application block diagram • Our code is based on 3 layers Business card application Framework Android SDK
FrameworkApplication block diagram • Enable & visualize logging. • Used mainly by bluetooth service. • Reusable code components • Implements non-standard Android abilities & functionality • Based on Android SDK • Used for accepting • Incoming bluetooth • messages and processing • application requests in • the background. • Runs independently from • the application. • Manange and extends android • notifications. • Used by background service to • alert user about new events Framework Utilities User interface Services Graphics Gallery view Background service • Threads for accepting, • sending and receiving • messages via bluetooth • with or without encryption Animations Explorer view Storage Swipe Color picker Notifications Watchdog Device picker Preferences Logger Misc. views Bluetooth Fonts & Resources Misc. dialogs Encryption
Class Diagrams • Background Service • Storage Service • Notification Service
Application block diagram • Our code is based on 3 layers Business card application Framework Android SDK
Business cards app.Application block diagram Edit personal cards. Set personal information as well as setting background, fonts, colors and layout. • Specific code for business cards logic • use cases • user interface • structures Business cards application Utilities User interface Contacts Editor Business cards painter Browse by tabs Themes manager Browse by folders Send card via bluetooth
Use cases • Editor • 1.1 Create card • 1.2 Edit card • 1.3 Create item layout • 1.4 Edit item layout • 1.5 Position item on a card • 1.6 Manage all items • 1.7 Create new theme from a card • 1.8 Apply a theme • 1.9 Set background from android gallery
Use cases • 1.1Create • 1.1.1 User starts card editor (from main) • 1.1.2 A card is generated using the default theme • 1.1.3 A popup screen opens and lets user edit item values • 1.1.4 User edits default items and clicks “save” • 1.1.5 The popup closes showing the editor surface. • 1.1.6 The user clicks on menu option “save as” and saves the card • 1.1.7 A save dialog opens and the user selects where to save the • card and its filename. • 1.1.8 Users clicks “ok” and the card is saved. • Exceptions • 1.1.4User clicks “cancel” or presses the back button in the popup • screen and the changes are ignored. • 1.1.8 User clicks “cancel” in save dialog
Use cases • 1.3Create item layout • Starts at the editor surface • 1.3.1 User clicks on menu option “Add Item” • 1.3.2 Layout dialog opens with the item’s information • 1.3.3 User editsitem’s text content • 1.3.5 User updates item’s type, style and color • 1.3.6 User clicks on “ok” button to save the changes • 1.3.7 Editor gets back the updated item, save the changes to the card and • updates the surface • Exceptions • 1.3.7User clicks “cancel” or presses the back button in the dialog • screen and the changes are ignored.
Use cases • 1.5 Position item on card • Starts at the editor surface • 1.5.1 User clicks on an item • 1.5.2 Editor surface shows edit, remove and drag buttons and a frame • around the item • 1.5.3 The user presses on the surface inside the frame or on the drag • button and drags the item on the surface to its new position • 1.5.4 The editor surface saves the changes to the card • Exceptions • 1.5.2User clicks outside of the item’s frame to cancel the item’s • selection.
Use cases • 1.8 Apply a theme • Starts at the editor surface • 1.8.1 User clicks on menu option “Set Theme” • 1.8.2 A themes gallery popup with the first theme applied to the card. • 1.8.3 User swipes left or right to iterate between themes, • each swipe alters the layout of the card according to the current • theme. • 1.8.4 User clicks on “Select theme” and the theme is set on the card • 1.8.5 Editor gets the result back from the themes gallery and set the • updates business card on the surface. • Exceptions • 1.8.4User clicks the back button and the changes are ignored.
Editor Activity - Class Diagram Business card application Framework Android SDK
View & manage • business cards. • Send email, • sms, call and • More. Send • cards via BT • and edit • personal cards. Business cards app.Application block diagram • View & manage business cards. • Send email, sms, call and more. • Send cards via BT and edit personal cards. • Specific code for business cards logic • use cases • user interface • structures Business cards application Utilities User interface Contacts Editor Business cards painter Browse by tabs Themes manager Browse by folders Send card via bluetooth
Use cases • Browse • 2.1 Browse for a card • 2.2 Search for a card • 2.3 Create folder • 2.4 Rename folder • 2.5 Delete folder • 2.6 Use business card (SMS, Call, Email, etc.) • 2.7 Move a card between folders
Use cases • 2.1 Browse for a card (tab activity) • 2.1.1 User clicks on “browse” button at main • 2.1.2 Browse activity opens up to show the default search tab • 2.1.3 User selects the folder with the card by clicking the folder’s tab • 2.1.4 The tabs view updates the list of cards to • display the cards in the current folder • 2.1.5 User scrolls to the requested card • and clicks on the card to select it
Use cases • 2.3 Create folder (tab activity) • Starts at tabs view • 2.3.1 User clicks the “New…” tab or chooses menu option “Create folder” • 2.3.2 An input dialog pops up • 2.3.3 User inserts the new folder name and clicks “Ok” button • 2.3.4 The folder is created and appears as a tab • Exceptions • 2.3.3User clicks the back button or “Cancel” button and the folder is • not created. • 2.3.3 User enters an existing name. The current tab is changed to the • existing tab, and no new folder is created • 2.3.3 User enters a forbidden name (“New…”, “Contacts”, “Search”). • No folder is created and the last used tab is active again
Use cases • 2.5 Delete folder (tab activity) • Starts at tabs view • 2.5.1 User selects a specific folder by clicking its tab • 2.5.2 User chooses menu option “Delete folder” • 2.5.3 A confirmation dialog pops up • 2.5.4 User clicks “Ok” button and the folder is deleted • Exceptions • 2.5.4User clicks the back button or “Cancel” button and the folder • is not deleted.
Tabs Activity - Class Diagram Business card application Framework Android SDK
Business cards app.Application block diagram • Specific code for business cards logic • use cases • user interface • structures Business cards application Utilities User interface Contacts Editor Business cards painter Browse by tabs Themes manager Browse by folders Send card via bluetooth
BluetoothVersion 2.1 • Bluetooth is a proprietary open wireless technology standard for exchanging data over short distances • The Bluetooth specifications are developed and licensed by the Bluetooth Special Interest Group(SIG). • consists of more than 13,000 companies • low power consumption • Maximum application throughput is 1.4Mbit/sec • Maximum distance of 100 meters (class 1)
BluetoothOn Android • Bluetooth 2.1 • Supported protocols • SDP – Service discovery protocol • allows a device to discover services supported by other devices • Each service is identified by a Universally Unique Identifier(UUID) • RFCOMM - Serial Port Emulation • provides a simple reliable data stream to the user, similar to TCP • The Bluetooth APIs let applications: • Scan for other Bluetooth devices • Query the local Bluetooth adapter for paired Bluetooth devices • Establish RFCOMM channels/sockets • Connect to specified sockets on other devices • Transfer data to and from other devices
Use cases • Bluetooth • 3.1 Send business card via Bluetooth • 3.2 Receive a business card
Use cases • 3.1 Send business card via Bluetooth (1) • Starts at tabs view with a selected card • 3.1.1 User clicks on menu option "Send” • 3.1.2 Device picker opens up with a list of paired devices • 3.1.3 User clicks on a device • 3.1.4 Connection is made with the device • 3.1.5 The card is sent to the remote device • 3.1.6 Application waits for a status response • 3.1.7 Application displays the status to the user • - Branch • 3.1.3b If the device is not in the known device list • 3.1.3b.1 User clicks on “Scan for new devices” • 3.1.3b.2 Application request device detection • 3.1.3b.3 Each detected device is added to the list • 3.1.3b.4 User clicks on a device • 3.1.3b.5 Continue to step 3.1.4
Use cases • 3.1 Send business card via Bluetooth (2) • - Branch (2) • 3.1.5b If encryption is enabled • 3.1.5b.1 Application asks user for a password • 3.1.5b.2 User inserts an agreed upon password and clicks “ok” • 3.1.5b.3 Application starts the EKE protocol to agree on a secret key • 3.1.5b.4 Application sends an encrypted card using the key • 3.1.5b.5 Continue to step 3.1.6 • Exception • 3.1.1 If bluetooth is not enabled ask user to enable bluetoot • 3.1.1.1 If user clicks “cancel” the operation is canceled and • the application return to the browser view • 3.1.4 Connection to remote device fails • 3.1.4.1 Display error message • 3.1.5b.3 Authentication fails • 3.1.5b.3.1 Display error message and abort operation • 3.1.6 Read timeout exception • 3.1.6.1 Display unknown response message
Use cases • 3.2 Receive a business card (1) • Service listens for an incoming connection • 3.2.1 A remote device a connection is accepted • 3.2.2 Service forks the socket to a receive handler • 3.2.3 Receiver reads the data from the remote device • 3.2.4 Receiver notifies the user about an incoming card • 3.2.5 Receiver saves the card to the default “received” folder • 3.2.6 Receiver sends the status (Accepted, Refused, Failed) to the remote device • - Branch (1) • 3.2.3b If the message is encrypted • 3.2.3b.1 Receiver opens a password dialog • 3.2.3b.2 User inserts a password and clicks on “ok” • 3.2.3b.3 Receiver start the EKE protocol • 3.2.3b.4 Receiver reads encrypted data from the remote device
Use cases • 3.2 Receive a business card (2) • - Branch (2) • 3.2.5b If the preference for “confirmation dialog” is checked • 3.2.5b.1 Receiver open a save card dialog, showing the card • 3.2.5b.2 User selects the location to save and clicks “ok” • 3.2.5b.3 Receiver saves the card to that location • 3.2.5b.4 Continue with step 3.2.6 • Exceptions • 3.2.1 If bluetooth is not enabled then nothing will happen • 3.2.3 Read timeout exception • 3.2.3.1 Display error message • 3.2.3b.3 Authentication fails • 3.2.3b.3.1 Display error message and abort operation
Send/Receive business card via bluetoothsequence diagram Sender Receiver Receiver • The background service creating listening thread • Listener thread waits for incoming connections Sender • User selects a card to send and a device to send to • The background service receives a request to send a message and creates sending thread • The sending thread connects to the remote device Receiver • The listening thread accepts the connection and creates a receiving thread • The receiving thread waits for an incoming message (blocking) If messageType = “Encrypted” setup encryption using EKE protocol
Send/Receive business card via bluetoothsequence diagram – cont. Sender Receiver Sender • The sending thread sends the message type Sender & Receiver • if message type is “Encrypted” then EKE protocol is started Receiver • Wait for incoming message Sender • Send the message to the remote device • Wait for status message Receiver • Receive message • Start registration block according to message type • Send status according to user answer If messageType = “Encrypted” setup encryption using EKE protocol
EncryptionEKE – Encrypted Key Exchange • A family of password authenticated key agreement methods • Based on Diffie-Hellman protocol • Protected against • Replay attack • resending client or server messages • Dictionary attack • trying out “dictionary” like passwords • Man in the middle attack • watch and understand the conversation between 2 users • Session hijacking • connecting to a pre-authenticated session and impersonate as one of the users
EncryptionOn Android • Easy to extend using javax.crypto.cipher package • Decorators over input/output stream • Supported cipher providers (need to select 3 parameters) • Algorithms: AES, DES, DES-EDE, RSA, PBE, etc. • Mode: None, CBC, CFB, ECB, OFB, PCBC • Padding: None, PKCS5, SSL3, OAEPwithMD5, etc. • Authentication • Supports Key generators such as • DH, AES, DES, HMacMD5, HMacSHA1, etc.
Encryption Algorithm EKE – Sequence diagram • Step 1 - Client A • Scrambles the password using function f • w=f(password) • Sends name and DH public key encrypted under w • Step 2 – Client B • Scrambles the password using function f • Computes common DH key k • K=g^ab mod p • Generates a random string – challenge B • Sends • DH public key encrypted under w • challenge B encrypted under k
Encryption Algorithm EKE – Sequence diagram • Step 3 – Client A • Computes common DH key k • Generates a random string – challenge A • Decrypts challenge B • Encrypts and sends challenge A || challenge B under k • This is the step where client A proves that he knows the common key k • Step 4 – Client B • Decrypts and extracts challenge A • Send challenge A encrypted under k • This is the step where client B proves that he knows the common key k
EncryptionEKE – Cont. • Protected against – Why? • Replay attack • Using random challenges in both sides • Dictionary attack • Hashing the password • Man in the middle attack • Based on shared password (known only to both sides) • Session hijacking • Using secret key to encrypt the entire session
Memory considerations • Android limits memory usage to 16mb per application • Using Eclipse memory analyzer & GC logs we traced the highest memory consumption in the code • Based on the results we refactored several parts of the code to reduce memory usage • Reduce bitmap processing • Minimized cache usage • Reduced business card size • Used disk as cache instead of memory
Sources • Google’s Android Developers • http://developer.android.com/index.html • Wikipedia • Bluetooth, encryption • Security in software applications - Course site • http://webcourse.cs.technion.ac.il/236350/Spring2010/en/ho_Lectures.html • Java docs • http://java.sun.com/j2se/1.4.2/docs/api/ • More…