@@ -53,7 +53,8 @@ public class InstrumentationTestRunner {
53
53
private final String testRunner ;
54
54
private final File outputDirectory ;
55
55
private final String exopackageLocalPath ;
56
- private final boolean attemptUninstall ;
56
+ private final boolean attemptUninstallApkUnderTest ;
57
+ private final boolean attemptUninstallInstrumentationApk ;
57
58
private final Map <String , String > extraInstrumentationArguments ;
58
59
private final boolean debug ;
59
60
private final boolean codeCoverage ;
@@ -73,7 +74,8 @@ public InstrumentationTestRunner(
73
74
String apkUnderTestPath ,
74
75
String exopackageLocalPath ,
75
76
String apkUnderTestExopackageLocalPath ,
76
- boolean attemptUninstall ,
77
+ boolean attemptUninstallApkUnderTest ,
78
+ boolean attemptUninstallInstrumentationApk ,
77
79
boolean debug ,
78
80
boolean codeCoverage ,
79
81
String codeCoverageOutputFile ,
@@ -88,7 +90,8 @@ public InstrumentationTestRunner(
88
90
this .apkUnderTestPath = apkUnderTestPath ;
89
91
this .exopackageLocalPath = exopackageLocalPath ;
90
92
this .apkUnderTestExopackageLocalPath = apkUnderTestExopackageLocalPath ;
91
- this .attemptUninstall = attemptUninstall ;
93
+ this .attemptUninstallApkUnderTest = attemptUninstallApkUnderTest ;
94
+ this .attemptUninstallInstrumentationApk = attemptUninstallInstrumentationApk ;
92
95
this .codeCoverageOutputFile = codeCoverageOutputFile ;
93
96
this .extraInstrumentationArguments = extraInstrumentationArguments ;
94
97
this .debug = debug ;
@@ -106,7 +109,8 @@ public static InstrumentationTestRunner fromArgs(String... args) {
106
109
String codeCoverageOutputFile = null ;
107
110
String exopackageLocalPath = null ;
108
111
String apkUnderTestExopackageLocalPath = null ;
109
- boolean attemptUninstall = false ;
112
+ boolean attemptUninstallApkUnderTest = false ;
113
+ boolean attemptUninstallInstrumentationApk = false ;
110
114
boolean debug = false ;
111
115
boolean codeCoverage = false ;
112
116
Map <String , String > extraInstrumentationArguments = new HashMap <String , String >();
@@ -145,7 +149,14 @@ public static InstrumentationTestRunner fromArgs(String... args) {
145
149
apkUnderTestExopackageLocalPath = args [++i ];
146
150
break ;
147
151
case "--attempt-uninstall" :
148
- attemptUninstall = true ;
152
+ attemptUninstallApkUnderTest = true ;
153
+ attemptUninstallInstrumentationApk = true ;
154
+ break ;
155
+ case "--attempt-uninstall-apk-under-test" :
156
+ attemptUninstallApkUnderTest = true ;
157
+ break ;
158
+ case "--attempt-uninstall-instrumentation-apk" :
159
+ attemptUninstallInstrumentationApk = true ;
149
160
break ;
150
161
case "--debug" :
151
162
debug = true ;
@@ -210,7 +221,8 @@ public static InstrumentationTestRunner fromArgs(String... args) {
210
221
apkUnderTestPath ,
211
222
exopackageLocalPath ,
212
223
apkUnderTestExopackageLocalPath ,
213
- attemptUninstall ,
224
+ attemptUninstallApkUnderTest ,
225
+ attemptUninstallInstrumentationApk ,
214
226
debug ,
215
227
codeCoverage ,
216
228
codeCoverageOutputFile ,
@@ -308,9 +320,11 @@ public void testRunStopped(long elapsedTime) {}
308
320
"/data/data/" + this .packageName + "/files/coverage.ec" , this .codeCoverageOutputFile );
309
321
}
310
322
} finally {
311
- if (this .attemptUninstall ) {
323
+ if (this .attemptUninstallInstrumentationApk ) {
312
324
// Best effort uninstall from the emulator/device.
313
325
device .uninstallPackage (this .packageName );
326
+ }
327
+ if (this .attemptUninstallApkUnderTest ) {
314
328
device .uninstallPackage (this .targetPackageName );
315
329
}
316
330
}
0 commit comments