Skip to content

Commit bd66144

Browse files
chore: Deprecate legacy app management helpers (#1571)
1 parent a1f802e commit bd66144

File tree

11 files changed

+111
-157
lines changed

11 files changed

+111
-157
lines changed

src/main/java/io/appium/java_client/InteractsWithApps.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
package io.appium.java_client;
1818

1919
import static io.appium.java_client.MobileCommand.ACTIVATE_APP;
20-
import static io.appium.java_client.MobileCommand.CLOSE_APP;
2120
import static io.appium.java_client.MobileCommand.INSTALL_APP;
2221
import static io.appium.java_client.MobileCommand.IS_APP_INSTALLED;
23-
import static io.appium.java_client.MobileCommand.LAUNCH_APP;
2422
import static io.appium.java_client.MobileCommand.QUERY_APP_STATE;
2523
import static io.appium.java_client.MobileCommand.REMOVE_APP;
26-
import static io.appium.java_client.MobileCommand.RESET;
2724
import static io.appium.java_client.MobileCommand.RUN_APP_IN_BACKGROUND;
2825
import static io.appium.java_client.MobileCommand.TERMINATE_APP;
2926
import static io.appium.java_client.MobileCommand.prepareArguments;
@@ -40,16 +37,9 @@
4037
import java.util.AbstractMap;
4138
import javax.annotation.Nullable;
4239

40+
@SuppressWarnings("rawtypes")
4341
public interface InteractsWithApps extends ExecutesMethod {
4442

45-
/**
46-
* Launches the app, which was provided in the capabilities at session creation,
47-
* and (re)starts the session.
48-
*/
49-
default void launchApp() {
50-
execute(LAUNCH_APP);
51-
}
52-
5343
/**
5444
* Install an app on the mobile device.
5545
*
@@ -63,7 +53,7 @@ default void installApp(String appPath) {
6353
* Install an app on the mobile device.
6454
*
6555
* @param appPath path to app to install or a remote URL.
66-
* @param options Set of the corresponding instllation options for
56+
* @param options Set of the corresponding installation options for
6757
* the particular platform.
6858
*/
6959
default void installApp(String appPath, @Nullable BaseInstallApplicationOptions options) {
@@ -86,13 +76,6 @@ default boolean isAppInstalled(String bundleId) {
8676
new AbstractMap.SimpleEntry<>(IS_APP_INSTALLED, prepareArguments("bundleId", bundleId)));
8777
}
8878

89-
/**
90-
* Resets the currently running app together with the session.
91-
*/
92-
default void resetApp() {
93-
execute(RESET);
94-
}
95-
9679
/**
9780
* Runs the current app as a background app for the time
9881
* requested. This is a synchronous method, it blocks while the
@@ -132,14 +115,6 @@ default boolean removeApp(String bundleId, @Nullable BaseRemoveApplicationOption
132115
new AbstractMap.SimpleEntry<>(REMOVE_APP, prepareArguments(parameters, values)));
133116
}
134117

135-
/**
136-
* Close the app which was provided in the capabilities at session creation
137-
* and quits the session.
138-
*/
139-
default void closeApp() {
140-
execute(CLOSE_APP);
141-
}
142-
143118
/**
144119
* Activates the given app if it installed, but not running or if it is running in the
145120
* background.

src/main/java/io/appium/java_client/MobileCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class MobileCommand {
4747
public static final String RUN_APP_IN_BACKGROUND;
4848
protected static final String PERFORM_TOUCH_ACTION;
4949
protected static final String PERFORM_MULTI_TOUCH;
50-
protected static final String LAUNCH_APP;
51-
protected static final String CLOSE_APP;
50+
public static final String LAUNCH_APP;
51+
public static final String CLOSE_APP;
5252
protected static final String GET_DEVICE_TIME;
5353
protected static final String GET_SESSION;
5454
protected static final String LOG_EVENT;

src/main/java/io/appium/java_client/PerformsTouchActions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ default TouchAction performTouchAction(TouchAction touchAction) {
6565
* is called.
6666
*
6767
* @param multiAction the MultiTouchAction object to perform.
68+
* @return MultiTouchAction instance for chaining.
6869
*/
6970
@Deprecated
7071
default MultiTouchAction performMultiTouchAction(MultiTouchAction multiAction) {

src/main/java/io/appium/java_client/InteractsWithFiles.java renamed to src/main/java/io/appium/java_client/PullsFiles.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,57 +26,41 @@
2626
import java.nio.charset.StandardCharsets;
2727
import java.util.Base64;
2828

29-
public interface InteractsWithFiles extends ExecutesMethod {
29+
public interface PullsFiles extends ExecutesMethod {
3030

3131
/**
32-
* Pull a file from the simulator/device.
33-
* On iOS the server should have ifuse
34-
* libraries installed and configured properly for this feature to work
35-
* on real devices.
32+
* Pull a file from the remote system.
3633
* On Android the application under test should be
3734
* built with debuggable flag enabled in order to get access to its container
3835
* on the internal file system.
3936
*
40-
* @see <a href="https://github.com/libimobiledevice/ifuse">iFuse GitHub page6</a>
41-
* @see <a href="https://github.com/osxfuse/osxfuse/wiki/FAQ">osxFuse FAQ</a>
42-
* @see <a href="https://developer.android.com/studio/debug/">'Debug Your App' developer article</a>
43-
*
4437
* @param remotePath If the path starts with <em>@applicationId/</em>/ prefix, then the file
4538
* will be pulled from the root of the corresponding application container.
46-
* Otherwise the root folder is considered as / on Android and
39+
* Otherwise, the root folder is considered as / on Android and
4740
* on iOS it is a media folder root (real devices only).
4841
* @return A byte array of Base64 encoded data.
4942
*/
5043
default byte[] pullFile(String remotePath) {
5144
Response response = execute(PULL_FILE, ImmutableMap.of("path", remotePath));
5245
String base64String = response.getValue().toString();
53-
5446
return Base64.getDecoder().decode(base64String.getBytes(StandardCharsets.UTF_8));
5547
}
5648

5749
/**
58-
* Pull a folder content from the simulator/device.
59-
* On iOS the server should have ifuse
60-
* libraries installed and configured properly for this feature to work
61-
* on real devices.
50+
* Pull a folder content from the remote system.
6251
* On Android the application under test should be
6352
* built with debuggable flag enabled in order to get access to its container
6453
* on the internal file system.
6554
*
66-
* @see <a href="https://github.com/libimobiledevice/ifuse">iFuse GitHub page6</a>
67-
* @see <a href="https://github.com/osxfuse/osxfuse/wiki/FAQ">osxFuse FAQ</a>
68-
* @see <a href="https://developer.android.com/studio/debug/">'Debug Your App' developer article</a>
69-
*
7055
* @param remotePath If the path starts with <em>@applicationId/</em> prefix, then the folder
7156
* will be pulled from the root of the corresponding application container.
72-
* Otherwise the root folder is considered as / on Android and
57+
* Otherwise, the root folder is considered as / on Android and
7358
* on iOS it is a media folder root (real devices only).
7459
* @return A byte array of Base64 encoded zip archive data.
7560
*/
7661
default byte[] pullFolder(String remotePath) {
7762
Response response = execute(PULL_FOLDER, ImmutableMap.of("path", remotePath));
7863
String base64String = response.getValue().toString();
79-
8064
return Base64.getDecoder().decode(base64String.getBytes(StandardCharsets.UTF_8));
8165
}
8266

src/main/java/io/appium/java_client/ios/PushesFiles.java renamed to src/main/java/io/appium/java_client/PushesFiles.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.appium.java_client.ios;
17+
package io.appium.java_client;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020
import static io.appium.java_client.MobileCommand.pushFileCommand;
2121

22-
import io.appium.java_client.CommandExecutionHelper;
23-
import io.appium.java_client.ExecutesMethod;
2422
import org.apache.commons.codec.binary.Base64;
2523
import org.apache.commons.io.FileUtils;
2624

@@ -30,13 +28,7 @@
3028
public interface PushesFiles extends ExecutesMethod {
3129

3230
/**
33-
* Saves base64 encoded data as a media file on the remote mobile device.
34-
* The server should have ifuse
35-
* libraries installed and configured properly for this feature to work
36-
* on real devices.
37-
*
38-
* @see <a href="https://github.com/libimobiledevice/ifuse">iFuse GitHub page</a>
39-
* @see <a href="https://github.com/osxfuse/osxfuse/wiki/FAQ">osxFuse FAQ</a>
31+
* Saves base64 encoded data as a media file on the remote system.
4032
*
4133
* @param remotePath Path to file to write data to on remote device
4234
* Only the filename part matters there on Simulator, so the remote end
@@ -53,13 +45,7 @@ default void pushFile(String remotePath, byte[] base64Data) {
5345
}
5446

5547
/**
56-
* Saves base64 encoded data as a media file on the remote mobile device.
57-
* The server should have ifuse
58-
* libraries installed and configured properly for this feature to work
59-
* on real devices.
60-
*
61-
* @see <a href="https://github.com/libimobiledevice/ifuse">iFuse GitHub page</a>
62-
* @see <a href="https://github.com/osxfuse/osxfuse/wiki/FAQ">osxFuse FAQ</a>
48+
* Saves base64 encoded data as a media file on the remote system.
6349
*
6450
* @param remotePath See the documentation on {@link #pushFile(String, byte[])}
6551
* @param file Is an existing local file to be written to the remote device
@@ -68,7 +54,8 @@ default void pushFile(String remotePath, byte[] base64Data) {
6854
default void pushFile(String remotePath, File file) throws IOException {
6955
checkNotNull(file, "A reference to file should not be NULL");
7056
if (!file.exists()) {
71-
throw new IOException(String.format("The given file %s doesn't exist", file.getAbsolutePath()));
57+
throw new IOException(String.format("The given file %s doesn't exist",
58+
file.getAbsolutePath()));
7259
}
7360
pushFile(remotePath, Base64.encodeBase64(FileUtils.readFileToByteArray(file)));
7461
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client;
18+
19+
import static io.appium.java_client.MobileCommand.CLOSE_APP;
20+
import static io.appium.java_client.MobileCommand.LAUNCH_APP;
21+
import static io.appium.java_client.MobileCommand.RESET;
22+
23+
@Deprecated
24+
public interface SupportsLegacyAppManagement extends ExecutesMethod {
25+
/**
26+
* Launches the app, which was provided in the capabilities at session creation,
27+
* and (re)starts the session.
28+
*
29+
* @deprecated This method is deprecated and will be removed.
30+
* See https://github.com/appium/appium/issues/15807
31+
*/
32+
@Deprecated
33+
default void launchApp() {
34+
execute(LAUNCH_APP);
35+
}
36+
37+
/**
38+
* Resets the currently running app together with the session.
39+
*
40+
* @deprecated This method is deprecated and will be removed.
41+
* See https://github.com/appium/appium/issues/15807
42+
*/
43+
@Deprecated
44+
default void resetApp() {
45+
execute(RESET);
46+
}
47+
48+
/**
49+
* Close the app which was provided in the capabilities at session creation
50+
* and quits the session.
51+
*
52+
* @deprecated This method is deprecated and will be removed.
53+
* See https://github.com/appium/appium/issues/15807
54+
*/
55+
@Deprecated
56+
default void closeApp() {
57+
execute(CLOSE_APP);
58+
}
59+
}

src/main/java/io/appium/java_client/TouchAction.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
* Calling perform() sends the action command to the Mobile Driver. Otherwise,
4444
* more and more actions can be chained.
4545
*
46-
* Touch actions are deprecated.
47-
* Please use W3C Actions instead or the corresponding
48-
* extension methods for the driver (if available).
49-
* Check
50-
* - https://www.youtube.com/watch?v=oAJ7jwMNFVU
51-
* - https://appiumpro.com/editions/30-ios-specific-touch-action-methods
52-
* - https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api
53-
* for more details.
46+
* @deprecated Touch actions are deprecated.
47+
* Please use W3C Actions instead or the corresponding
48+
* extension methods for the driver (if available).
49+
* Check
50+
* - https://www.youtube.com/watch?v=oAJ7jwMNFVU
51+
* - https://appiumpro.com/editions/30-ios-specific-touch-action-methods
52+
* - https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api
53+
* for more details.
5454
*/
5555
@Deprecated
5656
public class TouchAction<T extends TouchAction<T>> implements PerformsActions<T> {

src/main/java/io/appium/java_client/android/AndroidDriver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
import io.appium.java_client.HasOnScreenKeyboard;
3232
import io.appium.java_client.HidesKeyboard;
3333
import io.appium.java_client.InteractsWithApps;
34-
import io.appium.java_client.InteractsWithFiles;
34+
import io.appium.java_client.PullsFiles;
3535
import io.appium.java_client.LocksDevice;
3636
import io.appium.java_client.PerformsTouchActions;
37+
import io.appium.java_client.PushesFiles;
38+
import io.appium.java_client.SupportsLegacyAppManagement;
3739
import io.appium.java_client.android.connection.HasNetworkConnection;
3840
import io.appium.java_client.android.geolocation.SupportsExtendedGeolocationCommands;
3941
import io.appium.java_client.android.nativekey.PressesKey;
@@ -66,8 +68,9 @@ public class AndroidDriver extends AppiumDriver implements
6668
PerformsTouchActions,
6769
HidesKeyboard,
6870
HasDeviceTime,
69-
InteractsWithFiles,
71+
PullsFiles,
7072
InteractsWithApps,
73+
SupportsLegacyAppManagement,
7174
HasAppStrings,
7275
HasNetworkConnection,
7376
PushesFiles,

src/main/java/io/appium/java_client/android/PushesFiles.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)