mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-25 15:39:26 -05:00
Overhaul last commit
This commit is contained in:
parent
b3108b9e7f
commit
0a238fd21e
@ -1,16 +0,0 @@
|
|||||||
//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
|
|
@ -1,42 +1,98 @@
|
|||||||
From 259267c0ffa34a99aad3af08d58dfd5aa340bd04 Mon Sep 17 00:00:00 2001
|
From 26c93270376c4c786d76ceed0f6ae78f822dbda6 Mon Sep 17 00:00:00 2001
|
||||||
From: Tad <tad@spotco.us>
|
From: Tad <tad@spotco.us>
|
||||||
Date: Fri, 20 Oct 2017 15:29:25 -0400
|
Date: Fri, 20 Oct 2017 16:53:48 -0400
|
||||||
Subject: [PATCH] Reduced Resolution Feature 2/2
|
Subject: [PATCH] Reduced Resolution Feature 2/2
|
||||||
|
|
||||||
Change-Id: Ib3d363e4fc66821ebb5303a974589c0b18c5ef9b
|
Change-Id: I53234c8db2bd522c90c2d8fe734670482c9c8caa
|
||||||
---
|
---
|
||||||
core/java/android/os/PowerManager.java | 46 ++++++++++++++++++++++++++++++++++
|
core/java/android/os/IPowerManager.aidl | 2 +
|
||||||
1 file changed, 46 insertions(+)
|
core/java/android/os/PowerManager.java | 16 +++++
|
||||||
|
.../android/server/power/PowerManagerService.java | 69 ++++++++++++++++++++++
|
||||||
|
3 files changed, 87 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
|
||||||
|
index 26eb7f169a0..86e4175f444 100644
|
||||||
|
--- a/core/java/android/os/IPowerManager.aidl
|
||||||
|
+++ b/core/java/android/os/IPowerManager.aidl
|
||||||
|
@@ -46,6 +46,8 @@ interface IPowerManager
|
||||||
|
boolean isInteractive();
|
||||||
|
boolean isPowerSaveMode();
|
||||||
|
boolean setPowerSaveMode(boolean mode);
|
||||||
|
+ boolean isReducedResolution()
|
||||||
|
+ setReducedResolution(boolean mode)
|
||||||
|
boolean isDeviceIdleMode();
|
||||||
|
boolean isLightDeviceIdleMode();
|
||||||
|
|
||||||
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
|
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
|
||||||
index 5c8effec0ed..62954ddadea 100644
|
index 5c8effec0ed..358fe61c46f 100644
|
||||||
--- a/core/java/android/os/PowerManager.java
|
--- a/core/java/android/os/PowerManager.java
|
||||||
+++ b/core/java/android/os/PowerManager.java
|
+++ b/core/java/android/os/PowerManager.java
|
||||||
@@ -438,6 +438,8 @@ public final class PowerManager {
|
@@ -988,6 +988,22 @@ 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() {
|
+ public boolean isReducedResolution() {
|
||||||
+ try {
|
+ try {
|
||||||
|
+ return mService.isReducedResolution();
|
||||||
|
+ } catch (RemoteException e) {
|
||||||
|
+ throw e.rethrowFromSystemServer();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ 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/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
|
||||||
|
index 55d0809ee4e..7328dfd4dc9 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;
|
||||||
|
@@ -67,6 +68,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 +205,7 @@ public final class PowerManagerService extends SystemService
|
||||||
|
private final Context mContext;
|
||||||
|
private final ServiceThread mHandlerThread;
|
||||||
|
private final PowerManagerHandler mHandler;
|
||||||
|
+ private final IWindowManager mWm;
|
||||||
|
|
||||||
|
private LightsManager mLightsManager;
|
||||||
|
private BatteryManagerInternal mBatteryManagerInternal;
|
||||||
|
@@ -583,6 +586,8 @@ 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 +2663,43 @@ public final class PowerManagerService extends SystemService
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private boolean isReducedResolutionInternal() {
|
||||||
|
+ synchronized (mLock) {
|
||||||
+ Point initialSize = new Point();
|
+ Point initialSize = new Point();
|
||||||
+ Point baseSize = new Point();
|
+ Point baseSize = new Point();
|
||||||
+
|
+
|
||||||
@ -44,13 +100,11 @@ index 5c8effec0ed..62954ddadea 100644
|
|||||||
+ mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
|
+ mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
|
||||||
+
|
+
|
||||||
+ return !initialSize.equals(baseSize);
|
+ return !initialSize.equals(baseSize);
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ throw e.rethrowFromSystemServer();
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean setReducedResolution(boolean mode) {
|
+ private boolean isLowPowerModeInternal(boolean mode) {
|
||||||
+ try {
|
+ synchronized (mLock) {
|
||||||
+ if (mode) {
|
+ if (mode) {
|
||||||
+ Point initialSize = new Point();
|
+ Point initialSize = new Point();
|
||||||
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
||||||
@ -70,15 +124,54 @@ index 5c8effec0ed..62954ddadea 100644
|
|||||||
+ } else {
|
+ } else {
|
||||||
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
|
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
|
||||||
+ }
|
+ }
|
||||||
+ return isReducedResolution();
|
+ return isReducedResolutionInternal();
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ throw e.rethrowFromSystemServer();
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
/**
|
boolean isDeviceIdleModeInternal() {
|
||||||
* Returns true if the device is currently in idle mode. This happens when a device
|
synchronized (mLock) {
|
||||||
* has been sitting unused and unmoving for a sufficiently long period of time, so that
|
return mDeviceIdleMode;
|
||||||
|
@@ -3833,6 +3875,28 @@ public final class PowerManagerService extends SystemService
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ @Override // Binder call
|
||||||
|
+ public boolean isReducedResolutionMode() {
|
||||||
|
+ final long ident = Binder.clearCallingIdentity();
|
||||||
|
+ try {
|
||||||
|
+ return isReducedResolutionInternal();
|
||||||
|
+ } finally {
|
||||||
|
+ Binder.restoreCallingIdentity(ident);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override // Binder call
|
||||||
|
+ public boolean setReducedResolutionode(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 +4278,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
|
2.14.2
|
||||||
|
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
From 4205a403acba83df87feef538bd9495f3f49c951 Mon Sep 17 00:00:00 2001
|
From c7055d7cb2cf5c72d98742b0f2a09c96cc69e9f5 Mon Sep 17 00:00:00 2001
|
||||||
From: Tad <tad@spotco.us>
|
From: Tad <tad@spotco.us>
|
||||||
Date: Fri, 20 Oct 2017 15:28:00 -0400
|
Date: Fri, 20 Oct 2017 16:36:00 -0400
|
||||||
Subject: [PATCH] Reduced Resolution Feature 1/2
|
Subject: [PATCH] Reduced Resolution Feature 1/2
|
||||||
|
|
||||||
Change-Id: Id76c429a7bf806db59726d7d64a4dca267cb36c1
|
Change-Id: Ia23616825fb70e3abfe9c71508e60c5452dea39d
|
||||||
---
|
---
|
||||||
res/values/strings.xml | 2 ++
|
res/values/strings.xml | 3 +++
|
||||||
res/xml/perf_profile_settings.xml | 5 +++++
|
res/xml/perf_profile_settings.xml | 5 +++++
|
||||||
.../cyanogenmod/cmparts/power/PerfProfileSettings.java | 16 ++++++++++++++++
|
.../cyanogenmod/cmparts/power/PerfProfileSettings.java | 16 ++++++++++++++++
|
||||||
3 files changed, 23 insertions(+)
|
3 files changed, 24 insertions(+)
|
||||||
|
|
||||||
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
index a7e31ca..cfaef0b 100644
|
index 21b8b78..1fee482 100644
|
||||||
--- a/res/values/strings.xml
|
--- a/res/values/strings.xml
|
||||||
+++ b/res/values/strings.xml
|
+++ b/res/values/strings.xml
|
||||||
@@ -576,6 +576,8 @@
|
@@ -576,6 +576,9 @@
|
||||||
<string name="power_save_category_title">Battery saving</string>
|
<string name="power_save_category_title">Battery saving</string>
|
||||||
<string name="power_save_title">Extreme power saver</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="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_title">Reduce screen resolution</string>
|
||||||
+ <string name="reduce_resolution_summary">Lowers the screen resolution to save power</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_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_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>
|
||||||
@ -40,7 +41,7 @@ index 3585cb7..0513137 100644
|
|||||||
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..d77c51c 100644
|
index ec2138d..80b0b28 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
|
||||||
@ -81,7 +82,7 @@ index ec2138d..d77c51c 100644
|
|||||||
+ 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.perf_profile_fail_toast, Toast.LENGTH_SHORT).show();
|
+ R.string.reduce_resolution_fail_toast, Toast.LENGTH_SHORT).show();
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ updateReducedResolutionValue();
|
+ updateReducedResolutionValue();
|
||||||
|
Loading…
Reference in New Issue
Block a user