diff --git a/app/build.gradle b/app/build.gradle index 9e70289a..b3eda672 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,8 +34,8 @@ android { minSdkVersion 30 //noinspection OldTargetApi,ExpiredTargetSdkVersion targetSdkVersion 31 - versionCode 13 - versionName "3.2.1.2207011" + versionCode 14 + versionName "3.2.1.2207012" resConfigs 'ru-rRU', 'zh-rCN' ndk { abiFilters "arm64-v8a" } } diff --git a/app/src/main/java/name/mikanoshi/customiuizer/mods/Controls.java b/app/src/main/java/name/mikanoshi/customiuizer/mods/Controls.java index 2ba0dbad..7871eb80 100644 --- a/app/src/main/java/name/mikanoshi/customiuizer/mods/Controls.java +++ b/app/src/main/java/name/mikanoshi/customiuizer/mods/Controls.java @@ -588,33 +588,33 @@ public static void FingerprintEventsHook(LoadPackageParam lpparam) { Helpers.hookAllMethods("com.android.server.policy.BaseMiuiPhoneWindowManager", lpparam.classLoader, "initInternal", new MethodHook() { @Override protected void after(MethodHookParam param) throws Throwable { - Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); - Handler mHandler = (Handler)XposedHelpers.getObjectField(param.thisObject, "mHandler"); - - new Helpers.SharedPrefObserver(mContext, mHandler) { - @Override - public void onChange(Uri uri) { - try { - String type = uri.getPathSegments().get(1); - String key = uri.getPathSegments().get(2); - if (!key.contains("pref_key_controls_fingerprint")) return; + Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); + Handler mHandler = (Handler)XposedHelpers.getObjectField(param.thisObject, "mHandler"); - switch (type) { - case "string": - MainModule.mPrefs.put(key, Helpers.getSharedStringPref(mContext, key, "")); - break; - case "integer": - MainModule.mPrefs.put(key, Helpers.getSharedIntPref(mContext, key, 1)); - break; - case "boolean": - MainModule.mPrefs.put(key, Helpers.getSharedBoolPref(mContext, key, false)); - break; - } - } catch (Throwable t) { - XposedBridge.log(t); + new Helpers.SharedPrefObserver(mContext, mHandler) { + @Override + public void onChange(Uri uri) { + try { + String type = uri.getPathSegments().get(1); + String key = uri.getPathSegments().get(2); + if (!key.contains("pref_key_controls_fingerprint")) return; + + switch (type) { + case "string": + MainModule.mPrefs.put(key, Helpers.getSharedStringPref(mContext, key, "")); + break; + case "integer": + MainModule.mPrefs.put(key, Helpers.getSharedIntPref(mContext, key, 1)); + break; + case "boolean": + MainModule.mPrefs.put(key, Helpers.getSharedBoolPref(mContext, key, false)); + break; } + } catch (Throwable t) { + XposedBridge.log(t); } - }; + } + }; } }); @@ -721,30 +721,20 @@ protected void after(MethodHookParam param) throws Throwable { Helpers.hookAllMethods(fpService, lpparam.classLoader, "startClient", new MethodHook() { @Override protected void before(MethodHookParam param) throws Throwable { - Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); - Settings.System.putInt(mContext.getContentResolver(), "is_fingerprint_active", 1); + Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); + Settings.System.putInt(mContext.getContentResolver(), "is_fingerprint_active", 1); } }); Helpers.hookAllMethods(fpService, lpparam.classLoader, "removeClient", new MethodHook() { @Override protected void after(MethodHookParam param) throws Throwable { - Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); - Settings.System.putInt(mContext.getContentResolver(), "is_fingerprint_active", 0); + Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); + Settings.System.putInt(mContext.getContentResolver(), "is_fingerprint_active", 0); } }); } -// public static void FingerprintHook(LoadPackageParam lpparam) { -// Helpers.findAndHookMethod("com.android.server.devicepolicy.DevicePolicyManagerService", lpparam.classLoader, "reportSuccessfulFingerprintAttempt", int.class, new MethodHook() { -// @Override -// protected void before(MethodHookParam param) throws Throwable { -// Helpers.log("reportSuccessfulFingerprintAttempt"); -// Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); -// } -// }); -// } - @SuppressLint("StaticFieldLeak") private static Context basePWMContext; private static Object basePWMObject; @@ -1013,19 +1003,6 @@ protected void before(final MethodHookParam param) throws Throwable { } }); - Helpers.findAndHookMethod("com.android.systemui.assist.AssistManager", lpparam.classLoader, "startAssist", Bundle.class, new MethodHook() { - @Override - protected void before(final MethodHookParam param) throws Throwable { - Bundle bundle = (Bundle)param.args[0]; - if (bundle == null || bundle.getInt("triggered_by", 0) != 83 || bundle.getInt("invocation_type", 0) != 1) return; - Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); - if (GlobalActions.handleAction(mContext, "pref_key_controls_fsg_assist")) { - Helpers.performLightVibration(mContext); - param.setResult(null); - } - } - }); - Helpers.hookAllConstructors("com.android.systemui.assist.ui.DefaultUiController", lpparam.classLoader, new MethodHook() { @Override protected void after(MethodHookParam param) throws Throwable { diff --git a/app/src/main/java/name/mikanoshi/customiuizer/mods/System.java b/app/src/main/java/name/mikanoshi/customiuizer/mods/System.java index 596a78ce..618608b1 100644 --- a/app/src/main/java/name/mikanoshi/customiuizer/mods/System.java +++ b/app/src/main/java/name/mikanoshi/customiuizer/mods/System.java @@ -3498,7 +3498,8 @@ public static void AudioVisualizerHook(LoadPackageParam lpparam) { Helpers.hookAllMethods("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "makeStatusBarView", new MethodHook() { @Override protected void after(final MethodHookParam param) throws Throwable { - ViewGroup mNotificationPanel = (ViewGroup)XposedHelpers.getObjectField(param.thisObject, "mNotificationPanel"); + Object viewController = XposedHelpers.getObjectField(param.thisObject, "mNotificationPanelViewController"); + FrameLayout mNotificationPanel = (FrameLayout) XposedHelpers.getObjectField(viewController, "mView"); if (mNotificationPanel == null) { Helpers.log("AudioVisualizerHook", "Cannot find mNotificationPanel"); return; @@ -3524,14 +3525,21 @@ protected void after(final MethodHookParam param) throws Throwable { } }); - Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "onScreenTurnedOff", new MethodHook() { + Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.ScrimController", lpparam.classLoader, "onScreenTurnedOff", new MethodHook() { @Override protected void after(final MethodHookParam param) throws Throwable { if (audioViz != null) audioViz.updateScreenOn(false); } }); - Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "updateKeyguardState", boolean.class, boolean.class, new MethodHook() { + Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.ScrimController", lpparam.classLoader, "onScreenTurnedOn", new MethodHook() { + @Override + protected void after(final MethodHookParam param) throws Throwable { + if (audioViz != null) audioViz.updateScreenOn(true); + } + }); + + Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "updateKeyguardState", new MethodHook() { @Override protected void after(final MethodHookParam param) throws Throwable { Object mStatusBarKeyguardViewManager = XposedHelpers.getObjectField(param.thisObject, "mStatusBarKeyguardViewManager"); @@ -3544,46 +3552,46 @@ protected void after(final MethodHookParam param) throws Throwable { } }); - Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.NotificationPanelView", lpparam.classLoader, "onExpandingFinished", new MethodHook() { + Helpers.hookAllMethods("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "setPanelExpanded", new MethodHook() { @Override protected void after(final MethodHookParam param) throws Throwable { - boolean isNotificationPanelExpandedNew = XposedHelpers.getBooleanField(param.thisObject, "mPanelExpanded"); - if (isNotificationPanelExpanded != isNotificationPanelExpandedNew) { - isNotificationPanelExpanded = isNotificationPanelExpandedNew; - updateAudioVisualizerState((Context)XposedHelpers.getObjectField(param.thisObject, "mContext")); - } + boolean isNotificationPanelExpandedNew = XposedHelpers.getBooleanField(param.thisObject, "mPanelExpanded"); + if (isNotificationPanelExpanded != isNotificationPanelExpandedNew) { + isNotificationPanelExpanded = isNotificationPanelExpandedNew; + updateAudioVisualizerState((Context)XposedHelpers.getObjectField(param.thisObject, "mContext")); + } } }); - Helpers.findAndHookMethod("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "updateMediaMetaData", boolean.class, boolean.class, new MethodHook() { + Helpers.findAndHookMethod("com.android.systemui.statusbar.NotificationMediaManager", lpparam.classLoader, "updateMediaMetaData", boolean.class, boolean.class, new MethodHook() { @Override protected void before(final MethodHookParam param) throws Throwable { - if (audioViz == null) return; - Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); - PowerManager powerMgr = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); - boolean isScreenOn = powerMgr.isInteractive(); - if (!isScreenOn) { - audioViz.updateScreenOn(false); - return; - } else audioViz.isScreenOn = true; + if (audioViz == null) return; + Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext"); + PowerManager powerMgr = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); + boolean isScreenOn = powerMgr.isInteractive(); + if (!isScreenOn) { + audioViz.updateScreenOn(false); + return; + } else audioViz.isScreenOn = true; - MediaMetadata mMediaMetadata = (MediaMetadata)XposedHelpers.getObjectField(param.thisObject, "mMediaMetadata"); - Bitmap art = null; - if (mMediaMetadata != null) { - art = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); - if (art == null) art = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); - if (art == null) art = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_DISPLAY_ICON); - } - if (art == null) { - WallpaperManager wallpaperMgr = WallpaperManager.getInstance(mContext); - Drawable wallpaperDrawable = wallpaperMgr.getDrawable(); - if (wallpaperDrawable instanceof BitmapDrawable) - art = ((BitmapDrawable)wallpaperDrawable).getBitmap(); - } + MediaMetadata mMediaMetadata = (MediaMetadata)XposedHelpers.getObjectField(param.thisObject, "mMediaMetadata"); + Bitmap art = null; + if (mMediaMetadata != null) { + art = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ART); + if (art == null) art = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART); + if (art == null) art = mMediaMetadata.getBitmap(MediaMetadata.METADATA_KEY_DISPLAY_ICON); + } + if (art == null) { + WallpaperManager wallpaperMgr = WallpaperManager.getInstance(mContext); + @SuppressLint("MissingPermission") Drawable wallpaperDrawable = wallpaperMgr.getDrawable(); + if (wallpaperDrawable instanceof BitmapDrawable) + art = ((BitmapDrawable)wallpaperDrawable).getBitmap(); + } - mMediaController = (MediaController)XposedHelpers.getObjectField(param.thisObject, "mMediaController"); - updateAudioVisualizerState(mContext); - audioViz.updateMusicArt(art); + mMediaController = (MediaController)XposedHelpers.getObjectField(param.thisObject, "mMediaController"); + updateAudioVisualizerState(mContext); + audioViz.updateMusicArt(art); } }); } @@ -7584,7 +7592,6 @@ public static void HideLockScreenStatusBarHook(LoadPackageParam lpparam) { Helpers.hookAllMethods("com.android.systemui.statusbar.phone.StatusBar", lpparam.classLoader, "makeStatusBarView", new MethodHook() { @Override protected void after(final MethodHookParam param) throws Throwable { - XposedHelpers.getObjectField(param.thisObject, "mNotificationPanelViewController"); View mKeyguardStatusBar = (View) XposedHelpers.getObjectField(XposedHelpers.getObjectField(param.thisObject, "mNotificationPanelViewController"), "mKeyguardStatusBar"); mKeyguardStatusBar.setTranslationY(-999f); } diff --git a/app/src/main/java/name/mikanoshi/customiuizer/subs/Controls.java b/app/src/main/java/name/mikanoshi/customiuizer/subs/Controls.java index 2d1fbf7c..5e8427bc 100644 --- a/app/src/main/java/name/mikanoshi/customiuizer/subs/Controls.java +++ b/app/src/main/java/name/mikanoshi/customiuizer/subs/Controls.java @@ -88,9 +88,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { case "pref_key_controls_cat_fsg": findPreference("pref_key_controls_fsg_horiz_apps").setOnPreferenceClickListener(openAppsEdit); findPreference("pref_key_controls_fsg_assist").setOnPreferenceClickListener(openNavbarActions); - - if (!Helpers.is12()) ((PreferenceEx)findPreference("pref_key_controls_fsg_assist")).setUnsupported(true); - break; } }