The principle of mobile phone lock machine Software

Source: Internet
Author: User

These two days in the mobile phone forum found a lot of mobile phone lock screen software lock screen, lock screen effect (simulator) as follows:

The first contact with this software, I always thought it was locked fastloader, but asked which lock screen people, they do not root, nor brush the machine, but only installed the software, so you have to rule out the way to lock loader.

Until later to decompile the lock screen software installation package, only to solve the principle of its true implementation:

1. Lock the back key by locking the home key so that the button cannot exit the app.

2. The user may choose to force shutdown, once powered on, the system will be restored to the desktop application, and not the application, in order to open the application after the boot, it is necessary to register a completed broadcast recipient in the application

The broadcast is as follows: Android:name= "Android.intent.action.BOOT_COMPLETED"/>, after receiving the broadcast, open the application via intent.

3. When the application is not in the foreground, such as the following: The phone is locked, the phone calls, then the application is in the phone application of the next application, this time you can press the home button, the background of the application side-slip removed,

In order to ensure that the slide is not clear point, it will be in the background to open a watchdog service, every 150ms check the foreground application is not my application, if not on the jump to my application, that is, the bottom of the application is not my lock screen application, if so, re-open my application.

The application key code is as follows:

More than 4.0 lock home key
GetWindow (). SetFlags (0x80000000, 0x80000000);

This method is locked home key, 4.0 available, 4.0 on some models available.
GetWindow (). SetType (WindowManager.LayoutParams.TYPE_KEYGUARD);

Mask back key

     

@Override
public void onbackpressed () {

Masking the return processing of a parent class
Super.onbackpressed ();
}

Boot broadcast Accept processing:

public class Bootbroadcastreceiver extends Broadcastreceiver
{
String action_boot= "Android.intent.action.BOOT_COMPLETED";

@Override
public void OnReceive (context context, Intent Intent)
{

/* Because the phone brush miui, I do not know whether can be self-starting, if not, delete the comment symbol. */

if (Intent.getaction (). Equals (Action_boot)) {
Intent ootstartintent=new Intent (context, mainactivity.class);
Ootstartintent.addflags (Intent.flag_activity_new_task);
Context.startactivity (ootstartintent);
}

}

}

Open the Dog code:

public class Killpoccessserve extends Service
{
Context context;
@Override
Public IBinder onbind (Intent p1)
{
Todo:implement This method
return null;
}

@Override
public void OnCreate ()
{
context = this;
Handler thread, receives a message from the TimerTask, and is used to restart the app.
Final Handler h = new Handler (new Handler.callback () {
public boolean handlemessage (Message msg) {
Activitymanager am= (Activitymanager) context.getsystemservice (context. Activity_service);
list<activitymanager.runningtaskinfo> runningtasks = am.getrunningtasks (1);
Activitymanager.runningtaskinfo runningtaskinfo = runningtasks.get (0);
ComponentName topactivity =runningtaskinfo.topactivity;
String PackageName =topactivity.getpackagename ();
if (Packagename.equals ("Tk.jianmo.study")) {//Determine if this is the application
}else{
Not the app, launch the app, and kill the previous app
Intent intent=new Intent ();
Intent.setclass (Context,mainactivity.class);
Intent.setflags (Intent.flag_activity_clear_top);
Intent.addflags (Intent.flag_activity_new_task);
StartActivity (Intent);
Am.killbackgroundprocesses (PackageName);
}
return false;
}
});

Timer timer;
TimerTask TimerTask;
Timer = new timer ();
TimerTask = new TimerTask () {
@Override
public void Run () {
H.obtainmessage (). Sendtotarget ();

}
};

Timer.schedule (timertask, 0, 150);//0.15 seconds start timertask, no delay

}

@Override
public void OnStart (Intent Intent, int startid) {
Todo:implement This method
Super.onstart (Intent, Startid);

}


@Override
public void OnDestroy ()
{
Todo:implement This method
Super.ondestroy ();
}
}

Workaround: Software offload (the following workarounds increase in degree)

1. Lock screen Software is also software, but you start the software after the phone can not quit the software, of course, do not rule out your hand fast enough in 150ms (software developers set, if 1s you gg) time to uninstall the application.

2. Since the mobile phone is unable to quit the application, then we can use the computer to uninstall the software, if the phone turned on the USB debugging, you can use the Phone assistant in the computer to uninstall the software installed in the phone, how does not open, if the hand speed is fast enough, you can also open the USB debugging within 150ms time.

3. Even some phones can remotely manage mobile apps, or even erase data.

4. Mobile phone data shuangqing.

5. Mobile phone brush machine.

The principle of mobile phone lock machine Software

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.