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 3, 2023
2 parents 380f487 + 10f180d commit d8b258c
Show file tree
Hide file tree
Showing 23 changed files with 250 additions and 139 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ jobs:
echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks
fi
- name: Checkout libxposed/api
uses: actions/checkout@v3
with:
repository: libxposed/api
path: libxposed/api

- name: Checkout libxposed/service
uses: actions/checkout@v3
with:
repository: libxposed/service
path: libxposed/service

- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -54,10 +66,20 @@ jobs:
restore-keys: ${{ runner.os }}
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

- name: Build dependencies
working-directory: libxposed
run: |
cd api
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
./gradlew :api:publishApiPublicationToMavenLocal
cd ..
cd service
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
./gradlew :interface:publishInterfacePublicationToMavenLocal
- name: Build with Gradle
run: |
echo 'org.gradle.parallel=true' >> gradle.properties
echo 'org.gradle.vfs.watch=true' >> gradle.properties
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
echo 'android.native.buildOutput=verbose' >> gradle.properties
sed -i 's/org.gradle.configuration-cache=true//g' gradle.properties
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/org/lsposed/manager/adapters/AppHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Parcel;
import android.view.MenuItem;

import org.lsposed.manager.ConfigManager;
Expand Down Expand Up @@ -140,6 +141,20 @@ public static Comparator<PackageInfo> getAppListComparator(int sort, PackageMana
synchronized public static List<PackageInfo> getAppList(boolean force) {
if (appList == null || force) {
appList = ConfigManager.getInstalledPackagesFromAllUsers(PackageManager.GET_META_DATA | PackageManager.MATCH_UNINSTALLED_PACKAGES, true);
PackageInfo system = null;
for (var app : appList) {
if ("android".equals(app.packageName)) {
var p = Parcel.obtain();
app.writeToParcel(p, 0);
p.setDataPosition(0);
system = PackageInfo.CREATOR.createFromParcel(p);
system.packageName = "system";
break;
}
}
if (system != null) {
appList.add(system);
}
}
return appList;
}
Expand Down
37 changes: 18 additions & 19 deletions app/src/main/java/org/lsposed/manager/adapters/ScopeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import rikka.widget.mainswitchbar.MainSwitchBar;
import rikka.widget.mainswitchbar.OnMainSwitchChangeListener;

@SuppressLint("NotifyDataSetChanged")
public class ScopeAdapter extends EmptyStateRecyclerView.EmptyStateAdapter<ScopeAdapter.ViewHolder> implements Filterable {

private final Activity activity;
Expand Down Expand Up @@ -165,7 +164,7 @@ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
}

private boolean shouldHideApp(PackageInfo info, ApplicationWithEquals app, HashSet<ApplicationWithEquals> tmpChkList) {
if (info.packageName.equals("android")) {
if (info.packageName.equals("system")) {
return false;
}
if (tmpChkList.contains(app)) {
Expand All @@ -190,18 +189,15 @@ private boolean shouldHideApp(PackageInfo info, ApplicationWithEquals app, HashS
return true;
}
}
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_HAS_CODE) == 0) {
return true;
}
return preferences.getBoolean("filter_system_apps", true) && (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
}

private int sortApps(AppInfo x, AppInfo y) {
Comparator<PackageInfo> comparator = AppHelper.getAppListComparator(preferences.getInt("list_sort", 0), pm);
Comparator<AppInfo> frameworkComparator = (a, b) -> {
if (a.packageName.equals("android") == b.packageName.equals("android")) {
if (a.packageName.equals("system") == b.packageName.equals("system")) {
return comparator.compare(a.packageInfo, b.packageInfo);
} else if (a.packageName.equals("android")) {
} else if (a.packageName.equals("system")) {
return -1;
} else {
return 1;
Expand Down Expand Up @@ -320,7 +316,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}

@SuppressLint("WrongConstant")
public boolean onContextItemSelected(@NonNull MenuItem item) {
ApplicationInfo info = selectedInfo;
if (info == null) {
Expand All @@ -342,7 +337,7 @@ public boolean onContextItemSelected(@NonNull MenuItem item) {
} else if (itemId == R.id.menu_app_info) {
ConfigManager.startActivityAsUserWithFeature(new Intent(ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", info.packageName, null)), module.userId);
} else if (itemId == R.id.menu_force_stop) {
if (info.packageName.equals("android")) {
if (info.packageName.equals("system")) {
ConfigManager.reboot();
} else {
new BlurBehindDialogBuilder(activity, R.style.ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons)
Expand Down Expand Up @@ -413,10 +408,10 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
AppInfo appInfo = showList.get(position);
boolean deny = denyList.contains(appInfo.packageName);
holder.root.setAlpha(!deny && enabled ? 1.0f : .5f);
boolean android = appInfo.packageName.equals("android");
boolean system = appInfo.packageName.equals("system");
CharSequence appName;
int userId = appInfo.applicationInfo.uid / App.PER_USER_RANGE;
appName = android ? activity.getString(R.string.android_framework) : appInfo.label;
appName = system ? activity.getString(R.string.android_framework) : appInfo.label;
holder.appName.setText(appName);
GlideApp.with(holder.appIcon).load(appInfo.packageInfo).into(new CustomTarget<Drawable>() {
@Override
Expand All @@ -434,16 +429,18 @@ public void onLoadFailed(@Nullable Drawable errorDrawable) {
holder.appIcon.setImageDrawable(pm.getDefaultActivityIcon());
}
});
SpannableStringBuilder sb = new SpannableStringBuilder();
if (android) {
holder.appPackageName.setVisibility(View.GONE);
if (system) {
//noinspection SetTextI18n
holder.appPackageName.setText("system");
holder.appVersionName.setVisibility(View.GONE);
} else {
holder.appPackageName.setVisibility(View.VISIBLE);
holder.appVersionName.setVisibility(View.VISIBLE);
holder.appPackageName.setText(appInfo.packageName);
holder.appVersionName.setText(activity.getString(R.string.app_version, appInfo.packageInfo.versionName));

}
holder.appPackageName.setVisibility(View.VISIBLE);
holder.appVersionName.setText(activity.getString(R.string.app_version, appInfo.packageInfo.versionName));
var sb = new SpannableStringBuilder();
if (!recommendedList.isEmpty() && recommendedList.contains(appInfo.application)) {
String recommended = activity.getString(R.string.requested_by_module);
sb.append(recommended);
Expand Down Expand Up @@ -485,9 +482,11 @@ public void onLoadFailed(@Nullable Drawable errorDrawable) {
if (launchIntent == null) {
menu.removeItem(R.id.menu_launch);
}
if (android) {
if (system) {
menu.findItem(R.id.menu_force_stop).setTitle(R.string.reboot);
menu.removeItem(R.id.menu_compile_speed);
menu.removeItem(R.id.menu_other_app);
menu.removeItem(R.id.menu_app_info);
}
});

Expand Down Expand Up @@ -540,7 +539,7 @@ public void refresh(boolean force) {
appList.parallelStream().forEach(info -> {
int userId = info.applicationInfo.uid / App.PER_USER_RANGE;
String packageName = info.packageName;
if (packageName.equals("android") && userId != 0 ||
if (packageName.equals("system") && userId != 0 ||
packageName.equals(module.packageName) ||
packageName.equals(BuildConfig.APPLICATION_ID)) {
return;
Expand Down Expand Up @@ -605,7 +604,7 @@ protected void onCheckedChange(CompoundButton buttonView, boolean isChecked, App
tmpChkList.remove(appInfo.application);
}
buttonView.setChecked(!isChecked);
} else if (appInfo.packageName.equals("android")) {
} else if (appInfo.packageName.equals("system")) {
fragment.showHint(R.string.reboot_required, true, R.string.reboot, v -> ConfigManager.reboot());
} else if (denyList.contains(appInfo.packageName)) {
fragment.showHint(activity.getString(R.string.deny_list, appInfo.label), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,25 @@ public void onDetach() {
parentFragment = null;
}

@Override
public void onResume() {
super.onResume();
MaterialSwitchPreference notificationPreference = findPreference("enable_status_notification");
if (notificationPreference != null && notificationPreference.isVisible()) {
setNotificationPreferenceEnabled(notificationPreference, ShortcutUtil.isLaunchShortcutPinned());
}
}

private void setNotificationPreferenceEnabled(MaterialSwitchPreference notificationPreference, boolean enabled) {
if (notificationPreference != null) {
notificationPreference.setEnabled(!ConfigManager.enableStatusNotification() || enabled);
notificationPreference.setSummaryOn(enabled ?
notificationPreference.getContext().getString(R.string.settings_enable_status_notification_summary) :
notificationPreference.getContext().getString(R.string.settings_enable_status_notification_summary) + "\n" +
notificationPreference.getContext().getString(R.string.disable_status_notification_error));
}
}

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
final String SYSTEM = "SYSTEM";
Expand All @@ -158,18 +177,16 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
});
}

MaterialSwitchPreference notification = findPreference("enable_status_notification");
if (notification != null) {
MaterialSwitchPreference notificationPreference = findPreference("enable_status_notification");
if (notificationPreference != null) {
if (App.isParasitic && !ShortcutUtil.isLaunchShortcutPinned()) {
var s = notification.getContext().getString(R.string.disable_status_notification_error);
notification.setSummaryOn(notification.getSummary() + "\n" + s);
if (ConfigManager.enableStatusNotification()) notification.setEnabled(false);
setNotificationPreferenceEnabled(notificationPreference, false);
}
notification.setVisible(installed);
notification.setChecked(installed && ConfigManager.enableStatusNotification());
notification.setOnPreferenceChangeListener((p, v) -> {
notificationPreference.setVisible(installed);
notificationPreference.setChecked(installed && ConfigManager.enableStatusNotification());
notificationPreference.setOnPreferenceChangeListener((p, v) -> {
if ((boolean) v && App.isParasitic && !ShortcutUtil.isLaunchShortcutPinned()) {
p.setEnabled(false);
setNotificationPreferenceEnabled(notificationPreference, false);
}
return ConfigManager.setEnableStatusNotification((boolean) v);
});
Expand All @@ -188,10 +205,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
if (!ShortcutUtil.requestPinLaunchShortcut(() -> {
shortcut.setEnabled(false);
shortcut.setSummary(R.string.settings_created_shortcut_summary);
if (notification != null) {
notification.setEnabled(true);
notification.setSummaryOn(R.string.settings_enable_status_notification_summary);
}
setNotificationPreferenceEnabled(notificationPreference, true);
App.getPreferences().edit().putBoolean("never_show_welcome", true).apply();
parentFragment.showHint(R.string.settings_shortcut_pinned_hint, false);
})) {
Expand Down
46 changes: 30 additions & 16 deletions app/src/main/java/org/lsposed/manager/util/ModuleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -257,9 +258,9 @@ public class InstalledModule {
public final long updateTime;
public final ApplicationInfo app;
public final PackageInfo pkg;
private String appName; // loaded lazyily
private String description; // loaded lazyily
private List<String> scopeList; // loaded lazyily
private String appName; // loaded lazily
private String description; // loaded lazily
private List<String> scopeList; // loaded lazily

private InstalledModule(PackageInfo pkg, ZipFile modernModuleApk) {
app = pkg.applicationInfo;
Expand Down Expand Up @@ -305,6 +306,8 @@ private InstalledModule(PackageInfo pkg, ZipFile modernModuleApk) {
try (var reader = new BufferedReader(new InputStreamReader(modernModuleApk.getInputStream(scopeEntry)))) {
scopeList = reader.lines().collect(Collectors.toList());
}
} else {
scopeList = Collections.emptyList();
}
} catch (IOException | OutOfMemoryError e) {
Log.e(App.TAG, "Error while closing modern module APK", e);
Expand Down Expand Up @@ -350,25 +353,36 @@ public String getDescription() {

public List<String> getScopeList() {
if (scopeList != null) return scopeList;
if (legacy) {
try {
int scopeListResourceId = app.metaData.getInt("xposedscope");
if (scopeListResourceId != 0) {
scopeList = Arrays.asList(pm.getResourcesForApplication(app).getStringArray(scopeListResourceId));
} else {
String scopeListString = app.metaData.getString("xposedscope");
if (scopeListString != null)
scopeList = Arrays.asList(scopeListString.split(";"));
}
} catch (Exception ignored) {
List<String> list = null;
try {
int scopeListResourceId = app.metaData.getInt("xposedscope");
if (scopeListResourceId != 0) {
list = Arrays.asList(pm.getResourcesForApplication(app).getStringArray(scopeListResourceId));
} else {
String scopeListString = app.metaData.getString("xposedscope");
if (scopeListString != null)
list = Arrays.asList(scopeListString.split(";"));
}
} catch (Exception ignored) {
}
if (scopeList == null) {
if (list == null) {
OnlineModule module = RepoLoader.getInstance().getOnlineModule(packageName);
if (module != null && module.getScope() != null) {
scopeList = module.getScope();
list = module.getScope();
}
}
if (list != null) {
//For historical reasons, legacy modules use the opposite name.
//https://github.com/rovo89/XposedBridge/commit/6b49688c929a7768f3113b4c65b429c7a7032afa
list.replaceAll(s ->
switch (s) {
case "android" -> "system";
case "system" -> "android";
default -> s;
}
);
scopeList = list;
}
return scopeList;
}

Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/org/lsposed/manager/util/ShortcutUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ private static Intent getLaunchIntent(Context context) {
@SuppressLint("InlinedApi")
private static IntentSender registerReceiver(Context context, Runnable task) {
if (task == null) return null;

var uuid = UUID.randomUUID().toString();
var filter = new IntentFilter(uuid);
var permission = "android.permission.CREATE_USERS";
Expand Down Expand Up @@ -194,6 +193,10 @@ private static String getDefaultLauncherPackageName(Context context) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
var resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
return resolveInfo.activityInfo.packageName;
if (resolveInfo != null) {
return resolveInfo.activityInfo.packageName;
} else {
return null;
}
}
}
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ val verCode by extra(commitCount)
val verName by extra(latestTag)
val androidTargetSdkVersion by extra(33)
val androidMinSdkVersion by extra(27)
val androidBuildToolsVersion by extra("33.0.1")
val androidBuildToolsVersion by extra("33.0.2")
val androidCompileSdkVersion by extra(33)
val androidCompileNdkVersion by extra("25.2.9519653")
val androidSourceCompatibility by extra(JavaVersion.VERSION_11)
val androidTargetCompatibility by extra(JavaVersion.VERSION_11)
val androidSourceCompatibility by extra(JavaVersion.VERSION_17)
val androidTargetCompatibility by extra(JavaVersion.VERSION_17)

tasks.register("Delete", Delete::class) {
delete(rootProject.buildDir)
Expand Down
Loading

0 comments on commit d8b258c

Please sign in to comment.