Improvement in general
*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
}
This commit is contained in:
parent
05e3941950
commit
3d5c7eebcb
61
.gitignore
vendored
61
.gitignore
vendored
@ -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
|
||||
|
||||
@ -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'
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
ReactApplicationContext 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
private boolean mLoadConstantsAsynchronously;
|
||||
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
public JailMonkeyPackage() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
modules.add(new JailMonkeyModule(reactContext));
|
||||
public JailMonkeyPackage(boolean loadConstantsAsynchronously) {
|
||||
mLoadConstantsAsynchronously = loadConstantsAsynchronously;
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
@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();
|
||||
}
|
||||
// Deprecated RN 0.47
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(
|
||||
ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
15
jailmonkey.d.ts
vendored
Normal file
15
jailmonkey.d.ts
vendored
Normal file
@ -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
jailmonkey.js
Normal file
18
jailmonkey.js
Normal file
@ -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
jailmonkey.js.flow
Normal file
11
jailmonkey.js.flow
Normal file
@ -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
package.json
65
package.json
@ -1,16 +1,41 @@
|
||||
{
|
||||
"name": "jail-monkey",
|
||||
"version": "2.2.0",
|
||||
"_args": [
|
||||
[
|
||||
"jail-monkey@2.2.0"
|
||||
]
|
||||
],
|
||||
"_from": "jail-monkey@2.2.0",
|
||||
"_id": "jail-monkey@2.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-83e5CiTiR0p/CLBOP1JzI+rKGayyOteyPIpJuoplQcgPpS22jMSOhkx08csupXGmxPs/lEv+XElqCOunKrU/hA==",
|
||||
"_location": "/jail-monkey",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "jail-monkey@2.2.0",
|
||||
"name": "jail-monkey",
|
||||
"escapedName": "jail-monkey",
|
||||
"rawSpec": "2.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.2.0"
|
||||
},
|
||||
"_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",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo Not yet",
|
||||
"shipit": "np"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/GantMan/jail-monkey.git"
|
||||
"devDependencies": {
|
||||
"np": "^2.18.3"
|
||||
},
|
||||
"homepage": "https://github.com/GantMan/jail-monkey#readme",
|
||||
"keywords": [
|
||||
"React-Native",
|
||||
"Native",
|
||||
@ -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://git@github.com/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"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user