diff --git a/Misc/Scaling.txt b/Misc/Scaling.txt new file mode 100644 index 00000000..e8064122 --- /dev/null +++ b/Misc/Scaling.txt @@ -0,0 +1,16 @@ +//frameworks/base/cmds/wm/src/com/android/commands/wm/Wm.java + +IWindowManager mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService( + Context.WINDOW_SERVICE)); + +Point initialSize = new Point(); +Point baseSize = new Point(); +mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize); //Get true size +mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize); //Get current size + +mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h); //Set to custom size +mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY); //Reset to true size + +1440*2560 +1080*1920 +720*1280 diff --git a/Patches/LineageOS-14.1/android_frameworks_base/0001-Reduced_Resolution.patch b/Patches/LineageOS-14.1/android_frameworks_base/0001-Reduced_Resolution.patch new file mode 100644 index 00000000..6d100c28 --- /dev/null +++ b/Patches/LineageOS-14.1/android_frameworks_base/0001-Reduced_Resolution.patch @@ -0,0 +1,84 @@ +From 259267c0ffa34a99aad3af08d58dfd5aa340bd04 Mon Sep 17 00:00:00 2001 +From: Tad +Date: Fri, 20 Oct 2017 15:29:25 -0400 +Subject: [PATCH] Reduced Resolution Feature 2/2 + +Change-Id: Ib3d363e4fc66821ebb5303a974589c0b18c5ef9b +--- + core/java/android/os/PowerManager.java | 46 ++++++++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java +index 5c8effec0ed..62954ddadea 100644 +--- a/core/java/android/os/PowerManager.java ++++ b/core/java/android/os/PowerManager.java +@@ -438,6 +438,8 @@ public final class PowerManager { + final IPowerManager mService; + final Handler mHandler; + ++ final IWindowManager mWm; ++ + IDeviceIdleController mIDeviceIdleController; + + /** +@@ -447,6 +449,9 @@ public final class PowerManager { + mContext = context; + mService = service; + mHandler = handler; ++ ++ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService( ++ Context.WINDOW_SERVICE)); + } + + /** +@@ -988,6 +993,47 @@ public final class PowerManager { + } + } + ++ public boolean isReducedResolution() { ++ try { ++ Point initialSize = new Point(); ++ Point baseSize = new Point(); ++ ++ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize); ++ mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize); ++ ++ return !initialSize.equals(baseSize); ++ } catch (Exception e) { ++ throw e.rethrowFromSystemServer(); ++ } ++ } ++ ++ public boolean setReducedResolution(boolean mode) { ++ try { ++ if (mode) { ++ Point initialSize = new Point(); ++ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize); ++ ++ Point newSize; ++ ++ switch(initialSize.x) { ++ case 1440: ++ newSize = new Point(1080, 1920); ++ case 1080: ++ newSize = new Point(720, 1280); ++ default: ++ return false; ++ } ++ ++ mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, newSize.x, newSize.y); ++ } else { ++ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY); ++ } ++ return isReducedResolution(); ++ } catch (Exception e) { ++ throw e.rethrowFromSystemServer(); ++ } ++ } ++ + /** + * Returns true if the device is currently in idle mode. This happens when a device + * has been sitting unused and unmoving for a sufficiently long period of time, so that +-- +2.14.2 + diff --git a/Patches/LineageOS-14.1/android_packages_apps_CMParts/0002-Reduced_Resolution.patch b/Patches/LineageOS-14.1/android_packages_apps_CMParts/0002-Reduced_Resolution.patch new file mode 100644 index 00000000..be819420 --- /dev/null +++ b/Patches/LineageOS-14.1/android_packages_apps_CMParts/0002-Reduced_Resolution.patch @@ -0,0 +1,104 @@ +From 4205a403acba83df87feef538bd9495f3f49c951 Mon Sep 17 00:00:00 2001 +From: Tad +Date: Fri, 20 Oct 2017 15:28:00 -0400 +Subject: [PATCH] Reduced Resolution Feature 1/2 + +Change-Id: Id76c429a7bf806db59726d7d64a4dca267cb36c1 +--- + res/values/strings.xml | 2 ++ + res/xml/perf_profile_settings.xml | 5 +++++ + .../cyanogenmod/cmparts/power/PerfProfileSettings.java | 16 ++++++++++++++++ + 3 files changed, 23 insertions(+) + +diff --git a/res/values/strings.xml b/res/values/strings.xml +index a7e31ca..cfaef0b 100644 +--- a/res/values/strings.xml ++++ b/res/values/strings.xml +@@ -576,6 +576,8 @@ + Battery saving + Extreme power saver + Restrict device performance and background activity to save power ++ Reduce screen resolution ++ Lowers the screen resolution to save power + Automatic power saver + Automatically enable power save mode at %s battery + Do not enable power save mode automatically +diff --git a/res/xml/perf_profile_settings.xml b/res/xml/perf_profile_settings.xml +index 3585cb7..0513137 100644 +--- a/res/xml/perf_profile_settings.xml ++++ b/res/xml/perf_profile_settings.xml +@@ -29,6 +29,11 @@ + android:summary="@string/power_save_summary" + android:persistent="false" /> + ++ ++ + 2|config_longPressOnHomeBehavior">0|' core/res/res/values/config.xml; sed -i 's|config_doubleTapOnHomeBehavior">0|config_doubleTapOnHomeBehavior">8|' core/res/res/values/config.xml; sed -i 's|config_permissionReviewRequired">false|config_permissionReviewRequired">true|' core/res/res/values/config.xml; +patch -p1 < $patches"android_frameworks_base/0001-Reduced_Resolution.patch" #Allow reducing resolution to save power patch -p1 < $patches"android_frameworks_base/0003-Signature_Spoofing.patch" #Allow packages to spoof their signature (MicroG) patch -p1 < $patches"android_frameworks_base/0005-Harden_Sig_Spoofing.patch" #Restrict signature spoofing to system apps signed with the platform key rm -rf packages/PrintRecommendationService; #App that just creates popups to install proprietary print apps @@ -121,6 +122,7 @@ rm -rf src/org/cyanogenmod/cmparts/cmstats/ res/xml/anonymous_stats.xml res/xml/ git fetch https://review.lineageos.org/LineageOS/android_packages_apps_CMParts refs/changes/15/113415/25 && git cherry-pick FETCH_HEAD #network traffic sed -i 's|config_showWeatherMenu">true|config_showWeatherMenu">false|' res/values/config.xml; #Disable Weather patch -p1 < $patches"android_packages_apps_CMParts/0001-Remove_Analytics.patch" #Remove the rest of CMStats +patch -p1 < $patches"android_packages_apps_CMParts/0002-Reduced_Resolution.patch" #Allow reducing resolution to save power enter "packages/apps/Updater" patch -p1 < $patches"android_packages_apps_Updater/0001-Server.patch" #Switch to our server