Automated API-Usage Update for Android Apps Mattia Fazzini Qi Xin - - PowerPoint PPT Presentation

automated api usage update for android apps
SMART_READER_LITE
LIVE PREVIEW

Automated API-Usage Update for Android Apps Mattia Fazzini Qi Xin - - PowerPoint PPT Presentation

Automated API-Usage Update for Android Apps Mattia Fazzini Qi Xin Alessandro Orso Mobile Applications Platform Platform Tight Coupling Platforms Change Platforms Change Frequently Android Petit Four Cupcake Donut 1.1 Eclair Froyo


slide-1
SLIDE 1

Automated API-Usage Update for Android Apps

Mattia Fazzini Qi Xin Alessandro Orso

slide-2
SLIDE 2

Mobile Applications

slide-3
SLIDE 3

Platform

slide-4
SLIDE 4

Platform

Tight Coupling

slide-5
SLIDE 5

Platforms Change

slide-6
SLIDE 6

Platforms Change Frequently

Android Eclair Ice Cream Marshmallow Donut Petit Four Cupcake Honeycomb Froyo Gingerbread Lollipop Jelly Bean KitKat Pie Nougat Oreo

1.1

slide-7
SLIDE 7

App

Developer

Adaptive Maintenance

Platform

App

New Platform

slide-8
SLIDE 8

Platform Fragmentation

Gingerbread Ice Cream Jelly Bean KitKat Lollipop Marshmallow Nougat Oreo

slide-9
SLIDE 9

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

slide-10
SLIDE 10

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

slide-11
SLIDE 11

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

slide-12
SLIDE 12

API Updates

API-Usage Changes

public NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network) public NetworkInfo[] getAllNetworkInfo()

Old API Usage

slide-13
SLIDE 13

API Updates

API-Usage Changes

public NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network) public NetworkInfo[] getAllNetworkInfo()

Old API Usage

slide-14
SLIDE 14

API Updates

API-Usage Changes

public NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network) public NetworkInfo[] getAllNetworkInfo()

Old API Usage

slide-15
SLIDE 15

API Updates

API-Usage Changes

public NetworkInfo[] getAllNetworkInfo()

public Network[] getAllNetworks()

New API Usage

public NetworkInfo getNetworkInfo(Network network) public NetworkInfo[] getAllNetworkInfo()

Old API Usage

slide-16
SLIDE 16

Update Example

Update Example Before Update Example After

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (int i = 0; i < info.length; i++) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; } public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

slide-17
SLIDE 17

Update Example

Update Example Before Update Example After

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (int i = 0; i < info.length; i++) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; } public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

slide-18
SLIDE 18

Update Example After

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

Update Example

Update Example Before

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; }

slide-19
SLIDE 19

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

Update Example After

Update Example

Update Example Before

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; }

slide-20
SLIDE 20

APPEVOLVE Overview

Identify API usages requiring update in target app

Find update examples for identified API usages Abstract update examples into generic update patches and rank them Update and validate API usages in target app based on patches

slide-21
SLIDE 21

APPEVOLVE Overview

Identify API usages requiring update in target app

Find update examples for identified API usages Abstract update examples into generic update patches and rank them Update and validate API usages in target app based on patches

slide-22
SLIDE 22

APPEVOLVE Overview

Identify API usages requiring update in target app

Find update examples for identified API usages Abstract update examples into generic update patches and rank them Update and validate API usages in target app based on patches

slide-23
SLIDE 23

Update Example Search

Code Hosting Infrastructure Keyword-Based Search

method signature New API Usage

Search Result

Code Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n f1i−1 f1i

f2j−1 f2j

f4k−1 f4k

method name, param types, declaring class

slide-24
SLIDE 24

Update Example Search

Code Hosting Infrastructure Keyword-Based Search

method signature New API Usage

Search Result

Code Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n f1i−1 f1i

f2j−1 f2j

f4k−1 f4k

Search Result

Code Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n f1i−1 f1i

f2j−1 f2j

f4k−1 f4k

method name, param types, declaring class

slide-25
SLIDE 25

Update Example Search

Code Hosting Infrastructure Keyword-Based Search

method signature New API Usage

Search Result

Code Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n f1i−1 f1i

f2j−1 f2j

f4k−1 f4k

Search Result

Code Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n f1i−1 f1i

f2j−1 f2j

f4k−1 f4k

method name, param types, declaring class

slide-26
SLIDE 26

Update Example Search

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (int i = 0; i < info.length; i++) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; } public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

( f1i−1)

Before Update

( f1i)

After Update

slide-27
SLIDE 27

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; + if (VERSION.SDK_INT >= VERSION_CODES.M) { + Network[] networks = cm.getAllNetworks(); + for (Network mNetwork : networks) { + NetworkInfo networkInfo = + cm.getNetworkInfo(mNetwork); + if(networkInfo.isConnected()) { + Log.d(networkInfo.getTypeName()); return true; } } + } else { + NetworkInfo[] info = cm.getAllNetworkInfo(); + for (NetworkInfo anInfo : info) { + if(anInfo.isConnected()) { + Log.d(anInfo.getTypeName()); + return true; + } } + } + Toast.makeText(cont.getString(...)).show(); return false; }

Update Example Search

Compute Differences

public boolean isConnected(Context cont) { ConnectivityManager cm = ...;

  • NetworkInfo[] info = cm.getAllNetworkInfo();
  • for (int i = 0; i < info.length; i++) {
  • if(info[i].isConnected()) {

return true; } }

  • Toast.makeText(R.s.noNet).show();

return false; }

( f1i−1)

Before Update

( f1i)

After Update

slide-28
SLIDE 28

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; + if (VERSION.SDK_INT >= VERSION_CODES.M) { + Network[] networks = cm.getAllNetworks(); + for (Network mNetwork : networks) { + NetworkInfo networkInfo = + cm.getNetworkInfo(mNetwork); + if(networkInfo.isConnected()) { + Log.d(networkInfo.getTypeName()); return true; } } + } else { + NetworkInfo[] info = cm.getAllNetworkInfo(); + for (NetworkInfo anInfo : info) { + if(anInfo.isConnected()) { + Log.d(anInfo.getTypeName()); + return true; + } } + } + Toast.makeText(cont.getString(...)).show(); return false; }

Update Example Search

Compute Differences

public boolean isConnected(Context cont) { ConnectivityManager cm = ...;

  • NetworkInfo[] info = cm.getAllNetworkInfo();
  • for (int i = 0; i < info.length; i++) {
  • if(info[i].isConnected()) {

return true; } }

  • Toast.makeText(R.s.noNet).show();

return false; }

( f1i−1)

Before Update

( f1i)

After Update Added check on platform version Added new API Usage Moved old API Usage

slide-29
SLIDE 29

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; + if (VERSION.SDK_INT >= VERSION_CODES.M) { + Network[] networks = cm.getAllNetworks(); + for (Network mNetwork : networks) { + NetworkInfo networkInfo = + cm.getNetworkInfo(mNetwork); + if(networkInfo.isConnected()) { + Log.d(networkInfo.getTypeName()); return true; } } + } else { + NetworkInfo[] info = cm.getAllNetworkInfo(); + for (NetworkInfo anInfo : info) { + if(anInfo.isConnected()) { + Log.d(anInfo.getTypeName()); + return true; + } } + } + Toast.makeText(cont.getString(...)).show(); return false; }

Update Example Search

Compute Differences

public boolean isConnected(Context cont) { ConnectivityManager cm = ...;

  • NetworkInfo[] info = cm.getAllNetworkInfo();
  • for (int i = 0; i < info.length; i++) {
  • if(info[i].isConnected()) {

return true; } }

  • Toast.makeText(R.s.noNet).show();

return false; }

( f1i−1)

Before Update

( f1i)

After Update Added check on platform version Added new API Usage Moved old API Usage Update Example

slide-30
SLIDE 30

public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; + if (VERSION.SDK_INT >= VERSION_CODES.M) { + Network[] networks = cm.getAllNetworks(); + for (Network mNetwork : networks) { + NetworkInfo networkInfo = + cm.getNetworkInfo(mNetwork); + if(networkInfo.isConnected()) { + Log.d(networkInfo.getTypeName()); return true; } } + } else { + NetworkInfo[] info = cm.getAllNetworkInfo(); + for (NetworkInfo anInfo : info) { + if(anInfo.isConnected()) { + Log.d(anInfo.getTypeName()); + return true; + } } + } + Toast.makeText(cont.getString(...)).show(); return false; }

Update Example Search

Compute Differences

public boolean isConnected(Context cont) { ConnectivityManager cm = ...;

  • NetworkInfo[] info = cm.getAllNetworkInfo();
  • for (int i = 0; i < info.length; i++) {
  • if(info[i].isConnected()) {

return true; } }

  • Toast.makeText(R.s.noNet).show();

return false; }

( f1i−1)

Before Update

( f1i)

After Update Added check on platform version Added new API Usage Moved old API Usage Update Example Update Examples

Code Base App1 Code Base App2 Code Base App4 Code Base App3

slide-31
SLIDE 31

APPEVOLVE Overview

Identify API usages requiring update in target app

Find update examples for identified API usages Abstract update examples into generic update patches and rank them Update and validate API usages in target app based on patches

slide-32
SLIDE 32

Update Example Analysis

public boolean isConnected(Context cont) { ConnectivityManager cm = ...; NetworkInfo[] info = cm.getAllNetworkInfo(); for (int i = 0; i < info.length; i++) { if(info[i].isConnected()) { return true; } } Toast.makeText(R.s.noNet).show(); return false; } public boolean isConnected(Context cont) { ConnectivityManager cm = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = cm.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = cm.getNetworkInfo(mNetwork); if(networkInfo.isConnected()) { Log.d(networkInfo.getTypeName()); return true; } } } else { NetworkInfo[] info = cm.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.isConnected()) { Log.d(anInfo.getTypeName()); return true; } } } Toast.makeText(cont.getString(...)).show(); return false; }

( f1i−1)

Update Example Before

( f1i)

Update Example After

Compute Update Patch

slide-33
SLIDE 33

Update Example Analysis

( f1i−1)

Abstract Syntax Tree Before

( f1i)

Abstract Syntax Tree After

Compute Update Patch

slide-34
SLIDE 34

Update Example Analysis

( f1i−1)

Abstract Syntax Tree Before

( f1i)

Abstract Syntax Tree After

Compute Update Patch

Edit Operations

INSERT(sn1, sn2, i) MOVE(sn1, sn2, i) UPDATE(sn1, sn2) DELETE(sn1)

slide-35
SLIDE 35

Update Example Analysis

( f1i−1)

Abstract Syntax Tree Before

( f1i)

Abstract Syntax Tree After

Compute Update Patch

Raw Edit Script

INSERT if VERSION.SDK_INT>=VERSION_CODES.M UPDATE Toast.makeText(R.s.noNet).show() Toast.makeText(cont.getString(...)).show() INSERT Network[] networks=cm.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cm.getAllNetworkInfo() INSERT NetworkInfo nI=cm.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

slide-36
SLIDE 36

Update Example Analysis

( f1i−1)

Abstract Syntax Tree Before

( f1i)

Abstract Syntax Tree After Unrelated Edits

INSERT if VERSION.SDK_INT>=VERSION_CODES.M UPDATE Toast.makeText(R.s.noNet).show() Toast.makeText(cont.getString(...)).show() INSERT Network[] networks=cm.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cm.getAllNetworkInfo() INSERT NetworkInfo nI=cm.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Compute Update Patch

slide-37
SLIDE 37

Update Example Analysis

( f1i−1)

Abstract Syntax Tree Before

( f1i)

Abstract Syntax Tree After Edit Script

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=cm.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cm.getAllNetworkInfo() INSERT NetworkInfo nI=cm.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Dependency Analysis

Compute Update Patch

slide-38
SLIDE 38

Update Example Analysis

( f1i−1)

Abstract Syntax Tree Before

( f1i)

Abstract Syntax Tree After Unneeded Edits

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=cm.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cm.getAllNetworkInfo() INSERT NetworkInfo nI=cm.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Compute Update Patch

slide-39
SLIDE 39

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=cm.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cm.getAllNetworkInfo() INSERT NetworkInfo nI=cm.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Edit Script Update Example #1

Update Example Analysis

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=cMan.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cMan.getAllNetworkInfo() INSERT NetworkInfo nI=cMan.getNetworkInfo(mNetwork) UPDATE if info[i].getState()==CONNECTED if nI.getState()==CONNECTED MOVERT if nI.getState()==CONNECTED INSERT for NetworkInfo anInfo:info INSERT if anInfo.getState()==CONNECTED INSERT return true DELETE for int j=0 j<info.length j++

Edit Script Update Example #2

slide-40
SLIDE 40

Edit Script Abstraction #1

Update Example Analysis

Edit Script Abstraction #2

Find common core using Multiple Longest Common Subsequence (MLCS)

MLCS Solution Core Proximity Value

|MLC Solution| |Edit Script|

Core Proximity Value = 0.62 Core Proximity Value = 0.72

slide-41
SLIDE 41

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Edit Script

Update Example Analysis

Core Proximity Value = 0.62

Context Variable Computation

Context Variables[($V,ConnectivityManager:cm)]

slide-42
SLIDE 42

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Edit Script

Update Example Analysis

Core Proximity Value = 0.62

Generic Update Patch

Context Variables[($V,ConnectivityManager:cm)]

slide-43
SLIDE 43

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].isConnected() if nI.isConnected() MOVERT if nI.isConnected() INSERT Log.d(networkInfo.getTypeName()) INSERT for NetworkInfo anInfo:info INSERT if anInfo.isConnected() INSERT Log.d(anInfo.getTypeName()) INSERT return true DELETE for int i=0 i<info.length i++

Edit Script

Update Example Analysis

Core Proximity Value = 0.62

Generic Update Patch

Context Variables[($V,ConnectivityManager:cm)]

Generic Update Patches

1st 2nd 3rd

slide-44
SLIDE 44

APPEVOLVE Overview

Identify API usages requiring update in target app

Find update examples for identified API usages Abstract update examples into generic update patches and rank them Update and validate API usages in target app based on patches

slide-45
SLIDE 45

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].getState()==CONNECTED if nI.getState()==CONNECTED MOVERT if nI.getState()==CONNECTED INSERT for NetworkInfo anInfo:info INSERT if anInfo.getState()==CONNECTED INSERT return true DELETE for int j=0 j<info.length j++

Core Proximity Value = 0.72 Context Variables[($V,ConnectivityManager:cMan)]

API-Usage Update

public boolean hasNetwork(Context context) { ConnectivityManager conn = ...; NetworkInfo[] netInfo = conn.getAllNetworkInfo(); for (int k = 0; k < netInfo; k++) { if (netInfo[k].getState() == NetworkInfo.State.CONNECTED) { return true; } } return false; }

Target App Code Generic Update Patch Edit Script

slide-46
SLIDE 46

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=cMan.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=cMan.getAllNetworkInfo() INSERT NetworkInfo nI=cMan.getNetworkInfo(mNetwork) UPDATE if info[i].getState()==CONNECTED if nI.getState()==CONNECTED MOVERT if nI.getState()==CONNECTED INSERT for NetworkInfo anInfo:info INSERT if anInfo.getState()==CONNECTED INSERT return true DELETE for int j=0 j<info.length j++

Core Proximity Value = 0.72 Context Variables

API-Usage Update

public boolean hasNetwork(Context context) { ConnectivityManager conn = ...; NetworkInfo[] netInfo = conn.getAllNetworkInfo(); for (int k = 0; k < netInfo; k++) { if (netInfo[k].getState() == NetworkInfo.State.CONNECTED) { return true; } } return false; }

Target App Code Generic Update Patch Edit Script

[($V,ConnectivityManager:cMan)]

Analyze Variables in Scope

slide-47
SLIDE 47

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].getState()==CONNECTED if nI.getState()==CONNECTED MOVERT if nI.getState()==CONNECTED INSERT for NetworkInfo anInfo:info INSERT if anInfo.getState()==CONNECTED INSERT return true DELETE for int j=0 j<info.length j++

Core Proximity Value = 0.72 Context Variables

API-Usage Update

Abstract Syntax Tree Target App Generic Update Patch Edit Script

[($V,ConnectivityManager:cMan)] [($V,ConnectivityManager:conn)]

slide-48
SLIDE 48

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].getState()==CONNECTED if nI.getState()==CONNECTED MOVERT if nI.getState()==CONNECTED INSERT for NetworkInfo anInfo:info INSERT anInfo.getState()==CONNECTED INSERT return true DELETE for int j=0 j<info.length j++

Core Proximity Value = 0.72 Context Variables

API-Usage Update

Updated Abstract Syntax Tree Target App Generic Update Patch Edit Script

[($V,ConnectivityManager:cMan)] [($V,ConnectivityManager:conn)]

slide-49
SLIDE 49

INSERT if VERSION.SDK_INT>=VERSION_CODES.M INSERT Network[] networks=$V.getAllNetworks() INSERT for Network mNetwork:networks MOVERT NetworkInfo[] info=$V.getAllNetworkInfo() INSERT NetworkInfo nI=$V.getNetworkInfo(mNetwork) UPDATE if info[i].getState()==CONNECTED if nI.getState()==CONNECTED MOVERT if nI.getState()==CONNECTED INSERT for NetworkInfo anInfo:info INSERT anInfo.getState()==CONNECTED INSERT return true DELETE for int j=0 j<info.length j++

Core Proximity Value = 0.72 Context Variables

API-Usage Update

Updated Target App Code Generic Update Patch Edit Script

[($V,ConnectivityManager:cMan)] [($V,ConnectivityManager:conn)] public boolean hasNetwork(Context context) { ConnectivityManager conn = ... ; if (VERSION.SDK_INT >= VERSION_CODES.M) { Network[] networks = conn.getAllNetworks(); for (Network mNetwork : networks) { NetworkInfo networkInfo = conn.getNetworkInfo(mNetwork); if(networkInfo.getState() == NetworkInfo.State.CONNECTED) { return true; } } } else { NetworkInfo[] info = conn.getAllNetworkInfo(); for (NetworkInfo anInfo : info) { if(anInfo.getState() == NetworkInfo.State.CONNECTED) { return true; } } } return false; }

slide-50
SLIDE 50

API-Usage Update

New Platform

Differential Testing

Old Platform

slide-51
SLIDE 51

API-Usage Update

New Platform

Differential Testing

Old Platform

Target App

slide-52
SLIDE 52

API-Usage Update

New Platform

Differential Testing

Old Platform

Target App Updated Target App Updated Target App

slide-53
SLIDE 53

Empirical Evaluation

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps? RQ2 (EFFICIENCY): What is the cost of running APPEVOLVE?

Research Questions

slide-54
SLIDE 54

Empirical Evaluation

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps? RQ2 (EFFICIENCY): What is the cost of running APPEVOLVE?

Research Questions

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

slide-55
SLIDE 55

Empirical Evaluation

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps? RQ2 (EFFICIENCY): What is the cost of running APPEVOLVE?

Research Questions

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps? RQ2 (EFFICIENCY): What is the cost of running APPEVOLVE?

slide-56
SLIDE 56

Benchmarks and Setup

20 API Usages

addAction getAllNetworkInfo getCurrentHour getCurrentMinute setCurrentHour setCurrentMinute setTextAppearance addGpsStatusListener fromHtml release removeGpsStatusListener shouldOverrideUrlLoading startDrag abandonAudioFocus getDeviceId requestAudioFocus saveLayer setAudioStreamType vibrate(long) vibrate(long[],int) (41 occurrences)

Lollipop Marshmallow Nougat

15 Apps

BIPOLALARM CONVERSATIONS PARKENDD CLEAN SB OPENSUDOKU WIGLE WIFI FOOTGUY CALENDAR IE DIOLINUX SOLAR COMPASS SYMPHONY SYSLOG MUZEI NOTES ONETWO

Setup

  • Ran technique on benchmarks
  • Measured successful update and validation rate
  • Measured execution time
slide-57
SLIDE 57

Benchmarks and Setup

20 API Usages

addAction getAllNetworkInfo getCurrentHour getCurrentMinute setCurrentHour setCurrentMinute setTextAppearance addGpsStatusListener fromHtml release removeGpsStatusListener shouldOverrideUrlLoading startDrag abandonAudioFocus getDeviceId requestAudioFocus saveLayer setAudioStreamType vibrate(long) vibrate(long[],int) (41 occurrences)

Lollipop Marshmallow Nougat

15 Apps

BIPOLALARM CONVERSATIONS PARKENDD CLEAN SB OPENSUDOKU WIGLE WIFI FOOTGUY CALENDAR IE DIOLINUX SOLAR COMPASS SYMPHONY SYSLOG MUZEI NOTES ONETWO

20 API Usages

addAction getAllNetworkInfo getCurrentHour getCurrentMinute setCurrentHour setCurrentMinute setTextAppearance addGpsStatusListener fromHtml release removeGpsStatusListener shouldOverrideUrlLoading startDrag abandonAudioFocus getDeviceId requestAudioFocus saveLayer setAudioStreamType vibrate(long) vibrate(long[],int) (41 occurrences)

Setup

  • Ran technique on benchmarks
  • Measured successful update and validation rate
  • Measured execution time
slide-58
SLIDE 58

Benchmarks and Setup

20 API Usages

addAction getAllNetworkInfo getCurrentHour getCurrentMinute setCurrentHour setCurrentMinute setTextAppearance addGpsStatusListener fromHtml release removeGpsStatusListener shouldOverrideUrlLoading startDrag abandonAudioFocus getDeviceId requestAudioFocus saveLayer setAudioStreamType vibrate(long) vibrate(long[],int) (41 occurrences)

Lollipop Marshmallow Nougat

15 Apps

BIPOLALARM CONVERSATIONS PARKENDD CLEAN SB OPENSUDOKU WIGLE WIFI FOOTGUY CALENDAR IE DIOLINUX SOLAR COMPASS SYMPHONY SYSLOG MUZEI NOTES ONETWO

20 API Usages

addAction getAllNetworkInfo getCurrentHour getCurrentMinute setCurrentHour setCurrentMinute setTextAppearance addGpsStatusListener fromHtml release removeGpsStatusListener shouldOverrideUrlLoading startDrag abandonAudioFocus getDeviceId requestAudioFocus saveLayer setAudioStreamType vibrate(long) vibrate(long[],int) (41 occurrences)

Setup

  • Ran technique on benchmarks
  • Measured successful update and validation rate
  • Measured execution time

Setup

  • Ran technique on benchmarks
  • Measured successful update and validation rate
  • Measured execution time
slide-59
SLIDE 59

Evaluation: Effectiveness

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

  • In 19/20 cases, APPEVOLVE could find update examples
  • In 14/19 cases, the number of relevant edits is lower than the number of AST edits
  • In 11/19 cases, the core proximity value is different from its minimum and maximum

Details

APPEVOLVE is effective in automatically updating API usages.

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

  • 37/41 (90%) successful update rate (for API-usage occurrences)
  • 25/37 (68%) automatic validation rate (for API-usage occurrences)

Overall Effectivness

  • 17/20 (85%) successful update rate (for API usages)
slide-60
SLIDE 60

Evaluation: Effectiveness

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

  • In 19/20 cases, APPEVOLVE could find update examples
  • In 14/19 cases, the number of relevant edits is lower than the number of AST edits
  • In 11/19 cases, the core proximity value is different from its minimum and maximum

Details

APPEVOLVE is effective in automatically updating API usages.

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

  • 37/41 (90%) successful update rate (for API-usage occurrences)
  • 25/37 (68%) automatic validation rate (for API-usage occurrences)

Overall Effectivness

  • 17/20 (85%) successful update rate (for API usages)
  • In 19/20 cases, APPEVOLVE could find update examples
  • In 14/19 cases, the number of relevant edits is lower than the number of AST edits
  • In 11/19 cases, the core proximity value is different from its minimum and maximum

Details

slide-61
SLIDE 61

Evaluation: Effectiveness

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

  • In 19/20 cases, APPEVOLVE could find update examples
  • In 14/19 cases, the number of relevant edits is lower than the number of AST edits
  • In 11/19 cases, the core proximity value is different from its minimum and maximum

Details

APPEVOLVE is effective in automatically updating API usages.

RQ1 (EFFECTIVENESS): Can APPEVOLVE update API usages in real-world apps?

  • 37/41 (90%) successful update rate (for API-usage occurrences)
  • 25/37 (68%) automatic validation rate (for API-usage occurrences)

Overall Effectivness

  • 17/20 (85%) successful update rate (for API usages)
  • In 19/20 cases, APPEVOLVE could find update examples
  • In 14/19 cases, the number of relevant edits is lower than the number of AST edits
  • In 11/19 cases, the core proximity value is different from its minimum and maximum

Details

APPEVOLVE is effective in automatically updating API usages.

slide-62
SLIDE 62

Evaluation: Efficiency

RQ2 (EFFICIENCY): What is the cost of running APPEVOLVE?

API-Usage Analysis Update Examples Search Update Examples Analysis API-Usage Update 28s 10h27m 2s204ms 20s The cost of the update examples search phase dominates the cost of the other phases.

Average Execution Time

API-Usage Analysis Update Examples Search Update Examples Analysis API-Usage Update 28s 10h27m 2s204ms 20s The cost of the update examples search phase dominates the cost of the other phases.

Average Execution Time

slide-63
SLIDE 63

Future Work

Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing Investigate use of APPEVOLVE in other contexts (e.g., web apps)

slide-64
SLIDE 64

Future Work

Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing Investigate use of APPEVOLVE in other contexts (e.g., web apps) Handle updates that span across multiple methods

slide-65
SLIDE 65

Future Work

Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing Investigate use of APPEVOLVE in other contexts (e.g., web apps) Handle updates that span across multiple methods Automatically compute API change specifications

slide-66
SLIDE 66

Future Work

Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing Investigate use of APPEVOLVE in other contexts (e.g., web apps) Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing

slide-67
SLIDE 67

Future Work

Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing Investigate use of APPEVOLVE in other contexts (e.g., web apps) Handle updates that span across multiple methods Automatically compute API change specifications Improve validation through differential testing Investigate use of APPEVOLVE in other contexts (e.g., web apps)

slide-68
SLIDE 68

Summary

slide-69
SLIDE 69

Summary

https://b.gatech.edu/2JKkpWV

Artifact

slide-70
SLIDE 70

Related Work

Example Based Program Update

SYDIT, LASE, RASE, MEDITOR, REFAZER, ARES,…

Other Techniques

ICTAPIFINDER, CHANGEDISTILLING