/// <summary> /// 用所有可能的方法设置设备管理员,并返回结果 /// </summary> /// <param name="device"></param> /// <param name="executor"></param> /// <param name="dpmpro"></param> /// <returns></returns> static CommandResult SetDeviceOwner(IDevice targetDevice, ILeafUI ui, string componentName, ICommandExecutor executor, DpmPro dpmpro) { //先用自带dpm进行设置 CommandResult result = executor.AdbShell(targetDevice, "dpm set-device-owner", componentName); //如果返回值为127,也就是说这设备连dpm都阉割了,就询问用户是否用dpmpro来设置设备管理员 if (result.ExitCode == 127 && ui.DoYN(text["UseDpmPro"])) { //用dpmpro设置设备管理员,并记录结果(覆盖普通dpm设置器的记录) result = dpmpro.SetDeviceOwner(componentName); } return(result); }
/// <summary> /// 用所有可能的方法设置设备管理员,并返回结果 /// </summary> /// <param name="device"></param> /// <param name="executor"></param> /// <param name="dpmpro"></param> /// <returns></returns> private ICommandResult SetDeviceOwner(CommandExecutor executor, DpmPro dpmpro) { ICommandResult result = null; //先用自带dpm进行设置 result = executor.AdbShell(Device, "dpm set-device-owner", ComponentName); //如果返回值为127,也就是说这设备连dpm都阉割了,就询问用户是否用dpmpro来设置设备管理员 if (result.ExitCode == 127 && UI.DoYN(TextManager["UseDpmPro"])) { //用dpmpro设置设备管理员,并记录结果(覆盖普通dpm设置器的记录) result = dpmpro.SetDeviceOwner(ComponentName); } return(result); }