Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
R
RatelExtension
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ratel
RatelExtension
Commits
2921b239
Commit
2921b239
authored
Jan 27, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PermissionDeny
parent
4d732e2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
PermissionDeny.java
...n/java/com/virjar/ratel/api/extension/PermissionDeny.java
+76
-0
No files found.
src/main/java/com/virjar/ratel/api/extension/PermissionDeny.java
0 → 100644
View file @
2921b239
package
com
.
virjar
.
ratel
.
api
.
extension
;
import
android.app.Activity
;
import
android.app.Fragment
;
import
android.content.pm.PackageManager
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.support.annotation.RequiresApi
;
import
android.util.Log
;
import
com.virjar.ratel.api.RatelToolKit
;
import
com.virjar.ratel.api.SDK_VERSION_CODES
;
import
com.virjar.ratel.api.rposed.RC_MethodHook
;
import
com.virjar.ratel.api.rposed.RposedBridge
;
import
com.virjar.ratel.api.rposed.RposedHelpers
;
import
java.util.Arrays
;
public
class
PermissionDeny
{
public
static
void
denyAllPermission
()
{
if
(
Build
.
VERSION
.
SDK_INT
<
SDK_VERSION_CODES
.
M
)
{
return
;
}
RposedBridge
.
hookAllMethods
(
Activity
.
class
,
"requestPermissions"
,
new
RC_MethodHook
()
{
@Override
protected
void
beforeHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
param
.
setResult
(
null
);
final
Activity
activity
=
(
Activity
)
param
.
thisObject
;
final
String
[]
permissions
=
(
String
[])
param
.
args
[
0
];
Log
.
i
(
RatelToolKit
.
TAG
,
"Activity hook permissions "
+
Arrays
.
toString
(
permissions
));
final
int
requestCode
=
(
int
)
param
.
args
[
1
];
final
int
[]
ints
=
new
int
[
permissions
.
length
];
Arrays
.
fill
(
ints
,
PackageManager
.
PERMISSION_DENIED
);
new
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(
new
Runnable
()
{
@RequiresApi
(
api
=
SDK_VERSION_CODES
.
M
)
@Override
public
void
run
()
{
RposedHelpers
.
callMethod
(
activity
,
"onRequestPermissionsResult"
,
requestCode
,
permissions
,
ints
);
// activity.onRequestPermissionsResult(requestCode, permissions, ints);
}
},
1500
);
}
});
RposedBridge
.
hookAllMethods
(
Fragment
.
class
,
"requestPermissions"
,
new
RC_MethodHook
()
{
@Override
protected
void
beforeHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
param
.
setResult
(
null
);
final
Fragment
fragment
=
(
Fragment
)
param
.
thisObject
;
final
String
[]
permissions
=
(
String
[])
param
.
args
[
0
];
Log
.
i
(
RatelToolKit
.
TAG
,
"Fragment hook permissions "
+
Arrays
.
toString
(
permissions
));
final
int
requestCode
=
(
int
)
param
.
args
[
1
];
final
int
[]
ints
=
new
int
[
permissions
.
length
];
Arrays
.
fill
(
ints
,
PackageManager
.
PERMISSION_DENIED
);
new
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(
new
Runnable
()
{
@RequiresApi
(
api
=
SDK_VERSION_CODES
.
M
)
@Override
public
void
run
()
{
// fragment.onRequestPermissionsResult(requestCode, permissions, ints);
RposedHelpers
.
callMethod
(
fragment
,
"onRequestPermissionsResult"
,
requestCode
,
permissions
,
ints
);
}
},
1500
);
}
});
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment