Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mywalkb committed Jul 21, 2023
2 parents 54507b8 + bd7a9b9 commit 4a5ae23
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 124 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Android 8.1 ~ 13
## Download

- For stable releases, please go to [Github Releases page](https://github.com/mywalkb/LSPosed_mod/releases)
- For canary build, please check [Github Actions](https://github.com/mywalkb/LSPosed_mod/actions)
- For canary build, please check [Github Actions](https://github.com/mywalkb/LSPosed_mod/actions/workflows/core.yml?query=branch%3Amain)

Note: debug builds are only available in Github Actions.

Expand Down
7 changes: 1 addition & 6 deletions core/src/main/java/org/lsposed/lspd/impl/LSPosedContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ public String getProcessName() {
}
}
Log.d(TAG, "Loaded module " + module.packageName + ": " + ctx);
module.file.moduleLibraryNames.forEach(NativeAPI::recordNativeEntrypoint);
return true;
} catch (Throwable e) {
Log.d(TAG, "Loading module " + module.packageName, e);
}
module.file.moduleLibraryNames.forEach(NativeAPI::recordNativeEntrypoint);
return false;
}

Expand Down Expand Up @@ -862,11 +862,6 @@ public int getFrameworkPrivilege() {
}
}

@Override
public Object featuredMethod(String name, Object... args) {
throw new UnsupportedOperationException();
}

private <T, U extends Executable> MethodUnhooker<T, U> doHook(U hookMethod, int priority, T callback) {
if (Modifier.isAbstract(hookMethod.getModifiers())) {
throw new IllegalArgumentException("Cannot hook abstract methods: " + hookMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ public int getFrameworkPrivilege() throws RemoteException {
return IXposedService.FRAMEWORK_PRIVILEGE_ROOT;
}

@Override
public Bundle featuredMethod(String name, Bundle args) {
throw new UnsupportedOperationException();
}

@Override
public List<String> getScope() throws RemoteException {
ensureModule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static boolean hasNotificationChannelForSystem(
} else {
channel = nm.getNotificationChannelForPackage("android", 1000, channelId, false);
}
if(channel != null) {
if (channel != null) {
Log.d(TAG, "hasNotificationChannelForSystem: " + channel);
}
return channel != null;
Expand Down Expand Up @@ -178,6 +178,7 @@ static void notifyStatusNotification() {
static void cancelStatusNotification() {
try {
var nm = getNotificationManager();
createNotificationChannel(nm);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
nm.cancelNotificationWithTag("android", "android", null, STATUS_NOTIFICATION_ID, 0);
} else {
Expand Down Expand Up @@ -224,89 +225,85 @@ static void notifyModuleUpdated(String modulePackageName,
int moduleUserId,
boolean enabled,
boolean systemModule) {
var context = new FakeContext();
var userName = UserService.getUserName(moduleUserId);
String title = context.getString(enabled ? systemModule ?
R.string.xposed_module_updated_notification_title_system :
R.string.xposed_module_updated_notification_title :
R.string.module_is_not_activated_yet);
String content = context.getString(enabled ? systemModule ?
R.string.xposed_module_updated_notification_content_system :
R.string.xposed_module_updated_notification_content :
(moduleUserId == 0 ?
R.string.module_is_not_activated_yet_main_user_detailed :
R.string.module_is_not_activated_yet_multi_user_detailed), modulePackageName, userName);

var style = new Notification.BigTextStyle();
style.bigText(content);

var notification = new Notification.Builder(context, UPDATED_CHANNEL_ID)
.setContentTitle(title)
.setContentText(content)
.setSmallIcon(getNotificationIcon())
.setContentIntent(getModuleIntent(modulePackageName, moduleUserId))
.setVisibility(Notification.VISIBILITY_SECRET)
.setColor(0xFFF48FB1)
.setAutoCancel(true)
.setStyle(style)
.build();
notification.extras.putString("android.substName", "LSPosed");
try {
var context = new FakeContext();
var userInfo = UserService.getUserInfo(moduleUserId);
String userName = userInfo != null ? userInfo.name : String.valueOf(moduleUserId);
String title = context.getString(enabled ? systemModule ?
R.string.xposed_module_updated_notification_title_system :
R.string.xposed_module_updated_notification_title :
R.string.module_is_not_activated_yet);
String content = context.getString(enabled ? systemModule ?
R.string.xposed_module_updated_notification_content_system :
R.string.xposed_module_updated_notification_content :
(moduleUserId == 0 ?
R.string.module_is_not_activated_yet_main_user_detailed :
R.string.module_is_not_activated_yet_multi_user_detailed), modulePackageName, userName);

var style = new Notification.BigTextStyle();
style.bigText(content);

var notification = new Notification.Builder(context, UPDATED_CHANNEL_ID)
.setContentTitle(title)
.setContentText(content)
.setSmallIcon(getNotificationIcon())
.setContentIntent(getModuleIntent(modulePackageName, moduleUserId))
.setVisibility(Notification.VISIBILITY_SECRET)
.setColor(0xFFF48FB1)
.setAutoCancel(true)
.setStyle(style)
.build();
notification.extras.putString("android.substName", "LSPosed");
var nm = getNotificationManager();
createNotificationChannel(nm);
nm.enqueueNotificationWithTag("android", opPkg, modulePackageName,
pushAndGetNotificationId(UPDATED_CHANNEL_ID, modulePackageName, moduleUserId),
notification, 0);
} catch (Throwable e) {
} catch (RemoteException e) {
Log.e(TAG, "notify module updated", e);
}
}

static void requestModuleScope(String modulePackageName, int moduleUserId, String scopePackageName, IXposedScopeCallback callback) {
var context = new FakeContext();
var userName = UserService.getUserName(moduleUserId);
String title = context.getString(R.string.xposed_module_request_scope_title);
String content = context.getString(R.string.xposed_module_request_scope_content, modulePackageName, userName, scopePackageName);

var style = new Notification.BigTextStyle();
style.bigText(content);

var notification = new Notification.Builder(context, SCOPE_CHANNEL_ID)
.setContentTitle(title)
.setContentText(content)
.setSmallIcon(getNotificationIcon())
.setVisibility(Notification.VISIBILITY_SECRET)
.setColor(0xFFF48FB1)
.setAutoCancel(true)
.setTimeoutAfter(1000 * 60 * 60)
.setStyle(style)
.setDeleteIntent(getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "delete", callback))
.setActions(new Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_baseline_check_24),
context.getString(R.string.scope_approve),
getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "approve", callback))
.build(),
new Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_baseline_close_24),
context.getString(R.string.scope_deny),
getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "deny", callback))
.build(),
new Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_baseline_block_24),
context.getString(R.string.nerver_ask_again),
getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "block", callback))
.build()
).build();
notification.extras.putString("android.substName", "LSPosed");
try {
var context = new FakeContext();
var userInfo = UserService.getUserInfo(moduleUserId);
String userName = userInfo != null ? userInfo.name : String.valueOf(moduleUserId);
String title = context.getString(R.string.xposed_module_request_scope_title);
String content = context.getString(R.string.xposed_module_request_scope_content, modulePackageName, userName, scopePackageName);

var style = new Notification.BigTextStyle();
style.bigText(content);

var notification = new Notification.Builder(context, SCOPE_CHANNEL_ID)
.setContentTitle(title)
.setContentText(content)
.setSmallIcon(getNotificationIcon())
.setVisibility(Notification.VISIBILITY_SECRET)
.setColor(0xFFF48FB1)
.setAutoCancel(true)
.setTimeoutAfter(1000 * 60 * 60)
.setStyle(style)
.setDeleteIntent(getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "delete", callback))
.setActions(new Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_baseline_check_24),
context.getString(R.string.scope_approve),
getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "approve", callback))
.build(),
new Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_baseline_close_24),
context.getString(R.string.scope_deny),
getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "deny", callback))
.build(),
new Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_baseline_block_24),
context.getString(R.string.nerver_ask_again),
getModuleScopeIntent(modulePackageName, moduleUserId, scopePackageName, "block", callback))
.build()
).build();
notification.extras.putString("android.substName", "LSPosed");
var nm = getNotificationManager();
createNotificationChannel(nm);
nm.enqueueNotificationWithTag("android", opPkg, modulePackageName,
pushAndGetNotificationId(SCOPE_CHANNEL_ID, modulePackageName, moduleUserId),
notification, 0);
} catch (Throwable e) {
} catch (RemoteException e) {
try {
callback.onScopeRequestFailed(scopePackageName, e.getMessage());
} catch (RemoteException ignored) {
Expand Down
Loading

0 comments on commit 4a5ae23

Please sign in to comment.