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

View File

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