在Xamarin iOS中检测设备是否已越狱

时间:2017-09-27 07:35:49

标签: ios xamarin.ios jailbreak

我已经实施了以下方法来检查。

const {
  Editor,
  Modifier,
  EditorState,
  RichUtils,
  CompositeDecorator,
  EditorChangeType,
  getDefaultKeyBinding,
} = Draft;

class Example extends React.Component {
  constructor(props){
    super(props)
    const compositeDecorator = new CompositeDecorator([
            { strategy: getEntityStrategy('LINK'), component: LinkComponent },
        ]);

    this.state = { editorState: EditorState.createEmpty(compositeDecorator) };
    this.onChange = (editorState) => { this.setState({editorState}) };
    this.handleReturn = this.handleReturn.bind(this);
  }

  handleReturn(e, editorState) {
    e.preventDefault();

    const { start, end, text } = getFullWordWithCoordinates(editorState);
    const contentState = editorState.getCurrentContent();
    const selectionState = editorState.getSelection();
    const contentStateWithEntity = contentState.createEntity(
      'LINK',
      'MUTABLE',
      { status: 'complete' }
    );
    const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
    const newContentState = Modifier.replaceText(contentState,
      selectionState.merge({ anchorOffset: start, focusOffset: end }),
      `:${text}:`,
      null,
      entityKey);
    const newEditorState = EditorState.set(editorState, { currentContent: newContentState });
    this.setState({ editorState: EditorState.moveFocusToEnd(newEditorState) });

    return 'handled';
  }

  render(){
    return (
      <div style={{border: '1px solid black', padding: '8px'}}>
        <Editor
          handleReturn={this.handleReturn}
          editorState={this.state.editorState}
          onChange={this.onChange} />
      </div>
    )
  }
}

function getFullWordWithCoordinates(editorState) {
    const selectionState = editorState.getSelection();
    const anchorKey = selectionState.getAnchorKey();
    const currentContent = editorState.getCurrentContent();
    const currentContentBlock = currentContent.getBlockForKey(anchorKey);
    const start = selectionState.getStartOffset();
    const end = selectionState.getEndOffset();
    const blockText = currentContentBlock.getText();
    let wholeWordStart = start;
    let wholeWordEnd = end;

    while (blockText.charAt(wholeWordStart - 1) !== ' ' && wholeWordStart > 0) {
        wholeWordStart--;
    }

    while (blockText.charAt(wholeWordEnd) !== ' ' && wholeWordEnd < blockText.length) {
        wholeWordEnd++;
    }
    return {
        text: currentContentBlock.getText().slice(wholeWordStart, wholeWordEnd),
        start: wholeWordStart,
        end: wholeWordEnd,
    };
}

function getEntityStrategy(type) {
    return function(contentBlock, callback, contentState) {
        contentBlock.findEntityRanges(
            (character) => {
                const entityKey = character.getEntity();
                if (entityKey === null) {
                    return false;
                }
                return contentState.getEntity(entityKey).getType() === type;
            },
            callback
        );
    };
}

const LinkComponent = (props) => (<span style={{ background: 'red'}}>{props.children}</span>)

ReactDOM.render(
  <Example />,
  document.getElementById('target')
);

我需要知道如何在Xamarin iOS中调用 System,Fork,OpenSSH服务检测并建议任何其他方法来检查

1 个答案:

答案 0 :(得分:1)

ios 10越狱不使用Openssh,并且我建议尝试执行需要root的命令,如果它没有返回错误标记为越狱。另外,请仅在需要时添加越狱检测。