summaryrefslogtreecommitdiff
authorTing Li <ting.li@amlogic.com>2016-01-08 05:26:15 (GMT)
committer Ting Li <ting.li@amlogic.com>2016-01-08 05:26:15 (GMT)
commit2dbfd6b6c424908f115cf0efcb080e83562ba924 (patch)
tree0027b2c282790608290b645434e58d56fb6d73d6
parent36db328ce37abd392b69f6063e92f899c3cd5ae4 (diff)
downloadOTAUpgrade2-2dbfd6b6c424908f115cf0efcb080e83562ba924.zip
OTAUpgrade2-2dbfd6b6c424908f115cf0efcb080e83562ba924.tar.gz
OTAUpgrade2-2dbfd6b6c424908f115cf0efcb080e83562ba924.tar.bz2
pd#117513 fix bug of backup file directory
Change-Id: I6e42d36fe98f78eee4ccbb703235db5a3613f318
Diffstat
-rw-r--r--src/com/droidlogic/otaupgrade/InstallPackage.java2
-rw-r--r--src/com/droidlogic/otaupgrade/PrefUtils.java48
2 files changed, 28 insertions, 22 deletions
diff --git a/src/com/droidlogic/otaupgrade/InstallPackage.java b/src/com/droidlogic/otaupgrade/InstallPackage.java
index 24109ba..ac51c63 100644
--- a/src/com/droidlogic/otaupgrade/InstallPackage.java
+++ b/src/com/droidlogic/otaupgrade/InstallPackage.java
@@ -90,7 +90,7 @@ public class InstallPackage extends LinearLayout implements OtaUpgradeUtils.Prog
new Thread(new Runnable() {
@Override
public void run() {
- PrefUtils.copyBKFile();
+ mPref.copyBKFile();
mUpdateUtils.upgrade(new File(mPackagePath),
InstallPackage.this, mUpdateMode);
}
diff --git a/src/com/droidlogic/otaupgrade/PrefUtils.java b/src/com/droidlogic/otaupgrade/PrefUtils.java
index 7622a46..17d8656 100644
--- a/src/com/droidlogic/otaupgrade/PrefUtils.java
+++ b/src/com/droidlogic/otaupgrade/PrefUtils.java
@@ -214,18 +214,22 @@ public class PrefUtils {
return outPath;
}
-
- void write2File() {
+ private String getCanWritePath(){
ArrayList<File> externalDevs = getExternalStorageList();
- String flagParentPath = null;
+ String filePath = null;
for ( int j = 0; (externalDevs != null) && j < externalDevs.size(); j++ ) {
File dir = externalDevs.get(j);
if ( dir.isDirectory() && dir.canWrite() ) {
- flagParentPath = dir.getAbsolutePath();
- flagParentPath += "/";
+ filePath = dir.getAbsolutePath();
+ filePath += "/";
break;
}
}
+ return filePath;
+ }
+
+ void write2File() {
+ String flagParentPath = getCanWritePath();
if ( flagParentPath == null ) {
return;
}
@@ -264,28 +268,30 @@ public class PrefUtils {
}
}
- public static void copyBKFile() {
+ public void copyBKFile() {
String backupInrFile = "/data/data/com.droidlogic.otaupgrade/BACKUP";
- String backupOutFile = "";
- if ( new File ( backupInrFile ).exists() ) {
- File devDir = new File ( PrefUtils.DEV_PATH );
- File[] devs = devDir.listFiles();
- for ( File dev : devs ) {
- if ( dev.isDirectory() && dev.canWrite() ) {
- backupOutFile = dev.getAbsolutePath();
- backupOutFile += "/BACKUP";
- break;
- }
+ String backupOutFile = getCanWritePath();
+
+ if ( new File ( backupInrFile ).exists() && backupOutFile != null ) {
+ File dev = new File ( backupOutFile );
+ if ( dev == null || !dev.canWrite() ) {
+ return;
}
- if ( !backupOutFile.equals ( "" ) ) {
- try {
- copyFile ( backupInrFile, backupOutFile );
- } catch ( Exception ex ) {
- ex.printStackTrace();
+ if ( dev.isDirectory() && dev.canWrite() && !dev.getName().startsWith(".") ) {
+ backupOutFile = dev.getAbsolutePath();
+ backupOutFile += "/BACKUP";
+ Log.d("OTA","back backupOutFile=null"+backupOutFile);
+ if ( !backupOutFile.equals ( "" ) ) {
+ try {
+ copyFile ( backupInrFile, backupOutFile );
+ } catch ( Exception ex ) {
+ ex.printStackTrace();
+ }
}
}
}
}
+
public static void copyFile ( String fileFromPath, String fileToPath ) throws Exception {
FileInputStream fi = null;