Giter VIP home page Giter VIP logo

autostarter's People

Contributors

alperenbabagil avatar awoisoak avatar cedricale avatar judemanutd avatar mansya avatar prometheus3k avatar rayworks avatar zeronfinity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autostarter's Issues

How to check if got the permission successfully?

After we navigate the user to the setting how to check if user successfully provided the permission.

And secondly is there way by which we can scroll user to the app after navigating to setting or if there any way to sort app by alphabet that would be very helpful our app name starts with 'U' me myself got sick scrolling for that long how user would not be.

It would be highly appreciated if there could help.

i have integrated it in java, Working smoothly, Great work.

not working in Letv x2

i am not getting any dialog for auto start permission screen in letv x2 phone, i have used your library, -->implementation 'com.github.judemanutd:autostarter:1.0.1
-- >AutoStartPermissionHelper.getInstance().getAutoStartPermission(getApplicationContext());


Then i have used other code :
if ("Letv".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.letv.android.letvsafe",
"com.letv.android.letvsafe.AutobootManageActivity"));

But not getting any screen and not getting notification( Please help me)

New logo/Icon

Hi, I am a graphic designer, I want to help others in graphic design.

After I reviewed your project, you have no logo on this project. Therefore I want to contribute to this project by creating a new logo / icon. what do you think?

Support for Realme devices

This is repo is very helpfull and working as per the README mentioned devices. But I am looking for the same in realme device.

OnePlus 6

Hello in the newest version there is experimental OnePlus support. I'd like to report an issue on OP6, where the intent is not working since there is no activity to be opened. I'd also like to mention that I didn't notice any issues on recent OP models in a conjunction wit applications auto-start capabilities.

Note working on Xiaomi Redmi Note 7

AutoStartPermissionHelper.getInstance().isAutoStartPermissionAvailable(getApplicationContext())

gives true as init installed(no any special action, just click apk and install).
And there's no action after call AutoStartPermissionHelper.getInstance().getAutoStartPermission(getApplicationContext());

AndroidRuntimeException: Calling startActivity()

Hi,

I'm using this library via a flutter plugin.

Device: OnePlus 7 GM1901
OS: Oxygen OS 10.3.2GM57AA

it returns true for isAutoStartPermissionAvailable

any help is appreciated.

Logs :
W/System.err(28183): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? W/System.err(28183): at android.app.ContextImpl.startActivity(ContextImpl.java:964) W/System.err(28183): at android.app.ContextImpl.startActivity(ContextImpl.java:940) W/System.err(28183): at android.content.ContextWrapper.startActivity(ContextWrapper.java:383) W/System.err(28183): at com.judemanutd.autostarter.AutoStartPermissionHelper.startIntent(AutoStartPermissionHelper.kt:325) W/System.err(28183): at com.judemanutd.autostarter.AutoStartPermissionHelper.autoStartOnePlus(AutoStartPermissionHelper.kt:308) W/System.err(28183): at com.judemanutd.autostarter.AutoStartPermissionHelper.getAutoStartPermission(AutoStartPermissionHelper.kt:118) W/System.err(28183): at com.yin.autostart.AutostartPlugin.onMethodCall(AutostartPlugin.java:53)

Realme 5 pro with Realme ui

Extract with adb shell dumpsys activity recents

Screen app settings start

com.coloros.safecenter/.startupapp.StartupAppListActivity

simple code for check intent is exist

        Intent intent = new Intent();
        intent.setComponent(new ComponentName(packageName, componentName));
        if (intent.resolveActivity(context.getPackageManager()) != null) {
            // the intent is exist
        }

Wrong activity on older Asus devices

It's me again!

The activity com.asus.mobilemanager.powersaver.PowerSaverSettings doesn't exist on Asus with Android 5. However, through my immeasurable skills of reverse engineering, I have found the right one that does exist:

ComponentName("com.asus.mobilemanager",
        "com.asus.mobilemanager.autostart.AutoStartActivity")

Don't know which version of Android has which, so I guess just consider adding a fallback to this activity if the current one is not found.

Not Working in Samsung Galaxy M20

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.samsung.android.lool/com.samsung.android.sm.ui.battery.BatteryActivity}; have you declared this activity in your AndroidManifest.xml?
System.err: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2069)
W/System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1717)
W/System.err: at android.app.Activity.startActivityForResult(Activity.java:5250)
W/System.err: at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:5208)
2020-01-19 20:24:09.357 29121-29121/wocs.solutions.tracker W/System.err: at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
W/System.err: at android.app.Activity.startActivity(Activity.java:5579)
W/System.err: at android.app.Activity.startActivity(Activity.java:5547)
W/System.err: at com.judemanutd.autostarter.AutoStartPermissionHelper.startIntent(AutoStartPermissionHelper.kt:300)
W/System.err: at com.judemanutd.autostarter.AutoStartPermissionHelper.autoStartSamsung(AutoStartPermissionHelper.kt:283)
W/System.err: at com.judemanutd.autostarter.AutoStartPermissionHelper.getAutoStartPermission(AutoStartPermissionHelper.kt:108)
W/System.err: at Activity.NewDashboardActivity.onCreate(NewDashboardActivity.kt:85)
W/System.err: at android.app.Activity.performCreate(Activity.java:7955)
W/System.err: at android.app.Activity.performCreate(Activity.java:7944)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
android.os.Handler.dispatchMessage(Handler.java:107)
android.os.Looper.loop(Looper.java:237)
android.app.ActivityThread.main(ActivityThread.java:7807)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

Demo app on playstore

Hi there,

I'd like to recommend the demo app from this project is published to the Google Play Store. I say this because it's important to use the app to test on device and some users we have aren't comfortable sideloading APKs (they are not devs) but they do have devices and know how to install. Obviously respecting the original author's work so best the app comes from this repository.

can't build project after adding this dependencies please help me

Task :app:mergeDebugResources

Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
Task :app:processDebugManifest
Task :app:processDebugResources
Task :app:compileDebugKotlin
Task :app:prepareLintJar UP-TO-DATE
Task :app:generateDebugSources
Task :app:javaPreCompileDebug

Task :app:compileDebugJavaWithJavac
Gradle may disable incremental compilation as the following annotation processors are not incremental: butterknife-compiler-8.2.1.jar (com.jakewharton:butterknife-compiler:8.2.1), auto-service-1.0-rc2.jar (com.google.auto.service:auto-service:1.0-rc2).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Task :app:mergeDebugShaders UP-TO-DATE
Task :app:compileDebugShaders UP-TO-DATE
Task :app:generateDebugAssets UP-TO-DATE
Task :app:mergeDebugAssets UP-TO-DATE
Task :app:packageInstantRunResourcesDebug
Task :app:validateSigningDebug UP-TO-DATE
Task :app:signingConfigWriterDebug UP-TO-DATE
Task :app:processInstantRunDebugResourcesApk
Task :app:fastDeployDebugExtractor UP-TO-DATE
Task :app:generateDebugInstantRunAppInfo
Task :app:checkManifestChangesDebug
Task :app:transformClassesWithExtractJarsForDebug UP-TO-DATE
Task :app:transformClassesWithInstantRunVerifierForDebug
Task :app:transformClassesWithDependencyCheckerForDebug
Task :app:compileDebugNdk NO-SOURCE
Task :app:mergeDebugJniLibFolders UP-TO-DATE
Task :app:transformNativeLibsWithMergeJniLibsForDebug
Task :app:processDebugJavaRes NO-SOURCE
Task :app:transformResourcesWithMergeJavaResForDebug
Task :app:transformNativeLibsAndResourcesWithJavaResourcesVerifierForDebug
Task :app:transformClassesWithInstantRunForDebug
Task :app:transformClassesAndClassesEnhancedWithInstantReloadDexForDebug
Task :app:incrementalDebugTasks
Task :app:preColdswapDebug
Task :app:transformClassesWithDexBuilderForDebug

Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
AGPBI: {"kind":"error","text":"Program type already present: android.support.design.widget.CoordinatorLayout$Behavior","sources":[{}],"tool":"D8"}

Task :app:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 5s
39 actionable tasks: 23 executed, 16 up-to-date

check if autostart permission is active for my app

Every time i open the app, it would open autostart settings window, how can I check if the autostart permission is selected before open the settings window?
do you have any idea?

class MainActivity : FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        if (AutoStartPermissionHelper.getInstance().isAutoStartPermissionAvailable(context))
            AutoStartPermissionHelper.getInstance().getAutoStartPermission(context)
    }
}

Checking whether it was already autostarted

It's more like a question than an issue, however I couldn't find any good place for asking.
Do you see it useful to add verification whether the app was already autostarted or not?
Of course if it is possible.

Overhaul activity checking to be cleaner

Original Issue : #27

refrain from catching an exception while trying to open an activity and falling back to a different one then. The "cleaner" alternative would be to check which one of the activities is actually present beforehand, without having to trigger an exception. But this really shouldn't affect the UX, so it doesn't really matter that much. Though the current fallback will very soon become the primary activity, as Huawei devices get updated.

Helper Issue : #29

Code snippet that should help

        Intent intent = new Intent();
        intent.setComponent(new ComponentName(packageName, componentName));
        if (intent.resolveActivity(context.getPackageManager()) != null) {
            // the intent is exist
        }

Realme 3 auto statup intent.

I've realme 3 and it is not supported. I want to know how can I figure out the intent name for startup manager? I can open the startup manager from settings but don't know the name to open it programmatically.

Issue on Honor View 20

This was working fine on my Honor View 20, however now I get a security exception.

I've ran the dump command and found the intent should be as below, but when I debug it says I need a permission adding:

intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity"));

The permission it is asking for is:

Even after adding it to the AndroidManifest.xml, it still shows the same error. Any ideas?

Huawei and Samsung support

Hi, first of all, you got a great library, very lightweight and easy to use!

Since the readme mentions Huawei devices not being tested, I took the liberty of doing so on two devices I have available.

  • P9 lite mini (SLA-L22) running Android 7.0 and EMUI 5.1.3. This one works perfectly with the intent present in the library.

  • Y6 2019 (MRD-LX1) running Android 9 and EMUI 9.1.0. This one doesn't work at all - simple ActivityNotFoundException since the System Manager has apparently changed. So I did some reverse engineering to see what's what.

Turns out there's a screen that might be of interest to you and can be opened with an intent (found a whole bunch of interesting activities, but they usually require a Huawei's custom permission).
It's the "App launch" screen that can be found in the device settings under the "Battery" screen. To open it, you can use

ComponentName("com.huawei.systemmanager",                     
    "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity")

Now I don't know which versions of EMUI have what, but I'd wager, based on what backgroundable says, that anything newer than EMUI 5 (which probably includes Android Oreo and up) isn't gonna support com.huawei.systemmanager.optimize.process.ProtectActivity.

Getting back to backgroundable and Samsung, I recommend checking out what they suggest, which is using

ComponentName("com.samsung.android.lool",
    "com.samsung.android.sm.ui.battery.BatteryActivity")

Two things to consider here though: this only works on Android 7.0 and up and it's not really about autostart - it's a "power monitor" setting, which I suppose lets you decide whether you want Samsung's power management (not to mistake with Android OS default power management) to screw your app up or not. This may or may not include autostart features.

Personally, I do recommend including Samsung in supported manufacturers, since their phones really do suck when it comes to running apps that have scheduled and/or background tasks.

OnePlus

I am facing similar issue on OnePlus. Do you know how to support OnePlus device running on android 8.1

Turkish I-ı character

When taking brand names the code lowercases it with the phone's locale. But it generates a problem in Turkish language devices. For example HUAWEI lowercased as "huaweı" and it is not equal to "huawei" obviously. I think there is no need for the phone's locale when lowercasing because device brand names are all returned in ASCII characters.

Huawei update not working perfectly

I'm really glad I could help and happy that you incorporated my suggestions!

There is however one small issue with it - the line with the comment should either return true or not be there at all, which would make it fall down to the return true at the very end of the function body. At the current state, it positively opens the required "fallback" screen, but returns false, causing any dependent application behavior to misbehave (in my case it shows a message that this option is not available).

  private fun autoStartHuawei(context: Context): Boolean {
        if (isPackageExists(context, PACKAGE_HUAWEI_MAIN)) {
            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
                }
                return false // this should be true or not here at all
            }
        } else {
            return false
        }

        return true
    }

Btw, a little suggestion, which is more about clean coding - I would refrain from catching an exception while trying to open an activity and falling back to a different one then. The "cleaner" alternative would be to check which one of the activities is actually present beforehand, without having to trigger an exception. But this really shouldn't affect the UX, so it doesn't really matter that much. Though the current fallback will very soon become the primary activity, as Huawei devices get updated.

And one final thought, it would be great to be able to implement a way to get any exceptions (not necessarily catch them outside the library, just to get the instance somehow) that occur while opening an activity in order to be able to report those through say Crashlytics. I have thousands of users which could provide some valuable compatibility data that way. But that's a little off-topic.

How to check AutoStart option is on or off ???

your solution has completed and its works properly ,
but how to know AutoStart permission is on or off in android device.
How to check AutoStart option is already on for my App in Xiaomi (oppo / vivo) phone Security App programmatically in android ,

Tecno and Infinix

Hi,

Thank you for developing this library. Have you been able to add more manufacturers? I am specifically looking for Tecno and Infinix. I am building an app in Africa and they are the biggest OEMs here. like 70% of my user base can not receive notifications.

If not, do you have any ideas on how to get the intent I need to call for this 2 OEMs. i have searched for contacts to their developer support and i don't think it exists.

Please let me know if you can help.

Regards
Simon

[Feature Request] Callback when failed

I think you need to add a callback when device isn't supported yet or device use custom ROM (or something) so the "package" not found. Because I haven't catch any Exception. I want to create this feature and pull request but I'm not familiar with kotlin 😄 ✌️

Problem with Huawei P10

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

OnePlus Android 11 fails to open ChainLaunchAppListActivity

Hi, I tried the library on my One Plus 7 Pro with Android 11 (Oxygen OS 11.0.0.2GM21BA) installed.

The isAutoStartPermissionAvailable() succeeds but when I call getAutoStartPermission() I get the following stacktrace.

    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.oneplus.security/com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2256)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1914)
        at android.app.Activity.startActivityForResult(Activity.java:5326)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:574)
        at android.app.Activity.startActivityForResult(Activity.java:5284)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:560)
        at android.app.Activity.startActivity(Activity.java:5670)
        at android.app.Activity.startActivity(Activity.java:5623)
        at com.judemanutd.autostarter.AutoStartPermissionHelper.startIntent(AutoStartPermissionHelper.kt:325)
        at com.judemanutd.autostarter.AutoStartPermissionHelper.autoStartOnePlus(AutoStartPermissionHelper.kt:308)
        at com.judemanutd.autostarter.AutoStartPermissionHelper.getAutoStartPermission(AutoStartPermissionHelper.kt:118)

I already tried to add the package to the query element in the AndroidManifest

<queries>
        <package android:name="com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity" />
</queries>

and even tried the prohibited "query all packages permission"
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>

But both results in the same stacktrace. Any ideas on this?

Edit: I think there is just the overall battery optimization settings on this specific phone and no option for auto-start settings; but it's confusing that the isAutoStartPermissionAvailable() returns true

Not working in Samsung note 10

I got an exception here. Activity Not found exception
try { startIntent(context, PACKAGE_SAMSUNG_MAIN, PACKAGE_SAMSUNG_COMPONENT) } catch (e: Exception) { e.printStackTrace() return false }

how can implement?

brother how can implement autostarter in other project?
means how call autostarter in main activity

Problems with Xiaomi (redmi brand)

Some smartphones return redmi instead of xiaomi when invoking Build.BRAND.toLowerCase(). The packages still have the same names (com.miui.securitycenter and com.miui.permcenter.autostart.AutoStartManagementActivity). The solution may be just adding a second constant BRAND_XIAOMI_2 = redmi.

You can recreate this situation with a Xiaomi Note Pro 8.

PD: sorry for my bad english

Errors on xiaomi device

W/System.err: com.judemanutd.autostarter.AutoStartPermissionHelper.startIntent(AutoStartPermissionHelper.kt:268)

I get 5 more errors when doing AutoStartPermissionHelper.getInstance().getAutoStartPermission(getApplicationContext());

get this on a xiaomi device. help?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.