Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: LocationManager provider #174

Merged
merged 9 commits into from
May 28, 2024

Conversation

Dor-bl
Copy link
Contributor

@Dor-bl Dor-bl commented May 18, 2024

  • Updated createLocationManagerMockProvider method to use getProviderProperties for API level 31 and above.
  • Added runtime API level checks to ensure backward compatibility with API levels below 31.
  • Removed dependency on LocationProvider in the calling method.
  • Handled null cases for provider name and provider properties.
  • Ensured compatibility and adherence to modern Android best practices.

- Updated createLocationManagerMockProvider method to use getProviderProperties for API level 31 and above.
- Added runtime API level checks to ensure backward compatibility with API levels below 31.
- Removed dependency on LocationProvider in the calling method.
- Handled null cases for provider name and provider properties.
- Ensured compatibility and adherence to modern Android best practices.
@Dor-bl
Copy link
Contributor Author

Dor-bl commented May 18, 2024

@mykola-mokhnach , I see the install dependencies failed.
Should I add the below elsewhere?
import android.location.provider.ProviderProperties;
UPDATE : forgot to commit the sdk version update.
But now have another issue I need to resolve

@KazuCocoa
Copy link
Member

For the lint error, it can have @SuppressLint("MissingPermission") for now I think

@KazuCocoa
Copy link
Member

KazuCocoa commented May 25, 2024

It looks like Method getAnimationScales = windowManagerClass.getDeclaredMethod("getAnimationScales"); may raise an error for target api level 31 as https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces

https://developer.android.com/about/versions/12/non-sdk-12

It looks like the animation command usage is only for lower than API level 26 https://github.com/appium/appium-uiautomator2-driver/blob/4cd489aa9a282f412ee45e1366c86bf7e580c798/lib/driver.ts#L594-L597
Espresso actually uses this method but I think espresso server also can follow the --no-window-animation. Then we can completely drop this animation command in settings.

We could add an annotation for @SuppressLint("SoonBlockedPrivateApi" to ignore this error I believe. We disable https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces with hidden policy settings command call, but some devices may not allow to apply the hidden policy. So... I think it would be nice to drop lower Android OS version first, and remove animation command via settings app, then apply this change to settings.

@KazuCocoa
Copy link
Member

lg, but please wait for appium/appium-espresso-driver#1007 so that we can safely apply the animation related change for lower os versions only

@KazuCocoa KazuCocoa changed the title Refactor LocationManager provider refactor: LocationManager provider May 28, 2024
@KazuCocoa KazuCocoa merged commit da7e36a into appium:master May 28, 2024
7 checks passed
github-actions bot pushed a commit that referenced this pull request May 31, 2024
## [5.10.1](v5.10.0...v5.10.1) (2024-05-31)

### Miscellaneous Chores

* **deps:** bump com.google.android.gms:play-services-location ([#177](#177)) ([f751709](f751709))

### Code Refactoring

* LocationManager provider ([#174](#174)) ([da7e36a](da7e36a))
Copy link

🎉 This PR is included in version 5.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Dor-bl Dor-bl deleted the location_service_31 branch May 31, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants