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

Problem with Huawei P10 #38

Closed
0xbadb0d00 opened this issue Mar 7, 2020 · 4 comments
Closed

Problem with Huawei P10 #38

0xbadb0d00 opened this issue Mar 7, 2020 · 4 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@0xbadb0d00
Copy link

Hello,
I just want to report a problem with Huawei P10.

In the "autoStartHuawei" method, if the intent "PACKAGE_HUAWEI_COMPONENT" exist and gets correctly called, but also exist the intent "PACKAGE_HUAWEI_COMPONENT_FALLBACK", the second one don't get called because the first one do not throw an exception.

Is this wanted?

Best regards, and thank you for your wonderful library

@judemanutd
Copy link
Owner

Hey @giudon010 thanks, the library essentially is looking for a combination of package names so if huawei changes their package names, there is a very good chance it would either not find the package or it would find 1 and not the next one because huawei shuffed them up, did the current setup of the library open up the autostart on the P10?

@0xbadb0d00
Copy link
Author

Hello @judemanutd, thank your for your answer.

No, the current setup doesn't work.

I try to explain better the trouble, because it's a "rare case", but it happens.

On My Huawei P10 (Android 8.0.0, EMUI 8.0.0), are available both Intents that you check with AutoStarter:

  • private val PACKAGE_HUAWEI_COMPONENT = "com.huawei.systemmanager.optimize.process.ProtectActivity"
  • private val PACKAGE_HUAWEI_COMPONENT_FALLBACK = "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"

The first one is still-present Intent, but never used by the phone because is unreachable from the Phone Settings (I think it is an Intent left wrongly by the old versions of Huawei smartphones), the second one is the real activity that I should view with AutoStarter, but it is never showed because AutoStarter find (wrongly) the first one.

A possible solution is simply to replace the most recent Intent with the old ones (I think that it could be a good solutions also for other manufacturers managed by AutoStarters).
To be more precise, in Huawei case, you should replace COMPONENT variables as follows:

  • private val PACKAGE_HUAWEI_COMPONENT = "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"
  • private val PACKAGE_HUAWEI_COMPONENT_FALLBACK = "com.huawei.systemmanager.optimize.process.ProtectActivity"

or, in alternative, try to check for both ones presences, something like:

        try {
            startIntent(context, PACKAGE_HUAWEI_MAIN, PACKAGE_HUAWEI_COMPONENT)
        } catch (e: Exception) {
            e.printStackTrace()
        }
        try {
                startIntent(context, PACKAGE_HUAWEI_MAIN, PACKAGE_HUAWEI_COMPONENT_FALLBACK)
            } catch (ex: Exception) {
                ex.printStackTrace()
                return false
        }

I hope that my proposed solutions can help me and other developers too. Let me know what you think about it.

@judemanutd
Copy link
Owner

That actually helps alot, thanks for taking the time and debugging this. I'll probably implement that last suggestion that you made and keep both intents just so that it can work with older devices as well since that was the one that worked initially. I'll have to wait until the weekend to actually make a change and have it up but in the mean time if you can make a pull request instead that would be great.

@judemanutd judemanutd added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Mar 9, 2020
awoisoak added a commit to awoisoak/AutoStarter that referenced this issue Jun 4, 2021
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
@judemanutd
Copy link
Owner

This should be resolved by #69 but feel free to open the issue if it is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants