Loading res/layout/display_topology_preference.xml +20 −4 Original line number Original line Diff line number Diff line Loading @@ -29,13 +29,29 @@ android:src="@drawable/display_topology_background"/> android:src="@drawable/display_topology_background"/> <FrameLayout <FrameLayout android:id="@+id/display_topology_pane_content" android:id="@+id/display_topology_pane_content" android:clipToOutline="true" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent"/> android:layout_height="match_parent"/> <TextView android:id="@+id/topology_hint" <!-- Give the textview a solid-color background (the same as the pane) in order to make the text clear when a DisplayBlock is drawn under it as part of display_topology_pane_content. If the padding is in the TextView, then the background will fill the padding, which we don't want vertically, as there is a lot of vertical padding. We do need some horizontal padding because otherwise the rounded corners will touch the edge of the text. --> <FrameLayout android:importantForAccessibility="no" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_gravity="top|center_horizontal" android:layout_gravity="top|center_horizontal" android:paddingBottom="10dp" android:paddingVertical="10dp"> android:paddingTop="10dp" /> <TextView android:id="@+id/topology_hint" android:background="@drawable/display_topology_background" android:paddingHorizontal="5dp" android:layout_height="wrap_content" android:layout_width="wrap_content" /> </FrameLayout> </FrameLayout> </FrameLayout> res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -14110,4 +14110,6 @@ <string name="supervision_pin_management_preference_title">Manage PIN</string> <string name="supervision_pin_management_preference_title">Manage PIN</string> <!-- Description for supervision PIN management settings entry, in the case of adding a PIN [CHAR LIMIT=NONE] --> <!-- Description for supervision PIN management settings entry, in the case of adding a PIN [CHAR LIMIT=NONE] --> <string name="supervision_pin_management_preference_summary_add">Add a PIN recovery method</string> <string name="supervision_pin_management_preference_summary_add">Add a PIN recovery method</string> <!-- Title for supervision change PIN setting entry [CHAR LIMIT=60] --> <string name="supervision_change_pin_preference_title">Change PIN</string> </resources> </resources> src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1313,6 +1313,15 @@ public class FingerprintSettings extends SubSettings { } } } } } else if (requestCode == LAUNCH_EXT_PREF_REQUEST) { } else if (requestCode == LAUNCH_EXT_PREF_REQUEST) { if (resultCode == RESULT_TIMEOUT) { Activity activity = getActivity(); if (activity != null) { activity.setResult(resultCode); activity.finish(); return; } } if (!mLaunchedExtPrefKey.isEmpty()) { if (!mLaunchedExtPrefKey.isEmpty()) { final Preference preference = findPreference(mLaunchedExtPrefKey); final Preference preference = findPreference(mLaunchedExtPrefKey); if (preference instanceof PrimarySwitchIntentPreference) { if (preference instanceof PrimarySwitchIntentPreference) { Loading src/com/android/settings/connecteddevice/display/DisplayTopology.kt +25 −33 Original line number Original line Diff line number Diff line Loading @@ -67,10 +67,10 @@ fun Float.atLeast(n: Number): Float = max(this, n.toFloat()) * pane coordinates is necessary when rendering the original topology. Conversion in the other * pane coordinates is necessary when rendering the original topology. Conversion in the other * direction, to display coordinates, is necessary for resolve a drag position to display space. * direction, to display coordinates, is necessary for resolve a drag position to display space. * * * The topology pane coordinates are integral and represent the relative position from the upper- * The topology pane coordinates are physical pixels and represent the relative position from the * left corner of the pane. It uses a scale optimized for showing all displays with minimal or no * upper-left corner of the pane. It uses a scale optimized for showing all displays with minimal * scrolling. The display coordinates are floating point and the origin can be in any position. In * or no scrolling. The display coordinates are floating point and the origin can be in any * practice the origin will be the upper-left coordinate of the primary display. * position. In practice the origin will be the upper-left coordinate of the primary display. * * * @param paneWidth width of the pane in view coordinates * @param paneWidth width of the pane in view coordinates * @param minPaneHeight smallest allowed height of the pane in view coordinates. This will not * @param minPaneHeight smallest allowed height of the pane in view coordinates. This will not Loading @@ -79,14 +79,13 @@ fun Float.atLeast(n: Number): Float = max(this, n.toFloat()) * @param minEdgeLength the smallest length permitted of a display block. This should be set based * @param minEdgeLength the smallest length permitted of a display block. This should be set based * on accessibility requirements, but also accounting for padding that appears * on accessibility requirements, but also accounting for padding that appears * around each button. * around each button. * @param maxBlockRatio the highest allowed ratio of block size to display size. For instance, a * @param maxEdgeLength the longest width or height permitted of a display block. This will limit * value of 0.05 means the block will at most be 1/20 the size of the display * the amount of dragging and scrolling the user will need to do to set the * it represents. This limit may be breached to account for minEdgeLength, * arrangement. * which is considered an a11y requirement. * @param displaysPos the absolute topology coordinates for each display in the topology. * @param displaysPos the absolute topology coordinates for each display in the topology. */ */ class TopologyScale( class TopologyScale( paneWidth: Int, minPaneHeight: Float, minEdgeLength: Float, maxBlockRatio: Float, paneWidth: Int, minPaneHeight: Float, minEdgeLength: Float, maxEdgeLength: Float, displaysPos: Collection<RectF>) { displaysPos: Collection<RectF>) { /** Scale of block sizes to real-world display sizes. Should be less than 1. */ /** Scale of block sizes to real-world display sizes. Should be less than 1. */ val blockRatio: Float val blockRatio: Float Loading @@ -104,40 +103,33 @@ class TopologyScale( val displayBounds = RectF( val displayBounds = RectF( Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE) Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE) var smallestDisplayDim = Float.MAX_VALUE var smallestDisplayDim = Float.MAX_VALUE var biggestDisplayHeight = Float.MIN_VALUE var biggestDisplayDim = Float.MIN_VALUE // displayBounds is the smallest rect encompassing all displays, in display space. // displayBounds is the smallest rect encompassing all displays, in display space. // smallestDisplayDim is the size of the smallest display edge, in display space. // smallestDisplayDim is the size of the smallest display edge, in display space. for (pos in displaysPos) { for (pos in displaysPos) { displayBounds.union(pos) displayBounds.union(pos) smallestDisplayDim = minOf(smallestDisplayDim, pos.height(), pos.width()) smallestDisplayDim = minOf(smallestDisplayDim, pos.height(), pos.width()) biggestDisplayHeight = max(biggestDisplayHeight, pos.height()) biggestDisplayDim = maxOf(biggestDisplayDim, pos.height(), pos.width()) } } // Set height according to the width and the aspect ratio of the display bounds limited by // Initialize blockRatio such that there is 20% padding on left and right sides of the // maxBlockRatio. It prevents blocks from being too large, which would make dragging and // display bounds. // dropping awkward. blockRatio = (paneWidth * 0.6 / displayBounds.width()).toFloat() blockRatio = maxBlockRatio // If the `ratio` is set too high because one of the displays will have an edge .atMost(paneWidth * 0.6 / displayBounds.width()) // greater than maxEdgeLength(px) long, decrease it such that the largest edge is // If the `ratio` is set too low because one of the displays will have an edge less // that long. // than minEdgeLength(dp) long, increase it such that the smallest edge is that .atMost(maxEdgeLength / biggestDisplayDim) // long. // Also do the opposite of the above, this latter step taking precedence for a11y // requirements. .atLeast(minEdgeLength / smallestDisplayDim) .atLeast(minEdgeLength / smallestDisplayDim) // Essentially, we just set the pane height based on the pre-determined pane width and the paneHeight = minPaneHeight // aspect ratio of the display bounds. // A tall pane is likely to result in more scrolling. So we paneHeight = (paneWidth.toFloat() / displayBounds.width() * displayBounds.height()) // We may need to increase it slightly to achieve 20% padding above and below the // display bounds - this is where the 0.6 comes from. .atLeast(displayBounds.height() * blockRatio / 0.6) // It is easy for the aspect ratio to result in an excessively tall pane, since the // width is pre-determined and may be considerably wider than necessary. So we // prevent the height from growing too large here, by limiting vertical padding to // prevent the height from growing too large here, by limiting vertical padding to // the size of the tallest display. This improves results for very tall display // 1.5x of the minEdgeLength on each side. This keeps a comfortable amount of // bounds. // padding without it resulting in too much deadspace. .atMost(blockRatio * (displayBounds.height() + biggestDisplayHeight * 2f)) .atLeast(blockRatio * displayBounds.height() + minEdgeLength * 3f) .atLeast(minPaneHeight) // Set originPaneXY (the location of 0,0 in display space in the pane's coordinate system) // Set originPaneXY (the location of 0,0 in display space in the pane's coordinate system) // such that the display bounds rect is centered in the pane. // such that the display bounds rect is centered in the pane. Loading Loading @@ -414,7 +406,7 @@ class DisplayTopologyPreference(context : Context) val scaling = TopologyScale( val scaling = TopologyScale( mPaneContent.width, minPaneHeight = mTopologyInfo?.scaling?.paneHeight ?: 0f, mPaneContent.width, minPaneHeight = mTopologyInfo?.scaling?.paneHeight ?: 0f, minEdgeLength = DisplayTopology.dpToPx(60f, dpi), minEdgeLength = DisplayTopology.dpToPx(60f, dpi), maxBlockRatio = DisplayTopology.dpToPx(0.12f, dpi), maxEdgeLength = DisplayTopology.dpToPx(256f, dpi), newBounds.map { it.second }.toList()) newBounds.map { it.second }.toList()) mPaneHolder.layoutParams.let { mPaneHolder.layoutParams.let { val newHeight = scaling.paneHeight.toInt() val newHeight = scaling.paneHeight.toInt() Loading src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java +16 −21 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,6 @@ package com.android.settings.fuelgauge; package com.android.settings.fuelgauge; import static com.android.settings.fuelgauge.BatteryOptimizeUtils.MODE_UNRESTRICTED; import android.Manifest; import android.Manifest; import android.content.DialogInterface; import android.content.DialogInterface; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; Loading @@ -26,20 +24,20 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.net.Uri; import android.os.Bundle; import android.os.Bundle; import android.os.PowerManager; import android.os.PowerManager; import android.text.TextUtils; import android.os.PowerWhitelistManager; import android.util.Log; import android.util.Log; import com.android.internal.app.AlertActivity; import com.android.internal.app.AlertActivity; import com.android.internal.app.AlertController; import com.android.internal.app.AlertController; import com.android.settings.R; import com.android.settings.R; import com.android.settings.fuelgauge.BatteryOptimizeHistoricalLogEntry.Action; public class RequestIgnoreBatteryOptimizations extends AlertActivity public class RequestIgnoreBatteryOptimizations extends AlertActivity implements DialogInterface.OnClickListener { implements DialogInterface.OnClickListener { private static final String TAG = "RequestIgnoreBatteryOptimizations"; private static final String TAG = "RequestIgnoreBatteryOptimizations"; private static final boolean DEBUG = false; private static final boolean DEBUG = false; private ApplicationInfo mApplicationInfo; private PowerWhitelistManager mPowerWhitelistManager; private String mPackageName; @Override @Override public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) { Loading @@ -49,6 +47,8 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity android.view.WindowManager.LayoutParams android.view.WindowManager.LayoutParams .SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); .SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); mPowerWhitelistManager = getSystemService(PowerWhitelistManager.class); Uri data = getIntent().getData(); Uri data = getIntent().getData(); if (data == null) { if (data == null) { debugLog( debugLog( Loading @@ -56,18 +56,17 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity finish(); finish(); return; return; } } final String packageName = data.getSchemeSpecificPart(); mPackageName = data.getSchemeSpecificPart(); if (TextUtils.isEmpty(packageName)) { if (mPackageName == null) { debugLog( debugLog( "No data supplied for IGNORE_BATTERY_OPTIMIZATION_SETTINGS in: " + getIntent()); "No data supplied for IGNORE_BATTERY_OPTIMIZATION_SETTINGS in: " + getIntent()); finish(); finish(); return; return; } } // Package in Unrestricted mode already ignoring the battery optimizations. PowerManager power = getSystemService(PowerManager.class); PowerManager power = getSystemService(PowerManager.class); if (power.isIgnoringBatteryOptimizations(packageName)) { if (power.isIgnoringBatteryOptimizations(mPackageName)) { debugLog("Not should prompt, already ignoring optimizations: " + packageName); debugLog("Not should prompt, already ignoring optimizations: " + mPackageName); finish(); finish(); return; return; } } Loading @@ -75,28 +74,29 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity if (getPackageManager() if (getPackageManager() .checkPermission( .checkPermission( Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, packageName) mPackageName) != PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) { debugLog( debugLog( "Requested package " "Requested package " + packageName + mPackageName + " does not hold permission " + " does not hold permission " + Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); finish(); finish(); return; return; } } ApplicationInfo ai; try { try { mApplicationInfo = getPackageManager().getApplicationInfo(packageName, 0); ai = getPackageManager().getApplicationInfo(mPackageName, 0); } catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) { debugLog("Requested package doesn't exist: " + packageName); debugLog("Requested package doesn't exist: " + mPackageName); finish(); finish(); return; return; } } final AlertController.AlertParams p = mAlertParams; final AlertController.AlertParams p = mAlertParams; final CharSequence appLabel = final CharSequence appLabel = mApplicationInfo.loadSafeLabel( ai.loadSafeLabel( getPackageManager(), getPackageManager(), PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.SAFE_LABEL_FLAG_TRIM PackageItemInfo.SAFE_LABEL_FLAG_TRIM Loading @@ -114,12 +114,7 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) { switch (which) { switch (which) { case BUTTON_POSITIVE: case BUTTON_POSITIVE: BatteryOptimizeUtils batteryOptimizeUtils = mPowerWhitelistManager.addToWhitelist(mPackageName); new BatteryOptimizeUtils( getApplicationContext(), mApplicationInfo.uid, mApplicationInfo.packageName); batteryOptimizeUtils.setAppUsageState(MODE_UNRESTRICTED, Action.APPLY); break; break; case BUTTON_NEGATIVE: case BUTTON_NEGATIVE: break; break; Loading Loading
res/layout/display_topology_preference.xml +20 −4 Original line number Original line Diff line number Diff line Loading @@ -29,13 +29,29 @@ android:src="@drawable/display_topology_background"/> android:src="@drawable/display_topology_background"/> <FrameLayout <FrameLayout android:id="@+id/display_topology_pane_content" android:id="@+id/display_topology_pane_content" android:clipToOutline="true" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent"/> android:layout_height="match_parent"/> <TextView android:id="@+id/topology_hint" <!-- Give the textview a solid-color background (the same as the pane) in order to make the text clear when a DisplayBlock is drawn under it as part of display_topology_pane_content. If the padding is in the TextView, then the background will fill the padding, which we don't want vertically, as there is a lot of vertical padding. We do need some horizontal padding because otherwise the rounded corners will touch the edge of the text. --> <FrameLayout android:importantForAccessibility="no" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_gravity="top|center_horizontal" android:layout_gravity="top|center_horizontal" android:paddingBottom="10dp" android:paddingVertical="10dp"> android:paddingTop="10dp" /> <TextView android:id="@+id/topology_hint" android:background="@drawable/display_topology_background" android:paddingHorizontal="5dp" android:layout_height="wrap_content" android:layout_width="wrap_content" /> </FrameLayout> </FrameLayout> </FrameLayout>
res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -14110,4 +14110,6 @@ <string name="supervision_pin_management_preference_title">Manage PIN</string> <string name="supervision_pin_management_preference_title">Manage PIN</string> <!-- Description for supervision PIN management settings entry, in the case of adding a PIN [CHAR LIMIT=NONE] --> <!-- Description for supervision PIN management settings entry, in the case of adding a PIN [CHAR LIMIT=NONE] --> <string name="supervision_pin_management_preference_summary_add">Add a PIN recovery method</string> <string name="supervision_pin_management_preference_summary_add">Add a PIN recovery method</string> <!-- Title for supervision change PIN setting entry [CHAR LIMIT=60] --> <string name="supervision_change_pin_preference_title">Change PIN</string> </resources> </resources>
src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1313,6 +1313,15 @@ public class FingerprintSettings extends SubSettings { } } } } } else if (requestCode == LAUNCH_EXT_PREF_REQUEST) { } else if (requestCode == LAUNCH_EXT_PREF_REQUEST) { if (resultCode == RESULT_TIMEOUT) { Activity activity = getActivity(); if (activity != null) { activity.setResult(resultCode); activity.finish(); return; } } if (!mLaunchedExtPrefKey.isEmpty()) { if (!mLaunchedExtPrefKey.isEmpty()) { final Preference preference = findPreference(mLaunchedExtPrefKey); final Preference preference = findPreference(mLaunchedExtPrefKey); if (preference instanceof PrimarySwitchIntentPreference) { if (preference instanceof PrimarySwitchIntentPreference) { Loading
src/com/android/settings/connecteddevice/display/DisplayTopology.kt +25 −33 Original line number Original line Diff line number Diff line Loading @@ -67,10 +67,10 @@ fun Float.atLeast(n: Number): Float = max(this, n.toFloat()) * pane coordinates is necessary when rendering the original topology. Conversion in the other * pane coordinates is necessary when rendering the original topology. Conversion in the other * direction, to display coordinates, is necessary for resolve a drag position to display space. * direction, to display coordinates, is necessary for resolve a drag position to display space. * * * The topology pane coordinates are integral and represent the relative position from the upper- * The topology pane coordinates are physical pixels and represent the relative position from the * left corner of the pane. It uses a scale optimized for showing all displays with minimal or no * upper-left corner of the pane. It uses a scale optimized for showing all displays with minimal * scrolling. The display coordinates are floating point and the origin can be in any position. In * or no scrolling. The display coordinates are floating point and the origin can be in any * practice the origin will be the upper-left coordinate of the primary display. * position. In practice the origin will be the upper-left coordinate of the primary display. * * * @param paneWidth width of the pane in view coordinates * @param paneWidth width of the pane in view coordinates * @param minPaneHeight smallest allowed height of the pane in view coordinates. This will not * @param minPaneHeight smallest allowed height of the pane in view coordinates. This will not Loading @@ -79,14 +79,13 @@ fun Float.atLeast(n: Number): Float = max(this, n.toFloat()) * @param minEdgeLength the smallest length permitted of a display block. This should be set based * @param minEdgeLength the smallest length permitted of a display block. This should be set based * on accessibility requirements, but also accounting for padding that appears * on accessibility requirements, but also accounting for padding that appears * around each button. * around each button. * @param maxBlockRatio the highest allowed ratio of block size to display size. For instance, a * @param maxEdgeLength the longest width or height permitted of a display block. This will limit * value of 0.05 means the block will at most be 1/20 the size of the display * the amount of dragging and scrolling the user will need to do to set the * it represents. This limit may be breached to account for minEdgeLength, * arrangement. * which is considered an a11y requirement. * @param displaysPos the absolute topology coordinates for each display in the topology. * @param displaysPos the absolute topology coordinates for each display in the topology. */ */ class TopologyScale( class TopologyScale( paneWidth: Int, minPaneHeight: Float, minEdgeLength: Float, maxBlockRatio: Float, paneWidth: Int, minPaneHeight: Float, minEdgeLength: Float, maxEdgeLength: Float, displaysPos: Collection<RectF>) { displaysPos: Collection<RectF>) { /** Scale of block sizes to real-world display sizes. Should be less than 1. */ /** Scale of block sizes to real-world display sizes. Should be less than 1. */ val blockRatio: Float val blockRatio: Float Loading @@ -104,40 +103,33 @@ class TopologyScale( val displayBounds = RectF( val displayBounds = RectF( Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE) Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE) var smallestDisplayDim = Float.MAX_VALUE var smallestDisplayDim = Float.MAX_VALUE var biggestDisplayHeight = Float.MIN_VALUE var biggestDisplayDim = Float.MIN_VALUE // displayBounds is the smallest rect encompassing all displays, in display space. // displayBounds is the smallest rect encompassing all displays, in display space. // smallestDisplayDim is the size of the smallest display edge, in display space. // smallestDisplayDim is the size of the smallest display edge, in display space. for (pos in displaysPos) { for (pos in displaysPos) { displayBounds.union(pos) displayBounds.union(pos) smallestDisplayDim = minOf(smallestDisplayDim, pos.height(), pos.width()) smallestDisplayDim = minOf(smallestDisplayDim, pos.height(), pos.width()) biggestDisplayHeight = max(biggestDisplayHeight, pos.height()) biggestDisplayDim = maxOf(biggestDisplayDim, pos.height(), pos.width()) } } // Set height according to the width and the aspect ratio of the display bounds limited by // Initialize blockRatio such that there is 20% padding on left and right sides of the // maxBlockRatio. It prevents blocks from being too large, which would make dragging and // display bounds. // dropping awkward. blockRatio = (paneWidth * 0.6 / displayBounds.width()).toFloat() blockRatio = maxBlockRatio // If the `ratio` is set too high because one of the displays will have an edge .atMost(paneWidth * 0.6 / displayBounds.width()) // greater than maxEdgeLength(px) long, decrease it such that the largest edge is // If the `ratio` is set too low because one of the displays will have an edge less // that long. // than minEdgeLength(dp) long, increase it such that the smallest edge is that .atMost(maxEdgeLength / biggestDisplayDim) // long. // Also do the opposite of the above, this latter step taking precedence for a11y // requirements. .atLeast(minEdgeLength / smallestDisplayDim) .atLeast(minEdgeLength / smallestDisplayDim) // Essentially, we just set the pane height based on the pre-determined pane width and the paneHeight = minPaneHeight // aspect ratio of the display bounds. // A tall pane is likely to result in more scrolling. So we paneHeight = (paneWidth.toFloat() / displayBounds.width() * displayBounds.height()) // We may need to increase it slightly to achieve 20% padding above and below the // display bounds - this is where the 0.6 comes from. .atLeast(displayBounds.height() * blockRatio / 0.6) // It is easy for the aspect ratio to result in an excessively tall pane, since the // width is pre-determined and may be considerably wider than necessary. So we // prevent the height from growing too large here, by limiting vertical padding to // prevent the height from growing too large here, by limiting vertical padding to // the size of the tallest display. This improves results for very tall display // 1.5x of the minEdgeLength on each side. This keeps a comfortable amount of // bounds. // padding without it resulting in too much deadspace. .atMost(blockRatio * (displayBounds.height() + biggestDisplayHeight * 2f)) .atLeast(blockRatio * displayBounds.height() + minEdgeLength * 3f) .atLeast(minPaneHeight) // Set originPaneXY (the location of 0,0 in display space in the pane's coordinate system) // Set originPaneXY (the location of 0,0 in display space in the pane's coordinate system) // such that the display bounds rect is centered in the pane. // such that the display bounds rect is centered in the pane. Loading Loading @@ -414,7 +406,7 @@ class DisplayTopologyPreference(context : Context) val scaling = TopologyScale( val scaling = TopologyScale( mPaneContent.width, minPaneHeight = mTopologyInfo?.scaling?.paneHeight ?: 0f, mPaneContent.width, minPaneHeight = mTopologyInfo?.scaling?.paneHeight ?: 0f, minEdgeLength = DisplayTopology.dpToPx(60f, dpi), minEdgeLength = DisplayTopology.dpToPx(60f, dpi), maxBlockRatio = DisplayTopology.dpToPx(0.12f, dpi), maxEdgeLength = DisplayTopology.dpToPx(256f, dpi), newBounds.map { it.second }.toList()) newBounds.map { it.second }.toList()) mPaneHolder.layoutParams.let { mPaneHolder.layoutParams.let { val newHeight = scaling.paneHeight.toInt() val newHeight = scaling.paneHeight.toInt() Loading
src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java +16 −21 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,6 @@ package com.android.settings.fuelgauge; package com.android.settings.fuelgauge; import static com.android.settings.fuelgauge.BatteryOptimizeUtils.MODE_UNRESTRICTED; import android.Manifest; import android.Manifest; import android.content.DialogInterface; import android.content.DialogInterface; import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo; Loading @@ -26,20 +24,20 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.net.Uri; import android.os.Bundle; import android.os.Bundle; import android.os.PowerManager; import android.os.PowerManager; import android.text.TextUtils; import android.os.PowerWhitelistManager; import android.util.Log; import android.util.Log; import com.android.internal.app.AlertActivity; import com.android.internal.app.AlertActivity; import com.android.internal.app.AlertController; import com.android.internal.app.AlertController; import com.android.settings.R; import com.android.settings.R; import com.android.settings.fuelgauge.BatteryOptimizeHistoricalLogEntry.Action; public class RequestIgnoreBatteryOptimizations extends AlertActivity public class RequestIgnoreBatteryOptimizations extends AlertActivity implements DialogInterface.OnClickListener { implements DialogInterface.OnClickListener { private static final String TAG = "RequestIgnoreBatteryOptimizations"; private static final String TAG = "RequestIgnoreBatteryOptimizations"; private static final boolean DEBUG = false; private static final boolean DEBUG = false; private ApplicationInfo mApplicationInfo; private PowerWhitelistManager mPowerWhitelistManager; private String mPackageName; @Override @Override public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) { Loading @@ -49,6 +47,8 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity android.view.WindowManager.LayoutParams android.view.WindowManager.LayoutParams .SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); .SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); mPowerWhitelistManager = getSystemService(PowerWhitelistManager.class); Uri data = getIntent().getData(); Uri data = getIntent().getData(); if (data == null) { if (data == null) { debugLog( debugLog( Loading @@ -56,18 +56,17 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity finish(); finish(); return; return; } } final String packageName = data.getSchemeSpecificPart(); mPackageName = data.getSchemeSpecificPart(); if (TextUtils.isEmpty(packageName)) { if (mPackageName == null) { debugLog( debugLog( "No data supplied for IGNORE_BATTERY_OPTIMIZATION_SETTINGS in: " + getIntent()); "No data supplied for IGNORE_BATTERY_OPTIMIZATION_SETTINGS in: " + getIntent()); finish(); finish(); return; return; } } // Package in Unrestricted mode already ignoring the battery optimizations. PowerManager power = getSystemService(PowerManager.class); PowerManager power = getSystemService(PowerManager.class); if (power.isIgnoringBatteryOptimizations(packageName)) { if (power.isIgnoringBatteryOptimizations(mPackageName)) { debugLog("Not should prompt, already ignoring optimizations: " + packageName); debugLog("Not should prompt, already ignoring optimizations: " + mPackageName); finish(); finish(); return; return; } } Loading @@ -75,28 +74,29 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity if (getPackageManager() if (getPackageManager() .checkPermission( .checkPermission( Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, packageName) mPackageName) != PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) { debugLog( debugLog( "Requested package " "Requested package " + packageName + mPackageName + " does not hold permission " + " does not hold permission " + Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); finish(); finish(); return; return; } } ApplicationInfo ai; try { try { mApplicationInfo = getPackageManager().getApplicationInfo(packageName, 0); ai = getPackageManager().getApplicationInfo(mPackageName, 0); } catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) { debugLog("Requested package doesn't exist: " + packageName); debugLog("Requested package doesn't exist: " + mPackageName); finish(); finish(); return; return; } } final AlertController.AlertParams p = mAlertParams; final AlertController.AlertParams p = mAlertParams; final CharSequence appLabel = final CharSequence appLabel = mApplicationInfo.loadSafeLabel( ai.loadSafeLabel( getPackageManager(), getPackageManager(), PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, PackageItemInfo.SAFE_LABEL_FLAG_TRIM PackageItemInfo.SAFE_LABEL_FLAG_TRIM Loading @@ -114,12 +114,7 @@ public class RequestIgnoreBatteryOptimizations extends AlertActivity public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) { switch (which) { switch (which) { case BUTTON_POSITIVE: case BUTTON_POSITIVE: BatteryOptimizeUtils batteryOptimizeUtils = mPowerWhitelistManager.addToWhitelist(mPackageName); new BatteryOptimizeUtils( getApplicationContext(), mApplicationInfo.uid, mApplicationInfo.packageName); batteryOptimizeUtils.setAppUsageState(MODE_UNRESTRICTED, Action.APPLY); break; break; case BUTTON_NEGATIVE: case BUTTON_NEGATIVE: break; break; Loading