This commit is contained in:
LoveSy 2021-09-25 16:35:38 +08:00 committed by GitHub
parent 957896fd63
commit c224efddcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -189,6 +189,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
}
if (intent.getCategories() != null) intent.getCategories().clear();
intent.addCategory("org.lsposed.manager.LAUNCH_MANAGER");
intent.setPackage(BuildConfig.MANAGER_INJECTED_PKG_NAME);
managerIntent = (Intent) intent.clone();
}
} catch (Throwable e) {
@ -252,16 +253,19 @@ public class LSPManagerService extends ILSPManagerService.Stub {
try {
var smCtor = ShortcutManager.class.getDeclaredConstructor(Context.class);
smCtor.setAccessible(true);
var context = new FakeContext();
var context = new FakeContext("com.android.settings");
var sm = smCtor.newInstance(context);
if (!sm.isRequestPinShortcutSupported()) {
Log.d(TAG, "pinned shortcut not supported, skipping");
return;
}
var intent = getManagerIntent();
var shortcut = new ShortcutInfo.Builder(context, SHORTCUT_ID)
.setShortLabel("LSPosed")
.setLongLabel("LSPosed")
.setIntent(getManagerIntent())
.setIntent(intent)
.setActivity(new ComponentName("com.android.settings", "android.__dummy__"))
.setCategories(intent.getCategories())
.setIcon(getManagerIcon())
.build();

View File

@ -19,14 +19,19 @@ import hidden.HiddenApiBridge;
public class FakeContext extends ContextWrapper {
static ApplicationInfo systemApplicationInfo = null;
static Resources.Theme theme = null;
private String packageName = "android";
public FakeContext() {
super(null);
}
public FakeContext(String packageName) {
super(null);
this.packageName = packageName;
}
@Override
public String getPackageName() {
return "android";
return packageName;
}
@Override