SMS Communication Library Lee, Chia-Peng 2015/12/09 Outline What - - PowerPoint PPT Presentation

sms communication library
SMART_READER_LITE
LIVE PREVIEW

SMS Communication Library Lee, Chia-Peng 2015/12/09 Outline What - - PowerPoint PPT Presentation

PCS Term Project: SMS Communication Library Lee, Chia-Peng 2015/12/09 Outline What can this lib do? Architecture Prerequisite Data structure How to use this lib? Example : FindMe! Error reporting Reference


slide-1
SLIDE 1

PCS Term Project: SMS Communication Library

Lee, Chia-Peng 2015/12/09

slide-2
SLIDE 2

Outline

  • What can this lib do?
  • Architecture
  • Prerequisite
  • Data structure
  • How to use this lib?
  • Example :
  • Error reporting
  • Reference
  • API

FindMe!

slide-3
SLIDE 3

What can this lib do?

  • Record the SMS commands.
  • Record interacting devices.
  • Help parsing the command.
  • Make developers focus on designing services.
slide-4
SLIDE 4

CommandHandler # addExecutor Recorder Executor 1 Executor 2 … Database (Devices, Commands) SMS Service app SmsReceiver User input SMSCommunicate Executor filter

Architecture

slide-5
SLIDE 5

Prerequisite

  • 1. T
  • ol : Eclipse + ADT
  • 2. Media : JSONObject
  • 3. Database : SQLite
slide-6
SLIDE 6
  • 1. Tool : Eclipse + ADT

http://www.eclipse.org/ http://developer .android.com/

slide-7
SLIDE 7
  • 2. Media : JSONObject

http://www.json.org/ JSONObject JavaDoc : http://www.json.org/javadoc/org /json/JSONObject.html

slide-8
SLIDE 8
  • 3. Database SQLite

http://www.sqlite.org/ Android Support API http://developer .android.com/reference/andro id/database/sqlite/SQLiteDatabase.html

slide-9
SLIDE 9

Data structure (SQLite)

Device info : (可以在 String[] Recorder . DEVICES_TABLE_COLUMNS取得清單與順序) Command info : (可以用 String[] Recorder . COMMANDS_T ABLE_COLUMNS取得清單與順序)

Column name Data type Description id integer Primary key name varchar(32) Device’s display name phonenumber varchar(16) Device’s phonenumber Column name Data type Description id integer Primary key timestamp timestamp Created timestamp count integer age of msg role boolean Active(TRUE)/Passive(FALSE) device_id integer From/to which device command varchar(16) Command name content varchar(512) Content (JSONString)

slide-10
SLIDE 10

How to use this lib?

1. Setting up environment

a) Import library b) Set app permission c) Register receiver to “SmsReceiver”

2. Creating your own “Executor”

a) Flow chart of message passing b) Implement “Executor” and recommended style

3. Using “Recorder” and “CommandHandler”

a) Initialize at the beginning of the program b) Accessing database via “Recorder” c) Add implemented executors

4. Invoke Executor

a) Usual condition b) Dealing with asynchronous condition

slide-11
SLIDE 11
  • 1. Setting up environment
slide-12
SLIDE 12

1 – a : Import library

slide-13
SLIDE 13

1 – b : Set app permission

AndroidManifest.xml (before <application>)

slide-14
SLIDE 14

1 – c : Register receiver to “SmsReceiver”

AndroidManifest.xml (Inside <application>)

slide-15
SLIDE 15
  • 2. Creating your own “Executor”
slide-16
SLIDE 16

2 – a : Flow chart of message passing

SmsReceiver CommandHandler Executor SmsReceiver CommandHandler Executor Device A Device B (i) (ii) (iii) cnt : 0, role : 1 (true) cnt : 1, role : 0 (false) cnt : 2, role : 1 (true) cnt : 0, role : 0 (false) cnt : 1, role : 1 (true) cnt : 2, role : 0 (false)

slide-17
SLIDE 17

2 – b : Implement “Executor” and recommended style

slide-18
SLIDE 18
  • 3. Initialize “Recorder” and

“CommandHandler”

slide-19
SLIDE 19

3 – a : Initialize at the beginning of the program

slide-20
SLIDE 20

3 – b : Accessing database via “Recorder”

slide-21
SLIDE 21

3 – c : Add implemented executors

slide-22
SLIDE 22
  • 4. Invoke Executor
slide-23
SLIDE 23

4 – a : Usual condition

slide-24
SLIDE 24

4 – b : Dealing with asynchronous condition

slide-25
SLIDE 25

Example : FindMe!

https://dl.dropbox.com/u/12632228/SMSDoc/downloads/FindMe.apk

slide-26
SLIDE 26

Reference:

  • SmsCommunicateLibrary.jar

http://tinyurl.com/smsclibv1-0

  • SmsCommunicateLibrary JavaDoc

http://tinyurl.com/smsclibjavadoc

  • Android Developer

http://developer .android.com/

  • Android Package JavaDoc

http://developer .android.com/reference/

  • SQLite

http://www.sqlite.org/

  • Eclipse

http://www.eclipse.org/

slide-27
SLIDE 27

API – CommandHandler

# CommandHandler

static CommandHandler init(Context context) static CommandHandler getSharedRecorder() void Execute(String cmd, int device_id, int count, JSONObject usr_json)

slide-28
SLIDE 28

API – Recorder Database

# Recorder Database

static Recorder init(Context context, String db_name) static Recorder getSharedRecorder() void deleteDevicesAndCommandsTable(SQLiteDatabase db)

slide-29
SLIDE 29

API – Table “devices”

# T able “devices”

void changeDeviceNameById(SQLiteDatabase db, int device_id, String new_name) void createDevice(SQLiteDatabase db, String name, String phonenumber) void deleteDeviceById(SQLiteDatabase db, int device_id) void deleteDeviceByPhonenumber(SQLiteDatabase db, String phonenumber) Object[][] getAllDevices(SQLiteDatabase db) Object[] getDeviceByID(SQLiteDatabase db, int device_id) int getDeviceIdByPhonenumberOrCreate(SQLiteDatabase db, String phonenumber)

slide-30
SLIDE 30

API – Table “commands”

# T able “commands”

void saveCommand(SQLiteDatabase db, boolean role, int device_id String command , String content) void createDevice(SQLiteDatabase db, String name, String phonenumber) void deleteCommandById(SQLiteDatabase db, int command_id) void deleteCommandByDeviceId(SQLiteDatabase db, int device_id) Object[][] getAllCommands(SQLiteDatabase db)

slide-31
SLIDE 31