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 Gingerbread Honeycomb Ice Cream Jelly Bean KitKat Lollipop Marshmallow Nougat Oreo Pie
Adaptive Maintenance Platform New Platform App App Developer
Platform Fragmentation Ice Cream Gingerbread Jelly Bean KitKat Oreo Lollipop Nougat Marshmallow
Intuition Developer B App B Developer A App A Developer C App C
Intuition Developer B App B Developer A App A Developer C App C
Intuition Developer B App B Developer A App A Developer C App C
API Updates API-Usage Changes public NetworkInfo[] getAllNetworkInfo() Old API Usage public NetworkInfo[] getAllNetworkInfo() New API Usage public Network[] getAllNetworks() public NetworkInfo getNetworkInfo(Network network)
API Updates API-Usage Changes public NetworkInfo[] getAllNetworkInfo() Old API Usage public NetworkInfo[] getAllNetworkInfo () New API Usage public Network[] getAllNetworks () public NetworkInfo getNetworkInfo (Network network)
API Updates API-Usage Changes public NetworkInfo[] getAllNetworkInfo() Old API Usage public NetworkInfo[] getAllNetworkInfo () New API Usage public Network[] getAllNetworks () public NetworkInfo getNetworkInfo ( Network network )
API Updates API-Usage Changes public NetworkInfo[] getAllNetworkInfo() Old API Usage public NetworkInfo[] getAllNetworkInfo() New API Usage public Network[] getAllNetworks() public NetworkInfo getNetworkInfo(Network network)
Update Example Update Example Before Update Example After public boolean isConnected(Context cont) { public boolean isConnected(Context cont) { ConnectivityManager cm = ...; ConnectivityManager cm = ... ; NetworkInfo[] info = cm.getAllNetworkInfo(); if (VERSION.SDK_INT >= VERSION_CODES.M) { for (int i = 0; i < info.length; i++) { Network[] networks = cm.getAllNetworks(); if(info[i].isConnected()) { for (Network mNetwork : networks) { return true; NetworkInfo networkInfo = } } cm.getNetworkInfo(mNetwork); Toast.makeText(R.s.noNet).show(); if(networkInfo.isConnected()) { return false; 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 Update Example After public boolean isConnected(Context cont) { public boolean isConnected(Context cont) { ConnectivityManager cm = ...; ConnectivityManager cm = ... ; NetworkInfo[] info = cm.getAllNetworkInfo(); if (VERSION.SDK_INT >= VERSION_CODES.M) { for (int i = 0; i < info.length; i++) { Network[] networks = cm.getAllNetworks(); if(info[i].isConnected()) { for (Network mNetwork : networks) { return true; NetworkInfo networkInfo = } } cm.getNetworkInfo(mNetwork); Toast.makeText(R.s.noNet).show(); if(networkInfo.isConnected()) { return false; 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 Update Example After public boolean isConnected(Context cont) { public boolean isConnected(Context cont) { ConnectivityManager cm = ...; ConnectivityManager cm = ... ; NetworkInfo[] info = cm.getAllNetworkInfo(); if (VERSION.SDK_INT >= VERSION_CODES.M) { for (NetworkInfo anInfo : info) { Network[] networks = cm.getAllNetworks(); if(info[i].isConnected()) { for (Network mNetwork : networks) { return true; NetworkInfo networkInfo = } } cm.getNetworkInfo(mNetwork); Toast.makeText(R.s.noNet).show(); if(networkInfo.isConnected()) { return false; 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 Update Example After public boolean isConnected(Context cont) { public boolean isConnected(Context cont) { ConnectivityManager cm = ...; ConnectivityManager cm = ... ; NetworkInfo[] info = cm.getAllNetworkInfo(); if (VERSION.SDK_INT >= VERSION_CODES.M) { for (NetworkInfo anInfo : info) { Network[] networks = cm.getAllNetworks(); if(info[i].isConnected()) { for (Network mNetwork : networks) { return true; NetworkInfo networkInfo = } } cm.getNetworkInfo(mNetwork); Toast.makeText( R.s.noNet ).show(); if(networkInfo.isConnected()) { return false; 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; }
A PP E VOLVE Overview Update and Find update Abstract update Identify API validate API usages requiring examples for examples into update in target usages in target identified API generic update app app based on usages patches and patches rank them
A PP E VOLVE Overview Update and Find update Abstract update Identify API validate API usages requiring examples for examples into update in target usages in target identified API generic update app app based on usages patches and patches rank them
A PP E VOLVE Overview Update and Find update Abstract update Identify API validate API usages requiring examples for examples into update in target usages in target identified API generic update app app based on usages patches and patches rank them
Update Example Search Code Hosting Infrastructure Keyword-Based Search method ∈ ∀ New API Usage signature method name, param types, declaring class Search Result Code Base App 2 Code Base App 1 Code Base App 3 Code Base App 4 f 1 i − n f 2 j − 1 f 4 k − 1 f 1 i − 1 f 2 j f 4 k f 1 i
Update Example Search Code Hosting Infrastructure Keyword-Based Search method ∈ ∀ New API Usage signature method name, param types, declaring class Search Result Search Result Code Base App 2 Code Base App 2 Code Base App 1 Code Base App 1 Code Base App 3 Code Base App 3 Code Base App 4 Code Base App 4 f 1 i − n f 1 i − n f 2 j − 1 f 2 j − 1 f 4 k − 1 f 4 k − 1 f 1 i − 1 f 1 i − 1 f 2 j f 2 j f 4 k f 4 k f 1 i f 1 i
Update Example Search Code Hosting Infrastructure Keyword-Based Search method ∈ ∀ New API Usage signature method name, param types, declaring class Search Result Search Result Code Base App 2 Code Base App 2 Code Base App 1 Code Base App 1 Code Base App 3 Code Base App 3 Code Base App 4 Code Base App 4 f 1 i − n f 1 i − n f 2 j − 1 f 2 j − 1 f 4 k − 1 f 4 k − 1 f 1 i − 1 f 1 i − 1 f 2 j f 2 j f 4 k f 4 k f 1 i f 1 i
Update Example Search Before Update After Update ( f 1 i − 1 ) ( f 1 i ) public boolean isConnected(Context cont) { public boolean isConnected(Context cont) { ConnectivityManager cm = ...; ConnectivityManager cm = ... ; NetworkInfo[] info = cm.getAllNetworkInfo(); if (VERSION.SDK_INT >= VERSION_CODES.M) { for (int i = 0; i < info.length; i++) { Network[] networks = cm.getAllNetworks(); if(info[i].isConnected()) { for (Network mNetwork : networks) { return true; NetworkInfo networkInfo = } } cm.getNetworkInfo(mNetwork); Toast.makeText(R.s.noNet).show(); if(networkInfo.isConnected()) { return false; 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 Before Update After Update ( f 1 i − 1 ) ( f 1 i ) public boolean isConnected(Context cont) { public boolean isConnected(Context cont) { ConnectivityManager cm = ...; ConnectivityManager cm = ... ; - NetworkInfo[] info = cm.getAllNetworkInfo(); + if (VERSION.SDK_INT >= VERSION_CODES.M) { - for (int i = 0; i < info.length; i++) { + Network[] networks = cm.getAllNetworks(); - if(info[i].isConnected()) { + for (Network mNetwork : networks) { return true; + NetworkInfo networkInfo = } } + cm.getNetworkInfo(mNetwork); - Toast.makeText(R.s.noNet).show(); + if(networkInfo.isConnected()) { return false; + 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; }
Recommend
More recommend