Dynamically obtaining Android lock package name

I need to get the name of the Android lock activity package. Nothing was found for me googled, except for https://stackoverflow.com/a/3/2/2/2 , which seems to not work.

Is there any way to get the name of the screen lock package

+5
source share
2 answers

You can determine the package name for any Activity that comes to the forefront by analyzing 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 the ActivityManager line).

 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 Activity initial screen is com.android.launcher

However, when I click the "Nexus 4 Home Page" button to show the lock screen from any application, it never shows another action that starts. This makes me think that this is not what we understand as a typical Activity .

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

As for getting the package name dynamically, this is not possible for me. But, if you already know the name of the package ahead of time, then there is no need to receive it dynamically.

Hope this helps.

+1
source

Getting a list of all processes, and then checking the package name of the screen lock application.

Below is the code:

 ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE); long currentMillis = Calendar.getInstance().getTimeInMillis(); Calendar cal = Calendar.getInstance(); for (ActivityManager.RunningServiceInfo info : services) { cal.setTimeInMillis(currentMillis-info.activeSince); Log.i("TAG", String.format("Process %s has been running since: %d ms",info.process, info.activeSince)); } 

Logcat:

 TAG: Process com.android.systemui has been running since: 86526 ms 

This is the lock screen ^

 TAG: Process com.qualcomm.telephony has been running since: 68521 ms TAG: Process com.motorola.ccc has been running since: 57456 ms TAG: Process com.google.android.music:main has been running since: 26245 ms TAG: Process com.android.phone has been running since: 29421 ms TAG: Process com.motorola.ccc has been running since: 52141 ms TAG: Process system has been running since: 28602 ms TAG: Process com.motorola.actions has been running since: 74371 ms TAG: Process com.motorola.ccc has been running since: 59166 ms TAG: Process com.motorola.process.slpc has been running since: 25483 ms TAG: Process com.android.systemui has been running since: 30142 ms TAG: Process com.android.bluetooth has been running since: 22187 ms TAG: Process system has been running since: 28603 ms TAG: Process com.google.android.gms.persistent has been running since: 31621 ms TAG: Process com.android.systemui has been running since: 27361 ms TAG: Process com.google.android.gms.persistent has been running since: 99678 ms TAG: Process com.motorola.contacts.preloadcontacts has been running since: 45603 ms TAG: Process com.google.android.gms.persistent has been running since: 73457 ms TAG: Process com.google.android.gms.persistent has been running since: 72908 ms TAG: Process com.google.android.gms.persistent has been running since: 37251 
0
source

Source: https://habr.com/ru/post/1260769/


All Articles