automated api-usage update for android apps

70
Automated API-Usage Update for Android Apps Mattia Fazzini Qi Xin Alessandro Orso

Upload: others

Post on 03-Feb-2022

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automated API-Usage Update for Android Apps

Automated API-Usage Update for Android Apps

Mattia Fazzini Qi Xin Alessandro Orso

Page 2: Automated API-Usage Update for Android Apps

Mobile Applications

Page 3: Automated API-Usage Update for Android Apps

Platform

Page 4: Automated API-Usage Update for Android Apps

PlatformTight Coupling

Page 5: Automated API-Usage Update for Android Apps

Platforms Change

Page 6: Automated API-Usage Update for Android Apps

Platforms Change FrequentlyAndroid

Eclair

Ice Cream

Marshmallow

DonutPetit Four Cupcake

HoneycombFroyo Gingerbread

LollipopJelly Bean KitKat

PieNougat Oreo

1.1

Page 7: Automated API-Usage Update for Android Apps

AppDeveloper

Adaptive Maintenance

Platform

App

New Platform

Page 8: Automated API-Usage Update for Android Apps

Platform FragmentationGingerbread

Ice Cream

Jelly Bean

KitKat

Lollipop

Marshmallow

Nougat

Oreo

Page 9: Automated API-Usage Update for Android Apps

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

Page 10: Automated API-Usage Update for Android Apps

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

Page 11: Automated API-Usage Update for Android Apps

App C

Developer C

App B

Developer B

App A

Intuition

Developer A

Page 12: Automated API-Usage Update for Android Apps

API Updates

API-Usage ChangespublicNetworkInfo[]getAllNetworkInfo()

publicNetwork[]getAllNetworks()

New API Usage

publicNetworkInfogetNetworkInfo(Networknetwork)

publicNetworkInfo[]getAllNetworkInfo()Old API Usage

Page 13: Automated API-Usage Update for Android Apps

API Updates

API-Usage ChangespublicNetworkInfo[]getAllNetworkInfo()

publicNetwork[]getAllNetworks()

New API Usage

publicNetworkInfogetNetworkInfo(Networknetwork)

publicNetworkInfo[]getAllNetworkInfo()Old API Usage

Page 14: Automated API-Usage Update for Android Apps

API Updates

API-Usage ChangespublicNetworkInfo[]getAllNetworkInfo()

publicNetwork[]getAllNetworks()

New API Usage

publicNetworkInfogetNetworkInfo(Networknetwork)

publicNetworkInfo[]getAllNetworkInfo()Old API Usage

Page 15: Automated API-Usage Update for Android Apps

API Updates

API-Usage ChangespublicNetworkInfo[]getAllNetworkInfo()

publicNetwork[]getAllNetworks()

New API Usage

publicNetworkInfogetNetworkInfo(Networknetwork)

publicNetworkInfo[]getAllNetworkInfo()Old API Usage

Page 16: Automated API-Usage Update for Android Apps

Update ExampleUpdate Example Before Update Example After

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;NetworkInfo[]info=cm.getAllNetworkInfo();for(inti=0;i<info.length;i++){if(info[i].isConnected()){returntrue;}}Toast.makeText(R.s.noNet).show();returnfalse;}

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=cm.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=cm.getNetworkInfo(mNetwork);if(networkInfo.isConnected()){Log.d(networkInfo.getTypeName());returntrue;}}}else{NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.isConnected()){Log.d(anInfo.getTypeName());returntrue;}}}Toast.makeText(cont.getString(...)).show();returnfalse;}

Page 17: Automated API-Usage Update for Android Apps

Update ExampleUpdate Example Before Update Example After

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;NetworkInfo[]info=cm.getAllNetworkInfo();for(inti=0;i<info.length;i++){if(info[i].isConnected()){returntrue;}}Toast.makeText(R.s.noNet).show();returnfalse;}

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=cm.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=cm.getNetworkInfo(mNetwork);if(networkInfo.isConnected()){Log.d(networkInfo.getTypeName());returntrue;}}}else{NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.isConnected()){Log.d(anInfo.getTypeName());returntrue;}}}Toast.makeText(cont.getString(...)).show();returnfalse;}

Page 18: Automated API-Usage Update for Android Apps

Update Example AfterpublicbooleanisConnected(Contextcont){ConnectivityManagercm=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=cm.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=cm.getNetworkInfo(mNetwork);if(networkInfo.isConnected()){Log.d(networkInfo.getTypeName());returntrue;}}}else{NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.isConnected()){Log.d(anInfo.getTypeName());returntrue;}}}Toast.makeText(cont.getString(...)).show();returnfalse;}

Update ExampleUpdate Example Before

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(info[i].isConnected()){returntrue;}}Toast.makeText(R.s.noNet).show();returnfalse;}

Page 19: Automated API-Usage Update for Android Apps

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=cm.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=cm.getNetworkInfo(mNetwork);if(networkInfo.isConnected()){Log.d(networkInfo.getTypeName());returntrue;}}}else{NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.isConnected()){Log.d(anInfo.getTypeName());returntrue;}}}Toast.makeText(cont.getString(...)).show();returnfalse;}

Update Example After

Update ExampleUpdate Example Before

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(info[i].isConnected()){returntrue;}}Toast.makeText(R.s.noNet).show();returnfalse;}

Page 20: Automated API-Usage Update for Android Apps

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

Page 21: Automated API-Usage Update for Android Apps

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

Page 22: Automated API-Usage Update for Android Apps

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

Page 23: Automated API-Usage Update for Android Apps

Update Example SearchCode Hosting Infrastructure

Keyword-Based Search

∀ ∈methodsignature New API Usage

Search ResultCode 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

Page 24: Automated API-Usage Update for Android Apps

Update Example SearchCode Hosting Infrastructure

Keyword-Based Search

∀ ∈methodsignature New API Usage

Search ResultCode Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n

f1i−1

f1i

f2j−1

f2j

f4k−1

f4k

Search ResultCode 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

Page 25: Automated API-Usage Update for Android Apps

Update Example SearchCode Hosting Infrastructure

Keyword-Based Search

∀ ∈methodsignature New API Usage

Search ResultCode Base App1 Code Base App2 Code Base App3 Code Base App4

f1i−n

f1i−1

f1i

f2j−1

f2j

f4k−1

f4k

Search ResultCode 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

Page 26: Automated API-Usage Update for Android Apps

Update Example Search

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;NetworkInfo[]info=cm.getAllNetworkInfo();for(inti=0;i<info.length;i++){if(info[i].isConnected()){returntrue;}}Toast.makeText(R.s.noNet).show();returnfalse;}

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=cm.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=cm.getNetworkInfo(mNetwork);if(networkInfo.isConnected()){Log.d(networkInfo.getTypeName());returntrue;}}}else{NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.isConnected()){Log.d(anInfo.getTypeName());returntrue;}}}Toast.makeText(cont.getString(...)).show();returnfalse;}

( f1i−1)Before Update ( f1i

)After Update

Page 27: Automated API-Usage Update for Android Apps

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;+if(VERSION.SDK_INT>=VERSION_CODES.M){+Network[]networks=cm.getAllNetworks();+for(NetworkmNetwork:networks){+NetworkInfonetworkInfo=+cm.getNetworkInfo(mNetwork);+if(networkInfo.isConnected()){+Log.d(networkInfo.getTypeName());returntrue;}}+}else{+NetworkInfo[]info=cm.getAllNetworkInfo();+for(NetworkInfoanInfo:info){+if(anInfo.isConnected()){+Log.d(anInfo.getTypeName());+returntrue;+}}+}+Toast.makeText(cont.getString(...)).show();returnfalse;}

Update Example SearchCompute Differences

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;-NetworkInfo[]info=cm.getAllNetworkInfo();-for(inti=0;i<info.length;i++){-if(info[i].isConnected()){returntrue;}}-Toast.makeText(R.s.noNet).show();returnfalse;}

( f1i−1)Before Update ( f1i

)After Update

Page 28: Automated API-Usage Update for Android Apps

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;+if(VERSION.SDK_INT>=VERSION_CODES.M){+Network[]networks=cm.getAllNetworks();+for(NetworkmNetwork:networks){+NetworkInfonetworkInfo=+cm.getNetworkInfo(mNetwork);+if(networkInfo.isConnected()){+Log.d(networkInfo.getTypeName());returntrue;}}+}else{+NetworkInfo[]info=cm.getAllNetworkInfo();+for(NetworkInfoanInfo:info){+if(anInfo.isConnected()){+Log.d(anInfo.getTypeName());+returntrue;+}}+}+Toast.makeText(cont.getString(...)).show();returnfalse;}

Update Example SearchCompute Differences

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;-NetworkInfo[]info=cm.getAllNetworkInfo();-for(inti=0;i<info.length;i++){-if(info[i].isConnected()){returntrue;}}-Toast.makeText(R.s.noNet).show();returnfalse;}

( f1i−1)Before Update ( f1i

)After Update

Added check on platform version

Added new API Usage

Moved old API Usage

Page 29: Automated API-Usage Update for Android Apps

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;+if(VERSION.SDK_INT>=VERSION_CODES.M){+Network[]networks=cm.getAllNetworks();+for(NetworkmNetwork:networks){+NetworkInfonetworkInfo=+cm.getNetworkInfo(mNetwork);+if(networkInfo.isConnected()){+Log.d(networkInfo.getTypeName());returntrue;}}+}else{+NetworkInfo[]info=cm.getAllNetworkInfo();+for(NetworkInfoanInfo:info){+if(anInfo.isConnected()){+Log.d(anInfo.getTypeName());+returntrue;+}}+}+Toast.makeText(cont.getString(...)).show();returnfalse;}

Update Example SearchCompute Differences

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;-NetworkInfo[]info=cm.getAllNetworkInfo();-for(inti=0;i<info.length;i++){-if(info[i].isConnected()){returntrue;}}-Toast.makeText(R.s.noNet).show();returnfalse;}

( f1i−1)Before Update ( f1i

)After Update

Added check on platform version

Added new API Usage

Moved old API Usage

Update Example

Page 30: Automated API-Usage Update for Android Apps

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;+if(VERSION.SDK_INT>=VERSION_CODES.M){+Network[]networks=cm.getAllNetworks();+for(NetworkmNetwork:networks){+NetworkInfonetworkInfo=+cm.getNetworkInfo(mNetwork);+if(networkInfo.isConnected()){+Log.d(networkInfo.getTypeName());returntrue;}}+}else{+NetworkInfo[]info=cm.getAllNetworkInfo();+for(NetworkInfoanInfo:info){+if(anInfo.isConnected()){+Log.d(anInfo.getTypeName());+returntrue;+}}+}+Toast.makeText(cont.getString(...)).show();returnfalse;}

Update Example SearchCompute Differences

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;-NetworkInfo[]info=cm.getAllNetworkInfo();-for(inti=0;i<info.length;i++){-if(info[i].isConnected()){returntrue;}}-Toast.makeText(R.s.noNet).show();returnfalse;}

( f1i−1)Before Update ( f1i

)After Update

Added check on platform version

Added new API Usage

Moved old API Usage

Update ExampleUpdate ExamplesCode Base App1 Code Base App2 Code Base App4Code Base App3

Page 31: Automated API-Usage Update for Android Apps

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

Page 32: Automated API-Usage Update for Android Apps

Update Example Analysis

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;NetworkInfo[]info=cm.getAllNetworkInfo();for(inti=0;i<info.length;i++){if(info[i].isConnected()){returntrue;}}Toast.makeText(R.s.noNet).show();returnfalse;}

publicbooleanisConnected(Contextcont){ConnectivityManagercm=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=cm.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=cm.getNetworkInfo(mNetwork);if(networkInfo.isConnected()){Log.d(networkInfo.getTypeName());returntrue;}}}else{NetworkInfo[]info=cm.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.isConnected()){Log.d(anInfo.getTypeName());returntrue;}}}Toast.makeText(cont.getString(...)).show();returnfalse;}

( f1i−1)Update Example Before ( f1i

)Update Example AfterCompute Update Patch

Page 33: Automated API-Usage Update for Android Apps

Update Example Analysis( f1i−1

)Abstract Syntax Tree Before ( f1i)Abstract Syntax Tree After

Compute Update Patch

Page 34: Automated API-Usage Update for Android Apps

Update Example Analysis( f1i−1

)Abstract Syntax Tree Before ( f1i)Abstract Syntax Tree After

Compute Update Patch

Edit OperationsINSERT(sn1, sn2, i)MOVE(sn1, sn2, i)UPDATE(sn1, sn2)DELETE(sn1)

Page 35: Automated API-Usage Update for Android Apps

Update Example Analysis( f1i−1

)Abstract Syntax Tree Before ( f1i)Abstract Syntax Tree After

Compute Update Patch

Raw Edit ScriptINSERTifVERSION.SDK_INT>=VERSION_CODES.MUPDATEToast.makeText(R.s.noNet).show()Toast.makeText(cont.getString(...)).show()INSERTNetwork[]networks=cm.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cm.getAllNetworkInfo()INSERTNetworkInfonI=cm.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Page 36: Automated API-Usage Update for Android Apps

Update Example Analysis( f1i−1

)Abstract Syntax Tree Before ( f1i)Abstract Syntax Tree After

Unrelated EditsINSERTifVERSION.SDK_INT>=VERSION_CODES.MUPDATEToast.makeText(R.s.noNet).show()Toast.makeText(cont.getString(...)).show()INSERTNetwork[]networks=cm.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cm.getAllNetworkInfo()INSERTNetworkInfonI=cm.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Compute Update Patch

Page 37: Automated API-Usage Update for Android Apps

Update Example Analysis( f1i−1

)Abstract Syntax Tree Before ( f1i)Abstract Syntax Tree After

Edit ScriptINSERTifVERSION.SDK_INT>=VERSION_CODES.M

INSERTNetwork[]networks=cm.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cm.getAllNetworkInfo()INSERTNetworkInfonI=cm.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Dependency Analysis

Compute Update Patch

Page 38: Automated API-Usage Update for Android Apps

Update Example Analysis( f1i−1

)Abstract Syntax Tree Before ( f1i)Abstract Syntax Tree After

Unneeded EditsINSERTifVERSION.SDK_INT>=VERSION_CODES.M

INSERTNetwork[]networks=cm.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cm.getAllNetworkInfo()INSERTNetworkInfonI=cm.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Compute Update Patch

Page 39: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=cm.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cm.getAllNetworkInfo()INSERTNetworkInfonI=cm.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Edit Script Update Example #1

Update Example Analysis

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=cMan.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cMan.getAllNetworkInfo()INSERTNetworkInfonI=cMan.getNetworkInfo(mNetwork)UPDATEifinfo[i].getState()==CONNECTEDifnI.getState()==CONNECTEDMOVERTifnI.getState()==CONNECTEDINSERTforNetworkInfoanInfo:infoINSERTifanInfo.getState()==CONNECTEDINSERTreturntrueDELETEforintj=0j<info.lengthj++

Edit Script Update Example #2

Page 40: Automated API-Usage Update for Android Apps

Edit Script Abstraction #1

Update Example AnalysisEdit 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

Page 41: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Edit Script

Update Example Analysis

Core Proximity Value = 0.62

Context Variable Computation

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

Page 42: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Edit Script

Update Example Analysis

Core Proximity Value = 0.62

Generic Update Patch

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

Page 43: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].isConnected()ifnI.isConnected()MOVERTifnI.isConnected()INSERTLog.d(networkInfo.getTypeName())INSERTforNetworkInfoanInfo:infoINSERTifanInfo.isConnected()INSERTLog.d(anInfo.getTypeName())INSERTreturntrueDELETEforinti=0i<info.lengthi++

Edit Script

Update Example Analysis

Core Proximity Value = 0.62

Generic Update Patch

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

Generic Update Patches

1st 2nd 3rd

Page 44: Automated API-Usage Update for Android Apps

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

Page 45: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].getState()==CONNECTEDifnI.getState()==CONNECTEDMOVERTifnI.getState()==CONNECTEDINSERTforNetworkInfoanInfo:infoINSERTifanInfo.getState()==CONNECTEDINSERTreturntrueDELETEforintj=0j<info.lengthj++

Core Proximity Value = 0.72

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

API-Usage Update

publicbooleanhasNetwork(Contextcontext){ConnectivityManagerconn=...;NetworkInfo[]netInfo=conn.getAllNetworkInfo();for(intk=0;k<netInfo;k++){if(netInfo[k].getState()==NetworkInfo.State.CONNECTED){returntrue;}}returnfalse;}

Target App Code Generic Update Patch

Edit Script

Page 46: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=cMan.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=cMan.getAllNetworkInfo()INSERTNetworkInfonI=cMan.getNetworkInfo(mNetwork)UPDATEifinfo[i].getState()==CONNECTEDifnI.getState()==CONNECTEDMOVERTifnI.getState()==CONNECTEDINSERTforNetworkInfoanInfo:infoINSERTifanInfo.getState()==CONNECTEDINSERTreturntrueDELETEforintj=0j<info.lengthj++

Core Proximity Value = 0.72

Context Variables

API-Usage Update

publicbooleanhasNetwork(Contextcontext){ConnectivityManagerconn=...;NetworkInfo[]netInfo=conn.getAllNetworkInfo();for(intk=0;k<netInfo;k++){if(netInfo[k].getState()==NetworkInfo.State.CONNECTED){returntrue;}}returnfalse;}

Target App Code Generic Update Patch

Edit Script

[($V,ConnectivityManager:cMan)]

Analyze Variables in Scope

Page 47: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].getState()==CONNECTEDifnI.getState()==CONNECTEDMOVERTifnI.getState()==CONNECTEDINSERTforNetworkInfoanInfo:infoINSERTifanInfo.getState()==CONNECTEDINSERTreturntrueDELETEforintj=0j<info.lengthj++

Core Proximity Value = 0.72

Context Variables

API-Usage UpdateAbstract Syntax Tree Target App Generic Update Patch

Edit Script

[($V,ConnectivityManager:cMan)]

[($V,ConnectivityManager:conn)]

Page 48: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].getState()==CONNECTEDifnI.getState()==CONNECTEDMOVERTifnI.getState()==CONNECTEDINSERTforNetworkInfoanInfo:infoINSERTanInfo.getState()==CONNECTEDINSERTreturntrueDELETEforintj=0j<info.lengthj++

Core Proximity Value = 0.72

Context Variables

API-Usage UpdateUpdated Abstract Syntax Tree Target App Generic Update Patch

Edit Script

[($V,ConnectivityManager:cMan)]

[($V,ConnectivityManager:conn)]

Page 49: Automated API-Usage Update for Android Apps

INSERTifVERSION.SDK_INT>=VERSION_CODES.MINSERTNetwork[]networks=$V.getAllNetworks()INSERTforNetworkmNetwork:networksMOVERTNetworkInfo[]info=$V.getAllNetworkInfo()INSERTNetworkInfonI=$V.getNetworkInfo(mNetwork)UPDATEifinfo[i].getState()==CONNECTEDifnI.getState()==CONNECTEDMOVERTifnI.getState()==CONNECTEDINSERTforNetworkInfoanInfo:infoINSERTanInfo.getState()==CONNECTEDINSERTreturntrueDELETEforintj=0j<info.lengthj++

Core Proximity Value = 0.72

Context Variables

API-Usage UpdateUpdated Target App Code Generic Update Patch

Edit Script

[($V,ConnectivityManager:cMan)]

[($V,ConnectivityManager:conn)]

publicbooleanhasNetwork(Contextcontext){ConnectivityManagerconn=...;if(VERSION.SDK_INT>=VERSION_CODES.M){Network[]networks=conn.getAllNetworks();for(NetworkmNetwork:networks){NetworkInfonetworkInfo=conn.getNetworkInfo(mNetwork);if(networkInfo.getState()==NetworkInfo.State.CONNECTED){returntrue;}}}else{NetworkInfo[]info=conn.getAllNetworkInfo();for(NetworkInfoanInfo:info){if(anInfo.getState()==NetworkInfo.State.CONNECTED){returntrue;}}}returnfalse;}

Page 50: Automated API-Usage Update for Android Apps

API-Usage Update

New Platform

Differential Testing

Old Platform

Page 51: Automated API-Usage Update for Android Apps

API-Usage Update

New Platform

Differential Testing

Old Platform

TargetApp

Page 52: Automated API-Usage Update for Android Apps

API-Usage Update

New Platform

Differential Testing

Old Platform

TargetApp

UpdatedTargetApp

UpdatedTargetApp

Page 53: Automated API-Usage Update for Android Apps

Empirical Evaluation

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

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

Research Questions

Page 54: Automated API-Usage Update for Android Apps

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?

Page 55: Automated API-Usage Update for Android Apps

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?

Page 56: Automated API-Usage Update for Android Apps

Benchmarks and Setup

20 API UsagesaddActiongetAllNetworkInfogetCurrentHourgetCurrentMinutesetCurrentHoursetCurrentMinutesetTextAppearance

addGpsStatusListenerfromHtmlreleaseremoveGpsStatusListenershouldOverrideUrlLoadingstartDrag

abandonAudioFocusgetDeviceIdrequestAudioFocussaveLayersetAudioStreamTypevibrate(long)vibrate(long[],int)

(41 occurrences)

Lollipop Marshmallow Nougat

15 AppsBIPOLALARMCONVERSATIONSPARKENDDCLEAN SBOPENSUDOKU

WIGLE WIFIFOOTGUYCALENDAR IEDIOLINUXSOLAR COMPASS

SYMPHONYSYSLOGMUZEINOTESONETWO

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

Page 57: Automated API-Usage Update for Android Apps

Benchmarks and Setup

20 API UsagesaddActiongetAllNetworkInfogetCurrentHourgetCurrentMinutesetCurrentHoursetCurrentMinutesetTextAppearance

addGpsStatusListenerfromHtmlreleaseremoveGpsStatusListenershouldOverrideUrlLoadingstartDrag

abandonAudioFocusgetDeviceIdrequestAudioFocussaveLayersetAudioStreamTypevibrate(long)vibrate(long[],int)

(41 occurrences)

Lollipop Marshmallow Nougat

15 AppsBIPOLALARMCONVERSATIONSPARKENDDCLEAN SBOPENSUDOKU

WIGLE WIFIFOOTGUYCALENDAR IEDIOLINUXSOLAR COMPASS

SYMPHONYSYSLOGMUZEINOTESONETWO

20 API UsagesaddActiongetAllNetworkInfogetCurrentHourgetCurrentMinutesetCurrentHoursetCurrentMinutesetTextAppearance

addGpsStatusListenerfromHtmlreleaseremoveGpsStatusListenershouldOverrideUrlLoadingstartDrag

abandonAudioFocusgetDeviceIdrequestAudioFocussaveLayersetAudioStreamTypevibrate(long)vibrate(long[],int)

(41 occurrences)

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

Page 58: Automated API-Usage Update for Android Apps

Benchmarks and Setup

20 API UsagesaddActiongetAllNetworkInfogetCurrentHourgetCurrentMinutesetCurrentHoursetCurrentMinutesetTextAppearance

addGpsStatusListenerfromHtmlreleaseremoveGpsStatusListenershouldOverrideUrlLoadingstartDrag

abandonAudioFocusgetDeviceIdrequestAudioFocussaveLayersetAudioStreamTypevibrate(long)vibrate(long[],int)

(41 occurrences)

Lollipop Marshmallow Nougat

15 AppsBIPOLALARMCONVERSATIONSPARKENDDCLEAN SBOPENSUDOKU

WIGLE WIFIFOOTGUYCALENDAR IEDIOLINUXSOLAR COMPASS

SYMPHONYSYSLOGMUZEINOTESONETWO

20 API UsagesaddActiongetAllNetworkInfogetCurrentHourgetCurrentMinutesetCurrentHoursetCurrentMinutesetTextAppearance

addGpsStatusListenerfromHtmlreleaseremoveGpsStatusListenershouldOverrideUrlLoadingstartDrag

abandonAudioFocusgetDeviceIdrequestAudioFocussaveLayersetAudioStreamTypevibrate(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

Page 59: Automated API-Usage Update for Android Apps

Evaluation: EffectivenessRQ1 (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)

Page 60: Automated API-Usage Update for Android Apps

Evaluation: EffectivenessRQ1 (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

Page 61: Automated API-Usage Update for Android Apps

Evaluation: EffectivenessRQ1 (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.

Page 62: Automated API-Usage Update for Android Apps

Evaluation: Efficiency

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

API-UsageAnalysis

Update ExamplesSearch

Update ExamplesAnalysis

API-UsageUpdate

28s 10h27m 2s204ms 20s

The cost of the update examples search phase dominates the cost of the other phases.

Average Execution TimeAPI-UsageAnalysis

Update ExamplesSearch

Update ExamplesAnalysis

API-UsageUpdate

28s 10h27m 2s204ms 20s

The cost of the update examples search phase dominates the cost of the other phases.

Average Execution Time

Page 63: Automated API-Usage Update for Android Apps

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)

Page 64: Automated API-Usage Update for Android Apps

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

Page 65: Automated API-Usage Update for Android Apps

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

Page 66: Automated API-Usage Update for Android Apps

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

Page 67: Automated API-Usage Update for Android Apps

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)

Page 68: Automated API-Usage Update for Android Apps

Summary

Page 69: Automated API-Usage Update for Android Apps

Summary

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

Artifact

Page 70: Automated API-Usage Update for Android Apps

Related Work

Example Based Program Update

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

Other Techniques

ICTAPIFINDER, CHANGEDISTILLING