15.1: Cleanup

This commit is contained in:
Tad 2018-02-28 08:12:30 -05:00
parent 994a069deb
commit ac990f0491
3 changed files with 2 additions and 332 deletions

View File

@ -1,222 +0,0 @@
From 78c9088dabac1c042567faa3196dfd21fae900ef Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Sat, 21 Oct 2017 11:53:09 -0400
Subject: [PATCH] Reduced Resolution Feature 2/2
Change-Id: If92489ee9dc119acdeeb8f05f0d70970eef55817
---
core/java/android/os/IPowerManager.aidl | 3 +
core/java/android/os/PowerManager.java | 32 ++++++++
core/java/android/os/PowerManagerInternal.java | 2 +
.../android/server/power/PowerManagerService.java | 85 ++++++++++++++++++++++
4 files changed, 122 insertions(+)
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 26eb7f169a0..d6051d0db74 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -75,4 +75,7 @@ interface IPowerManager
void setKeyboardLight(boolean on, int key);
void wakeUpWithProximityCheck(long time, String reason, String opPackageName);
+
+ boolean isReducedResolution();
+ boolean setReducedResolution(boolean mode);
}
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 5c8effec0ed..8c1d2fdf65b 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -988,6 +988,38 @@ public final class PowerManager {
}
}
+ /**
+ * Returns true if the WindowManager is running at a reduced resolution
+ *
+ * @return Returns true if WindowManager is set to a reduced resolution, else false.
+ *
+ * @hide
+ */
+ public boolean isReducedResolution() {
+ try {
+ return mService.isReducedResolution();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Set the reduced resolution mode
+ *
+ * @return True if the set was allowed.
+ *
+ * @see #isReducedResolution()
+ *
+ * @hide
+ */
+ public boolean setReducedResolution(boolean mode) {
+ try {
+ return mService.setReducedResolution(mode);
+ } catch (RemoteException 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
diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java
index bbafb5662cd..e0c71a044a5 100644
--- a/core/java/android/os/PowerManagerInternal.java
+++ b/core/java/android/os/PowerManagerInternal.java
@@ -173,6 +173,8 @@ public abstract class PowerManagerInternal {
public abstract boolean setPowerSaveMode(boolean mode);
+ public abstract boolean setReducedResolution(boolean mode);
+
public abstract void setFeature(int featureId, int data);
public abstract int getFeature(int featureId);
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 55d0809ee4e..33cb0a93bb7 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -29,6 +29,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.database.ContentObserver;
+import android.graphics.Point;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@@ -49,6 +50,7 @@ import android.os.PowerManager;
import android.os.PowerManagerInternal;
import android.os.Process;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
@@ -67,6 +69,7 @@ import android.util.Slog;
import android.util.SparseIntArray;
import android.util.TimeUtils;
import android.view.Display;
+import android.view.IWindowManager;
import android.view.WindowManagerPolicy;
import com.android.internal.app.IAppOpsService;
@@ -203,6 +206,7 @@ public final class PowerManagerService extends SystemService
private final Context mContext;
private final ServiceThread mHandlerThread;
private final PowerManagerHandler mHandler;
+ private IWindowManager mWm;
private LightsManager mLightsManager;
private BatteryManagerInternal mBatteryManagerInternal;
@@ -2658,6 +2662,60 @@ public final class PowerManagerService extends SystemService
}
}
+ private boolean isReducedResolutionInternal() {
+ synchronized (mLock) {
+ try {
+ Point initialSize = new Point();
+ Point baseSize = new Point();
+
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
+ Context.WINDOW_SERVICE));
+
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
+ mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
+
+ return !initialSize.equals(baseSize);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
+ private boolean setReducedResolutionInternal(boolean mode) {
+ synchronized (mLock) {
+ try {
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
+ Context.WINDOW_SERVICE));
+ if (mode) {
+ Point initialSize = new Point();
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
+
+ Point newSize;
+
+ if (initialSize.x == 1440 && initialSize.y == 2560) {//16:9
+ newSize = new Point(1080, 1920);//.75
+ } else if(initialSize.x == 1200 && initialSize.y == 1920) {//16:10
+ newSize = new Point(900, 1440);//.75
+ } else if(initialSize.x == 1080 && initialSize.y == 1920) {//16:9
+ newSize = new Point(720, 1280);//.50
+ } else if(initialSize.x == 768 && initialSize.y == 1280) {//5:3
+ newSize = new Point(576, 960);//.75
+ } else {
+ return false;
+ }
+
+ mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, newSize.x, newSize.y);
+ return isReducedResolutionInternal();
+ } else {
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
+ return !isReducedResolutionInternal();
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
boolean isDeviceIdleModeInternal() {
synchronized (mLock) {
return mDeviceIdleMode;
@@ -3833,6 +3891,28 @@ public final class PowerManagerService extends SystemService
}
}
+ @Override // Binder call
+ public boolean isReducedResolution() {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return isReducedResolutionInternal();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override // Binder call
+ public boolean setReducedResolution(boolean mode) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.DEVICE_POWER, null);
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return setReducedResolutionInternal(mode);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
@Override // Binder call
public boolean isDeviceIdleMode() {
final long ident = Binder.clearCallingIdentity();
@@ -4214,6 +4294,11 @@ public final class PowerManagerService extends SystemService
return setLowPowerModeInternal(mode);
}
+ @Override
+ public boolean setReducedResolution(boolean mode) {
+ return setReducedResolutionInternal(mode);
+ }
+
@Override
public int getFeature(int featureId) {
return nativeGetFeature(featureId);
--
2.14.2

View File

@ -1,107 +0,0 @@
From a1e8c666a77d575c8d78a0d1269b3d06a7cb5d41 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Sat, 21 Oct 2017 09:05:09 -0400
Subject: [PATCH] Reduced Resolution Feature 1/2
Change-Id: I925a23e61ebf3ce06dc78898952085d87ad10410
---
res/values/strings.xml | 3 +++
res/xml/perf_profile_settings.xml | 6 ++++++
.../cyanogenmod/cmparts/power/PerfProfileSettings.java | 17 +++++++++++++++++
3 files changed, 26 insertions(+)
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 21b8b78..1fee482 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -576,6 +576,9 @@
<string name="power_save_category_title">Battery saving</string>
<string name="power_save_title">Extreme power saver</string>
<string name="power_save_summary">Restrict device performance and background activity to save power</string>
+ <string name="reduce_resolution_title">Reduce screen resolution</string>
+ <string name="reduce_resolution_summary">Lowers the screen resolution to save power</string>
+ <string name="reduce_resolution_fail_toast">Unable to set a lower screen resolution</string>
<string name="auto_power_save_title">Automatic power saver</string>
<string name="auto_power_save_summary_on">Automatically enable power save mode at %s battery</string>
<string name="auto_power_save_summary_off">Do not enable power save mode automatically</string>
diff --git a/res/xml/perf_profile_settings.xml b/res/xml/perf_profile_settings.xml
index 3585cb7..ce99c6c 100644
--- a/res/xml/perf_profile_settings.xml
+++ b/res/xml/perf_profile_settings.xml
@@ -34,6 +34,12 @@
android:title="@string/auto_power_save_title"
android:persistent="false" />
+ <SwitchPreference
+ android:key="reduce_resolution"
+ android:title="@string/reduce_resolution_title"
+ android:summary="@string/reduce_resolution_summary"
+ android:persistent="false" />
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
index ec2138d..5fdc8f1 100644
--- a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
+++ b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
@@ -56,11 +56,13 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
private static final String KEY_PERF_PROFILE_CATEGORY = "perf_profile_category";
private static final String KEY_AUTO_POWER_SAVE = "auto_power_save";
private static final String KEY_POWER_SAVE = "power_save";
+ private static final String KEY_REDUCE_RESOLUTION = "reduce_resolution";
private static final String KEY_PER_APP_PROFILES = "app_perf_profiles_enabled";
private static final String KEY_PERF_SEEKBAR = "perf_seekbar";
private ListPreference mAutoPowerSavePref;
private SwitchPreference mPowerSavePref;
+ private SwitchPreference mReduceResolutionPref;
private SeekBarPreference mPerfSeekBar;
private StopMotionVectorDrawable mPerfDrawable;
@@ -90,6 +92,7 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
mPerfSeekBar = (SeekBarPreference) findPreference(KEY_PERF_SEEKBAR);
mAutoPowerSavePref = (ListPreference) findPreference(KEY_AUTO_POWER_SAVE);
mPowerSavePref = (SwitchPreference) findPreference(KEY_POWER_SAVE);
+ mReduceResolutionPref = (SwitchPreference) findPreference(KEY_REDUCE_RESOLUTION);
mPerAppProfilesPref = (SwitchPreference) findPreference(KEY_PER_APP_PROFILES);
mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
@@ -124,6 +127,8 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
updateAutoPowerSaveValue();
mAutoPowerSavePref.setOnPreferenceChangeListener(this);
mPowerSavePref.setOnPreferenceChangeListener(this);
+ mReduceResolutionPref.setOnPreferenceChangeListener(this);
+ updateReduceResolutionValue();
}
@@ -245,6 +250,14 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
final int level = Integer.parseInt((String) newValue);
Global.putInt(getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, level);
updateAutoPowerSaveSummary(level);
+ } else if (preference == mReduceResolutionPref) {
+ if (!mPowerManager.setReducedResolution((boolean) newValue)) {
+ // Don't just fail silently, inform the user as well
+ Toast.makeText(getActivity(),
+ R.string.reduce_resolution_fail_toast, Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ updateReduceResolutionValue();
}
return true;
}
@@ -262,6 +275,10 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
PartsUpdater.notifyChanged(getActivity(), getPreferenceScreen().getKey());
}
+ private void updateReduceResolutionValue() {
+ mReduceResolutionPref.setChecked(mPowerManager.isReducedResolution());
+ }
+
private void updateAutoPowerSaveValue() {
final int level = Global.getInt(
getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
--
2.14.2

View File

@ -58,6 +58,7 @@ echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/a
cp -r $patches"Fennec_DOS-Shim" $base"packages/apps/"; #Add a shim to install Fennec DOS without actually including the large APK cp -r $patches"Fennec_DOS-Shim" $base"packages/apps/"; #Add a shim to install Fennec DOS without actually including the large APK
enterAndClear "build/make" enterAndClear "build/make"
#patch -p1 < $patches"android_build/0001-Automated_Build_Signing.patch" #Automated build signing. Disclaimer: From CopperheadOS 13.0 #TODO: Rebase
sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence sed -i 's/messaging/Silence/' target/product/*.mk; #Replace AOSP Messaging app with Silence
enterAndClear "device/qcom/sepolicy" enterAndClear "device/qcom/sepolicy"
@ -68,7 +69,6 @@ enterAndClear "frameworks/base"
sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox
sed -i 's/com.android.messaging/org.smssecure.smssecure/' core/res/res/values/config.xml; #Change default SMS app to Silence sed -i 's/com.android.messaging/org.smssecure.smssecure/' core/res/res/values/config.xml; #Change default SMS app to Silence
sed -i 's|config_permissionReviewRequired">false|config_permissionReviewRequired">true|' 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 TODO: Rebase and add 800x480
patch -p1 < $patches"android_frameworks_base/0002-Signature_Spoofing.patch" #Allow packages to spoof their signature (microG) patch -p1 < $patches"android_frameworks_base/0002-Signature_Spoofing.patch" #Allow packages to spoof their signature (microG)
patch -p1 < $patches"android_frameworks_base/0003-Harden_Sig_Spoofing.patch" #Restrict signature spoofing to system apps signed with the platform key patch -p1 < $patches"android_frameworks_base/0003-Harden_Sig_Spoofing.patch" #Restrict signature spoofing to system apps signed with the platform key
patch -p1 < $patches"android_frameworks_base/0004-OpenNIC.patch" #Change fallback and tethering DNS servers to OpenNIC AnyCast patch -p1 < $patches"android_frameworks_base/0004-OpenNIC.patch" #Change fallback and tethering DNS servers to OpenNIC AnyCast
@ -126,7 +126,6 @@ enterAndClear "packages/apps/LineageParts"
rm -rf src/org/lineageos/lineageparts/lineagestats/ res/xml/anonymous_stats.xml res/xml/preview_data.xml #Nuke part of the analytics rm -rf src/org/lineageos/lineageparts/lineagestats/ res/xml/anonymous_stats.xml res/xml/preview_data.xml #Nuke part of the analytics
sed -i 's|config_showWeatherMenu">true|config_showWeatherMenu">false|' res/values/config.xml; #Disable Weather sed -i 's|config_showWeatherMenu">true|config_showWeatherMenu">false|' res/values/config.xml; #Disable Weather
patch -p1 < $patches"android_packages_apps_LineageParts/0001-Remove_Analytics.patch" #Remove analytics patch -p1 < $patches"android_packages_apps_LineageParts/0001-Remove_Analytics.patch" #Remove analytics
#patch -p1 < $patches"android_packages_apps_LineageParts/0002-Reduced_Resolution.patch" #Allow reducing resolution to save power #TODO: Rebase
enterAndClear "packages/apps/Settings" enterAndClear "packages/apps/Settings"
git revert a96df110e84123fe1273bff54feca3b4ca484dcd git revert a96df110e84123fe1273bff54feca3b4ca484dcd
@ -135,7 +134,7 @@ sed -i 's/GSETTINGS_PROVIDER = "com.google.settings";/GSETTINGS_PROVIDER = "com.
#patch -p1 < $patches"android_packages_apps_Settings/0001-Privacy_Guard-More_Perms.patch" #Allow more control over various permissions via Privacy Guard #TODO: Rebase #patch -p1 < $patches"android_packages_apps_Settings/0001-Privacy_Guard-More_Perms.patch" #Allow more control over various permissions via Privacy Guard #TODO: Rebase
#enterAndClear "packages/apps/SetupWizard" #enterAndClear "packages/apps/SetupWizard"
#patch -p1 < $patches"android_packages_apps_SetupWizard/0001-Remove_Analytics.patch" #Remove analytics #patch -p1 < $patches"android_packages_apps_SetupWizard/0001-Remove_Analytics.patch" #Remove analytics #TODO: Rebase
enterAndClear "packages/apps/Silence" enterAndClear "packages/apps/Silence"
cp $patches"android_packages_apps_Silence/Android.mk" Android.mk #Add a build file cp $patches"android_packages_apps_Silence/Android.mk" Android.mk #Add a build file