2017-10-21 09:10:23 -04:00
|
|
|
From 661b40435f4b761e0a24687653b10b519d43eaa7 Mon Sep 17 00:00:00 2001
|
2017-10-20 15:31:04 -04:00
|
|
|
From: Tad <tad@spotco.us>
|
2017-10-21 09:10:23 -04:00
|
|
|
Date: Sat, 21 Oct 2017 09:09:48 -0400
|
2017-10-20 15:31:04 -04:00
|
|
|
Subject: [PATCH] Reduced Resolution Feature 2/2
|
|
|
|
|
2017-10-21 09:10:23 -04:00
|
|
|
Change-Id: I9111d55f0127151ee3a7530aa071e7e3298a4cc9
|
2017-10-20 15:31:04 -04:00
|
|
|
---
|
2017-10-20 19:57:01 -04:00
|
|
|
core/java/android/os/IPowerManager.aidl | 3 +
|
2017-10-21 00:39:22 -04:00
|
|
|
core/java/android/os/PowerManager.java | 32 +++++++++
|
|
|
|
core/java/android/os/PowerManagerInternal.java | 2 +
|
|
|
|
.../android/server/power/PowerManagerService.java | 84 ++++++++++++++++++++++
|
|
|
|
4 files changed, 121 insertions(+)
|
2017-10-20 15:31:04 -04:00
|
|
|
|
2017-10-20 16:54:46 -04:00
|
|
|
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
|
2017-10-20 19:57:01 -04:00
|
|
|
index 26eb7f169a0..d6051d0db74 100644
|
2017-10-20 16:54:46 -04:00
|
|
|
--- a/core/java/android/os/IPowerManager.aidl
|
|
|
|
+++ b/core/java/android/os/IPowerManager.aidl
|
2017-10-20 19:57:01 -04:00
|
|
|
@@ -75,4 +75,7 @@ interface IPowerManager
|
|
|
|
void setKeyboardLight(boolean on, int key);
|
|
|
|
|
|
|
|
void wakeUpWithProximityCheck(long time, String reason, String opPackageName);
|
|
|
|
+
|
2017-10-20 19:00:24 -04:00
|
|
|
+ boolean isReducedResolution();
|
|
|
|
+ boolean setReducedResolution(boolean mode);
|
2017-10-20 19:57:01 -04:00
|
|
|
}
|
2017-10-20 15:31:04 -04:00
|
|
|
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
|
2017-10-20 19:57:01 -04:00
|
|
|
index 5c8effec0ed..8c1d2fdf65b 100644
|
2017-10-20 15:31:04 -04:00
|
|
|
--- a/core/java/android/os/PowerManager.java
|
|
|
|
+++ b/core/java/android/os/PowerManager.java
|
2017-10-20 19:57:01 -04:00
|
|
|
@@ -988,6 +988,38 @@ public final class PowerManager {
|
2017-10-20 16:54:46 -04:00
|
|
|
}
|
|
|
|
}
|
2017-10-20 15:31:04 -04:00
|
|
|
|
2017-10-20 19:00:24 -04:00
|
|
|
+ /**
|
|
|
|
+ * Returns true if the WindowManager is running at a reduced resolution
|
|
|
|
+ *
|
|
|
|
+ * @return Returns true if WindowManager is set to a reduced resolution, else false.
|
2017-10-20 19:57:01 -04:00
|
|
|
+ *
|
|
|
|
+ * @hide
|
2017-10-20 19:00:24 -04:00
|
|
|
+ */
|
2017-10-20 16:54:46 -04:00
|
|
|
+ public boolean isReducedResolution() {
|
|
|
|
+ try {
|
|
|
|
+ return mService.isReducedResolution();
|
|
|
|
+ } catch (RemoteException e) {
|
|
|
|
+ throw e.rethrowFromSystemServer();
|
|
|
|
+ }
|
|
|
|
+ }
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-20 19:00:24 -04:00
|
|
|
+ /**
|
|
|
|
+ * Set the reduced resolution mode
|
|
|
|
+ *
|
|
|
|
+ * @return True if the set was allowed.
|
|
|
|
+ *
|
|
|
|
+ * @see #isReducedResolution()
|
|
|
|
+ *
|
|
|
|
+ * @hide
|
|
|
|
+ */
|
2017-10-20 16:54:46 -04:00
|
|
|
+ public boolean setReducedResolution(boolean mode) {
|
|
|
|
+ try {
|
|
|
|
+ return mService.setReducedResolution(mode);
|
|
|
|
+ } catch (RemoteException e) {
|
|
|
|
+ throw e.rethrowFromSystemServer();
|
|
|
|
+ }
|
|
|
|
+ }
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-20 16:54:46 -04:00
|
|
|
/**
|
|
|
|
* 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
|
2017-10-21 00:39:22 -04:00
|
|
|
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);
|
2017-10-20 16:54:46 -04:00
|
|
|
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
|
2017-10-21 09:10:23 -04:00
|
|
|
index 55d0809ee4e..24f9425898f 100644
|
2017-10-20 16:54:46 -04:00
|
|
|
--- 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;
|
2017-10-20 19:57:01 -04:00
|
|
|
@@ -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;
|
2017-10-20 16:54:46 -04:00
|
|
|
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;
|
2017-10-20 19:57:01 -04:00
|
|
|
@@ -203,6 +206,7 @@ public final class PowerManagerService extends SystemService
|
2017-10-20 16:54:46 -04:00
|
|
|
private final Context mContext;
|
|
|
|
private final ServiceThread mHandlerThread;
|
|
|
|
private final PowerManagerHandler mHandler;
|
2017-10-21 09:10:23 -04:00
|
|
|
+ private IWindowManager mWm;
|
2017-10-20 16:54:46 -04:00
|
|
|
|
|
|
|
private LightsManager mLightsManager;
|
|
|
|
private BatteryManagerInternal mBatteryManagerInternal;
|
2017-10-21 00:39:22 -04:00
|
|
|
@@ -2658,6 +2662,59 @@ public final class PowerManagerService extends SystemService
|
2017-10-20 15:31:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-20 16:54:46 -04:00
|
|
|
+ private boolean isReducedResolutionInternal() {
|
|
|
|
+ synchronized (mLock) {
|
2017-10-21 00:39:22 -04:00
|
|
|
+ try {
|
|
|
|
+ Point initialSize = new Point();
|
|
|
|
+ Point baseSize = new Point();
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-21 00:39:22 -04:00
|
|
|
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
|
|
|
|
+ Context.WINDOW_SERVICE));
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-21 00:39:22 -04:00
|
|
|
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
|
|
|
+ mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
|
|
|
|
+
|
|
|
|
+ return !initialSize.equals(baseSize);
|
|
|
|
+ } catch (RemoteException e) {
|
|
|
|
+ throw e.rethrowFromSystemServer();
|
|
|
|
+ }
|
2017-10-20 15:31:04 -04:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2017-10-20 19:57:01 -04:00
|
|
|
+ private boolean setReducedResolutionInternal(boolean mode) {
|
2017-10-20 16:54:46 -04:00
|
|
|
+ synchronized (mLock) {
|
2017-10-21 00:39:22 -04:00
|
|
|
+ try {
|
|
|
|
+ mWm = IWindowManager.Stub.asInterface(ServiceManager.checkService(
|
|
|
|
+ Context.WINDOW_SERVICE));
|
|
|
|
+ if (mode) {
|
|
|
|
+ Point initialSize = new Point();
|
|
|
|
+ mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
|
|
|
|
+
|
|
|
|
+ Point newSize;
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-21 00:39:22 -04:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2017-10-20 15:31:04 -04:00
|
|
|
+
|
2017-10-21 00:39:22 -04:00
|
|
|
+ mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, newSize.x, newSize.y);
|
2017-10-20 19:00:24 -04:00
|
|
|
+ } else {
|
2017-10-21 00:39:22 -04:00
|
|
|
+ mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
|
2017-10-20 15:31:04 -04:00
|
|
|
+ }
|
2017-10-21 00:39:22 -04:00
|
|
|
+ return isReducedResolutionInternal();
|
|
|
|
+ } catch (RemoteException e) {
|
|
|
|
+ throw e.rethrowFromSystemServer();
|
2017-10-20 15:31:04 -04:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2017-10-20 16:54:46 -04:00
|
|
|
boolean isDeviceIdleModeInternal() {
|
|
|
|
synchronized (mLock) {
|
|
|
|
return mDeviceIdleMode;
|
2017-10-21 00:39:22 -04:00
|
|
|
@@ -3833,6 +3890,28 @@ public final class PowerManagerService extends SystemService
|
2017-10-20 16:54:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ @Override // Binder call
|
2017-10-20 19:57:01 -04:00
|
|
|
+ public boolean isReducedResolution() {
|
2017-10-20 16:54:46 -04:00
|
|
|
+ final long ident = Binder.clearCallingIdentity();
|
|
|
|
+ try {
|
|
|
|
+ return isReducedResolutionInternal();
|
|
|
|
+ } finally {
|
|
|
|
+ Binder.restoreCallingIdentity(ident);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override // Binder call
|
2017-10-20 19:57:01 -04:00
|
|
|
+ public boolean setReducedResolution(boolean mode) {
|
2017-10-20 16:54:46 -04:00
|
|
|
+ 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();
|
2017-10-21 00:39:22 -04:00
|
|
|
@@ -4214,6 +4293,11 @@ public final class PowerManagerService extends SystemService
|
2017-10-20 16:54:46 -04:00
|
|
|
return setLowPowerModeInternal(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean setReducedResolution(boolean mode) {
|
|
|
|
+ return setReducedResolutionInternal(mode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public int getFeature(int featureId) {
|
|
|
|
return nativeGetFeature(featureId);
|
2017-10-20 15:31:04 -04:00
|
|
|
--
|
|
|
|
2.14.2
|
|
|
|
|