diff options
author | Michael Jurka <mikejurka@google.com> | 2012-11-19 14:05:05 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2012-11-19 15:21:11 -0800 |
commit | 0a457bfbd9ca6562e8fcd604bcdfeb22f1fb4ded (patch) | |
tree | 7f096a45a316caab9a84b84d3894eb1af41e8afe /src/com/android/launcher2 | |
parent | ffc2682a9784e03d7cc9943f4f408255f8468b96 (diff) | |
download | android_packages_apps_Trebuchet-0a457bfbd9ca6562e8fcd604bcdfeb22f1fb4ded.tar.gz android_packages_apps_Trebuchet-0a457bfbd9ca6562e8fcd604bcdfeb22f1fb4ded.tar.bz2 android_packages_apps_Trebuchet-0a457bfbd9ca6562e8fcd604bcdfeb22f1fb4ded.zip |
Fix StrictMode violation
Switching how we set a property to tell launcher
to force rotation to be enabled, or to dump state.
Bug: 7538629
Change-Id: I8cb55f1a28ba59fe5d410562c66bc86eb9efabfe
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index f0077a6af..002b52045 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -101,7 +101,6 @@ import com.android.launcher2.DropTarget.DragObject; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileDescriptor; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; @@ -148,8 +147,10 @@ public final class Launcher extends Activity static final int DEFAULT_SCREEN = 2; private static final String PREFERENCES = "launcher.preferences"; - static final String FORCE_ENABLE_ROTATION_PROPERTY = "debug.force_enable_rotation"; - static final String DUMP_STATE_PROPERTY = "debug.dumpstate"; + // To turn on these properties, type + // adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS] + static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher_force_rotate"; + static final String DUMP_STATE_PROPERTY = "launcher_dump_state"; // The Intent extra that defines whether to ignore the launch animation static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION = @@ -319,6 +320,8 @@ public final class Launcher extends Activity private static ArrayList<PendingAddArguments> sPendingAddList = new ArrayList<PendingAddArguments>(); + private static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY); + private static class PendingAddArguments { int requestCode; Intent intent; @@ -328,18 +331,8 @@ public final class Launcher extends Activity int cellY; } - - private boolean doesFileExist(String filename) { - FileInputStream fis = null; - try { - fis = openFileInput(filename); - fis.close(); - return true; - } catch (java.io.FileNotFoundException e) { - return false; - } catch (java.io.IOException e) { - return true; - } + private static boolean isPropertyEnabled(String propertyName) { + return Log.isLoggable(propertyName, Log.VERBOSE); } @Override @@ -1883,7 +1876,7 @@ public final class Launcher extends Activity case KeyEvent.KEYCODE_HOME: return true; case KeyEvent.KEYCODE_VOLUME_DOWN: - if (doesFileExist(DUMP_STATE_PROPERTY)) { + if (isPropertyEnabled(DUMP_STATE_PROPERTY)) { dumpState(); return true; } @@ -3682,8 +3675,7 @@ public final class Launcher extends Activity } public boolean isRotationEnabled() { - boolean forceEnableRotation = doesFileExist(FORCE_ENABLE_ROTATION_PROPERTY); - boolean enableRotation = forceEnableRotation || + boolean enableRotation = sForceEnableRotation || getResources().getBoolean(R.bool.allow_rotation); return enableRotation; } |