diff --git a/.github/workflows/crowdin_download.yml b/.github/workflows/crowdin_download.yml new file mode 100644 index 000000000..13c5263c3 --- /dev/null +++ b/.github/workflows/crowdin_download.yml @@ -0,0 +1,34 @@ +name: Crowdin Download + +on: + schedule: + - cron: '0 0 * * 0' + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + + synchronize-with-crowdin: + name: Download translations from Crowdin + if: github.repository_owner == 'DHD2280' + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Download translations + uses: crowdin/github-action@v1 + with: + upload_translations: false + upload_sources: false + download_translations: true + localization_branch_name: beta-localization + create_pull_request: true + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} \ No newline at end of file diff --git a/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/UpdateFragment.java b/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/UpdateFragment.java index e527838a8..ea7febadc 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/UpdateFragment.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/UpdateFragment.java @@ -7,6 +7,8 @@ import android.Manifest; import android.annotation.SuppressLint; import android.app.DownloadManager; +import android.app.NotificationChannel; +import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; @@ -75,6 +77,7 @@ public class UpdateFragment extends Fragment { final BroadcastReceiver downloadCompletionReceiver = new BroadcastReceiver() { + @SuppressLint("MissingPermission") @Override public void onReceive(Context context, Intent intent) { if (getContext() != null) @@ -109,16 +112,6 @@ public void onReceive(Context context, Intent intent) { .setContentText(requireContext().getText(R.string.try_again_later)) .setPriority(NotificationCompat.PRIORITY_DEFAULT); - if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { - // TODO: Consider calling - // ActivityCompat#requestPermissions - // here to request the missing permissions, and then overriding - // public void onRequestPermissionsResult(int requestCode, String[] permissions, - // int[] grantResults) - // to handle the case where the user grants the permission. See the documentation - // for ActivityCompat#requestPermissions for more details. - ShellUtils.execCommand(String.format("pm grant %s android.permission.POST_NOTIFICATIONS", BuildConfig.APPLICATION_ID), true); //will ask root if not granted yet - } NotificationManagerCompat.from(requireContext()).notify(2, builder.build()); } } @@ -176,6 +169,8 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { //Android 13 requires notification permission to be granted or it won't allow it ShellUtils.execCommand(String.format("pm grant %s android.permission.POST_NOTIFICATIONS", BuildConfig.APPLICATION_ID), true); //will ask root if not granted yet + createChannels(); + if (!ShellUtils.checkRootPermission()) { currentVersionName = getString(R.string.root_not_here); currentVersionType = -1; @@ -285,6 +280,18 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { new ChangelogReceiver(URL, callback).start(); }*/ + private void createChannels() { + if (getContext() == null) { + Log.w("UpdateFragment", "createChannels: context is null"); + return; + } + + NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); + NotificationChannel channel = new NotificationChannel(getContext().getString(R.string.notification_channel_update), getContext().getString(R.string.notification_channel_update), NotificationManager.IMPORTANCE_DEFAULT); + channel.setDescription(getContext().getString(R.string.notification_channel_update_desc)); + notificationManager.createNotificationChannel(channel); + } + private void getCurrentVersion() { rebootPending = false; currentVersionName = BuildConfig.VERSION_NAME; @@ -317,6 +324,7 @@ public void onDestroyView() { binding = null; } + @SuppressLint("MissingPermission") public void notifyInstall() { if (getContext() == null) { Log.w("UpdateFragment", "notifyInstall: context is null"); @@ -341,9 +349,6 @@ public void notifyInstall() { .setContentIntent(pendingIntent) .setAutoCancel(true); - if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { - ShellUtils.execCommand(String.format("pm grant %s android.permission.POST_NOTIFICATIONS", BuildConfig.APPLICATION_ID), true); //will ask root if not granted yet - } NotificationManagerCompat.from(getContext()).notify(1, builder.build()); } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/FeatureEnabler.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/FeatureEnabler.java index 154105dcf..31879ce0a 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/FeatureEnabler.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/FeatureEnabler.java @@ -54,7 +54,6 @@ public class FeatureEnabler extends XposedMods { private int centerY; private int radius; private Class SystemUIDialogClass; - private Class OplusThemeSystemUiDialog; private boolean broadcastRegistered = false; final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @@ -97,11 +96,15 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th mContext.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_EXPORTED); //for Android 14, receiver flag is mandatory } - Class ShutdownViewControl = findClass("com.oplus.systemui.shutdown.ShutdownViewControl", lpparam.classLoader); + //Class ShutdownViewControl = findClass("com.oplus.systemui.shutdown.ShutdownViewControl", lpparam.classLoader); SystemUIDialogClass = findClass("com.android.systemui.statusbar.phone.SystemUIDialog", lpparam.classLoader); - OplusThemeSystemUiDialog = findClass("com.oplus.systemui.common.dialog.OplusThemeSystemUiDialog", lpparam.classLoader); - Class ShutdownView = findClass("com.oplus.systemui.shutdown.OplusShutdownView", lpparam.classLoader); + Class ShutdownView; + try { + ShutdownView = findClass("com.oplus.systemui.shutdown.OplusShutdownView", lpparam.classLoader); + } catch (Throwable t) { + ShutdownView = findClass("com.oplusos.systemui.controls.OplusShutdownView", lpparam.classLoader); // OOS 13 + } findAndHookMethod(ShutdownView, "onDraw", Canvas.class, new XC_MethodHook() { @Override @@ -146,7 +149,12 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } }); - Class FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader); + Class FeatureOptions; + try { + FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader); + } catch (Throwable t) { + FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader); + } hookAllMethods(FeatureOptions, "isOplusVolumeKeyInRight", new XC_MethodHook() { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/PulseViewHook.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/PulseViewHook.java index 31365e2ce..3a54b4be0 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/PulseViewHook.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/PulseViewHook.java @@ -225,15 +225,17 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { }); // Stole Screen Pinning - hookAllMethods(NavigationBarView, "setInScreenPinning", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - if (PulseControllerImpl.hasInstance()) { - //log(TAG + "Screen pinning: " + (boolean)param.args[0]); - PulseControllerImpl.getInstance().setScreenPinning((boolean) param.args[0]); + try { + hookAllMethods(NavigationBarView, "setInScreenPinning", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + if (PulseControllerImpl.hasInstance()) { + //log(TAG + "Screen pinning: " + (boolean)param.args[0]); + PulseControllerImpl.getInstance().setScreenPinning((boolean) param.args[0]); + } } - } - }); + }); + } catch (Throwable ignored){} } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/SettingsLibUtilsProvider.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/SettingsLibUtilsProvider.java index efcc8f4ad..8807e3819 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/SettingsLibUtilsProvider.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/SettingsLibUtilsProvider.java @@ -37,8 +37,8 @@ public static int getColorAttrDefaultColor(Context context, int resID) { try { return (int) callStaticMethod(UtilsClass, "getColorAttrDefaultColor", context, resID, 0); - } catch (Throwable ignored) { //13 QPR1 - return (int) callStaticMethod(UtilsClass, "getColorAttrDefaultColor", resID, context); + } catch (Throwable ignored) { //OOS 13 + return (int) callStaticMethod(UtilsClass, "getColorAttrDefaultColor", context, resID); } } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/navbar/GestureNavbarManager.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/navbar/GestureNavbarManager.java index 046f34d01..f1c0989a5 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/navbar/GestureNavbarManager.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/navbar/GestureNavbarManager.java @@ -92,9 +92,18 @@ public void updatePrefs(String... Key) { public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { if (!lpparam.packageName.equals(listenPackage)) return; - Class SideGestureDetector = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureDetector", lpparam.classLoader); - Class SideGestureNavView = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader); - Class ScreenShotRunnable = findClass("com.oplus.systemui.qs.tiles.ScreenshotTile$ScreenShotRunnable", lpparam.classLoader); + Class SideGestureDetector; + try { + SideGestureDetector = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureDetector", lpparam.classLoader); + } catch (Throwable t) { + SideGestureDetector = findClass("com.oplusos.systemui.navigationbar.gesture.sidegesture.SideGestureDetector", lpparam.classLoader); // OOS 13 + } + Class SideGestureNavView; + try { + SideGestureNavView = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader); + } catch (Throwable t) { + SideGestureNavView = findClass("com.oplusos.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader); // OOS 13 + } hookAllConstructors(SideGestureDetector, new XC_MethodHook() { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java index 4a792fa2b..3456bf3a2 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java @@ -589,7 +589,7 @@ private void notifyUpdate() { } updating = true; ShellUtils.execCommand("settings put system display_battery_style 2", true); - Thread.sleep(750); + Thread.sleep(500); ShellUtils.execCommand("settings put system display_battery_style 3", true); Thread.sleep(500); diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderClock.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderClock.java index 616c6b7fe..a2816002a 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderClock.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderClock.java @@ -225,7 +225,11 @@ public void updatePrefs(String... Key) { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { - final Class QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader); + Class QuickStatusBarHeader; + try { QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader); + } catch (Throwable t) { + QuickStatusBarHeader = findClass("com.android.systemui.qs.QuickStatusBarHeader", lpparam.classLoader); + } mClockChipDrawale = new GradientDrawable(); mDateChipDrawale = new GradientDrawable(); @@ -239,7 +243,12 @@ protected void afterHookedMethod(MethodHookParam param) { }); //OplusQSFooterImpl - Class OplusQSFooterImpl = findClass("com.oplus.systemui.qs.OplusQSFooterImpl", lpparam.classLoader); + Class OplusQSFooterImpl; + try { + OplusQSFooterImpl = findClass("com.oplus.systemui.qs.OplusQSFooterImpl", lpparam.classLoader); + } catch (Throwable t) { + OplusQSFooterImpl = findClass("com.oplusos.systemui.qs.OplusQSFooterImpl", lpparam.classLoader); + } hookAllMethods(OplusQSFooterImpl, "onFinishInflate", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { @@ -284,7 +293,12 @@ protected void afterHookedMethod(MethodHookParam param) { } }); - Class QsFragmentHelper = findClass("com.oplus.systemui.qs.helper.QSFragmentHelper", lpparam.classLoader); + Class QsFragmentHelper; + try { + QsFragmentHelper = findClass("com.oplus.systemui.qs.helper.QSFragmentHelper", lpparam.classLoader); + } catch (Throwable t) { + QsFragmentHelper = findClass("com.oplusos.systemui.qs.helper.QSFragmentHelper", lpparam.classLoader); + } hookAllMethods(QsFragmentHelper, "onFractionUpdated", new XC_MethodHook() { @Override @@ -304,7 +318,12 @@ protected void afterHookedMethod(MethodHookParam param) { } }); - Class OplusClockExImpl = findClass("com.oplus.systemui.common.clock.OplusClockExImpl", lpparam.classLoader); + Class OplusClockExImpl ; + try { + OplusClockExImpl = findClass("com.oplus.systemui.common.clock.OplusClockExImpl", lpparam.classLoader); + } catch (Throwable t) { + OplusClockExImpl = findClass("com.oplusos.systemui.ext.BaseClockExt", lpparam.classLoader); + } hookAllMethods(OplusClockExImpl, "setTextWithRedOneStyleInternal", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { @@ -342,18 +361,6 @@ protected void beforeHookedMethod(MethodHookParam param) { } }); - /*hookAllMethods(OplusQSFooterImpl, "updateQsClockView", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) { - log("updateQsClockView"); - boolean z; - ConstraintSet set = new ConstraintSet(); - set.setTranslation(mQsClockContainer.getId(), 10f, 10f); - set.applyTo((ConstraintLayout) mQsClockContainer.getParent()); - //z = ConstraintSetExt.updateScaleY(this.mTmpConstraintSet, this.mClockView.getId(), 1.0f) | ConstraintSetExt.updateTranslationX(this.mTmpConstraintSet, this.mClockView.getId(), 0.0f) | false | ConstraintSetExt.updateTranslationY(this.mTmpConstraintSet, this.mClockView.getId(), 0.0f) | ConstraintSetExt.updateScaleX(this.mTmpConstraintSet, this.mClockView.getId(), 1.0f); - } - });*/ - hookAllMethods(QuickStatusBarHeader, "updateResources", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderImage.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderImage.java index 747c10a6c..816a05bde 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderImage.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/HeaderImage.java @@ -119,8 +119,17 @@ public void updatePrefs(String... Key) { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { - Class OplusQSContainerImpl = findClass("com.oplus.systemui.qs.OplusQSContainerImpl", lpparam.classLoader);; - Class QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader);; + + Class OplusQSContainerImpl; + try { + OplusQSContainerImpl = findClass("com.oplus.systemui.qs.OplusQSContainerImpl", lpparam.classLoader); + } catch (Throwable t) { + OplusQSContainerImpl = findClass("com.oplusos.systemui.qs.OplusQSContainerImpl", lpparam.classLoader); // OOS 13 + } + Class QuickStatusBarHeader = null; + try { + QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader);; + } catch (Throwable ignored){} try { log(TAG + "Hooking"); @@ -129,7 +138,6 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th protected void afterHookedMethod(MethodHookParam param) { log(TAG + "onFinishInflate"); FrameLayout mQuickStatusBarHeader = (FrameLayout) param.thisObject; - mQuickStatusBarHeader.setBackgroundColor(Color.TRANSPARENT); mQsHeaderLayout = new FadingEdgeLayout(mContext); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, qshiHeightPortrait, mContext.getResources().getDisplayMetrics())); @@ -158,18 +166,23 @@ protected void afterHookedMethod(MethodHookParam param) { } }); - hookAllMethods(QuickStatusBarHeader, "onMeasure", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) { - View mDatePrivacyView = (View) getObjectField(param.thisObject, "mPrivacyContainer"); - int mTopViewMeasureHeight = getIntField(param.thisObject, "mTopViewMeasureHeight"); + } catch (Throwable ignored) {} - if ((int) callMethod(mDatePrivacyView, "getMeasuredHeight") != mTopViewMeasureHeight) { - setObjectField(param.thisObject, "mTopViewMeasureHeight", callMethod(mDatePrivacyView, "getMeasuredHeight")); - callMethod(param.thisObject, "updateAnimators"); + try { + if (QuickStatusBarHeader != null) { + hookAllMethods(QuickStatusBarHeader, "onMeasure", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) { + View mDatePrivacyView = (View) getObjectField(param.thisObject, "mPrivacyContainer"); + int mTopViewMeasureHeight = getIntField(param.thisObject, "mTopViewMeasureHeight"); + + if ((int) callMethod(mDatePrivacyView, "getMeasuredHeight") != mTopViewMeasureHeight) { + setObjectField(param.thisObject, "mTopViewMeasureHeight", callMethod(mDatePrivacyView, "getMeasuredHeight")); + callMethod(param.thisObject, "updateAnimators"); + } } - } - }); + }); + } } catch (Throwable ignored) {} } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java index 676ddfba2..54de8a715 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java @@ -124,7 +124,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); - Class OplusQSTileBaseView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSTileBaseView", lpparam.classLoader); + Class OplusQSTileBaseView; + try { + OplusQSTileBaseView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSTileBaseView", lpparam.classLoader); + } catch (Throwable ignored) { + OplusQSTileBaseView = findClass("com.oplusos.systemui.qs.qstileimpl.OplusQSTileBaseView", lpparam.classLoader); + } /* TESTING CUSTOMIZATIONS @@ -240,7 +245,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { hookAllMethods(OplusQSTileBaseView, "generateDrawable", colorHook); - Class OplusQSHighlightTileView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSHighlightTileView", lpparam.classLoader); + Class OplusQSHighlightTileView; + try { + OplusQSHighlightTileView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSHighlightTileView", lpparam.classLoader); + } catch (Throwable ignored) { + OplusQSHighlightTileView = findClass("com.oplusos.systemui.qs.qstileimpl.OplusQSHighlightTileView", lpparam.classLoader); + } hookAllMethods(OplusQSHighlightTileView, "generateDrawable", colorHook); @@ -261,7 +271,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); - Class OplusQSTileView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSTileView", lpparam.classLoader); + Class OplusQSTileView; + try { + OplusQSTileView = findClass("com.oplus.systemui.qs.qstileimpl.OplusQSTileView", lpparam.classLoader); + } catch (Throwable ignored) { + OplusQSTileView = findClass("com.oplusos.systemui.qs.qstileimpl.OplusQSTileView", lpparam.classLoader); // OOS 13 + } hookAllMethods(OplusQSTileView, "createLabel", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { @@ -287,7 +302,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); - Class OplusToggleSliderView = findClass("com.oplus.systemui.qs.widget.OplusToggleSliderView", lpparam.classLoader); + Class OplusToggleSliderView; + try { + OplusToggleSliderView = findClass("com.oplus.systemui.qs.widget.OplusToggleSliderView", lpparam.classLoader); + } catch (Throwable ignored) { + OplusToggleSliderView = findClass("com.oplusos.systemui.qs.widget.OplusToggleSliderView", lpparam.classLoader); + } findAndHookMethod(OplusToggleSliderView, "onShapeChanged", int.class, diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java index ab83d051d..e26f8252e 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java @@ -221,7 +221,6 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th Class ClockClass = findClass("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader); Class CollapsedStatusBarFragmentClass = findClass("com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment", lpparam.classLoader); - Class StatClockClass = findClass("com.oplus.systemui.statusbar.widget.StatClock", lpparam.classLoader); Class TaskStackListenerImpl = findClass("com.android.wm.shell.common.TaskStackListenerImpl", lpparam.classLoader); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java index d11ce52e1..f6520a027 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java @@ -180,18 +180,32 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th mLockscreenDoubleTapToSleep = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(@NonNull MotionEvent e) { - if (mStatusBar!=null) + if (mStatusBar != null) mStatusBar.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); SystemUtils.sleep(); return true; } }); - Class NotificationPanelViewControllerClass = findClass("com.android.systemui.shade.NotificationPanelViewController", lpparam.classLoader); + Class NotificationPanelViewControllerClass; + try { + NotificationPanelViewControllerClass = findClass("com.android.systemui.shade.NotificationPanelViewController", lpparam.classLoader); + } catch (Throwable e) { + NotificationPanelViewControllerClass = findClass("com.android.systemui.statusbar.phone.NotificationPanelViewController", lpparam.classLoader); + } Class PhoneStatusBarView = findClass("com.android.systemui.statusbar.phone.PhoneStatusBarView", lpparam.classLoader); Class PhoneStatusBarViewControllerClass = findClass("com.android.systemui.statusbar.phone.PhoneStatusBarViewController", lpparam.classLoader); - Class QSSecurityFooterUtilsClass = findClass("com.android.systemui.qs.QSSecurityFooterUtils", lpparam.classLoader); - Class QuickStatusBarHeaderClass = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader); + Class QSSecurityFooterUtilsClass; + try { + QSSecurityFooterUtilsClass = findClass("com.android.systemui.qs.QSSecurityFooterUtils", lpparam.classLoader); + } catch (Throwable e) { + QSSecurityFooterUtilsClass = findClass("com.android.systemui.qs.QSSecurityFooter", lpparam.classLoader); + } + Class QuickStatusBarHeaderClass; + try { QuickStatusBarHeaderClass = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader); + } catch (Throwable t) { + QuickStatusBarHeaderClass = findClass("com.android.systemui.qs.QuickStatusBarHeader", lpparam.classLoader); + } hookAllConstructors(QSSecurityFooterUtilsClass, new XC_MethodHook() { @Override @@ -215,13 +229,16 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { callMethod(mBatteryRemainingIcon, "setOnClickListener", clickListener); callMethod(mBatteryRemainingIcon, "setOnLongClickListener", clickListener); - } catch (Throwable e) {e.printStackTrace();} + } catch (Throwable e) { + e.printStackTrace(); + } } }); try { //13 QPR3 hookTouchHandler(PhoneStatusBarViewControllerClass); - }catch (Throwable ignored){} + } catch (Throwable ignored) { + } hookAllConstructors(PhoneStatusBarView, new XC_MethodHook() { @Override @@ -259,8 +276,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { GestureDetector pullUpDetector = new GestureDetector(mContext, getPullUpListener()); try { hookTouchHandler(getObjectField(param.thisObject, "mStatusBarViewTouchEventHandler").getClass()); + } catch (Throwable ignored) { } - catch (Throwable ignored){} hookAllMethods(mTouchHandler.getClass(), "onTouchEvent", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { @@ -286,7 +303,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { @Override protected void afterHookedMethod(MethodHookParam param) { View mSettingsButton = (View) getObjectField(param.thisObject, "mSettingsButton"); - try{ + try { callMethod(mSettingsButton, "setOnLongClickListener", onLongClick); } catch (Throwable e) { e.printStackTrace(); @@ -473,36 +490,36 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { Context.class, "com.android.internal.statusbar.StatusBarIcon", new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - if (!mNewIconStyle) return; - Drawable icon = null; - Object statusBarIcon = param.args[2]; + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (!mNewIconStyle) return; + Drawable icon = null; + Object statusBarIcon = param.args[2]; - String pkgName = (String) getObjectField(statusBarIcon, "pkg"); - int userId = (int) callMethod(getObjectField(statusBarIcon, "user"), "getIdentifier"); - try { - if (!pkgName.contains("systemui")) { - icon = mContext.getPackageManager().getApplicationIcon(pkgName); - } - } catch (Throwable e) { - return; - } + String pkgName = (String) getObjectField(statusBarIcon, "pkg"); + int userId = (int) callMethod(getObjectField(statusBarIcon, "user"), "getIdentifier"); + try { + if (!pkgName.contains("systemui")) { + icon = mContext.getPackageManager().getApplicationIcon(pkgName); + } + } catch (Throwable e) { + return; + } - int dimen; - if (icon != null) { - dimen = 48; - float density = mContext.getResources().getDisplayMetrics().density; - int dimensionPixelSize = Math.round(dimen * density); - Drawable icon2 = (Drawable) callStaticMethod(DrawableSize, "downscaleToSize", mContext.getResources(), icon, dimensionPixelSize, dimensionPixelSize); - if (icon2 != null) { - param.setResult(icon2); - } - } + int dimen; + if (icon != null) { + dimen = 48; + float density = mContext.getResources().getDisplayMetrics().density; + int dimensionPixelSize = Math.round(dimen * density); + Drawable icon2 = (Drawable) callStaticMethod(DrawableSize, "downscaleToSize", mContext.getResources(), icon, dimensionPixelSize, dimensionPixelSize); + if (icon2 != null) { + param.setResult(icon2); + } + } - } - }); + } + }); hookAllConstructors(StatusBarIconView, new XC_MethodHook() { @Override @@ -567,7 +584,8 @@ private void enableCount() { //region icon tap related class ClickListener implements View.OnClickListener, View.OnLongClickListener { - public ClickListener() {} + public ClickListener() { + } @Override public void onClick(View v) { @@ -581,7 +599,7 @@ public void onClick(View v) { public boolean onLongClick(View v) { String name = mContext.getResources().getResourceName(v.getId()); - if(name.endsWith("batteryRemainingIcon")) { + if (name.endsWith("batteryRemainingIcon")) { showBatteryPage(); return true; } @@ -737,20 +755,25 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { private void updateStatusbarHeight() { try { callMethod(PSBV, "updateStatusBarHeight"); - } catch (Throwable ignored) {} + } catch (Throwable ignored) { + } } private void updateResources() { try { callMethod(PSBV, "updateResources"); - } catch (Throwable ignored) {} + } catch (Throwable ignored) { + } try { callMethod(PSBV, "updateLayoutForCutout"); - } catch (Throwable ignored) {} + } catch (Throwable ignored) { + } try { callMethod(PSBV, "requestLayout"); - } catch (Throwable ignored) {} + } catch (Throwable ignored) { + } } + private void updateNotificationIcons() { try { callMethod(mNotificationIconAreaController, "updateStatusBarIcons"); diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarNotification.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarNotification.java index 663e22ba4..a5fbb1951 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarNotification.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarNotification.java @@ -65,7 +65,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { //Class OplusGutsContent = findClass("com.oplus.systemui.statusbar.notification.row.OpNotificationGuts.OplusGutsContent", lpparam.classLoader); //Class NotificationMenuRowExtImpl = findClass("com.oplus.systemui.statusbar.notification.row.NotificationMenuRowExtImpl", lpparam.classLoader); - Class OplusPowerNotificationWarnings = findClass("com.oplus.systemui.statusbar.notification.power.OplusPowerNotificationWarnings", lpparam.classLoader); + Class OplusPowerNotificationWarnings; + try { + OplusPowerNotificationWarnings = findClass("com.oplus.systemui.statusbar.notification.power.OplusPowerNotificationWarnings", lpparam.classLoader); + } catch (Throwable t) { + OplusPowerNotificationWarnings = findClass("com.oplusos.systemui.notification.power.OplusPowerNotificationWarnings", lpparam.classLoader); // OOS 13 + } findAndHookMethod(OplusPowerNotificationWarnings, "showChargeErrorDialog", int.class, new XC_MethodHook() { @Override