Bug 785032 - SD card issues with new Tegras ("INFO: attempting to create file /mnt/sdcard/writetest ... Push File Failed to Validate!"). r=jmaher DONTBUILD

This commit is contained in:
Clint Talbert 2012-10-10 10:17:50 -04:00
parent 03663446ef
commit 239c54fe3a
6 changed files with 47 additions and 39 deletions

View File

@ -15,11 +15,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".SUTStartupIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED"></action>
</intent-filter>
</receiver>
<service android:name=".service.ASMozStub">
<intent-filter>
<action android:name="com.mozilla.SUTAgentAndroid.service.LISTENER_SERVICE" />

View File

@ -1314,23 +1314,33 @@ private void CancelNotification()
public String GetTestRoot()
{
String sRet = null;
File tmpFile = new java.io.File("/data/local/tests");
if (tmpFile.exists() && tmpFile.isDirectory())
// According to all the docs this should work, but I keep getting an
// exception when I attempt to create the file because I don't have
// permission, although /data/local/tmp is supposed to be world
// writeable/readable
File tmpFile = new java.io.File("/data/local/tmp/tests");
try{
tmpFile.createNewFile();
} catch (IOException e){
Log.i("SUTAgentAndroid", "Caught exception creating file in /data/local/tmp: " + e.getMessage());
}
String state = Environment.getExternalStorageState();
// Ensure sdcard is mounted and NOT read only
if (state.equalsIgnoreCase(Environment.MEDIA_MOUNTED) &&
(Environment.MEDIA_MOUNTED_READ_ONLY.compareTo(state) != 0))
{
return(Environment.getExternalStorageDirectory().getAbsolutePath());
}
if (tmpFile.exists())
{
Log.i("CLINT", "tmpfile exists");
return("/data/local");
}
if (Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED))
{
sRet = Environment.getExternalStorageDirectory().getAbsolutePath();
}
else
{
sRet = GetTmpDir();
}
Log.e("SUTAgentAndroid", "ERROR: Cannot access world writeable test root");
return(sRet);
return(null);
}
public String GetAppRoot(String AppName)

View File

@ -24,7 +24,6 @@ JAVAFILES = \
RunCmdThread.java \
RunDataThread.java \
SUTAgentAndroid.java \
SUTStartupIntentReceiver.java \
WifiConfiguration.java \
R.java \
$(NULL)

View File

@ -109,6 +109,12 @@ public class SUTAgentAndroid extends Activity
String today = "";
String yesterday = "";
// test root can be null (if getTestRoot fails), handle that:
if (testroot == null) {
testroot = "";
}
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
Date dateObj = sdf.parse(datestamp);

View File

@ -1,20 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package com.mozilla.SUTAgentAndroid;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class SUTStartupIntentReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Intent mySUTAgentIntent = new Intent(context, SUTAgentAndroid.class);
mySUTAgentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(mySUTAgentIntent);
}
}

View File

@ -42,6 +42,7 @@ import android.provider.Settings;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import android.os.Environment;
public class WatcherService extends Service
{
@ -489,9 +490,9 @@ public class WatcherService extends Service
if (strProcName.contains(sProcName))
{
bRet = true;
break;
}
}
return (bRet);
}
@ -895,6 +896,8 @@ public class WatcherService extends Service
private class MyTime extends TimerTask
{
int nStrikes = 0;
final int PERIODS_TO_WAIT_FOR_SDCARD = 3;
int nPeriodsWaited = 0;
public MyTime()
{
@ -931,8 +934,23 @@ public class WatcherService extends Service
// Debug.waitForDebugger();
// Ensure the sdcard is mounted before we even attempt to start the agent
// We will wait for the sdcard to mount for PERIODS_TO_WAIT_FOR_SDCARD
// after which time we go ahead and attempt to start the agent.
if (nPeriodsWaited++ < PERIODS_TO_WAIT_FOR_SDCARD) {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.compareTo(state) != 0) {
Log.i("SUTAgentWatcher", "SDcard not mounted, waiting another turn");
return;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
Log.e("SUTAgentWatcher", "SDcard mounted read only not starting agent now, try again in 60s");
return;
}
}
if (bStartSUTAgent && !GetProcessInfo(sProgramName))
{
Log.i("SUTAgentWatcher", "Starting SUTAgent from watcher code");
Intent agentIntent = new Intent();
agentIntent.setPackage(sProgramName);
agentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);