mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-25 07:29:24 -05:00
More fixes
This commit is contained in:
parent
0975c5251b
commit
d9f56cc8ff
@ -1,14 +1,15 @@
|
|||||||
From 1f5d2697b801e4f4ddfdd4edad464b09f39c416e Mon Sep 17 00:00:00 2001
|
From f2bcdb23270812840f2ff4bdab22a711a8b89045 Mon Sep 17 00:00:00 2001
|
||||||
From: Tad <tad@spotco.us>
|
From: Tad <tad@spotco.us>
|
||||||
Date: Fri, 20 Oct 2017 19:54:57 -0400
|
Date: Sat, 21 Oct 2017 00:36:49 -0400
|
||||||
Subject: [PATCH] Reduced Resolution Feature 2/2
|
Subject: [PATCH] Reduced Resolution Feature 2/2
|
||||||
|
|
||||||
Change-Id: Iafa177e66dca11da1a595ea6c1bbc3171b71eb67
|
Change-Id: Ie6245ae8ac97aaa05fb52106d1356122e2587b80
|
||||||
---
|
---
|
||||||
core/java/android/os/IPowerManager.aidl | 3 +
|
core/java/android/os/IPowerManager.aidl | 3 +
|
||||||
core/java/android/os/PowerManager.java | 32 ++++++++++
|
core/java/android/os/PowerManager.java | 32 +++++++++
|
||||||
.../android/server/power/PowerManagerService.java | 73 ++++++++++++++++++++++
|
core/java/android/os/PowerManagerInternal.java | 2 +
|
||||||
3 files changed, 108 insertions(+)
|
.../android/server/power/PowerManagerService.java | 84 ++++++++++++++++++++++
|
||||||
|
4 files changed, 121 insertions(+)
|
||||||
|
|
||||||
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
|
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
|
||||||
index 26eb7f169a0..d6051d0db74 100644
|
index 26eb7f169a0..d6051d0db74 100644
|
||||||
@ -65,8 +66,21 @@ index 5c8effec0ed..8c1d2fdf65b 100644
|
|||||||
/**
|
/**
|
||||||
* Returns true if the device is currently in idle mode. This happens when a device
|
* 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
|
* 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
|
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
|
||||||
index 55d0809ee4e..c1620ea74f8 100644
|
index 55d0809ee4e..76a275db073 100644
|
||||||
--- a/services/core/java/com/android/server/power/PowerManagerService.java
|
--- a/services/core/java/com/android/server/power/PowerManagerService.java
|
||||||
+++ b/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;
|
@@ -29,6 +29,7 @@ import android.content.IntentFilter;
|
||||||
@ -101,63 +115,67 @@ index 55d0809ee4e..c1620ea74f8 100644
|
|||||||
|
|
||||||
private LightsManager mLightsManager;
|
private LightsManager mLightsManager;
|
||||||
private BatteryManagerInternal mBatteryManagerInternal;
|
private BatteryManagerInternal mBatteryManagerInternal;
|
||||||
@@ -583,6 +587,8 @@ public final class PowerManagerService extends SystemService
|
@@ -2658,6 +2662,59 @@ public final class PowerManagerService extends SystemService
|
||||||
Process.THREAD_PRIORITY_DISPLAY, false /*allowIo*/);
|
|
||||||
mHandlerThread.start();
|
|
||||||
mHandler = new PowerManagerHandler(mHandlerThread.getLooper());
|
|
||||||
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
|
|
||||||
+ Context.WINDOW_SERVICE));
|
|
||||||
qcNsrmPowExt = new QCNsrmPowerExtension(this);
|
|
||||||
synchronized (mLock) {
|
|
||||||
mWakeLockSuspendBlocker = createSuspendBlockerLocked("PowerManagerService.WakeLocks");
|
|
||||||
@@ -2658,6 +2664,46 @@ public final class PowerManagerService extends SystemService
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ private boolean isReducedResolutionInternal() {
|
+ private boolean isReducedResolutionInternal() {
|
||||||
+ synchronized (mLock) {
|
+ synchronized (mLock) {
|
||||||
+ Point initialSize = new Point();
|
+ try {
|
||||||
+ Point baseSize = new Point();
|
+ Point initialSize = new Point();
|
||||||
|
+ Point baseSize = new Point();
|
||||||
+
|
+
|
||||||
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
|
||||||
+ mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
|
+ Context.WINDOW_SERVICE));
|
||||||
+
|
+
|
||||||
+ return !initialSize.equals(baseSize);
|
+ 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) {
|
+ private boolean setReducedResolutionInternal(boolean mode) {
|
||||||
+ synchronized (mLock) {
|
+ synchronized (mLock) {
|
||||||
+ if (mode) {
|
+ try {
|
||||||
+ Point initialSize = new Point();
|
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
|
||||||
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
+ Context.WINDOW_SERVICE));
|
||||||
|
+ if (mode) {
|
||||||
|
+ Point initialSize = new Point();
|
||||||
|
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
||||||
+
|
+
|
||||||
+ Point newSize;
|
+ Point newSize;
|
||||||
+
|
+
|
||||||
+ if (initialSize.x == 1440 && initialSize.y == 2560) {//16:9
|
+ if (initialSize.x == 1440 && initialSize.y == 2560) {//16:9
|
||||||
+ newSize = new Point(1080, 1920);//.75
|
+ newSize = new Point(1080, 1920);//.75
|
||||||
+ } else if(initialSize.x == 1200 && initialSize.y == 1920) {//16:10
|
+ } else if(initialSize.x == 1200 && initialSize.y == 1920) {//16:10
|
||||||
+ newSize = new Point(900, 1440);//.75
|
+ newSize = new Point(900, 1440);//.75
|
||||||
+ } else if(initialSize.x == 1080 && initialSize.y == 1920) {//16:9
|
+ } else if(initialSize.x == 1080 && initialSize.y == 1920) {//16:9
|
||||||
+ newSize = new Point(720, 1280);//.50
|
+ newSize = new Point(720, 1280);//.50
|
||||||
+ } else if(initialSize.x == 768 && initialSize.y == 1280) {//5:3
|
+ } else if(initialSize.x == 768 && initialSize.y == 1280) {//5:3
|
||||||
+ newSize = new Point(576, 960);//.75
|
+ newSize = new Point(576, 960);//.75
|
||||||
|
+ } else {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, newSize.x, newSize.y);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ return false;
|
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
|
||||||
+ }
|
+ }
|
||||||
+
|
+ return isReducedResolutionInternal();
|
||||||
+ mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, newSize.x, newSize.y);
|
+ } catch (RemoteException e) {
|
||||||
+ } else {
|
+ throw e.rethrowFromSystemServer();
|
||||||
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
|
|
||||||
+ }
|
+ }
|
||||||
+ return isReducedResolutionInternal();
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
boolean isDeviceIdleModeInternal() {
|
boolean isDeviceIdleModeInternal() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return mDeviceIdleMode;
|
return mDeviceIdleMode;
|
||||||
@@ -3833,6 +3879,28 @@ public final class PowerManagerService extends SystemService
|
@@ -3833,6 +3890,28 @@ public final class PowerManagerService extends SystemService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +204,7 @@ index 55d0809ee4e..c1620ea74f8 100644
|
|||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public boolean isDeviceIdleMode() {
|
public boolean isDeviceIdleMode() {
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
@@ -4214,6 +4282,11 @@ public final class PowerManagerService extends SystemService
|
@@ -4214,6 +4293,11 @@ public final class PowerManagerService extends SystemService
|
||||||
return setLowPowerModeInternal(mode);
|
return setLowPowerModeInternal(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
From c7055d7cb2cf5c72d98742b0f2a09c96cc69e9f5 Mon Sep 17 00:00:00 2001
|
From fcfd534bd46ee9bb96dd6da068671647d500ec4d Mon Sep 17 00:00:00 2001
|
||||||
From: Tad <tad@spotco.us>
|
From: Tad <tad@spotco.us>
|
||||||
Date: Fri, 20 Oct 2017 16:36:00 -0400
|
Date: Sat, 21 Oct 2017 00:38:33 -0400
|
||||||
Subject: [PATCH] Reduced Resolution Feature 1/2
|
Subject: [PATCH] Reduced Resolution Feature 1/2
|
||||||
|
|
||||||
Change-Id: Ia23616825fb70e3abfe9c71508e60c5452dea39d
|
Change-Id: I6209ebf286aab5a4342255fa6defb8331650d1b2
|
||||||
---
|
---
|
||||||
res/values/strings.xml | 3 +++
|
res/values/strings.xml | 3 +++
|
||||||
res/xml/perf_profile_settings.xml | 5 +++++
|
res/xml/perf_profile_settings.xml | 5 +++++
|
||||||
@ -25,7 +25,7 @@ index 21b8b78..1fee482 100644
|
|||||||
<string name="auto_power_save_summary_on">Automatically enable power save mode at %s battery</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>
|
<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
|
diff --git a/res/xml/perf_profile_settings.xml b/res/xml/perf_profile_settings.xml
|
||||||
index 3585cb7..0513137 100644
|
index 3585cb7..870e393 100644
|
||||||
--- a/res/xml/perf_profile_settings.xml
|
--- a/res/xml/perf_profile_settings.xml
|
||||||
+++ b/res/xml/perf_profile_settings.xml
|
+++ b/res/xml/perf_profile_settings.xml
|
||||||
@@ -29,6 +29,11 @@
|
@@ -29,6 +29,11 @@
|
||||||
@ -35,13 +35,13 @@ index 3585cb7..0513137 100644
|
|||||||
+ <SwitchPreference
|
+ <SwitchPreference
|
||||||
+ android:key="reduce_resolution"
|
+ android:key="reduce_resolution"
|
||||||
+ android:title="@string/reduce_resolution_title"
|
+ android:title="@string/reduce_resolution_title"
|
||||||
+ android:summary="@string/reduce_resoution_summary" />
|
+ android:summary="@string/reduce_resolution_summary" />
|
||||||
+
|
+
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="auto_power_save"
|
android:key="auto_power_save"
|
||||||
android:title="@string/auto_power_save_title"
|
android:title="@string/auto_power_save_title"
|
||||||
diff --git a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
diff --git a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
||||||
index ec2138d..80b0b28 100644
|
index ec2138d..2773df3 100644
|
||||||
--- a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
--- a/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
||||||
+++ b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
+++ b/src/org/cyanogenmod/cmparts/power/PerfProfileSettings.java
|
||||||
@@ -56,11 +56,13 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
@@ -56,11 +56,13 @@ public class PerfProfileSettings extends SettingsPreferenceFragment
|
||||||
@ -78,14 +78,14 @@ index ec2138d..80b0b28 100644
|
|||||||
final int level = Integer.parseInt((String) newValue);
|
final int level = Integer.parseInt((String) newValue);
|
||||||
Global.putInt(getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, level);
|
Global.putInt(getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL, level);
|
||||||
updateAutoPowerSaveSummary(level);
|
updateAutoPowerSaveSummary(level);
|
||||||
+ } else if (preference = mReduceResolutionPref) {
|
+ } else if (preference == mReduceResolutionPref) {
|
||||||
+ if (!mPowerManager.setReducedResolution((boolean) newValue)) {
|
+ if (!mPowerManager.setReducedResolution((boolean) newValue)) {
|
||||||
+ // Don't just fail silently, inform the user as well
|
+ // Don't just fail silently, inform the user as well
|
||||||
+ Toast.makeText(getActivity(),
|
+ Toast.makeText(getActivity(),
|
||||||
+ R.string.reduce_resolution_fail_toast, Toast.LENGTH_SHORT).show();
|
+ R.string.reduce_resolution_fail_toast, Toast.LENGTH_SHORT).show();
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ updateReducedResolutionValue();
|
+ updateReduceResolutionValue();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ index ec2138d..80b0b28 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ private void updateReduceResolutionValue() {
|
+ private void updateReduceResolutionValue() {
|
||||||
+ mReduceResolution.setChecked(mPowerManager.isReducedResolution());
|
+ mReduceResolutionPref.setChecked(mPowerManager.isReducedResolution());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
private void updateAutoPowerSaveValue() {
|
private void updateAutoPowerSaveValue() {
|
||||||
|
Loading…
Reference in New Issue
Block a user