diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-08-03 14:01:57 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-08-03 17:27:29 -0700 |
commit | dde331cebd87982faded6818ad5f9927ff994c96 (patch) | |
tree | c2f9c4c62113fc93948d3988fc09cc3727c4b9ca /cmds/am | |
parent | 5345c310af8363948cee6a91d11add3ec51e8a9c (diff) | |
download | frameworks_base-dde331cebd87982faded6818ad5f9927ff994c96.zip frameworks_base-dde331cebd87982faded6818ad5f9927ff994c96.tar.gz frameworks_base-dde331cebd87982faded6818ad5f9927ff994c96.tar.bz2 |
We can now (kind-of) change screen density on the fly.
Preloaded drawables now have a density associated with them, so we
can load the correct drawable if we are using a different density.
Window manager now formally keeps track of the density for each
screen, allowing it to be overridden like you can already do with
size, and relies on this density to drive itself internally and
the configurations it reports.
There are a new set of Bitmap constructors where you provide a
DisplayMetrics so they can be constructed with the correct density.
(This will be for when you can have different windows in the same
app running at different densities.)
ActivityThread now watches for density changes, and pushes them
to the DENSITY_DEVICE and Bitmap global density values for that
process.
A new am command allows you to change the density.
Diffstat (limited to 'cmds/am')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index f42fd2a..a79eb14 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -133,6 +133,8 @@ public class Am { runScreenCompat(); } else if (op.equals("display-size")) { runDisplaySize(); + } else if (op.equals("display-density")) { + runDisplayDensity(); } else if (op.equals("to-uri")) { runToUri(false); } else if (op.equals("to-intent-uri")) { @@ -1127,6 +1129,44 @@ public class Am { } } + private void runDisplayDensity() throws Exception { + String densityStr = nextArgRequired(); + int density; + if ("reset".equals(densityStr)) { + density = -1; + } else { + try { + density = Integer.parseInt(densityStr); + } catch (NumberFormatException e) { + System.err.println("Error: bad number " + e); + showUsage(); + return; + } + if (density < 72) { + System.err.println("Error: density must be >= 72"); + showUsage(); + return; + } + } + + IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.checkService( + Context.WINDOW_SERVICE)); + if (wm == null) { + System.err.println(NO_SYSTEM_ERROR_CODE); + throw new AndroidException("Can't connect to window manager; is the system running?"); + } + + try { + if (density > 0) { + // TODO(multidisplay): For now Configuration only applies to main screen. + wm.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, density); + } else { + wm.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY); + } + } catch (RemoteException e) { + } + } + private void runToUri(boolean intentScheme) throws Exception { Intent intent = makeIntent(); System.out.println(intent.toUri(intentScheme ? Intent.URI_INTENT_SCHEME : 0)); @@ -1301,6 +1341,7 @@ public class Am { " am monitor [--gdb <port>]\n" + " am screen-compat [on|off] <PACKAGE>\n" + " am display-size [reset|MxN]\n" + + " am display-density [reset|DENSITY]\n" + " am to-uri [INTENT]\n" + " am to-intent-uri [INTENT]\n" + "\n" + @@ -1355,6 +1396,8 @@ public class Am { "\n" + "am display-size: override display size.\n" + "\n" + + "am display-density: override display density.\n" + + "\n" + "am to-uri: print the given Intent specification as a URI.\n" + "\n" + "am to-intent-uri: print the given Intent specification as an intent: URI.\n" + |