-
Notifications
You must be signed in to change notification settings - Fork 115
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
Several Improvements #69
Conversation
It checks the existence of the activities before attempting to open them. Now if the activity can really not be opened, getAutoStartPermission will return false. Related issues: judemanutd#29 judemanutd#30 isAutoStartPermissionAvailable is checking the existence of the activity in order to avoid 'false positives' when the library is not able to open a specific settings screen. Inverted the Huawei intents to process the newer ones first (I didn't invert the rest of the manufacturers as I can't test all of them). This fix known issue with Huawei P 10 Lite judemanutd#38 (tested) Use Build.BRAND.toLowerCase(Locale.ROOT) to avoid issues with certain languages as Turkish as mentioned here: judemanutd#66 (tested) Includes FLAG_ACTIVITY_NEW_TASK so that it can be called outside an Activity. Fixed this: judemanutd#62 Add a new activity to be opened in Samsung devices as: This one open the exact Sleeping Apps setting com.samsung.android.lool/com.samsung.android.sm.battery.ui.usage.CheckableAppListActivity While this one opens the main battery settings com.samsung.android.lool/com.samsung.android.sm.battery.ui.BatteryActivity That should fixes theses (Tested with Note 8, Note 9 & Note 20): judemanutd#37 judemanutd#33
Set to false by default for backward compatibility
For backward compatibility with the library, by default autostart is considered available even if the library does not support the specific screen.
This opens the main Battery Settings com.samsung.android.sm.battery.ui.BatteryActivity so we should only use it if we can't open the specific Sleeping Apps settings with: com.samsung.android.sm.battery.ui.usage.CheckableAppListActivity
|
||
when (Build.BRAND.toLowerCase(Locale.getDefault())) { | ||
when (Build.BRAND.toLowerCase(Locale.ROOT)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prometheus3k I think you guys will need to sort out which one actually work here because I don't have the resources to actually verify this. @awoisoak for context, there is a PR that updates this very line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My PR is a restoration of @alperenbabagil Original work that was approved previously.
#58
However I will close my PR as I haven't tested it (assumed the approval meant it worked).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I just tested with Locale.ROOT
as is the approach we are following in similar scenarios in our side.
@judemanutd I added an extra commit to make sure the class is only instantiated once. Ideally the class should probably be a Kotlin object but for backward compatibility with current release I kept the |
@awoisoak can't thank you enough for these changes and testing them out. |
I tried to modify the minimum from the original code but some of the current issues required quite a few changes, sorry in advance for that.
Main change is that it checks the existence of the activities before attempting to open them. Now if the activity can't really be opened,
getAutoStartPermission
will return false. Related issues: simple code for check intent is exist #29 Overhaul activity checking to be cleaner #30isAutoStartPermissionAvailable
now allows the caller to only consider the permissions available if the library is able to open the corresponding settings screen (in order to avoid false positives). For backward compatibility with previous versions of the library, by default autostart is considered available even if the library does not support the specific screen.Inverted the Huawei intents to process the newer ones first (I didn't invert the rest of the manufacturers as I can't test all of them). This fixes the known issue with Huawei P 10 Lite: Problem with Huawei P10 #38 [tested]
Use
Build.BRAND.toLowerCase(Locale.ROOT)
to avoid issues with certain languages as Turkish as mentioned here: toLowerCase fail #66 [tested]Includes
FLAG_ACTIVITY_NEW_TASK
as optional so that the library can be called outside an Activity.Fix this: AndroidRuntimeException: Calling startActivity() #42 (related to PR: Added for react native project #62) [Tested]
Add a new activity to be opened in Samsung devices.
Prioritize this one as it opens the exact Sleeping Apps setting
com.samsung.android.lool/com.samsung.android.sm.battery.ui.usage.CheckableAppListActivity
If that screen does not exist it will fallback to this one which opens the main battery settings
com.samsung.android.lool/com.samsung.android.sm.battery.ui.BatteryActivity
That should fix these issues :Not working in Samsung note 10 #37 Not Working in Samsung Galaxy M20 #33 [Tested with Note 8, Note 9 & Note 20]
Handle OnePlus newer devices (via intent action
com.android.settings.action.BACKGROUND_OPTIMIZE
)Should fix these: OnePlus 6 #36 [OnePlus 7 Pro] getAutoStartPermission exception #45 OnePlus Android 11 fails to open ChainLaunchAppListActivity #67 [Tested with OnePlus 7 pro (10), Oneplus 7T(10) & OnePlus 8(11)]