Skip to content

Commit

Permalink
Improvement in general
Browse files Browse the repository at this point in the history
*The existing code was improved to return promises every time it is called
*Added the function to know if the device has activated the development function
*Other improvement in general

//New  use way  
async componentDidMount() {
 // Check if device has development settings enabled
  let Dev = await JailMonkey.isDevelopmentSettingsMode()
  console.log(Dev) // true or false 
}
  • Loading branch information
DanthonyPabon committed Jul 25, 2019
1 parent 05e3941 commit 3d5c7ee
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 69 deletions.
61 changes: 54 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
android/.gradle/
android/.idea/
android/android.iml
android/gradle/
android/gradlew
android/gradlew.bat
android/local.properties
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ android {
}

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.scottyab:rootbeer-lib:0.0.6'
implementation 'com.facebook.react:react-native:+'
implementation 'com.scottyab:rootbeer-lib:0.0.6'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.gantix.JailMonkey.AdbEnabled;

import android.content.Context;
import android.provider.Settings;
import android.util.Log;


public class AdbEnabled {

//returns true if mock location enabled, false if not enabled.
public static boolean AdbEnabled(Context context) {

Log.i("AdbEnabled", "AdbEnabled: " + (Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ADB_ENABLED, 0) == 1));

if (Settings.Global.getInt(context.getContentResolver(), Settings.Global.ADB_ENABLED, 0) == 1) {
// ADB_ENABLED enabled
return true;
} else {
// ADB_ENABLED does not enabled
return false;
}
}
}
87 changes: 65 additions & 22 deletions android/src/main/java/com/gantix/JailMonkey/JailMonkeyModule.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,81 @@
package com.gantix.JailMonkey;

import android.content.pm.ApplicationInfo;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Debug;
import android.provider.Settings;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Nullable;

import static com.gantix.JailMonkey.AdbEnabled.AdbEnabled.AdbEnabled;
import static com.gantix.JailMonkey.ExternalStorage.ExternalStorageCheck.isOnExternalStorage;
import static com.gantix.JailMonkey.HookDetection.HookDetectionCheck.hookDetected;
import static com.gantix.JailMonkey.MockLocation.MockLocationCheck.isMockLocationOn;
import static com.gantix.JailMonkey.Rooted.RootedCheck.isJailBroken;
import static com.gantix.JailMonkey.Debugged.DebuggedCheck.isDebugged;
import static com.gantix.JailMonkey.HookDetection.HookDetectionCheck.hookDetected;


public class JailMonkeyModule extends ReactContextBaseJavaModule {

public JailMonkeyModule(ReactApplicationContext reactContext) {
super(reactContext);
}

@Override
public String getName() {
return "JailMonkey";
}

@Override
public Map<String, Object> getConstants() {
ReactContext context = getReactApplicationContext();
final Map<String, Object> constants = new HashMap<>();
constants.put("isJailBroken", isJailBroken(context));
constants.put("hookDetected", hookDetected(context));
constants.put("canMockLocation", isMockLocationOn(context));
constants.put("isOnExternalStorage", isOnExternalStorage(context));
constants.put("isDebugged", isDebugged(context));
return constants;
}
ReactApplicationContext reactContext;


public JailMonkeyModule(ReactApplicationContext reactContext, boolean loadConstantsAsynchronously) {
super(reactContext);

this.reactContext = reactContext;

}

@Override
public String getName() {
return "JailMonkey";
}


@ReactMethod
public void isDevelopmentSettingsMode(Promise p) {
boolean isDevelopmentSettingsMode;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
isDevelopmentSettingsMode = Settings.System.getInt(this.reactContext.getContentResolver(), Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) != 1;
} else {
isDevelopmentSettingsMode = Settings.Global.getInt(this.reactContext.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1;
}
p.resolve(isDevelopmentSettingsMode);
}


@ReactMethod
public void isDebuggedMode(Promise p) {
boolean isDebuggedMode;
if (Debug.isDebuggerConnected()) {
isDebuggedMode = true;
} else {
isDebuggedMode = (this.reactContext.getApplicationContext().getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
p.resolve(isDebuggedMode);
}


@Override
public @Nullable
Map<String, Object> getConstants() {
ReactContext context = getReactApplicationContext();
final Map<String, Object> constants = new HashMap<>();
constants.put("isJailBroken", isJailBroken(context));
constants.put("hookDetected", hookDetected(context));
constants.put("canMockLocation", isMockLocationOn(context));
constants.put("isOnExternalStorage", isOnExternalStorage(context));
constants.put("AdbEnabled", AdbEnabled(context));
return constants;
}
}
50 changes: 29 additions & 21 deletions android/src/main/java/com/gantix/JailMonkey/JailMonkeyPackage.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
package com.gantix.JailMonkey;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;

public class JailMonkeyPackage implements ReactPackage {

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {

List<NativeModule> modules = new ArrayList<>();

modules.add(new JailMonkeyModule(reactContext));

return modules;
}

// Deprecated RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
private boolean mLoadConstantsAsynchronously;

public JailMonkeyPackage() {
this(false);
}

public JailMonkeyPackage(boolean loadConstantsAsynchronously) {
mLoadConstantsAsynchronously = loadConstantsAsynchronously;
}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new JailMonkeyModule(reactContext, mLoadConstantsAsynchronously));
return modules;
}

// Deprecated RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}

@Override
public List<ViewManager> createViewManagers(
ReactApplicationContext reactContext) {
return Collections.emptyList();
}

}
15 changes: 15 additions & 0 deletions jailmonkey.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// should be imported this way:
// import JailMonkey from 'jail-monkey';


declare const _default: {
isJailBroken: () => Promise<boolean>;
isDebuggedMode: () => Promise<boolean>;
canMockLocation: () => Promise<boolean>;
trustFall: () => Promise<boolean>;
isOnExternalStorage: () => Promise<boolean>;
AdbEnabled: () => Promise<boolean>;
isDevelopmentSettingsMode: () => Promise<boolean>;
};

export default _default;
18 changes: 18 additions & 0 deletions jailmonkey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NativeModules } from "react-native";

const { JailMonkey } = NativeModules;

export default {
isJailBroken: () => JailMonkey.isJailBroken,
hookDetected: () => JailMonkey.hookDetected,
canMockLocation: () => JailMonkey.canMockLocation,
trustFall: () => JailMonkey.isJailBroken || JailMonkey.canMockLocation,
isOnExternalStorage: () => JailMonkey.isOnExternalStorage,
isDebuggedMode: function() {
return JailMonkey.isDebuggedMode();
},
isDevelopmentSettingsMode: function() {
return JailMonkey.isDevelopmentSettingsMode();
},
AdbEnabled: () => JailMonkey.AdbEnabled
};
11 changes: 11 additions & 0 deletions jailmonkey.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @flow

declare module.exports: {
isJailBroken: () => Promise<boolean>,
isDebuggedMode: () => Promise<boolean>,
canMockLocation: () => Promise<boolean>,
trustFall: () => Promise<boolean>,
isOnExternalStorage: () => Promise<boolean>,
AdbEnabled: () => Promise<boolean>,
isDevelopmentSettingsMode: () => Promise<boolean>,
};
65 changes: 48 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
{
"name": "jail-monkey",
"version": "2.2.0",
"description": "A React Native module for identifying jail-broken, rooted, or mock locations on iOS and Android",
"main": "index.js",
"scripts": {
"test": "echo Not yet",
"shipit": "np"
"_args": [
[
"[email protected]"
]
],
"_from": "[email protected]",
"_id": "[email protected]",
"_inBundle": false,
"_integrity": "sha512-83e5CiTiR0p/CLBOP1JzI+rKGayyOteyPIpJuoplQcgPpS22jMSOhkx08csupXGmxPs/lEv+XElqCOunKrU/hA==",
"_location": "/jail-monkey",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "[email protected]",
"name": "jail-monkey",
"escapedName": "jail-monkey",
"rawSpec": "2.2.0",
"saveSpec": null,
"fetchSpec": "2.2.0"
},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/GantMan/jail-monkey.git"
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/jail-monkey/-/jail-monkey-2.2.0.tgz",
"_spec": "2.2.0",
"author": {
"name": "Gant Laborde"
},
"bugs": {
"url": "https://github.com/GantMan/jail-monkey/issues"
},
"description": "A React Native module for identifying jail-broken, rooted, or mock locations on iOS and Android",
"devDependencies": {
"np": "^2.18.3"
},
"homepage": "https://github.com/GantMan/jail-monkey#readme",
"keywords": [
"React-Native",
"Native",
Expand All @@ -22,13 +47,19 @@
"Mock-Locations",
"Detect"
],
"author": "Gant Laborde",
"license": "MIT",
"bugs": {
"url": "https://github.com/GantMan/jail-monkey/issues"
"main": "jailmonkey.js",
"name": "jail-monkey",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/GantMan/jail-monkey.git"
},
"homepage": "https://github.com/GantMan/jail-monkey#readme",
"devDependencies": {
"np": "^2.18.3"
}
"scripts": {
"shipit": "np",
"test": "echo Not yet",
"flow-check": "npx flow check-contents < jailmonkey.js.flow",
"ts-check": "npx tsc jailmonkey.d.ts --noEmit"
},
"typings": "./jailmonkey.d.ts",
"version": "2.2.0"
}

0 comments on commit 3d5c7ee

Please sign in to comment.