summaryrefslogtreecommitdiff
authorTellen Yu <tellen.yu@amlogic.com>2016-01-18 07:33:39 (GMT)
committer Gerrit Code Review <gituser@scgit.amlogic.com>2016-01-18 07:33:39 (GMT)
commitfed0bf6faab2ca608d317b1818cb7fce4e1f628f (patch)
tree234622536552b22a7f129b69a49a3aca50cd8575
parentd5306e82f3d487eae9873c8b1fafa7928bed8e3b (diff)
parent2dbfd6b6c424908f115cf0efcb080e83562ba924 (diff)
downloadOTAUpgrade2-fed0bf6faab2ca608d317b1818cb7fce4e1f628f.zip
OTAUpgrade2-fed0bf6faab2ca608d317b1818cb7fce4e1f628f.tar.gz
OTAUpgrade2-fed0bf6faab2ca608d317b1818cb7fce4e1f628f.tar.bz2
Merge "pd#117513 fix bug of backup file directory" into m-amlogic
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;