A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

44
e Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka Un A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences Tetsuya Kanda, Yuki Manabe, Takashi Ishio, Makoto Matsushita, Katsuro Inoue Graduate School of Information Science and Technology, Osaka University, Japan

description

A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences. Tetsuya Kanda, Yuki Manabe , Takashi Ishio , Makoto Matsushita, Katsuro Inoue. Graduate School of Information Science and Technology, Osaka University, Japan. - PowerPoint PPT Presentation

Transcript of A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Page 1: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

A Prototype of Comparison Tool for Android Applications Based on Difference

of API Calling Sequences

Tetsuya Kanda, Yuki Manabe, Takashi Ishio,Makoto Matsushita, Katsuro Inoue

Graduate School of Information Science and Technology, Osaka University, Japan

Page 2: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Many Applications in the World

• Many applications are available– from Android Market– from Apple App Store ...

• We focused on Android applications.• Some applications have similar features

– About 3,000 “calculator” applications in Android Market (May 2011)

2

Page 3: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Similar Applications

• Screenshots of Android applications labeled “Map” in Google Code

3

Page 4: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Similar Applications

• Screenshots of Android applications labeled “Map” in Google Code

4

What is the difference of these applications?

Page 5: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Differences of the Applications

ID App A App B App C App DAlert Dialog ✓ ✓ ✓ ✓Get Latitude and Longitude ✓ ✓ ✓

Show Toast(pop-up message) ✓ ✓ ✓

Set Latitude and Longitude ✓

• Make comparison chart to clarify differences

5

Page 6: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

How to Compare Applications

6

• Trial use of applications– Can’t test ALL features in applications

• Users can’t test the feature they don’t know.– Takes a lot of time

• Reading documents– Some documents are too long to understand.– Some documents have too little information.– Some applications have no documents.

• Comparing source code

Page 7: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Comparing source code• Source code explains almost all behavior

of the applications.• Can’t compare directly

– Almost all of source code will be extracted as differences.

7

+ if (colIndex > -1) {+ inReplyTo = mCursor.getString(colIndex);+ if (inReplyTo != null && "null".equals(inReplyTo) == false) {+ inReplyTo = String.format(Locale.getDefault(), getText(R.string.tweet_source_in_reply_to).toString(), inReplyTo); }- terp_handler = new Handler() {- public void handleMessage(Message m) {- switch (m.arg1) {- case -1:

Comparing two twitter client applications

Page 8: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Android

• A platform for mobile devices• Android smartphones have many

characteristic devices.– Wi-Fi adaptor– GPS– Touch panels– Gravity sensors– Cameras– etc…

8

Page 9: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Display a map ofcurrent location

Features

Features and Devices

• Features correspond to devices.

9

Get current location

Scroll Map

GPS

Touch panel

Application Devices

Page 10: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Display a map ofcurrent location

Features

Features, APIs and Devices

• Application controls devices by calling APIs.

10

Get current location

Scroll Map

GPS

Touch panel

Application Devices

APIs for controlling a GPS device

APIs for controlling a touch panel

SDK

Page 11: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Idea

• A feature calls APIs to control devices.• An API calling sequence corresponds

to a feature.– an API calling sequence: a sequence of

method calls of API classes in a single method• Compare APIs to compare features of

applications– The difference of API calls represents the

difference of features.11

Page 12: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

  

Proposal Method

Applications

Applications

Applicationswith similar

feature

Phase1: Making a

knowledge-base

Knowledge-base

Phase 2: Comparing

applications

ApplicationX1

ApplicationX2

Common-Feature

X1 -Feature X2 -FeatureProposal method

12

Page 13: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

  

Proposal Method

Applications

Applications

Applicationswith similar

feature

Phase1: Making a

knowledge-base

Knowledge-base

Phase 2: Comparing

applications

ApplicationX1

ApplicationX2

Common-Feature

X1 -Feature X2 -FeatureProposal method

13

Page 14: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Knowledge-base

• Mappings of API calling sequence and its feature name

• Example:

14

Feature name API calling sequencesShow Toast(pop-up message)

android.widget.Toast.makeTextandroid.widget.Toast.show

Get Latitude and Longitude

android.location.Location.getLatitudeandroid.location.Location.getLongitude

Page 15: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Making a Knowledge-base

Knowledge-base

A.m1()

B.m2()

B.m2()

C.m1()

A.m1()

B.m2()

B.m2()

C.m1()

Feature2

ExtractAPI calls

Filtering Filtering

COMMON

15

Assign afeature name

ApplicationsApplicationsApplicationswith similar

feature

1. Collect applications with similar feature

2. Extract API calls appeared in two or more applications (COMMON)

3. Filter COMMON manually and assign a feature name

(Removed)

Page 16: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Making a Knowledge-base

Knowledge-base

A.m1()

B.m2()

B.m2()

C.m1()

A.m1()

B.m2()

B.m2()

C.m1()

Feature2

ExtractAPI calls

Filtering Filtering

COMMON

16

Assign afeature name

ApplicationsApplicationsApplicationswith similar

feature

(Removed)1. Collect applications with similar feature

2. Extract API calls appeared in two or more applications (COMMON)

3. Filter COMMON manually and assign a feature name

Page 17: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Extract API Calls• Each method is translated into an API

calling.• Extract only Android API calls• We define Android API as:

– Whose fully qualified names start with “android” or “com.google.android”

• Ignore control statement

17

Page 18: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Example of extracting API Calls

18

public void onClick(View v) { String s = str.substring(2); Intent intent=new Intent(this,com.example.edit.class); startActivity(intent);}

android.content.Intent.android.content.Intentandroid.app.Activity.startActivity

Source Code

API Calling Sequence

1

1

2

2

Page 19: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Making a Knowledge-base

Knowledge-base

A.m1()

B.m2()

B.m2()

C.m1()

A.m1()

B.m2()

B.m2()

C.m1()

Feature2

ExtractAPI calls

Filtering Filtering

COMMON

19

Assign afeature name

ApplicationsApplicationsApplicationswith similar

feature

1. Collect applications with similar feature

2. Extract API calls commonly appeared (COMMON)

3. Filter COMMON manually and assign a feature name

(Removed)

Page 20: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Filtering(1/2)

20

• Manually remove API calling sequences that are not explaining a specific feature

• Criteria:– Control or get information using devices– Showing notification (dialog)– Using Intent (call for another application)

Feature name API calling sequences

??? android.widget.TextView.setTextandroid.view.View.setVisibility

??? android.location.Location.getLatitudeandroid.location.Location.getLongitude

Page 21: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Filtering(2/2)

21

• Manually remove API calling sequences that are not explaining a specific feature

• Criteria:– Control or get information using devices– Showing notification (dialog)– Using Intent (call for another application)

Feature name API calling sequences

??? android.widget.TextView.setTextandroid.view.View.setVisibility

Get Latitude and Longitude

android.location.Location.getLatitudeandroid.location.Location.getLongitude

Page 22: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

  

Proposal Method

Applications

Applications

Applicationswith similar

feature

Phase1: Making a

knowledge-base

Knowledge-base

Phase 2: Comparing

applications

ApplicationX1

ApplicationX2

Common-Feature

X1 -Feature X2 -FeatureProposal method

22

Page 23: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Comparing Applications

2323

A.m1()

B.m2()

D.m2()

B.m3()

  

  

  

Application X1

Application X2

A.m1()

B.m2()

B.m3()

C.m1()

D.m4()

DIFF-X1 COMMON DIFF-X2

Common-Feature

X1 -Feature X2 -Feature

Extract API calls

Extract API calls

Knowledge-base

API Calling Sequences

Compare

Check CheckCheck

Page 24: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Comparing Applications

2424

A.m1()

B.m2()

D.m2()

B.m3()

  

  

  

Application X1

Application X2

A.m1()

B.m2()

B.m3()

C.m1()

D.m4()

DIFF-X1 COMMON DIFF-X2

Common-Feature

X1 -Feature X2 -Feature

Extract API calls

Extract API calls

Knowledge-base

API Calling Sequences

Compare

Check CheckCheck

Page 25: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Compare API CallingSequences (1/3)

25

API calling sequencefrom Application X1

A.m1()B.m2()B.m3()C.m1()D.m4()

B.m3()A.m1()B.m2()D.m2()B.m3()

API calling sequencefrom Application X2

Page 26: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Compare API CallingSequences (2/3)

26

A.m1()B.m2()

API calling sequencefrom Application X1

COMMON

A.m1()B.m2()B.m3()C.m1()D.m4()

B.m3()A.m1()B.m2()D.m2()B.m3()

Compare

API calling sequencefrom Application X2

Page 27: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Compare API CallingSequences (3/3)

27

A.m1()B.m2()

B.m3()C.m1()D.m4()

D.m2()B.m3()

API calling sequencefrom Application X1

DIFF-X1 COMMON

B.m3()

A.m1()B.m2()B.m3()C.m1()D.m4()

B.m3()A.m1()B.m2()D.m2()B.m3()

Compare

DIFF-X2

API calling sequencefrom Application X2

Page 28: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Compare Two Applications

2828

A.m1()

B.m2()

D.m2()

B.m3()

  

  

  

Application X1

Application X2

A.m1()

B.m2()

B.m3()

C.m1()

D.m4()

DIFF-X1 COMMON DIFF-X2

Common-Feature

X1 -Feature X2 -Feature

Extract API calls

Extract API calls

Knowledge-base

API Calling Sequences

Compare

Check CheckCheck

Page 29: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Check with a Knowledge-base

29

D.m2()

B.m3()

Knowledge-base

B.m2()B.m3()C.m1()D.m4()

A.m1()B.m2()

A.m1()

B.m2()

D.m2()

B.m3()

B.m2()

B.m3()

C.m1()

Feature1

Feature2

Feature3

COMMON

DIFF-X1

DIFF-X2

A.m1()

B.m3()

B.m2()Match

Match

Match

NotMatch

Page 30: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Prototype Tool : Startup Window

30

Select target applications

Page 31: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Prototype Tool : Showing Result

31

Select oneFeature name and

API calling sequence

Information about each API calling

sequence

ExtractedCommon-feature

ExtractedX1-feature

ExtractedX2-feature

Page 32: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Case Study

• Goal : To answer the following questions– RQ1 Does an API calling sequence correspond

to a feature of an application?– RQ2 Is our prototype tool able to clarify

differences of two applications?• Target :

– 11 applications labeled “MAP” in Google code

32

Page 33: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Process

1. Make a knowledge-base with 6 applications

2. Check rest 5 applications with the knowledge-base

3. Compare two applications using our prototype tool

33

For making a knowledge-base

Page 34: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Process

1. Make a knowledge-base with 6 applications

2. Check rest 5 applications with the knowledge-base

3. Compare two applications using our prototype tool

34

Check with the knowledge-base

Page 35: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Process

1. Make a knowledge-base with 6 applications

2. Check rest 5 applications with the knowledge-base

3. Compare two applications using our prototype tool

35

Compare using our prototype tool

Page 36: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Knowledge-base

Feature name API calling sequencesAlert Dialog android.app.AlertDialog.Builder.<Comstructor>

android.app.AlertDialog.Builder.setTitleGet Latitude and Longitude

android.location.Location.getLatitudeandroid.location.Location.getLongitude

Show Toast(pop-up message)

android.widget.Toast.makeTextandroid.widget.Toast.show

Set Latitude and Longitude

android.location.Location.setLatitudeandroid.location.Location.setLongitude

Submenu android.view.Menu.addSubMenuandroid.view.SubMenu.setIcon

36

23 API Calling sequences are stored into a knowledge-base.

Page 37: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Result (1/4)

37

ID App1 App2 App3 App4 App5Alert Dialog ✓ ✓ ✓ ✓ ✓Get Latitude and Longitude ✓ ✓ ✓ ✓Show Toast(pop-up message) ✓ ✓ ✓ ✓Set Latitude and Longitude ✓ ✓Submenu ✓

Page 38: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Result (2/4)

38

ID App1 App2 App3 App4 App5Alert Dialog ✓ ✓ ✓ ✓ ✓Get Latitude and Longitude ✓ ✓ ✓ ✓Show Toast(pop-up message) ✓ ✓ ✓ ✓Set Latitude and Longitude ✓ ✓Submenu ✓

All five applications have “Alert Dialog” Feature

Page 39: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Result (3/4)

39

ID App1 App2 App3 App4 App5Alert Dialog ✓ ✓ ✓ ✓ ✓Get Latitude and Longitude ✓ ✓ ✓ ✓Show Toast(pop-up message) ✓ ✓ ✓ ✓Set Latitude and Longitude ✓ ✓Submenu ✓

Application 2 doesn’t have “Get Latitude and Longitude” feature

Page 40: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Result (4/4)

40

ID App1 App2 App3 App4 App5Alert Dialog ✓ ✓ ✓ ✓ ✓Get Latitude and Longitude ✓ ✓ ✓ ✓Show Toast(pop-up message) ✓ ✓ ✓ ✓Set Latitude and Longitude ✓ ✓Submenu ✓

API calling sequence shows the features of applications

Page 41: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Output of the Tool (1/3)

41

App 2 App 4

Page 42: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Output of the Tool (2/3)

42

App 2 App 4

Both applications have “Alert Dialog” Feature

Page 43: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Output of the Tool (3/3)

43

App 2 App 4

Information about each API calling sequence GeoActivity.java

Class: GeoActivityMethod: onCreateLine: 56

Page 44: A Prototype of Comparison Tool for Android Applications Based on Difference of API Calling Sequences

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

Conclusion and Future Work• Conclusion:

– A prototype tool to compare two Android applications using API calling sequences

– Performed a case study– API calling sequences are usable for

comparing applications• Future work:

– Support to give an appropriate name to a sequence of API calls

44Portions of this presentation are reproduced from work created and shared by Google andused according to terms described in the Creative Commons 3.0 Attribution License.