Skip to content
This repository was archived by the owner on Nov 25, 2022. It is now read-only.

Commit 50a0a8a

Browse files
committed
Added example to restrict public storage
1 parent 7205fe2 commit 50a0a8a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/BlockGuardOs.open.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"builtin": true,
3+
"collection": "Privacy",
4+
"group": "Public.Storage",
5+
"name": "BlockGuardOs.open",
6+
"author": "M66B",
7+
"className": "libcore.io.BlockGuardOs",
8+
"methodName": "open",
9+
"parameterTypes": [
10+
"java.lang.String",
11+
"int",
12+
"int"
13+
],
14+
"returnType": "java.io.FileDescriptor",
15+
"minSdk": 1,
16+
"maxSdk": 999,
17+
"enabled": true,
18+
"optional": false,
19+
"usage": true,
20+
"notify": false,
21+
"luaScript": "function before(hook, param)\n local class = luajava.bindClass('java.lang.Class')\n local clsFile = class:forName('java.io.File')\n\n local ai = param:getApplicationContext():getApplicationInfo()\n local dataDir = ai.dataDir .. '\/'\n local sourceDir = luajava.new(clsFile, ai.sourceDir):getParent() .. '\/'\n\n local path = param:getArgument(0)\n if path == nil or\n string.sub(path, 1, string.len(dataDir)) == dataDir or\n string.sub(path, 1, string.len(sourceDir)) == sourceDir then\n log('Allow ' .. path)\n return false\n else\n log('Deny ' .. path)\n local clsFileNotFound = class:forName('java.io.FileNotFoundException')\n local fake = luajava.new(clsFileNotFound, path)\n param:setResult(fake)\n return true\n end\nend\n"
22+
}

0 commit comments

Comments
 (0)