iOS小技能:lua代码实现解锁和打开特定app的代码、tweak 实现自动解锁以及打开特定app

468 阅读1分钟

开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第15天,点击查看活动详情

I lua代码实现解锁和打开特定app的代码

init("0", 0);
require "TSLib"

local sz = require("sz")
local http = sz.i82.http
local pos = sz.pos
local json = sz.json

pFlag = 1;
timer = 0;

while (true) do

	io.popen('echo "" > /private/var/log/syslog')

		-- mSleep(2000*60);			--2分钟检测一次
--[["1、处理设备lock"]]
	if deviceIsLock()  == 1 then	--判断设备是否锁定
		unlockDevice()--解锁无密码的设备
	end

--[[""]]


--[[""]]

	if isFrontApp("com.tencent.xin") == 0 then
		mSleep(3000);
		runApp("com.tencent.xin");
	end
end

II 自动解锁以及打开特定的app

launchApplicationWithIdentifier、unlockUIFromSource


NSTimer *timer ;

%hook SpringBoard
//applicationDidFinishLaunching
-(void)applicationDidFinishLaunching: (id)application
{
        %orig;
	timer = [NSTimer scheduledTimerWithTimeInterval:60*2 target:self selector:@selector(checkHeart) userInfo:nil repeats:YES];
}

%new
- (void)checkHeart
{
	//定时检测微信是否开启
    [[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.tencent.xin" suspended:0];
}

%end

//qutolock
%hook SBLockScreenViewController
-(void)activate{

	%orig;

	[[%c(SBLockScreenManager) sharedInstance] unlockUIFromSource:0 withOptions:nil];
}
%end

III 查看触动精灵lua脚本的PID

  • 查看触动精灵lua脚本的PID
iPhone:~ root#  ps aux |grep 'Mobile27bc'
root       353   0.6  4.1   609432  42144   ??  Ss    2:38PM   0:54.73 /Applications/TouchSprite.app/Mobile27bc -run /private/var/mobile/Media/TouchSprite/lua/tao.lua,0,0,0 -now -server
root       949   0.0  0.0   535232    416 s001  R+    4:41PM   0:00.01 grep Mobile27bc
  • ps aux |grep 'TouchSprite'
iPhone:~ root#  ps aux |grep 'TouchSprite'

see also

  • SpringBoard 常用的一些API
+ (void) powerDown {
    id SpringBoard = [UIApplication sharedApplication];//#"<SpringBoard: 0x173d8800>"
    [SpringBoard powerDown];
}

  • UIApplication 常用的一些API
    [UIApplication sharedApplication].idleTimerDisabled=YES;//不自动锁屏,放在-(void)viewWillAppear:(BOOL)animated里面的时候,防止失效
  //
   [UIApplication sharedApplication].idleTimerDisabled=NO;//自动锁屏