@@ -904,10 +904,11 @@ def __call__(self, **kwargs):
904
904
905
905
906
906
class ApplicationOpStub :
907
- def __init__ (self , stub , applicationId ):
907
+ def __init__ (self , stub , applicationId , user = 0 ):
908
908
"""
909
909
Application 子接口,用来模拟出实例的意味
910
910
"""
911
+ self .user = user
911
912
self .applicationId = applicationId
912
913
self .stub = stub
913
914
def __str__ (self ):
@@ -919,13 +920,15 @@ def is_foreground(self):
919
920
应用是否正处于前台运行
920
921
"""
921
922
req = protos .ApplicationRequest (name = self .applicationId )
923
+ req .user = self .user
922
924
r = self .stub .isForeground (req )
923
925
return r .value
924
926
def permissions (self ):
925
927
"""
926
928
获取应用的所有权限列表
927
929
"""
928
930
req = protos .ApplicationRequest (name = self .applicationId )
931
+ req .user = self .user
929
932
r = self .stub .getPermissions (req )
930
933
return r .permissions
931
934
def grant (self , permission , mode = GrantType .GRANT_ALLOW ):
@@ -935,6 +938,7 @@ def grant(self, permission, mode=GrantType.GRANT_ALLOW):
935
938
req = protos .ApplicationRequest (name = self .applicationId ,
936
939
permission = permission ,
937
940
mode = mode )
941
+ req .user = self .user
938
942
r = self .stub .grantPermission (req )
939
943
return r .value
940
944
def revoke (self , permission ):
@@ -943,13 +947,15 @@ def revoke(self, permission):
943
947
"""
944
948
req = protos .ApplicationRequest (name = self .applicationId ,
945
949
permission = permission )
950
+ req .user = self .user
946
951
r = self .stub .revokePermission (req )
947
952
return r .value
948
953
def query_launch_activity (self ):
949
954
"""
950
955
获取应用的启动 activity 信息
951
956
"""
952
957
req = protos .ApplicationRequest (name = self .applicationId )
958
+ req .user = self .user
953
959
r = self .stub .queryLaunchActivity (req )
954
960
return to_dict (r )
955
961
def is_permission_granted (self , permission ):
@@ -958,20 +964,23 @@ def is_permission_granted(self, permission):
958
964
"""
959
965
req = protos .ApplicationRequest (name = self .applicationId ,
960
966
permission = permission )
967
+ req .user = self .user
961
968
r = self .stub .isPermissionGranted (req )
962
969
return r .value
963
970
def delete_cache (self ):
964
971
"""
965
972
清空应用的缓存数据(非数据仅缓存)
966
973
"""
967
974
req = protos .ApplicationRequest (name = self .applicationId )
975
+ req .user = self .user
968
976
r = self .stub .deleteApplicationCache (req )
969
977
return r .value
970
978
def reset_data (self ):
971
979
"""
972
980
清空应用的所有数据
973
981
"""
974
982
req = protos .ApplicationRequest (name = self .applicationId )
983
+ req .user = self .user
975
984
r = self .stub .resetApplicationData (req )
976
985
return r .value
977
986
def reset (self ):
@@ -981,62 +990,71 @@ def start(self):
981
990
启动应用
982
991
"""
983
992
req = protos .ApplicationRequest (name = self .applicationId )
993
+ req .user = self .user
984
994
r = self .stub .startApplication (req )
985
995
return r .value
986
996
def stop (self ):
987
997
"""
988
998
停止应用
989
999
"""
990
1000
req = protos .ApplicationRequest (name = self .applicationId )
1001
+ req .user = self .user
991
1002
r = self .stub .stopApplication (req )
992
1003
return r .value
993
1004
def info (self ):
994
1005
"""
995
1006
获取应用信息
996
1007
"""
997
1008
req = protos .ApplicationRequest (name = self .applicationId )
1009
+ req .user = self .user
998
1010
r = self .stub .applicationInfo (req )
999
1011
return r
1000
1012
def uninstall (self ):
1001
1013
"""
1002
1014
卸载应用 (always return true)
1003
1015
"""
1004
1016
req = protos .ApplicationRequest (name = self .applicationId )
1017
+ req .user = self .user
1005
1018
r = self .stub .uninstallApplication (req )
1006
1019
return r .value
1007
1020
def enable (self ):
1008
1021
"""
1009
1022
启用应用
1010
1023
"""
1011
1024
req = protos .ApplicationRequest (name = self .applicationId )
1025
+ req .user = self .user
1012
1026
r = self .stub .enableApplication (req )
1013
1027
return r .value
1014
1028
def disable (self ):
1015
1029
"""
1016
1030
禁用应用(这将使应用从启动器消失)
1017
1031
"""
1018
1032
req = protos .ApplicationRequest (name = self .applicationId )
1033
+ req .user = self .user
1019
1034
r = self .stub .disableApplication (req )
1020
1035
return r .value
1021
1036
def add_to_doze_mode_whitelist (self ):
1022
1037
"""
1023
1038
将APP加入省电白名单(可以一直运行,可能不会覆盖所有系统)
1024
1039
"""
1025
1040
req = protos .ApplicationRequest (name = self .applicationId )
1041
+ req .user = self .user
1026
1042
r = self .stub .addToDozeModeWhiteList (req )
1027
1043
return True
1028
1044
def remove_from_doze_mode_whitelist (self ):
1029
1045
"""
1030
1046
将APP移除省电白名单 (always return true)
1031
1047
"""
1032
1048
req = protos .ApplicationRequest (name = self .applicationId )
1049
+ req .user = self .user
1033
1050
r = self .stub .removeFromDozeModeWhiteList (req )
1034
1051
return True
1035
1052
def is_installed (self ):
1036
1053
"""
1037
1054
检查应用是否已经安装
1038
1055
"""
1039
1056
req = protos .ApplicationRequest (name = self .applicationId )
1057
+ req .user = self .user
1040
1058
r = self .stub .isInstalled (req )
1041
1059
return r .value
1042
1060
@@ -1086,8 +1104,8 @@ def install_local_file(self, fpath):
1086
1104
req = protos .ApplicationRequest (path = fpath )
1087
1105
r = self .stub .installFromLocalFile (req )
1088
1106
return r
1089
- def __call__ (self , applicationId ):
1090
- return ApplicationOpStub (self .stub , applicationId )
1107
+ def __call__ (self , applicationId , user = 0 ):
1108
+ return ApplicationOpStub (self .stub , applicationId , user )
1091
1109
1092
1110
1093
1111
class StorageOpStub :
@@ -1893,8 +1911,8 @@ def get_last_activities(self, count=3):
1893
1911
return self .stub ("Application" ).get_last_activities (count = count )
1894
1912
def start_activity (self , ** activity ):
1895
1913
return self .stub ("Application" ).start_activity (** activity )
1896
- def application (self , applicationId ):
1897
- return self .stub ("Application" )(applicationId )
1914
+ def application (self , applicationId , user = 0 ):
1915
+ return self .stub ("Application" )(applicationId , user = user )
1898
1916
# 快速调用: Util
1899
1917
def record_touch (self ):
1900
1918
return self .stub ("Util" ).record_touch ()
0 commit comments