Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically getting android lock screen package name

I need to get package name of android lock screen activity. I have googled found nothing except https://stackoverflow.com/a/16881064/2803557 which doesn't seem to work.

Is there any way to get lock screen package name

like image 367
Skyyy Avatar asked Nov 08 '22 05:11

Skyyy


1 Answers

You can determine the package name for any Activity that comes to the foreground by analyzing the Android logs. For example, if you have Google Maps open, clicking on the device's Home button will show this in the log (I usually filter by the ActivityManager string).

START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] 
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher} 

Which shows you that the package name of the home screen Activity is com.android.launcher

However, when I click my Nexus 4 home button to show the lockscreen from any app, it never shows another Activity being launched. This makes me think that it's not what we understand as a typical Activity.

If you look at the source for KeyguardViewMediator.java the Android source code, you will find a method named private void doKeyguardLocked(Bundle options). I know from experience that changing the source to return immediately from this method will disable the lockscreen. The source for KeyguardViewMediator.java shows that it is in the package com.android.keyguard, and I believe that this is the package that you are looking for.

As for getting the package name dynamically, it doesn't seem possible to me. But, if you already know the package name ahead of time, then there's no need to get it dynamically.

I hope this helps.

like image 124
Martin Avatar answered Nov 15 '22 05:11

Martin