Browse Source

Removed type seperators (so functionlist would work) and fixed unlock

phone, since pass ain't allowed
master
Raphael Roberts 8 years ago
parent
commit
c962116973
  1. 50
      adb.py

50
adb.py

@ -8,11 +8,21 @@ import time
from load_things import loaded
from decode_parcel import decode_parcel
debug = True
# path = os.path.dirname(__file__)
defaults = loaded.defaults
keycodes = loaded.keycodes
exe = defaults.exe
exists = '''if [ -e "{file}" ]; then
if [ -d "{file}" ]; then
echo "directory"
elif [ -f "{file}" ]; then
echo "file"
else
echo "error"
fi
else
echo "na"
fi'''
def merge(src, dst,log = False):
if not os.path.exists(dst):
return False
@ -78,7 +88,7 @@ class Device:
if self.tcip:
_adb('disconnect',self.serial)
#init operations
def prim_device():
cont = True
while cont:
@ -97,9 +107,9 @@ class Device:
else:
serial,info = list(get_info().items())[0]
self.__dict__.update(info)
#end of init operations
#command interface
def adb(self,*args,out = False):
args = ['-s',self.serial]+ list(args)
return _adb(*args,out = out)
@ -112,21 +122,11 @@ class Device:
else:
args = '"{}"'.format(' '.join(args).replace('"','\\"'))
return self.shell('su','-c',args,out = out)
#end of cammand interface
#file operations
def type(self,file):
exists = '''if [ -e "{file}" ]; then
if [ -d "{file}" ]; then
echo "directory"
elif [ -f "{file}" ]; then
echo "file"
else
echo "error"
fi
else
echo "na"
fi'''
e = exists.format(file = file)
res = self.sudo(e,out=True)
return res
@ -174,9 +174,9 @@ fi'''
def push(self,local,remote):
self.adb('push',local,remote)
#end of file operations
#convenience
def reboot(self,mode = None):
if mode:
if mode == "soft":
@ -204,17 +204,17 @@ fi'''
keycode = str(code)
self.shell("input","keyevent",keycode)
def unlock_phone(self,pass):
def unlock_phone(self,password):
if self.mode != 'recovery':
if not decode_parcel(self.shell('service','call', 'power','12',out=True),'int'):
self.send_keycode('power')
if decode_parcel(self.shell('service','call','trust','7',out=True),'int'):
self.send_keycode('space')
self.shell("input","text",str(pass))
self.shell("input","text",str(password))
self.send_keycode('enter')
#end of convenience
#twrp
def backup(self,*partitions,name = None):
if self.mode != 'recovery':
self.reboot('recovery')
@ -258,7 +258,7 @@ fi'''
else:
update_path = '{}/{}'.format(defaults['remote']['updates'],name)
self.shell("twrp","install",update_path)
#end of twrp
if __name__ == "__main__" and debug:
d = Device.prim_device()
Loading…
Cancel
Save