am 0a457bfb: Fix StrictMode violation

* commit '0a457bfbd9ca6562e8fcd604bcdfeb22f1fb4ded':
  Fix StrictMode violation
This commit is contained in:
Michael Jurka
2012-11-19 15:25:30 -08:00
committed by Android Git Automerger
+10 -18
View File
@@ -101,7 +101,6 @@ import com.android.launcher2.DropTarget.DragObject;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -148,8 +147,10 @@ public final class Launcher extends Activity
static final int DEFAULT_SCREEN = 2; static final int DEFAULT_SCREEN = 2;
private static final String PREFERENCES = "launcher.preferences"; private static final String PREFERENCES = "launcher.preferences";
static final String FORCE_ENABLE_ROTATION_PROPERTY = "debug.force_enable_rotation"; // To turn on these properties, type
static final String DUMP_STATE_PROPERTY = "debug.dumpstate"; // 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 // The Intent extra that defines whether to ignore the launch animation
static final String INTENT_EXTRA_IGNORE_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 private static ArrayList<PendingAddArguments> sPendingAddList
= new ArrayList<PendingAddArguments>(); = new ArrayList<PendingAddArguments>();
private static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY);
private static class PendingAddArguments { private static class PendingAddArguments {
int requestCode; int requestCode;
Intent intent; Intent intent;
@@ -328,18 +331,8 @@ public final class Launcher extends Activity
int cellY; int cellY;
} }
private static boolean isPropertyEnabled(String propertyName) {
private boolean doesFileExist(String filename) { return Log.isLoggable(propertyName, Log.VERBOSE);
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;
}
} }
@Override @Override
@@ -1883,7 +1876,7 @@ public final class Launcher extends Activity
case KeyEvent.KEYCODE_HOME: case KeyEvent.KEYCODE_HOME:
return true; return true;
case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_DOWN:
if (doesFileExist(DUMP_STATE_PROPERTY)) { if (isPropertyEnabled(DUMP_STATE_PROPERTY)) {
dumpState(); dumpState();
return true; return true;
} }
@@ -3682,8 +3675,7 @@ public final class Launcher extends Activity
} }
public boolean isRotationEnabled() { public boolean isRotationEnabled() {
boolean forceEnableRotation = doesFileExist(FORCE_ENABLE_ROTATION_PROPERTY); boolean enableRotation = sForceEnableRotation ||
boolean enableRotation = forceEnableRotation ||
getResources().getBoolean(R.bool.allow_rotation); getResources().getBoolean(R.bool.allow_rotation);
return enableRotation; return enableRotation;
} }