summaryrefslogtreecommitdiff
authorTing Li <ting.li@amlogic.com>2017-06-30 02:16:28 (GMT)
committer Ting Li <ting.li@amlogic.com>2017-06-30 02:16:28 (GMT)
commitcc6208d8399d982b101be601993612b8f756d5b6 (patch)
tree7b25c6bb61df31efa95029c3e97ff9789ab7bc53
parent9d8ef53a131b5bff97ac9150471d4b15443a538d (diff)
downloadOTAUpgrade2-cc6208d8399d982b101be601993612b8f756d5b6.zip
OTAUpgrade2-cc6208d8399d982b101be601993612b8f756d5b6.tar.gz
OTAUpgrade2-cc6208d8399d982b101be601993612b8f756d5b6.tar.bz2
pd#146347 add apache 2.0 style license
Change-Id: Ifb5dafd0923a1a44aebe74494f8d464ae20e0d67
Diffstat
-rw-r--r--AndroidManifest.xml14
-rw-r--r--libs/libotaupdate.jar4206
-rw-r--r--res/drawable/progressbar_horizontal_1.xml15
-rw-r--r--res/layout-hdpi/main_view.xml14
-rw-r--r--res/layout-xhdpi/main_view.xml14
-rw-r--r--res/layout/downloading_process.xml14
-rw-r--r--[-rwxr-xr-x]res/layout/file_list.xml16
-rw-r--r--res/layout/install_ota.xml14
-rw-r--r--[-rwxr-xr-x]res/layout/large_text.xml24
-rw-r--r--res/layout/main_view.xml16
-rw-r--r--res/layout/medium_text.xml16
-rw-r--r--[-rwxr-xr-x]res/layout/mid.xml39
-rw-r--r--[-rwxr-xr-x]res/layout/update_checking.xml16
-rw-r--r--[-rwxr-xr-x]res/layout/update_download.xml15
-rw-r--r--[-rwxr-xr-x]res/menu/main.xml14
-rw-r--r--res/values/color.xml14
-rw-r--r--[-rwxr-xr-x]res/values/config.xml0
-rw-r--r--res/values/dimens.xml2
-rw-r--r--res/values/strings.xml14
-rw-r--r--res/values/styles.xml16
-rw-r--r--src/com/droidlogic/otaupgrade/ABCheckUpService.java17
-rw-r--r--src/com/droidlogic/otaupgrade/BackupActivity.java379
-rw-r--r--src/com/droidlogic/otaupgrade/BadMovedSDcard.java22
-rw-r--r--src/com/droidlogic/otaupgrade/FileSelector.java26
-rw-r--r--src/com/droidlogic/otaupgrade/InstallPackage.java22
-rw-r--r--src/com/droidlogic/otaupgrade/LoaderReceiver.java22
-rw-r--r--src/com/droidlogic/otaupgrade/MainActivity.java31
-rw-r--r--src/com/droidlogic/otaupgrade/PrefUtils.java26
-rw-r--r--src/com/droidlogic/otaupgrade/UpdateActivity.java26
-rw-r--r--src/com/droidlogic/otaupgrade/UpdateEngine.java19
-rw-r--r--src/com/droidlogic/otaupgrade/UpdateEngineCallback.java18
-rw-r--r--src/com/droidlogic/otaupgrade/UpdateService.java26
32 files changed, 912 insertions, 4215 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 02b4f20..92bcbe7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.droidlogic.otaupgrade"
android:versionCode="2"
diff --git a/libs/libotaupdate.jar b/libs/libotaupdate.jar
index a7e1d0a..27bac93 100644
--- a/libs/libotaupdate.jar
+++ b/libs/libotaupdate.jar
@@ -1,9 +1,9 @@
-PK
-
+PK
+
SourceFile
-
+
@@ -48,9 +48,9 @@ fullBackup
saveShared
SourceFile
-
-
-
+
+
+
,
: ̻
@@ -58,8 +58,8 @@ SourceFile
 
-r  )
-
+r  )
+
c
@@ -69,269 +69,26 @@ SourceFile

I

-
-
+
+
-
- * Description:
- *
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-package com.amlogic.update;
-
-import android.app.backup.BackupManager;
-import android.app.backup.IBackupManager;
-import android.content.Context;
-import android.os.Build;
-import android.os.IBinder;
-import android.os.ParcelFileDescriptor;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.Build.VERSION;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-
-import com.amlogic.update.util.PrefUtil;
-import com.amlogic.update.util.UpgradeInfo;
-
-public final class Backup {
- private boolean DEBUG = false || UpgradeInfo.isDebugAble();
- private IBackupConfirmListener mConfirmListener;
- static final String TAG = PrefUtil.TAG;
- static String[] mArgs;
- int mNextArg;
- private IBinder mIBinder;
- private IBackupManager mBackupManager;
- private Context mCxt;
-
- public Backup(Context cxt) {
- mCxt = cxt;
- }
-
- public void setConfirmListener(IBackupConfirmListener confirmlistener) {
- mConfirmListener = confirmlistener;
- }
-
- public void main(String[] args) {
- if (DEBUG)
- Log.d(TAG, "Beginning: " + args[0]);
- mArgs = args;
- try {
- // new Backup().
- run();
- } catch (Exception e) {
- if (DEBUG)
- Log.e(TAG, "Error running backup/restore", e);
- }
- if (DEBUG)
- Log.d(TAG, "Finished.");
- }
-
- String mFileName = null;
-
- public void run() {
- mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService("backup"));
- if (mBackupManager == null) {
- if (DEBUG)
- Log.e(TAG, "Can't obtain Backup Manager binder");
- return;
- }
- mFileName = nextArg();
- int socketFd = 0; // Integer.parseInt(nextArg());
- String arg = nextArg();
- if (arg.equals("backup")) {
- doFullBackup(socketFd);
- } else if (arg.equals("restore")) {
- doFullRestore(socketFd);
- } else {
- if (DEBUG)
- Log.e(TAG, "Invalid operation '" + arg + "'");
- }
- }
-
- private void doFullBackup(int socketFd) {
- ArrayList<String> packages = new ArrayList<String>();
- boolean saveApks = true;
- boolean saveObbs = false;
- boolean saveShared = false;
- boolean doEverything = true;
- boolean allIncludesSystem = true;
- String arg;
- while ((arg = nextArg()) != null) {
- if (arg.startsWith("-")) {
- if ("-apk".equals(arg)) {
- saveApks = true;
- } else if ("-noapk".equals(arg)) {
- saveApks = false;
- } else if ("-obb".equals(arg)) {
- saveObbs = true;
- } else if ("-noobb".equals(arg)) {
- saveObbs = false;
- } else if ("-shared".equals(arg)) {
- saveShared = true;
- } else if ("-noshared".equals(arg)) {
- saveShared = false;
- } else if ("-system".equals(arg)) {
- allIncludesSystem = true;
- } else if ("-nosystem".equals(arg)) {
- allIncludesSystem = false;
- } else if ("-all".equals(arg)) {
- doEverything = true;
- } else {
- Log.w(TAG, "Unknown backup flag " + arg);
- continue;
- }
- } else {
- // Not a flag; treat as a package name
- packages.add(arg);
- }
- }
- if (doEverything && packages.size() > 0) {
- if (DEBUG)
- Log.w(TAG, "-all passed for backup along with specific package names");
- }
- if (!doEverything && !saveShared && packages.size() == 0) {
- if (DEBUG)
- Log.e(TAG, "no backup packages supplied and neither -shared nor -all given");
- return;
- }
- // try {
- ParcelFileDescriptor fd = null;
- try {
- fd = ParcelFileDescriptor.open(new File(mFileName),
- ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE);
- Log.d(TAG, "param: saveApks " + saveApks + "saveObbs " + saveObbs + " saveShared " + saveShared
- + " fd==null" + (fd == null));
- String[] packArray = new String[packages.size()];
- try {
- Method getbuMethod = null;
- Log.d("tt", "android.os.version:" + android.os.Build.VERSION.SDK_INT);
- if (android.os.Build.VERSION.SDK_INT < 21) {
- getbuMethod = getbuMethod = Class.forName("android.app.backup.IBackupManager")
- .getMethod("fullBackup", new Class[] { ParcelFileDescriptor.class, boolean.class,
- boolean.class, boolean.class, boolean.class, boolean.class, String[].class });
- getbuMethod.invoke(mBackupManager, fd, saveApks, saveObbs, saveShared, doEverything,
- allIncludesSystem, (Object) (packages.toArray(packArray)));
- } else {
- getbuMethod = getbuMethod = Class.forName("android.app.backup.IBackupManager")
- .getMethod("fullBackup",
- new Class[] { ParcelFileDescriptor.class, boolean.class, boolean.class,
- boolean.class, boolean.class, boolean.class, boolean.class, boolean.class,
- String[].class });
- getbuMethod.invoke(mBackupManager, fd, saveApks, saveObbs, saveShared, doEverything,
- allIncludesSystem, allIncludesSystem, true, /* compress */
- (Object) (packages.toArray(packArray)));
-
- }
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- /*
- * mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared,
- * doEverything, allIncludesSystem, allIncludesSystem,
- * allIncludesSystem, packages.toArray(packArray));
- */
- } catch (FileNotFoundException e) {
- Log.e(TAG, "file not found ", e);
- } finally {
- if (fd != null) {
- try {
- fd.close();
- } catch (IOException e) {
- }
- }
- if (mConfirmListener != null) {
- mConfirmListener.onBackupComplete();
- }
- }
- /*
- * } catch (RemoteException e) { Log.e(TAG,
- * "Unable to invoke backup manager for backup"); }
- */
- }
-
- private void doFullRestore(int socketFd) {
- // No arguments to restore
- ParcelFileDescriptor fd = null;
- try {
- fd = ParcelFileDescriptor.open(new File(mFileName),
- ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE);
- // ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd);
- mBackupManager.fullRestore(fd);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "file not found ", e);
- } catch (RemoteException e) {
- Log.e(TAG, "Unable to invoke backup manager for restore");
- } finally {
- if (fd != null) {
- try {
- fd.close();
- } catch (IOException e) {
- }
- }
- if (mConfirmListener != null) {
- mConfirmListener.onRestoreComplete();
- }
- }
- }
-
- private String nextArg() {
- if (mNextArg >= mArgs.length) {
- return null;
- }
- String arg = mArgs[mNextArg];
- mNextArg++;
- return arg;
- }
-
- public interface IBackupConfirmListener {
- public void onBackupComplete();
-
- public void onRestoreComplete();
- }
-}
-PK
-
+
SourceFile
-
+
SourceFile
*+
-*
+*
-
-*
+
+3
-
+
@@ -341,20 +98,20 @@ updateSize
deleteSize
SourceFile
*+
-*
+*
-
+
*
-
+
Y
-
+
Y
-
+
-
+
downloader
@@ -402,371 +159,21 @@ Exceptions#
SourceFile
-
-
-
+
+
+
:
-*
+*
-
-*
-*
-*
-
-
- * Description: Main Download Thread, get Download Tasks from db, executing
- * Download ordinal
- *
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- * @time: 2013-2-15
- */
-package com.amlogic.update;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.amlogic.update.util.DownFileDao;
-import com.amlogic.update.util.DownFilesInfo;
-import com.amlogic.update.util.DownloadUtil;
-import com.amlogic.update.util.PrefUtil;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Color;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-import android.view.LayoutInflater;
-
-/**
- * @ClassName DownloadUpdateTask
- * @Description Download Update files from Server
- * @see UpdateTasks
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
-public class DownloadUpdateTask extends UpdateTasks {
- private static final String TAG = PrefUtil.TAG;
- public static final int ERROR_NETWORK_UNAVAIBLE = 1;
- public static final int ERROR_UNKNOWN = 2;
- public static final int ERROR_IOERROR = 3;
- private Notifier notifier;
- private Context mContext;
- private PrefUtil mPrefs;
- private DownFileDao dao;
- private DownFilesInfo curTask = null;
- private DownloadUtil downloader = null;
- private String targetString = "";
- private DownloadSize mDownSize = null;
- private CheckPathCallBack mcheckTaskCallback;
-
- /**
- * Constructs a object of DownloadUpdateTask for Download Update Files
- *
- * @param mContext
- */
- public DownloadUpdateTask(Context mContext) {
- this.mContext = mContext;
- mPrefs = new PrefUtil(mContext);
- mDownSize = new DownloadSize();
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- dao = new DownFileDao(mContext);
- }
-
- public void setErrorCode(int err) {
- mErrorCode = err;
- }
-
- public void setCallbacks(CheckPathCallBack callback) {
- mcheckTaskCallback = callback;
- }
-
- @Override
- protected void onRunning() {
- super.onRunning();
- List<DownFilesInfo> tasks = dao.getDowntasks();
- for (DownFilesInfo t : tasks) {
- t.setLocal(mcheckTaskCallback.onExternalPathSwitch(t.getLocal()));
- }
- boolean errOccur = false;
- if (tasks.size() > 0 && mRunningStatus == RUNNING_STATUS_RUNNING) {
- curTask = tasks.get(0);
- downloader = new DownloadUtil(mDownSize, mContext, this);
- Log.d(TAG, "CurTask:" + curTask.toString());
- do {
- if (mRunningStatus == RUNNING_STATUS_UNSTART) {
- break;
- } else if (mRunningStatus == RUNNING_STATUS_PAUSE) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- if (doDownload(downloader)) {
- tasks.remove(0);
- errOccur = false;
- if (tasks.size() > 0 && mRunningStatus == RUNNING_STATUS_RUNNING) {
- curTask = tasks.get(0);
- downloader = new DownloadUtil(mDownSize, mContext, this);
- }
- } else {
- errOccur = true;
- continue;
- }
- }
- } while (tasks.size() > 0
- && (mRunningStatus == RUNNING_STATUS_RUNNING || mRunningStatus == RUNNING_STATUS_PAUSE));
- }
- if (mRunningStatus == RUNNING_STATUS_RUNNING || mRunningStatus == RUNNING_STATUS_FINISH) {
- if (tasks.size() == 0 && !errOccur) {
- mRunningStatus = RUNNING_STATUS_FINISH;
- mErrorCode = NO_ERROR;
- mResult = new DownloadResult();
- if (notifier != null) {
- notifier.Successnotify();
- }
- } else {
- mRunningStatus = RUNNING_STATUS_FINISH;
- mErrorCode = ERROR_UNKNOWN;
- if (notifier != null) {
- notifier.Failednotify();
- }
- }
- mPrefs.setDownloadPos(0);
- mProgress = 0;
- }
- }
-
- private boolean doDownload(DownloadUtil download) {
- int ret = -1;
- while (mRunningStatus == RUNNING_STATUS_PAUSE) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- try {
- ret = download.Save2File(curTask.url, curTask.local, curTask.name, curTask.md5);
- Log.d(TAG, "ret:" + ret);
- } catch (Exception e) {
- mRunningStatus = RUNNING_STATUS_FINISH;
- e.printStackTrace();
- } finally {
- if (PrefUtil.DEBUG)
- Log.d(TAG, "ret is " + ret + " mRunningStatus" + mRunningStatus);
- if (ret == 0) {
- dao.delFile(curTask.local);
- download.delete(curTask.url);
- return true;
- } else if (ret == -1) {
- /*
- * if(downloader != null && downloader.isdownloading()) {
- * downloader.pause(); }
- */
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return false;
- } else {
- if (downloader != null && downloader.isdownloading()) {
- downloader.pause();
- }
- return false;
- }
- }
- }
-
- /**
- * return path of update file for execute update
- *
- * @return set Notifier object to Download work thread.
- * @param null
- */
- public void setNotify(Notifier notifier) {
- this.notifier = notifier;
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (downloader != null && downloader.isdownloading()) {
- downloader.pause();
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- if (downloader != null) {
- downloader.resume();
- }
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- if (downloader != null && downloader.isdownloading()) {
- downloader.stop();
- }
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- @Override
- public boolean equals(Object o) {
- return super.equals(o);
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public String toString() {
- return super.toString();
- }
-
- public class DownloadSize {
- /*
- * private int length; private int TimeoutException = 0;
- */
-
- void DownloadSize() {
- getSavedSize();
- }
-
- void getSavedSize() {
- mProgress = (int) mPrefs.getDownloadPos();
- }
- /*
- * void saveInitSize() { mPrefs.setDownloadPos(length); }
- */
-
- public void updateSize(int downSize) {
- synchronized (this) {
- mProgress += downSize;
- mPrefs.setDownloadPos(mProgress);
- }
- }
-
- public void deleteSize(long urlTotalSize) {
- synchronized (this) {
- mProgress -= urlTotalSize;
- mPrefs.setDownloadPos(mProgress);
- }
- }
- /*
- * int getDownloadSize() { synchronized (this) { return length; } }
- */
- }
-
- /**
- * @ClassName CheckUpdateResult
- * @Description inner class of CheckUpdateTask to return Check Result by
- * getResult()
- * @see UpdateTasks
- * @see CheckUpdateResult
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
- public class DownloadResult {
- /**
- * return Set of Update Download Files
- *
- * @return Set<String> update Files set
- * @param null
- */
- public Set<String> getFilesList() {
- if (mPrefs != null) {
- return mPrefs.getDownFileSet();
- }
- return null;
- }
-
- }
-
- @Override
- protected void onReset() {
- super.onReset();
- dao.cleardata();
- mPrefs.resetAll();
- }
-
- @Override
- public long getProgress() {
- return mPrefs.getDownloadPos();
- };
-
- /* interface for file path switch */
- public interface CheckPathCallBack {
- public String onExternalPathSwitch(String filePath);
- }
-}
-PK
-
+
+*
+*
+*
+
+

SourceFile
-
-/**
- * @Package
- * @Description
- *
- * Copyright (c) Inspur Group Co., Ltd. Unpublished
- *
- * Inspur Group Co., Ltd.
- * Proprietary & Confidential
- *
- * This source code and the algorithms implemented therein constitute
- * confidential information and may comprise trade secrets of Inspur
- * or its associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which this
- * source code was originally received.
- */
-/**
- * @ClassName Notifier
- * @Description
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
-public interface Notifier{
- public void Successnotify();
- public void Failednotify();
-}PK
-
+
@@ -776,14 +183,14 @@ public interface Notifier{
SourceFile
*+
*
-
+
-
-
-
-
+
+
+
+
-
+
updatename
update.xml
@@ -895,9 +302,9 @@ startsWith
SourceFile
-
-
-
+
+
+

,
+
@@ -908,9 +315,9 @@ SourceFile
N%W*P
-^
-
-
+^
+
+
@@ -920,11 +327,10 @@ SourceFile
ȸW*e
ȸW*e 
-ȸW*e
+ȸW*e

-%W*P*
-
+%W*P*
:6
@@ -940,563 +346,38 @@ SourceFile
*
{
-
-
-?@A+B4CMDTEmMNOPUVWXZ([1]7^R__atcdefghgijk ln o&pAqNt^ulvwx{|}~?&,5:?DENiu
+
+"
+EFG+H4IMJTKmSTUV[\]^`(a1c7dRe_gtijklmnmopq rt u&vAwNz^{l|}~E&25:?DENiu
l



-
-
-
-
-
-
- * @Package com.amlogic.update
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
-package com.amlogic.update;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.amlogic.update.util.DownFileDao;
-import com.amlogic.update.util.DownFilesInfo;
-import com.amlogic.update.util.PrefUtil;
-import com.amlogic.update.util.UpdatePositionStage;
-import com.amlogic.update.util.UpgradeInfo;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Handler;
-import android.util.Log;
-
-/**
- * @ClassName CheckUpdateTask
- * @Description Check for an new Update version, returns the updated information
- * @see UpdateTasks
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
-public class CheckUpdateTask extends UpdateTasks {
- private static boolean DEBUG = true || UpgradeInfo.isDebugAble();
- private static final String TAG = PrefUtil.TAG;
- private static final boolean CHECK_DEBUG = PrefUtil.DEBUG;
- public static final int ERROR_UNDISCOVERY_NEW_VERSION = 1;
- public static final int ERROR_NETWORK_UNAVAIBLE = 2;
- public static final int ERROR_UNKNOWN = 3;
- private Context mContext;
- private PrefUtil mPreferences;
- private UpgradeInfo mUtil;
- private DownFileDao dao;
- private static final int HANDLE_XML_DOWNLOAD_FINISH = 100;
- private static final int HANDLE_XML_DOWNLOAD_FAIL = 101;
- private static final int CHECK_TIMEOUT = 20 * 1000;
- public static String XML_NAME = "ota_update.xml";
- public static String FILE_NAME = "update.xml";
- private static String XmlDir = null;
- private static final String OTA_COMMAND = "update_with_inc_ota";
- private static final String SCRIPT_COMMAND = "update_with_script";
- private Notifier notifier = null;
- private String mCustomData = null;
- private String updatename = null;
- // private CheckPathCallBack mcheckTaskCallback;
- /**
- * Constructs a object of CheckUpdateTask for Check Update Work Thread
- *
- * @param mContext
- */
- public CheckUpdateTask(Context mContext) {
- this.mContext = mContext;
- XmlDir = mContext.getFilesDir().getAbsolutePath();
- mPreferences = new PrefUtil(mContext);
- mUtil = new UpgradeInfo(mContext);
- dao = new DownFileDao(mContext);
- mResult = new CheckUpdateResult();
- }
-
- /*
- * public void setCallbacks(CheckPathCallBack callback){ mcheckTaskCallback
- * = callback; }
- */
- @Override
- protected void onStart() {
- super.onStart();
- }
-
- public void setCustomRequestData(String val) {
- mCustomData = val;
- }
-
- public void setCustomUrl(String url) {
- if (!url.isEmpty()) {
- UpgradeInfo.postUrl = url;
- }
- }
-
- @Override
- protected void onRunning() {
- super.onRunning();
- sendPost();
- }
-
- private void sendPost() {
- if (DEBUG)
- Log.v(TAG, "send post to server");
- HttpPost post = new HttpPost(UpgradeInfo.postUrl);
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new BasicNameValuePair("updating_apk_version", UpgradeInfo.updating_apk_version));
- params.add(new BasicNameValuePair("brand", UpgradeInfo.brand));
- params.add(new BasicNameValuePair("device", UpgradeInfo.device));
- params.add(new BasicNameValuePair("board", UpgradeInfo.board));
- params.add(new BasicNameValuePair("mac", UpgradeInfo.mac));
- params.add(new BasicNameValuePair("firmware", UpgradeInfo.firmware));
- params.add(new BasicNameValuePair("android", UpgradeInfo.android));
- params.add(new BasicNameValuePair("time", UpgradeInfo.time));
- params.add(new BasicNameValuePair("builder", UpgradeInfo.builder));
- params.add(new BasicNameValuePair("fingerprint", UpgradeInfo.fingerprint));
- params.add(new BasicNameValuePair("id", mPreferences.getID() + ""));
- if (mCustomData != null) {
- String[] custom = mCustomData.split("&");
- for (int i = 0; i < custom.length; i++) {
- String[] data = custom[i].split("=");
- params.add(new BasicNameValuePair(data[0], data[1]));
- }
- }
- if (DEBUG)
- Log.d(TAG, params.toString());
- HttpParams httpParameters = new BasicHttpParams();
- HttpConnectionParams.setSoTimeout(httpParameters, CHECK_TIMEOUT);
- HttpClient httpClient = new DefaultHttpClient(httpParameters);
- try {
- post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
- HttpResponse response = httpClient.execute(post);
- if (DEBUG)
- Log.i(TAG, "response status: " + response.getStatusLine().getStatusCode());
- if (response.getStatusLine().getStatusCode() < 400 && response.getStatusLine().getStatusCode() >= 200) {
- HttpEntity entity = response.getEntity();
- String msg = EntityUtils.toString(entity);
- if (DEBUG)
- Log.i(TAG, "get data: " + msg);
- String url[] = msg.split("=");
- Log.i(TAG, "get data: " + url.length + "url:" + url[0]);
- if (url.length == 2 && url[0].equals("url") && url[1].length() > 10) {
- if (DEBUG)
- Log.i(TAG, "xml url:" + url[1]);
- url[1] = url[1].replace(" ", "");
- url[1] = url[1].replace("\r\n", "");
- downloadXML(url[1], XML_NAME);
- } else {
- if (DEBUG)
- Log.i(TAG, "Can'n find new firmware");
- mErrorCode = ERROR_UNDISCOVERY_NEW_VERSION;
- }
- } else {
- mErrorCode = ERROR_UNKNOWN;
- }
- } catch (Exception ex) {
- mErrorCode = ERROR_UNKNOWN;
- if (DEBUG) {
- Log.d(TAG, "download err...." + ex.fillInStackTrace());
- }
- }
- if (DEBUG)
- Log.v(TAG, "finish send post to server");
- }
-
- private void downloadXML(String url, String xmlName) {
- if (DEBUG)
- Log.i(TAG, "start download a xml file:" + xmlName + " url:" + url);
- mPreferences.resetAll();
- if (XmlDir == null)
- return;
- File dir = new File(XmlDir);
- File file = new File(XmlDir + "/" + xmlName);
- if (DEBUG)
- Log.i(TAG, "dir:" + dir.getAbsolutePath() + " exixts:" + dir.exists() + " mkdir:" + dir.mkdirs() + "file:"
- + file.getAbsolutePath());
- if (!dir.exists()) {
- dir.mkdirs();
- }
- if (file.exists()) {
- file.delete();
- }
- FileOutputStream xmlfile = null;
- int filesize = 0;
- int readSize = 0;
- try {
- URL Url = new URL(url);
- HttpURLConnection cn = (HttpURLConnection) Url.openConnection();
- InputStream input = cn.getInputStream();
- filesize = cn.getContentLength();
- if (filesize <= 0 || input == null) {
- mErrorCode = ERROR_UNKNOWN;
- handleDownloadResult(HANDLE_XML_DOWNLOAD_FAIL, null);
- }
- xmlfile = new FileOutputStream(file);
- byte[] buf = new byte[1024];
- int numread;
- while ((numread = input.read(buf)) != -1) {
- xmlfile.write(buf, 0, numread);
- readSize += numread;
- }
- xmlfile.flush();
- cn.disconnect();
- } catch (Exception ex) {
- if (DEBUG) {
- Log.d(TAG, "download err...." + ex.fillInStackTrace());
- }
- } finally {
- try {
- if (xmlfile != null) {
- xmlfile.close();
- xmlfile = null;
- }
- if (filesize == readSize && filesize != 0) {
- handleDownloadResult(HANDLE_XML_DOWNLOAD_FINISH, xmlName);
- } else {
- mErrorCode = ERROR_UNKNOWN;
- handleDownloadResult(HANDLE_XML_DOWNLOAD_FAIL, null);
- }
- } catch (IOException e) {
- mErrorCode = ERROR_UNKNOWN;
- if (PrefUtil.DEBUG)
- Log.d(TAG, "exception", e.fillInStackTrace());
- handleDownloadResult(HANDLE_XML_DOWNLOAD_FAIL, null);
- }
- }
- }
-
- private void handleDownloadResult(int msg, Object obj) {
- switch (msg) {
- case HANDLE_XML_DOWNLOAD_FINISH:
- if (DEBUG)
- Log.i(TAG, "xml " + obj.toString() + " download finish");
- dao.initrecord();
- parserXml(XML_NAME);
- mErrorCode = NO_ERROR;
- break;
- case HANDLE_XML_DOWNLOAD_FAIL:
- if (DEBUG)
- Log.i(TAG, "xml download fail");
- mErrorCode = ERROR_NETWORK_UNAVAIBLE;
- dao.cleardata();
- break;
- }
- }
-
- /* parser xml command file */
- private void parserXml(String xML_NAME2) {
- DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
- DocumentBuilder domBuilder;
- String command = null;
- String storagemem = null;
- String force = null;
- String sdcardask = null;
- String description = null;
- String country = null;
- updatename = null;
- HashMap<String, DownFilesInfo> downlist;
- if (XmlDir == null)
- return;
- try {
- domBuilder = domfac.newDocumentBuilder();
- InputStream in = new FileInputStream(XmlDir + "/" + XML_NAME);
- Document doc = domBuilder.parse(in);
- Element root = doc.getDocumentElement();
- NodeList nodelist_1 = root.getChildNodes();
- dao.cleardata();
- if (nodelist_1 != null) {
- for (int i = 0; i < nodelist_1.getLength(); i++) {
- Node node_1 = nodelist_1.item(i);
- if (node_1.getNodeName().equals("command")) {
- command = node_1.getAttributes().getNamedItem("name").getNodeValue();
- force = node_1.getAttributes().getNamedItem("force").getNodeValue();
- if (!command.equals(OTA_COMMAND) && !command.equals(SCRIPT_COMMAND)) {
- mErrorCode = ERROR_UNDISCOVERY_NEW_VERSION;
- return;
- } else if (command.equals(SCRIPT_COMMAND)) {
- sdcardask = "true";
- } else {
- sdcardask = "false";
- }
- NodeList nodelist_2 = node_1.getChildNodes();
- String isUpdateZip;
- if (nodelist_2 != null) {
- downlist = new HashMap<String, DownFilesInfo>();
- DownFilesInfo fileinfo;
- String fileNodeName = null;
- for (int j = 0; j < nodelist_2.getLength(); j++) {
- Node node_2 = nodelist_2.item(j);
- if (node_2.getNodeName().equals("url")) {
- fileinfo = new DownFilesInfo();
- fileinfo.name = node_2.getAttributes().getNamedItem("name").getNodeValue();
- fileNodeName = fileinfo.name;
- fileinfo.local = node_2.getAttributes().getNamedItem("locattr").getNodeValue();
-
- /*
- * if(mcheckTaskCallback!=null){
- * fileinfo.local =
- * mcheckTaskCallback.onExternalPathSwitch(
- * fileinfo.local); }
- */
- isUpdateZip = node_2.getAttributes().getNamedItem("updatezip").getNodeValue();
- fileinfo.url = node_2.getFirstChild().getNodeValue();
- if (PrefUtil.DEBUG)
- Log.d(TAG, " afileinfo.local" + fileinfo.local + "fileinfo.name");
- /*
- * configure on server local attribute is
- * NULL,useDefault Directory
- */
- if (fileinfo.name.equals(null) || fileinfo.name.equals("")
- || fileinfo.local.equals(null) || fileinfo.local.equals("")) {
- fileinfo.name = PrefUtil.DEFAULT_UPDATE_FILENAME;
- fileinfo.local = XmlDir + "/" + fileinfo.name;
- }
- if (isUpdateZip.equals("true")) {
- updatename = fileinfo.local;
- }
- if (CHECK_DEBUG)
- Log.d(TAG, "fileInfo:" + fileinfo.toString());
- downlist.put(fileinfo.name, fileinfo);
- } /* end parse url */
- if (fileNodeName != null && node_2.getNodeName().equals("md5")) {
- // int listsize = downlist.size();
- fileinfo = downlist.get(fileNodeName);
- Log.d(TAG, "fileInfo md5 fileinfo!=null ?:" + (fileinfo != null));
- if (fileinfo != null) {
- if (DEBUG)
- Log.i(TAG, "get xml md5:" + fileinfo.name + "url :" + fileinfo.url
- + " local:" + fileinfo.local);
- if (!fileinfo.name
- .equals(node_2.getAttributes().getNamedItem("name").getNodeValue())) {
- downlist.remove(fileinfo.name);
- continue;
- }
- fileinfo.md5 = node_2.getFirstChild().getNodeValue();
- if (DEBUG)
- Log.i(TAG, "get xml md5:" + fileinfo.md5);
- downlist.put(fileinfo.name, fileinfo);
- }
- } /* end parse md5 */
- if (node_2.getNodeName().equals("storagemem")) {
- storagemem = node_2.getFirstChild().getNodeValue();
- Log.i(TAG, "get storagemem:" + storagemem);
- if (sdcardask.equals("false")) {
- repDirForBigFile(storagemem, downlist);
- }
- }
- if (node_2.getNodeName().equals("description")) {
- country = node_2.getAttributes().getNamedItem("country").getNodeValue();
- if (description == null) {
- if (country.equals(mUtil.country) || country.equals("ELSE"))
- description = node_2.getFirstChild().getNodeValue();
- }
- }
- }
- if (DEBUG) {
- Log.i(TAG, "get xml description:" + description);
- }
- mPreferences.setDownFileList(downlist);
- dao.saveDowntasks(downlist);
- }
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- mErrorCode = ERROR_UNDISCOVERY_NEW_VERSION;
- return;
- }
- mPreferences.setPackageDescriptor(description);
- Log.i(TAG, "##################" + Long.parseLong(storagemem));
- mPreferences.setDownloadSize(Long.parseLong(storagemem));
- mPreferences.setUpdateFile(updatename);
- if (sdcardask.equals("true")) {
- mPreferences.setUpdateWithScript(true);
- }
- }
- /**replace storage directory when file size is more than 460M**/
- private boolean repDirForBigFile(String fileSize, HashMap map) {
- Long size = Long.valueOf(fileSize);
-
- if (size < UpdatePositionStage.M400ZIE) {
- return false;
- } else {
- Iterator iter = map.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- DownFilesInfo val = (DownFilesInfo) entry.getValue();
- if (val.local.startsWith(XmlDir)) {
- val.local=val.local.replace(XmlDir,UpdatePositionStage.getDefaultPostion());
- updatename = val.local;
- }
- map.put(entry.getKey(), val);
- return true;
- }
- }
- return false;
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- }
-
- public void setNotify(Notifier notifier) {
- this.notifier = notifier;
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- if (notifier != null) {
- if (mErrorCode == NO_ERROR && mPreferences != null) {
- mPreferences.setLastCheckTime(new Date().toString());
- notifier.Successnotify();
- } else {
- notifier.Failednotify();
- }
- }
- }
-
- /**
- * @ClassName CheckUpdateResult
- * @Description inner class of CheckUpdateTask to return Check Result by
- * getResult()
- * @see UpdateTasks
- * @see CheckUpdateResult
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
- public class CheckUpdateResult {
-
- public CheckUpdateResult() {
- }
-
- /**
- * return description information of new version
- *
- * @return new version description
- * @param null
- */
- public String getmUpdateDescript() {
- return mPreferences.getPackageDescriptor();
- }
-
- /**
- * return path of update file for execute update
- *
- * @return path of specified by Online update Server
- * @param null
- */
- public String getmUpdateFileName() {
- return mPreferences.getUpdatFile();
- }
-
- /**
- * @return whether this update is update_with_ota or update_with_script,
- * and return true when update is update_with_script
- * @param null
- */
- public boolean ismIsScriptAsk() {
- return mPreferences.getScriptASK();
- }
-
- /**
- * @return memory needed by all update files
- *
- * @param null
- */
- public long getMemoryAsk() {
- return mPreferences.getDownloadSize();
- }
- }
-
- @Override
- protected void onReset() {
- super.onReset();
-
- };
-
- /* interface for file path switch */
- /*
- * public interface CheckPathCallBack{ public String
- * onExternalPathSwitch(String filePath); }
- */
-}
-PK
-
+
+
+
+
+
+
SourceFile
*+
*
-
+

-
+
-
+
onProgress
SourceFile
-
+
update.zip
UPDATE_OTA
mFocusStop
@@ -1570,12 +451,12 @@ SourceFile
-
-
-
+
+
+
,
-,$
-
+,$
+
6 
  C a7nFj6  
G J
@@ -1583,422 +464,15 @@ SourceFile
:  X [
-
G J
-K
-
-*
+K
+
+*
-*
+*
-
-
-
- * Description:
- *
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-package com.amlogic.update;
-
-import android.content.Context;
-import android.content.BroadcastReceiver;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Build;
-import android.os.Build.VERSION;
-import android.os.BatteryManager;
-import android.os.Environment;
-import android.os.PowerManager;
-import android.os.RecoverySystem;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-import java.util.Locale;
-
-import com.amlogic.update.util.MD5;
-import com.amlogic.update.util.PrefUtil;
-import com.amlogic.update.util.UpdatePositionStage;
-import com.amlogic.update.util.UpgradeInfo;
-
-/**
- * @ClassName OtaUpgradeUtils
- * @Description Execute Update Operation
- * @see
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
-public class OtaUpgradeUtils {
- public static final int ERROR_INVALID_UPGRADE_PACKAGE = 0;
- public static final int ERROR_FILE_DOES_NOT_EXIT = 1;
- public static final int ERROR_FILE_IO_ERROR = 2;
- public static final int FAIL_REASON_BATTERY = 1;
- public static final int FAIL_STOP_FORCE = 2;
- public static final int FAIL_STOP_COPYERROR = 3;
- public static final File CHCHE_PARTITION_DIRECOTRY = Environment.getDownloadCacheDirectory();
- private boolean mCacheFileFlag = true;
- public static final String DEFAULT_PACKAGE_NAME = "update.zip";
- public static final int UPDATE_REBOOT = 0;
- public static final int UPDATE_RECOVERY = 1;
- public static final int UPDATE_UPDATE = 2;
- public static final int UPDATE_OTA = 3;
- private static File RECOVERY_DIR = new File("/cache/recovery");
- private static File COMMAND_FILE = new File(RECOVERY_DIR, "command");
- private static File LOG_FILE = new File(RECOVERY_DIR, "log");
- private Context mContext;
- private boolean mDeleteSource = false;
- private boolean mReceiverBattery = false;
- private boolean mFocusStop = false;
- private PrefUtil util = null;
-
- /**
- * Constructs a OtaUpgradeUtils object,which will perform an update
- *
- * @param mContext
- */
- public OtaUpgradeUtils(Context context) {
- mContext = context;
- util = new PrefUtil(mContext);
- }
-
- public void setDeleteSource(boolean setDel) {
- mDeleteSource = setDel;
- }
-
- /**
- * support Battery monitor during Update process
- *
- */
- public void unregistBattery() {
- if (mReceiverBattery) {
- mReceiverBattery = false;
- mContext.unregisterReceiver(batteryReceiver);
- }
- }
-
- /**
- * support Battery monitor during Update process
- *
- */
- public void registerBattery() {
- if (!mReceiverBattery) {
- mReceiverBattery = true;
- mContext.registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
- }
- }
-
- private BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- int level = intent.getIntExtra("level", 0);
- int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
- if (level < 20 && status == BatteryManager.BATTERY_STATUS_DISCHARGING) {
- mFocusStop = true;
- } else {
- mFocusStop = false;
- }
- }
- };
-
- public interface ProgressListener extends RecoverySystem.ProgressListener {
- @Override
- public void onProgress(int progress);
-
- public void onVerifyFailed(int errorCode, Object object);
-
- public void onCopyProgress(int progress);
-
- public void onCopyFailed(int errorCode, Object object);
-
- public void onStopProgress(int reason);
- }
-
- /**
- * Execute OTA update Function
- *
- * @param packageFile
- * is Upgrade file path, progressListener is update process
- */
- public boolean upgredeFromOta(File packageFile, ProgressListener progressListener) {
- return upgrade(packageFile, progressListener, UPDATE_OTA);
- }
-
- /**
- * Execute update Function
- *
- * @param packageFile
- * is Upgrade file path, progressListener is update
- * process,classfy is Update Category
- * @see UPDATE_REBOOT
- * @see UPDATE_OTA
- * @see UPDATE_RECOVERY
- * @see UPDATE_UPDATE
- */
- public boolean upgrade(File packageFile, ProgressListener progressListener, int classfy) {
- util.resetAll();
- if (classfy == UPDATE_OTA) {
- try {
- RecoverySystem.verifyPackage(packageFile, progressListener, null);
- } catch (IOException e) {
- progressListener.onVerifyFailed(ERROR_FILE_DOES_NOT_EXIT, packageFile.getPath());
- e.printStackTrace();
- return false;
- } catch (GeneralSecurityException e) {
- progressListener.onVerifyFailed(ERROR_INVALID_UPGRADE_PACKAGE, packageFile.getPath());
- e.printStackTrace();
- return false;
- }
- }
- if (mFocusStop) {
- progressListener.onStopProgress(FAIL_STOP_FORCE);
- return false;
- }
- if (classfy == UPDATE_OTA && !mFocusStop) {
- String sdkVersion = UpgradeInfo.getString("ro.build.version.sdk");
- try {
- int sdkInt = Integer.parseInt(sdkVersion);
- if (sdkInt >= 24) {
- String filePath = packageFile.getAbsolutePath();
- File updateFile ;
- if (!filePath.contains(UpdatePositionStage.getDefaultPostion())){
- if (UpdatePositionStage.isBigFile(packageFile)
- /*&& filePath.contains(UpdatePositionStage.getDefaultPostion())*/) {
- updateFile = new File(UpdatePositionStage.getDefaultPostion(), DEFAULT_PACKAGE_NAME);
- } else {
- updateFile = new File(CHCHE_PARTITION_DIRECOTRY, DEFAULT_PACKAGE_NAME);
- }
-
- boolean b = copyFile(packageFile, updateFile, progressListener);
- if (b && mDeleteSource) {
- packageFile.delete();
- }
- filePath = updateFile.getCanonicalPath();
- }
- writeCommand("--update_package=" + filePath, "--locale=" + Locale.getDefault().toString());
- // writeCommand("--update_package="+packageFile.getCanonicalPath(),"--locale="+Locale.getDefault().toString());
- bootCommand(mContext, UPDATE_RECOVERY);
- } else {
- File updateFile = new File(CHCHE_PARTITION_DIRECOTRY, DEFAULT_PACKAGE_NAME);
- boolean b = copyFile(packageFile, updateFile, progressListener);
- if (b && mDeleteSource) {
- packageFile.delete();
- }
- if (b) {
- installPackage(mContext, updateFile);
- return true;
- }
- }
- } catch (IOException e) {
- progressListener.onStopProgress(FAIL_STOP_FORCE);
- }
- } else {
- try {
- if (!mFocusStop) {
- bootCommand(mContext, classfy);
- return true;
- } else {
- progressListener.onStopProgress(FAIL_STOP_FORCE);
- }
- } catch (IOException e) {
- }
- }
- return false;
- }
-
- private void writeCommand(String... args) throws IOException {
- RECOVERY_DIR.mkdirs(); // In case we need it
- COMMAND_FILE.delete(); // In case it's not writable
- LOG_FILE.delete();
-
- FileWriter command = new FileWriter(COMMAND_FILE);
- try {
- for (String arg : args) {
- command.write(arg);
- command.write("\n");
- }
- } finally {
- command.close();
- }
-
- }
-
- /**
- * Execute boot command
- *
- * @param classfy
- * is update Category
- * @see UPDATE_REBOOT
- * @see UPDATE_OTA
- * @see UPDATE_RECOVERY
- * @see UPDATE_UPDATE
- */
- public static void bootCommand(Context context, int classfy) throws IOException {
-
- PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
- if (classfy == UPDATE_RECOVERY) {
- pm.reboot("recovery");
- }
- if (classfy == UPDATE_REBOOT) {
- pm.reboot("normal_reboot");
- } else if (classfy == UPDATE_UPDATE) {
- pm.reboot("update");
- }
- throw new IOException("Reboot failed (no permissions?)");
- }
-
- /**
- * Execute OTA update
- *
- * @param packagePath
- * is update file path
- * @see UPDATE_OTA
- */
- public boolean upgradeFromOta(String packagePath, ProgressListener progressListener) {
- return upgredeFromOta(new File(packagePath), progressListener);
- }
-
- // public void deleteSource(boolean b) {}
-
- private boolean copyFile(File src, File dst, ProgressListener listener) {
- long inSize = src.length();
- long outSize = 0;
- int progress = 0;
- listener.onCopyProgress(progress);
- try {
- if (dst.exists()) {
- dst.delete();
- dst.createNewFile();
- }
- FileInputStream in = new FileInputStream(src);
- FileOutputStream out = new FileOutputStream(dst);
- int length = -1;
- byte[] buf = new byte[1024];
- while ((length = in.read(buf)) != -1) {
- out.write(buf, 0, length);
- outSize += length;
- int temp = (int) (((float) outSize) / inSize * 100);
- if (temp != progress) {
- progress = temp;
- listener.onCopyProgress(progress);
- }
- if (mFocusStop) {
- listener.onStopProgress(FAIL_STOP_FORCE);
- out.flush();
- in.close();
- out.close();
- return false;
- }
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (outSize != in.available() || MD5.checkMd5Files(src, dst)) {
- listener.onStopProgress(FAIL_STOP_COPYERROR);
- }
- out.flush();
- in.close();
- out.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- return false;
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- private boolean copyFile(String src, String dst, ProgressListener listener) {
- return copyFile(new File(src), new File(dst), listener);
- }
-
- /**
- * Execute installPackage Update
- *
- * @param packagePath
- * is update file path
- *
- */
- public static void installPackage(Context context, File packageFile) {
- try {
- RecoverySystem.installPackage(context, packageFile);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /*
- * public static void rebootUpdate(Context context) { try {
- * bootCommand(context, "update", UPDATE_UPDATE); } catch (IOException e) {
- * // e.printStackTrace(); } }
- */
-
- /**
- * Execute recovery command
- *
- * @param
- * @see UPDATE_REBOOT
- */
- public static void rebootRecovery(Context context) {
- try {
- bootCommand(context, UPDATE_RECOVERY);
- } catch (IOException e) {
- // e.printStackTrace();
- }
- }
-
- /**
- * Execute reboot normal command
- *
- * @param
- * @see UPDATE_REBOOT
- */
- public static void rebootNormal(Context context) {
- try {
- bootCommand(context, UPDATE_REBOOT);
- } catch (IOException e) {
- // e.printStackTrace();
- }
- }
-
- /*
- * public static boolean checkVersion(long newVersion, String product) {
- * return (Build.TIME <= newVersion * 1000 && (Build.DEVICE .equals(product)
- * || Build.PRODUCT.equals(product))); }
- */
-
- /*
- * public static boolean checkIncVersion(String fingerprinter, String
- * product) { return (Build.FINGERPRINT.equals(fingerprinter) &&
- * (Build.DEVICE .equals(product) || Build.PRODUCT.equals(product))); }
- */
-
- /**
- * setMode to Debug
- *
- * @param debug
- * true:debug mode false: update mode
- */
- public static void setDebugMode(boolean debug) {
- PrefUtil.DEBUG = debug;
- }
-
- public void forceStop(boolean val) {
- mFocusStop = val;
- }
-}
-PK
-
+
+
+
mErrorCode
@@ -2021,162 +495,55 @@ mErrorCode
SourceFile
-
-*
-
-
- * @Package com.amlogic.update
- * @Description update function
- *
- * Copyright (c) Inspur Group Co., Ltd. Unpublished
- *
- * Inspur Group Co., Ltd.
- * Proprietary & Confidential
- *
- * This source code and the algorithms implemented therein constitute
- * confidential information and may comprise trade secrets of Inspur
- * or its associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which this
- * source code was originally received.
- */
-package com.amlogic.update;
-
-import android.util.Log;
-import com.amlogic.update.util.DesUtils;
-import com.amlogic.update.util.UpgradeInfo;
-/**
- * @ClassName UpdateTasks
- * @Description Work Thread For Online Update,Known Subclasses is @see CheckUpdateTask and @see DownloadUpdateTask
- * @Date 2012/12/03
- * @Email
- * @Author
- * @Version V1.0
- */
-public abstract class UpdateTasks implements Runnable {
- public static final int NO_ERROR = 0;
- private boolean DEBUG = true||UpgradeInfo.isDebugAble();
- public static final int RUNNING_STATUS_UNSTART = 0;
- public static final int RUNNING_STATUS_RUNNING = 1;
- public static final int RUNNING_STATUS_PAUSE = 2;
- public static final int RUNNING_STATUS_FINISH = 3;
- protected Thread mThread;
- protected long mProgress = 0;
- protected int mErrorCode = NO_ERROR;
- protected int mRunningStatus = RUNNING_STATUS_UNSTART;
- protected Object mResult;
-
- // ----------------Runtime Method
- /**
- * Start work Thread and set status to @see RUNNING_STATUS_RUNNING
- *
- * @param null
- */
- public void start() {
- if(DEBUG)android.util.Log.d("Upgrade","Upgrade:start");
- if (!DesUtils.isAmlogicChip()) {
- Log.d("warn", "Sorry, just for amlogic cpu!");
- mRunningStatus = RUNNING_STATUS_FINISH;
- return;
- }else if (mRunningStatus != RUNNING_STATUS_RUNNING) {
- mRunningStatus = RUNNING_STATUS_RUNNING;
- mThread = new Thread(this);
- onStart();
- mThread.start();
- }
- }
-
- protected void onStart() {}
-
- @Override
- public void run() {
- onRunning();
- stop();
- }
-
- protected void onRunning() {}
- /**
- * pause work thread and set status to @see RUNNING_STATUS_PAUSE
- *
- * @param null
- */
- public void pause() {
- mRunningStatus = RUNNING_STATUS_PAUSE;
- onPause();
- }
-
- protected void onPause() {}
- /**
- * resume work thread and set status from @see RUNNING_STATUS_PAUSE to @see RUNNING_STATUS_RUNNING
- *
- * @param null
- */
- public void resume() {
- if(mThread!=null){
- if(DEBUG) android.util.Log.d("Upgrade","Upgrade:resume"+(mThread.isAlive())+" mRunningStatus:"+mRunningStatus);
- }else{
- if(DEBUG) android.util.Log.d("Upgrade","Upgrade:resume mThread *= null");
- }
- if (mRunningStatus == RUNNING_STATUS_PAUSE){
- if (mThread != null && mThread.isAlive()) {
- mRunningStatus = RUNNING_STATUS_RUNNING;
- onResume();
- } else {
- start();
- }
- }
- }
-
- protected void onResume() {}
- /**
- * stop work thread and set status from @see RUNNING_STATUS_RUNNING to @see RUNNING_STATUS_FINISH
- * @param null
- */
- public void stop() {
- if (mRunningStatus != RUNNING_STATUS_UNSTART) {
- onStop();
- mRunningStatus = RUNNING_STATUS_FINISH;
- }
- }
-
- protected void onReset() {}
- /**
- * reset work thread and set status to @see RUNNING_STATUS_UNSTART
- *
- * @param null
- */
- public boolean reset() {
- if (mRunningStatus == RUNNING_STATUS_FINISH
- || mRunningStatus == RUNNING_STATUS_PAUSE
- || mRunningStatus == RUNNING_STATUS_RUNNING) {
- onReset();
- mProgress = 0;
- mRunningStatus = RUNNING_STATUS_UNSTART;
- return true;
- }
- return false;
- }
-
- protected void onStop() {}
-
- // -----------------Public Method
- public int getErrorCode() {
- return mErrorCode;
- }
-
- public int getRunningStatus() {
- return mRunningStatus;
- }
-
- public long getProgress() {
- return mProgress;
- }
-
- public Object getResult() {
- return mResult;
- }
-}
-PK
-
+
+*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+moveToNext
+resetInfos
+
+SourceFile
+
+
+*
+
+
+
+
+
+
+
+
+,
+
+
+
+
+
+
+
+
+
@@ -2184,95 +551,15 @@ PK
SourceFile
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
- * Description:
- *
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-package com.amlogic.update.util;
-
-public class DownFilesInfo {
- public String name;
- public String local;
- public String md5;
- public String url;
- int complete;
- int filesize;
-
- DownFilesInfo(String name, String local, String md5, String url) {
- this.name = name;
- this.local = local;
- this.md5 = md5;
- this.url = url;
- }
-
- DownFilesInfo(int filesize, int complete, String url) {
- this.filesize = filesize;
- this.complete = complete;
- this.url = url;
- }
-
- public DownFilesInfo() {}
-
- public String getName() {
- return name;
- }
-
- public String getLocal() {
- return local;
- }
-
- public String getMd5() {
- return md5;
- }
-
- public String getUrl() {
- return url;
- }
-
- public int getComplete() {
- return complete;
- }
-
- @Override
- public String toString() {
- return "DownloadFilesInfo [name=" + name + ", local=" + local
- + ", md5=" + md5 + ", url=" + url + ", complete=" + complete
- + "]";
- }
-
- void setName(String name) {
- this.name = name;
- }
-
- public void setLocal(String local) {
- this.local = local;
- }
-
- public void setMd5(String md5) {
- this.md5 = md5;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public void setComplete(int complete) {
- this.complete = complete;
- }
-}
-PK
-
+
@@ -2301,150 +588,19 @@ moveToNext
cleartable
initrecord
SourceFile
-
+


-
-
+
+
-
-
+
+
*
-
+
-
-* Description:
-* @Copyright: Copyright (c) 2012
-* @Company: Amlogic
-* @version: 1.0
-*/
-
-package com.amlogic.update.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.swing.text.html.HTMLDocument.Iterator;
-
-import android.os.Environment;
-import android.util.Log;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-
-public class DownFileDao {
-
- private DatabaseHelper dbHelper;
- private Context mContext;
-
- public DownFileDao(Context co) {
- mContext = co;
- dbHelper = new DatabaseHelper(co);
- }
-
- public List<DownFilesInfo> getDowntasks() {
- List<DownFilesInfo> list = new ArrayList<DownFilesInfo>();
- SQLiteDatabase database = getConnection();
- String sql = "select * from " + DatabaseHelper.DOWNTASKTABLE;
- Cursor cursor = database.rawQuery(sql,null);
- while (cursor.moveToNext()) {
- if (PrefUtil.DEBUG)
- Log.d("db","getDowntasks:1-"+cursor.getString(1)+" 2-"+cursor.getString(2)+" 3-"+cursor.getString(3)+" 4-"+cursor.getString(4));
-
- DownFilesInfo info = new DownFilesInfo(cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4));
- list.add(info);
- }
- cursor.close();
- database.close();
- return list;
- }
-
- DownFilesInfo getDownFile(String url) {
- SQLiteDatabase database = getConnection();
- DownFilesInfo info = null;
- Cursor cursor = null;
- try {
- String sql = "select * from " + DatabaseHelper.DOWNTASKTABLE + " where url=?";
- cursor = database.rawQuery(sql, new String[] { url });
- if(cursor.moveToNext()){
- info = new DownFilesInfo(cursor.getString(1), cursor.getString(2), cursor.getString(3),
- cursor.getString(4));
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- if (null != cursor) {
- cursor.close();
- }
- }
- return info;
- }
- synchronized SQLiteDatabase getConnection() {
- SQLiteDatabase sqliteDatabase = null;
- try {
- sqliteDatabase= dbHelper.getReadableDatabase();
- } catch (Exception e) {
- }
- return sqliteDatabase;
- }
-
- public void saveDowntasks(List<DownFilesInfo> tasks) {
- SQLiteDatabase database = dbHelper.getWritableDatabase();
- //Log.d("db","saveDowntasks:"+tasks.size());
- for (DownFilesInfo task : tasks) {
- String sql = "insert into "+DatabaseHelper.DOWNTASKTABLE+"(file_name,file_location,file_md5,url) values (?,?,?,?)";
- Object[] bindArgs = { task.getName(), task.getLocal(),
- task.getMd5(),task.getUrl()};
- database.execSQL(sql, bindArgs);
- }
- if (null != database) {
- database.close();
- }
- }
-
- public void saveDowntasks(HashMap<String,DownFilesInfo> taskMap) {
- SQLiteDatabase database = dbHelper.getWritableDatabase();
- for (DownFilesInfo task :taskMap.values()) {
- String sql = "insert into "+DatabaseHelper.DOWNTASKTABLE+"(file_name,file_location,file_md5,url) values (?,?,?,?)";
- String name = task.getLocal();
- Object[] bindArgs = { task.getName(), task.getLocal(),
- task.getMd5(),task.getUrl()};
- database.execSQL(sql, bindArgs);
- }
- if (null != database) {
- database.close();
- }
- }
-
- public void delFile(String locate) {
- SQLiteDatabase database = dbHelper.getWritableDatabase();
- try {
- database.delete(DatabaseHelper.DOWNTASKTABLE, "file_location=?", new String[] { locate});
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
- public void cleardata() {
- dbHelper.cleartable(DatabaseHelper.DOWNTASKTABLE);
- dbHelper.cleartable(DatabaseHelper.DOWNLOADINGRECORD);
- }
- public void initrecord() {
- dbHelper.cleartable(DatabaseHelper.DOWNLOADINGRECORD);
- }
-}
-PK
-
+
@@ -2474,204 +630,19 @@ disconnect
setIsStart
SourceFile
-
-
-
-
-
-
-
-
-
-
-
-
-
- * Description:
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-
-package com.amlogic.update.util;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import android.util.Log;
-
-class DownloadFile {
- private File file;
- private String url;
- private String fileName;
- private int startPos;
- private int endPos;
- private int completeSize;
- private int threadNumTotal = 1;
- private int currentThread = 1;
- private boolean startDown = false;
- private HttpURLConnection httpConn = null;
- static int BUFFER_SIZE = 1024 * 512;
-
- DownloadFile() {
- }
-
- /**
- * @param int1
- * @param int2
- * @param int3
- * @param int4
- * @param string
- */
- DownloadFile(int thread_id, int start_pos, int end_pos,
- int compelete_size, String url,boolean startDown) {
- currentThread = thread_id;
- startPos = start_pos;
- endPos = end_pos;
- startDown = false;
- completeSize = compelete_size;
- this.url = url;
- this.startDown = startDown;
- }
-
- File getFile() {
- return file;
- }
-
- void setFile(File file) {
- this.file = file;
- }
-
- String getUrl() {
- return url;
- }
-
- void setUrl(String url) {
- this.url = url;
- }
-
- String getFileName() {
- return fileName;
- }
-
- void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- int getStartPos() {
- return startPos;
- }
-
- void setStartPos(int startPos) {
- this.startPos = startPos;
- }
-
- int getEndPos() {
- return endPos;
- }
-
- void setEndPos(int endPos) {
- this.endPos = endPos;
- }
-
- int getThreadNumTotal() {
- return threadNumTotal;
- }
-
- void setThreadNumTotal(int threadNumTotal) {
- this.threadNumTotal = threadNumTotal;
- }
-
- int getCurrentThread() {
- return currentThread;
- }
-
- void setCurrentThread(int currentThread) {
- this.currentThread = currentThread;
- }
-
- static int getBUFFER_SIZE() {
- return BUFFER_SIZE;
- }
-
- static void setBUFFER_SIZE(int bUFFER_SIZE) {
- BUFFER_SIZE = bUFFER_SIZE;
- }
-
- InputStream getInputStreamByPos() {
- try {
- if(PrefUtil.DEBUG) Log.d(PrefUtil.TAG,"return InputStream"+this.startPos+" end:"+this.endPos);
- if (this.url != null && !"".equals(this.url)) {
-
- if (this.startPos >= 0 && this.endPos >= 0 &&
- this.completeSize >= 0 && (this.startPos + this.completeSize) < this.endPos) {
- int mStartPoi = (int) (this.startPos+this.completeSize);
- URL url = new URL(this.url);
- httpConn = (HttpURLConnection) url.openConnection();
- httpConn.setRequestMethod("GET");
- httpConn.setAllowUserInteraction(false);
- httpConn.setRequestProperty("Connection","Keep-Alive");
- httpConn.setConnectTimeout(6000*3);//never time out
- httpConn.setReadTimeout(0);
- httpConn.setDefaultUseCaches(false);
- httpConn.setRequestProperty("RANGE", "bytes=" + mStartPoi + "-" + getEndPos());
- httpConn.connect();
- if(httpConn.getResponseCode()!=206 && httpConn.getResponseCode()!=200){
- return null;
- }
- if(PrefUtil.DEBUG) Log.d(PrefUtil.TAG, "getStartPos( ) " + mStartPoi
- + " getEndPos( ) " + getEndPos());
- return httpConn.getInputStream();
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return null;
- }
-
-
- public void closeHttpConn(){
- if(httpConn!=null){
- httpConn.disconnect();
- httpConn=null;
- }
- startDown = false;
- }
-
- public boolean isStart(){
- return startDown;
- }
-
- public void setIsStart(boolean start){
- startDown = start;
- }
-
- @Override
- public String toString() {
- return "DownloadFile [file=" + file + ", url=" + url + ", fileName="
- + fileName + ", startPos=" + startPos + ", endPos=" + endPos
- + ", completeSize=" + completeSize + ", threadNumTotal="
- + threadNumTotal + ", currentThread=" + currentThread
- + ", httpConn=" + httpConn + "]";
- }
-
- public int getCompleteSize() {
- return completeSize;
- }
-
- public void setCompleteSize(int completeSize) {
- this.completeSize = completeSize;
- }
-
-}
-PK
-
+
+
+
+
+
+
+
+
+
+
+
+
+
update.zip
check_time
@@ -2702,326 +673,33 @@ targetFile
SourceFile
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-*,
-
-
-
-
-
-
-
-
-
-
+
+*,
+
+
+
+
+
+
+
+
+
+
-
- * @Package
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
-/**
- * @ClassName Utils
- * @Description TODO
- * @Date 2013-7-15
- * @Email
- * @Author
- * @Version V1.0
- */
-package com.amlogic.update.util;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.Environment;
-
-public class PrefUtil {
- public static final String DEFAULT_UPDATE_FILENAME = "update.zip";
- public static Boolean DEBUG = true;
- public static final String TAG = "OTA";
- private Context mContext;
- // access by download task
- static final String PREFS_DOWNLOAD_SIZE = "download_size";
- // access by download task
- static final String PREFS_DOWNLOAD_POSITION = "download_position";
- static final String PREFS_DOWNLOAD_UPDATEFILE = "download_updatefile";
- // access by checking task
- static final String PREFS_DOWNLOAD_TARGET = "download_target";
- static final String PREFS_DOWNLOAD_FILELIST = "download_filelist";
- // access by checking task
- static final String PREFS_DOWNLOAD_URL = "download_URL";
- // access by checking task
- static final String PREFS_PACKAGE_DESCRIPTOR = "package_descriptor";
- // access by checking task
- static final String PREFS_PACKAGE_MD5 = "package_md5";
- static final String PREFS_CHECK_STRING = "check_string";
- static final String PREFS_UPDATE_STRING = "update_string";
- // access by loader
- static final String PREFS_CHECK_TIME = "check_time";
- static final String PREFS_SCRIPT_ASK = "update_script";
- static final String PREFS_NOTICE_TRUE = "notice_true";
- //static final String PREF_START_RESTORE = "retore_start";
- //private static final String FlagFile = ".wipe_record";
- private SharedPreferences mPrefs;
-
- public PrefUtil(Context context) {
- mPrefs = context.getSharedPreferences("SHARE", Context.MODE_PRIVATE);
- mContext = context;
- }
-
- public void setLastCheckTime(String date) {
- setString(PREFS_CHECK_STRING, date);
- }
-
- String getLastCheckTime() {
- return mPrefs.getString(PREFS_CHECK_STRING, null);
- }
-
- void setLastUpdateTime(String date) {
- setString(PREFS_UPDATE_STRING, date);
- }
-
- String getLastUpdateTime() {
- return mPrefs.getString(PREFS_UPDATE_STRING, null);
- }
-
- private void setString(String key, String Str) {
- SharedPreferences.Editor mEditor = mPrefs.edit();
- mEditor.putString(key, Str);
- mEditor.commit();
- }
-
- private void setStringSet(String key, Set<String> downSet) {
- SharedPreferences.Editor mEditor = mPrefs.edit();
- mEditor.putStringSet(key, downSet);
- mEditor.commit();
- }
-
- private void setInt(String key, int Int) {
- SharedPreferences.Editor mEditor = mPrefs.edit();
- mEditor.putInt(key, Int);
- mEditor.commit();
- }
-
- private void setLong(String key, long Long) {
- SharedPreferences.Editor mEditor = mPrefs.edit();
- mEditor.putLong(key, Long);
- mEditor.commit();
- }
-
- public void setUpdateWithScript(boolean bool) {
- setBoolean(PREFS_SCRIPT_ASK, bool);
- }
-
- public boolean getScriptASK() {
- return mPrefs.getBoolean(PREFS_SCRIPT_ASK, false);
- }
-
- void setBoolean(String key, Boolean bool) {
- SharedPreferences.Editor mEditor = mPrefs.edit();
- mEditor.putBoolean(key, bool);
- mEditor.commit();
- }
-
- public void setDownloadSize(long size) {
- setLong(PREFS_DOWNLOAD_SIZE, size);
- }
-
- public void setDownFileList(HashMap<String, DownFilesInfo> downlist) {
-
- HashSet<String> filelist = new HashSet<String>();
- for (DownFilesInfo task :downlist.values()) {
- filelist.add(task.local);
- }
- if (filelist.size() > 0) {
- setStringSet(PREFS_DOWNLOAD_FILELIST, filelist);
- }
- }
-
- public void setDownloadPos(long position) {
- setLong(PREFS_DOWNLOAD_POSITION, position);
- }
-
- void setBreakpoint(long size, long position) {
- setLong(PREFS_DOWNLOAD_SIZE, size);
- setLong(PREFS_DOWNLOAD_POSITION, position);
- }
-
- void setDownloadInfo(String url, String targetFile) {
- setString(PREFS_DOWNLOAD_URL, url);
- setString(PREFS_DOWNLOAD_TARGET, targetFile);
- setBreakpoint(0, 0);
- }
-
- void setMd5(String md5) {
- setString(PREFS_PACKAGE_MD5, md5);
- }
-
- String getMd5() {
- return mPrefs.getString(PREFS_PACKAGE_MD5, null);
- }
-
- public void setUpdateFile(String filepath) {
- setString(PREFS_DOWNLOAD_UPDATEFILE, filepath);
- }
-
- public String getUpdatFile() {
- return mPrefs.getString(PREFS_DOWNLOAD_UPDATEFILE, null);
- }
-
- void setCheckTime(long time) {
- setLong(PREFS_CHECK_TIME, time);
- }
-
- public void setPackageDescriptor(String str) {
- setString(PREFS_PACKAGE_DESCRIPTOR, str);
- }
-
- void setDownloadTarget(String target) {
- setString(PREFS_DOWNLOAD_TARGET, target);
- }
-
- void setDownloadURL(String URL) {
- setString(PREFS_DOWNLOAD_URL, URL);
- }
-
- void setNotice(Boolean bool) {
- setBoolean(PREFS_NOTICE_TRUE, bool);
- }
-
- public String getPackageDescriptor() {
- return mPrefs.getString(PREFS_PACKAGE_DESCRIPTOR, null);
- }
-
- public synchronized long getDownloadSize() {
- return mPrefs.getLong(PREFS_DOWNLOAD_SIZE, 0);
- }
-
- public long getDownloadPos() {
- return mPrefs.getLong(PREFS_DOWNLOAD_POSITION, 0);
- }
-
- String getDownloadTarget() {
- return mPrefs.getString(PREFS_DOWNLOAD_TARGET, null);
- }
-
- String getDownloadURL() {
- return mPrefs.getString(PREFS_DOWNLOAD_URL, null);
- }
-
- long getCheckTime() {
- return mPrefs.getLong(PREFS_CHECK_TIME, 0);
- }
-
- boolean getNotice() {
- return mPrefs.getBoolean(PREFS_NOTICE_TRUE, true);
- }
-
- public Set<String> getDownFileSet() {
- return mPrefs.getStringSet(PREFS_DOWNLOAD_FILELIST, null);
- }
-
- void setDownloadInfo(long size, long position, String target, String URL) {
- setDownloadSize(size);
- setDownloadPos(position);
- setDownloadTarget(target);
- setDownloadURL(URL);
- }
-
- public void resetAll() {
- setDownloadURL("");
- setMd5("");
- setUpdateWithScript(false);
- setString(PREFS_DOWNLOAD_URL, "");
- setString(PREFS_DOWNLOAD_TARGET, "");
- setBreakpoint(0, 0);
- setStringSet(PREFS_DOWNLOAD_FILELIST, null);
- }
-
- /**
- * @return
- */
- public int getID() {
- if (mPrefs.getInt("ID", 1001) == 1001) {
- int random = (int) (Math.random() * 1000);
- setInt("ID", random);
- }
- if (DEBUG)
- return 1000;
- else
- return mPrefs.getInt("ID", 0);
- }
-
- boolean getBooleanVal(String key, boolean def) {
- return mPrefs.getBoolean(key, def);
- }
-
- /* void write2File() {
- String Mounted = Environment.getExternalStorage2State();
- if (!Mounted.equals(Environment.MEDIA_MOUNTED)) {
- return;
- }
- File flagFile = new File(Environment.getExternalStorage2Directory(),
- FlagFile);
- if (!flagFile.exists()) {
- try {
- flagFile.createNewFile();
- } catch (IOException excep) {
- }
- }
- FileWriter fw = null;
- try {
- fw = new FileWriter(flagFile);
- } catch (IOException excep) {
- }
- BufferedWriter output = new BufferedWriter(fw);
- Set<String> downfiles = mPrefs.getStringSet(PREFS_DOWNLOAD_FILELIST,
- null);
- if (downfiles != null && downfiles.size() > 0) {
- String[] downlist = downfiles.toArray(new String[0]);
- for (int i = 0; i < downlist.length; i++) {
- try {
- output.write(downlist[i]);
- output.newLine();
- } catch (IOException ex) {
- }
- }
- }
- try {
- output.close();
- } catch (IOException e) {
- }
- }*/
-
-}
-PK
-
+
randomFile
@@ -3065,14 +743,13 @@ updateSize
alreayload
SourceFile
-
+
-
+
*
-*
- ):ILPRZd E`ct'@e,Qlo;VYjy|
-
-p<
+*
+ ):ILPRZd E`ct'@e,Qlo;VYjy|
+
@@ -3166,14 +843,14 @@ isShutdown
SourceFile
-
-
-
-
-
-
+
+
+
+
+
+

-
+

@@ -3198,513 +875,16 @@ e6 *
Ը
۸
-
-
-
+
+
+
+k
{
-
-
-
-*
-
- * Description:
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-
-package com.amlogic.update.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.io.FileInputStream;
-import java.io.SyncFailedException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.SocketException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.apache.http.HttpConnection;
-
-import com.amlogic.update.DownloadUpdateTask;
-import com.amlogic.update.DownloadUpdateTask.DownloadSize;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-public class DownloadUtil {
- private boolean DEBUG = (true||UpgradeInfo.isDebugAble());
- private static final String TAG = PrefUtil.TAG;
- public static int defaultThread = 3;
- private int threadNum;
- static final int MSG_FILE_ZISE = 100;
- static final int MSG_DOWNLOAD_SIZE = 101;
- static final int MSG_DOWNLOAD_FINISH = 102;
- static final int MSG_DOWNLOAD_ERROR = 103;
- private Context mContext;
- private static final int INIT = 1;
- private static final int DOWNLOADING = 2;
- private static final int PAUSE = 3;
- private DownloadSize mDownloadSize = null;
- private int state = INIT;
- private DownloadUpdateTask downloadTask;
- ThreadPoolExecutor service;
- private CountDownLatch countDownLatch = null;
- private static List<SaveFileThread> workers = new ArrayList<SaveFileThread>();
-
- public boolean isdownloading() {
- return state == DOWNLOADING;
- }
-
- int getThreadNum() {
- return threadNum;
- }
-
- public DownloadUtil(DownloadSize downloadSize, Context mContext, DownloadUpdateTask downloadThread) {
- this.mDownloadSize = downloadSize;
- this.mContext = mContext;
- this.downloadTask = downloadThread;
- // defaultThread = getDefaltThread(mContext);
- service = new ThreadPoolExecutor(defaultThread, defaultThread + 2, 30, TimeUnit.SECONDS,
- new ArrayBlockingQueue<Runnable>(5), new ThreadPoolExecutor.DiscardOldestPolicy());
- Dao.getInstance(mContext).resetInfos();
- }
-
- boolean isExistFile(String filePath) {
- File file = new File(filePath);
- return file.exists();
- }
-
- void createDir(String dirPath) {
- if (dirPath != null || !"".equals(dirPath)) {
- File file = new File(dirPath);
- if (!file.isDirectory()) {
- file.mkdirs();
- }
- }
- }
-
- private static int getDefaltThread(Context cxt) {
- int threadDefault = 3;
- ConnectivityManager connectivityManager = (ConnectivityManager) cxt
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
- if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
- threadDefault = 1;
- }
- return threadDefault;
- }
-
- /**
- * param urlstr: Url to download
- */
- private boolean isFirst(String urlstr) {
- boolean ret = Dao.getInstance(mContext).isHasInfors(urlstr);
- return ret;
- }
-
- public boolean isServicePartDownload(int startPoi,long l,String urlStr){
-
- HttpURLConnection httpConn=null;
- boolean partDownload =false;
- try{
- URL url = new URL(urlStr);
- httpConn = (HttpURLConnection) url.openConnection();
- httpConn.setRequestMethod("GET");
- httpConn.setAllowUserInteraction(false);
- httpConn.setRequestProperty("Connection","Keep-Alive");
- httpConn.setConnectTimeout(6000*3);//never time out
- httpConn.setReadTimeout(0);
- httpConn.setDefaultUseCaches(false);
- httpConn.setRequestProperty("RANGE", "bytes=" + startPoi + "-" + l);
- httpConn.connect();
- if(httpConn.getResponseCode()==206){
- partDownload = true;
- }
- }catch(IOException ex){
- ex.printStackTrace();
- }finally{
- httpConn.disconnect();
- }
- if(DEBUG)
- Log.d(TAG,"Download update file,may service support partial download: " + partDownload);
- return partDownload;
-
- }
-
- int getFileLength(String url) {
- URL murl;
- int len = -1;
- try {
- murl = new URL(url);
- HttpURLConnection httpConn = (HttpURLConnection) murl.openConnection();
- httpConn.setRequestMethod("GET");
- httpConn.setRequestProperty("Accept-Encoding", "identity");
- if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
- len = httpConn.getContentLength();
- httpConn.disconnect();
- if (DEBUG)
- Log.d(TAG, "getFileLength:" + len);
- return len;
- }
- } catch (MalformedURLException e) {
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_NETWORK_UNAVAIBLE);
- e.printStackTrace();
- return -1;
- } catch (IOException ex) {
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_IOERROR);
- ex.printStackTrace();
- return -1;
- } catch (Exception exp) {
- exp.printStackTrace();
- }
- return -1;
- }
-
- public int Save2File(String urlAddress, String saveDir, String fileName, final String md5) throws IOException {
- if(DEBUG)
- Log.d(TAG,
- "Save2File urlAddress :" + urlAddress + "saveDir:" + saveDir + " fileName:" + fileName + " md5:" + md5);
- state = DOWNLOADING;
- long urlTotalSize = -1;
- final File file = new File(saveDir);
-
- try {
- List<DownloadFile> downInfo;
-
- urlTotalSize = getFileLength(urlAddress);
- if (urlTotalSize <= 0)
- return -1;
- if (isFirst(urlAddress)) {
- if (file.exists()) {
- file.delete();
- }
- downInfo = new ArrayList<DownloadFile>();
- threadNum = (int) (urlTotalSize / DownloadFile.BUFFER_SIZE) + 1;
- if (DEBUG)
- Log.d(TAG, "download target :" + file.getAbsolutePath() + "size:" + urlTotalSize);
- if (threadNum > defaultThread) {
- threadNum = defaultThread;
- }
- if (!isServicePartDownload(0, urlTotalSize / 2, urlAddress)) {
- threadNum = 1;
- }
- long spanSize = (long) Math.ceil((float) urlTotalSize / threadNum);
-
- if (DEBUG)
- Log.d(TAG, "spanSize=" + spanSize + " urlTotalSize=" + urlTotalSize);
- if (urlTotalSize <= 0)
- return -1;
-
- for (int i = 0; i < threadNum; i++) {
- DownloadFile downloadFile = new DownloadFile();
- downloadFile.setFile(new File(saveDir));
- downloadFile.setUrl(urlAddress);
- downloadFile.setStartPos((int) (i * spanSize));
- int ends = (int) ((i + 1) * spanSize - 1);
- if ((threadNum - 1) == i || ends >= urlTotalSize) {
- downloadFile.setEndPos((int) urlTotalSize - 1);
- } else {
- downloadFile.setEndPos(ends);
- }
- downloadFile.setCurrentThread(i);
- downloadFile.setFileName(fileName);
- downloadFile.setIsStart(false);
- if(DEBUG) Log.d(TAG, "dump download info:" + downloadFile.toString());
- downInfo.add(downloadFile);
- }
- if (downInfo.size() > 0) {
- Dao.getInstance(mContext).saveInfos(downInfo);
- }
- } else {
- downInfo = Dao.getInstance(mContext).getInfos(urlAddress);
- if (downInfo.size() > 0) {
- threadNum = downInfo.size();
- if (DEBUG)
- Log.d("OTA", downInfo.toString());
- }
- if (DEBUG)
- Log.d("OTA", "down Thread target:" + downInfo.size() + " file:" + file.getAbsolutePath());
- }
-
- countDownLatch = new CountDownLatch(downInfo.size() );
- for (int i = 0; i < downInfo.size(); i++) {
- RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
- DownloadFile downloadFile = downInfo.get(i);
- Log.d("OTA", "down Thread target:" + downloadFile.isStart() );
- if (downloadFile.isStart()) {
- continue;
- }
- try {
- SaveFileThread work = new SaveFileThread(randomAccessFile, downloadFile, countDownLatch,
- mDownloadSize);
- synchronized(workers){
- workers.add(work);
- }
- service.execute(work);
- } catch (RejectedExecutionException ex) {
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_NETWORK_UNAVAIBLE);
- ex.printStackTrace();
- return -1;
- }
- }
- } catch (Exception ex) {
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_UNKNOWN);
- ex.printStackTrace();
- throw new IOException();
- } finally {
- /*try {
- if (countDownLatch != null){
- countDownLatch.await();
- }
- if(DEBUG)
- Log.d("OTA", "await success" );
- } catch (InterruptedException ex) {
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_UNKNOWN);
- ex.printStackTrace();
- //throw new IOException();
- return -1;
- }*/
- while(true){
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- synchronized(workers){
- if(workers.size()==0){
- break;
- }
- /*boolean stop = true;
- for (SaveFileThread t : workers) {
- stop = stop&t.stopFlag;
- }
- if(workers.size()==0||stop){
- break;
- }*/
- }
- }
- }
- }
- if (state == PAUSE) {
- Log.d(TAG, "loading status is pause:" + state);
- return -1;
- }
- if(DEBUG)
- Log.d(TAG, "check md5 values of file:" + file.getName() + "path:" + file.getAbsolutePath());
-
- int retry = 0;
- while(retry<3){
- if (state == PAUSE) {
- Log.d(TAG, "loading status is pause:" + state);
- return -1;
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- FileInputStream fileIn = new FileInputStream(file);
- if (fileIn.available() < urlTotalSize) {
- // if (PrefUtil.DEBUG)
- Log.d(TAG, "filecheck times:"+retry+"xml size:" + fileIn.available() + "urlTotalSize:" + urlTotalSize);
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_UNKNOWN);
- fileIn.close();
- }else{
- retry=4;
- break;
- }
- retry ++;
- }
- }
- FileInputStream fileIn = new FileInputStream(file);
- if (fileIn.available() != urlTotalSize) {
- // if (PrefUtil.DEBUG)
- Log.d(TAG, "xml size:" + fileIn.available() + "urlTotalSize:" + urlTotalSize);
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_UNKNOWN);
- fileIn.close();
- return -1;
- }
- if (!MD5.checkMd5(md5, file)) {
- if(DEBUG)
- Log.d(TAG, "xml md5 check failed");
- if (file.exists()) {
- // file.delete();
- mDownloadSize.deleteSize(urlTotalSize);
- downloadTask.setErrorCode(DownloadUpdateTask.ERROR_UNKNOWN);
- }
- fileIn.close();
- return -1;
- } else {
- Log.d(TAG, "xml md5 check ok");
- fileIn.close();
- return 0;
- }
- }
-
- class SaveFileThread implements Runnable {
- private RandomAccessFile randomFile;
- private DownloadFile downloadFile;
- private CountDownLatch countDownLatch;
- private DownloadSize mDownloadSize;
- private boolean stopFlag = false;
-
- SaveFileThread(RandomAccessFile randomFile, DownloadFile downloadFile, CountDownLatch countDownLatch,
- DownloadSize downloadSize) {
- this.randomFile = randomFile;
- this.downloadFile = downloadFile;
- this.countDownLatch = countDownLatch;
- this.mDownloadSize = downloadSize;
- }
-
- public void stopSave() {
- stopFlag = true;
- //downloadFile.closeHttpConn();
- }
-
- public void run() {
- boolean isExceptionOccur = false;
- try {
- InputStream is = null;
- // try service 3 times wait for 206 response
- for (int count = 0; count < 3; count++) {
- is = this.downloadFile.getInputStreamByPos();
- if (is != null) {
- break;
- }
- }
- int length = 0;
- int lastLen = -1;
- if (is != null) {
- stopFlag = false;
- if(DEBUG) Log.d(TAG, "this.downloadFile.getStartPos():" + this.downloadFile.getStartPos() + ":"
- + this.downloadFile.getCompleteSize()+"Thread:"+Thread.currentThread().getName());
- long alreayload = this.downloadFile.getStartPos() + this.downloadFile.getCompleteSize();
- this.randomFile.seek(alreayload);
- byte[] by = new byte[1024 * 64];
- Dao.getInstance(mContext).updataInfos(this.downloadFile.getCurrentThread(),
- this.downloadFile.getCompleteSize(), this.downloadFile.getUrl(), true);
- int count = 0;
- while (!stopFlag && (length = is.read(by, 0, by.length)) > 0) {
-
- downloadFile.setIsStart(true);
- this.randomFile.write(by, 0, length);
- int n=64*1024/length;
- downloadFile.setCompleteSize(downloadFile.getCompleteSize() + length);
- if(stopFlag)
- break;
- if (lastLen != 0 && (count++) % (16*n) == 0) {
- mDownloadSize.updateSize(lastLen);
- lastLen = 0;
- }
- lastLen += length;
- if (false) {
- Log.d(TAG, "download fileSize:" + lastLen + " threadId"
- + this.downloadFile.getCurrentThread());
- }
- }
- Dao.getInstance(mContext).updataInfos(this.downloadFile.getCurrentThread(),
- this.downloadFile.getCompleteSize(), this.downloadFile.getUrl(), false);
- is.close();
- is = null;
- downloadFile.setIsStart(false);
- // this.randomFile.close();
- // this.downloadFile.closeHttpConn();
- if (DEBUG)
- Log.d(TAG, "execute Ok Delete" + state + "Thread:" + Thread.currentThread().getName()
- + " state:" + state);
-
- }
- }catch (IOException ex) {
- // handler.sendEmptyMessage(MSG_DOWNLOAD_ERROR);
- isExceptionOccur = true;
- ex.printStackTrace();
- if (DEBUG)
- Log.d(TAG, "download file err...." + this.downloadFile + " " + ex.fillInStackTrace());
- } catch (Exception e) {
- e.printStackTrace();
- isExceptionOccur = true;
- if (DEBUG)
- Log.d(TAG, "download err...." + this.downloadFile + " " + e.fillInStackTrace());
- } finally {
-
- if(DEBUG) Log.d(TAG,"finally"+Thread.currentThread().getName()+"stopFlag="+stopFlag);
- if (this.downloadFile.getCompleteSize()+this.downloadFile.getStartPos()==this.downloadFile.getEndPos()) {
- if(DEBUG) Log.d(TAG,"delete~!"+Thread.currentThread().getName());
- Dao.getInstance(mContext).delete(downloadFile.getUrl(), downloadFile.getCurrentThread());
- } else {
- Dao.getInstance(mContext).updataInfos(this.downloadFile.getCurrentThread(),
- this.downloadFile.getCompleteSize(), this.downloadFile.getUrl(), false);
- }
-
- try {
- this.randomFile.close();
- this.downloadFile.closeHttpConn();
- this.countDownLatch.countDown();
- synchronized(workers){
- workers.remove(this);
- }
- } catch (Exception exp) {
- exp.printStackTrace();
- }
-
- }
- // }
- }
- }
-
- public void delete(String urlstr) {
- Dao.getInstance(mContext).delete(urlstr);
- }
-
- public synchronized void pause() {
- state = PAUSE;
- synchronized(workers){
- for (SaveFileThread t : workers) {
- if(!t.stopFlag){
- t.stopSave();
- t.downloadFile.closeHttpConn();
- }
- }
- }
- }
-
- void reset() {
- state = INIT;
- }
-
- public synchronized void resume() {
- state = DOWNLOADING;
- }
-
- public synchronized void stop() {
- state = PAUSE;
- if (service != null && !service.isShutdown()) {
- service.shutdown();
- }
- }
-}
-PK
-
+
+
+
+*
+
@@ -3733,349 +913,15 @@ PK
SourceFile
-
+
-:
-
-
-
-
- * Description: For varify MD5 values of Download File
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-package com.amlogic.update.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import android.R.string;
-import android.util.Log;
-
-public class MD5 {
- static String TAG = "MD5";
-
- private static String createMd5(File file) {
- MessageDigest mMDigest;
- FileInputStream Input = null;
- byte buffer[] = new byte[1024];
- int len;
- if (!file.exists())
- return null;
- try {
- mMDigest = MessageDigest.getInstance("MD5");
- Input = new FileInputStream(file);
- while ((len = Input.read(buffer, 0, 1024)) != -1) {
- mMDigest.update(buffer, 0, len);
- }
- Input.close();
- Input=null;
- } catch (NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- try {
- Input.close();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- return null;
- }
- BigInteger mBInteger = new BigInteger(1, mMDigest.digest());
- Log.v(TAG, "create_MD5=" + mBInteger.toString(16));
- return mBInteger.toString(16);
-
- }
- public static boolean checkMd5(String Md5,File file){
- String str = createMd5(file);
- String mServMd5 = (new BigInteger(Md5,16)).toString(16);
- if(mServMd5.equalsIgnoreCase(str)){
- Log.d(TAG,"md5sum = " + str+"Md5="+Md5);
- return true;
- }else{
- Log.d(TAG," not equals md5sum = " + str+"Md5="+Md5);
- return false;
- }
- }
- public static boolean checkMd5(String Md5, String strfile) {
-
- File file = new File(strfile);
- return checkMd5(Md5,file);
- }
- public static boolean checkMd5Files(File file1,File file2){
- String str1 = createMd5(file1);
- String str2 = createMd5(file2);
- if(str1.equalsIgnoreCase(str2)){
- Log.d(TAG,"copy varify md5sum = " + str1+"Md5="+str2);
- return true;
- }else{
- Log.d(TAG," copy varify not equals md5sum = " + str1+"Md5="+str2);
- return false;
- }
- }
- public static void main(String args[]){
- String Md5 = "003ad4693194e5012f03f33606220d80";
- String servMd5 = "3ad4693194e5012f03f33606220d80";
- BigInteger mBInteger = new BigInteger(Md5,16);
- System.out.println("BInteger="+(new BigInteger(Md5,16)).toString(16));
- BigInteger mServ = new BigInteger(servMd5,16);
- System.out.println("servMd5="+mServ+"?"+(servMd5.equals(mBInteger.toString(16))));
- }
-}
-PK
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-moveToNext
-resetInfos
-
-SourceFile
-
-
-*
-
-
-
-
-
-
-
-
-,
-
-
-
-
-
-
-
-
-
-* Description:
-* @Copyright: Copyright (c) 2012
-* @Company: Amlogic
-* @author:
-* @version: 1.0
-* @time: 2013-2-17
-*/
-
-package com.amlogic.update.util;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-class Dao {
-
- private static Dao dao=null;
- private Context context;
- private Dao(Context context) {
- this.context=context;
- }
- static Dao getInstance(Context context){
- if(dao==null){
- dao=new Dao(context);
- }
- return dao;
- }
-
- SQLiteDatabase getConnection() {
- SQLiteDatabase sqliteDatabase = null;
- try {
- sqliteDatabase= new DatabaseHelper(context).getReadableDatabase();
- } catch (Exception e) {
- }
- return sqliteDatabase;
- }
-
- /**
- *
- */
- synchronized boolean isHasInfors(String urlstr) {
- SQLiteDatabase database = getConnection();
- int count = -1;
- Cursor cursor = null;
- try {
- String sql = "select count(*) from "+DatabaseHelper.DOWNLOADINGRECORD+" where url=?";
- cursor = database.rawQuery(sql, new String[] { urlstr });
- if (cursor.moveToFirst()) {
- count = cursor.getInt(0);
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- if (null != cursor) {
- cursor.close();
- }
- }
- return count == 0;
- }
-
- /**
- *
- */
- synchronized void saveInfos(List<DownloadFile> infos) {
- //init
- SQLiteDatabase database = getConnection();
- try {
- for (DownloadFile info : infos) {
- String sql = "insert into "+DatabaseHelper.DOWNLOADINGRECORD+"(thread_id,start_pos, end_pos,compelete_size,url,is_start) values (?,?,?,?,?,?)";
- Object[] bindArgs = {info.getCurrentThread(),info.getStartPos(),info.getEndPos(),info.getCompleteSize(),info.getUrl(),0};
- database.execSQL(sql, bindArgs);
- }
- } catch (Exception e) {
- //e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
-
- /**
- *
- */
- synchronized List<DownloadFile> getInfos(String urlstr) {
- List<DownloadFile> list = new ArrayList<DownloadFile>();
- SQLiteDatabase database = getConnection();
- Cursor cursor = null;
- try {
- String sql = "select thread_id, start_pos, end_pos,compelete_size,url,is_start from "+DatabaseHelper.DOWNLOADINGRECORD+" where url=?";
- cursor = database.rawQuery(sql, new String[] { urlstr });
- while (cursor.moveToNext()) {
- int complete_size = cursor.getInt(3);
- int download_startpos = cursor.getInt(1);
- int download_endpos = cursor.getInt(2);
- boolean download_start = (cursor.getInt(4)==1?true:false);
- DownloadFile info = new DownloadFile(cursor.getInt(0),
- download_startpos, download_endpos, complete_size,
- cursor.getString(4),download_start);
- list.add(info);
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- if (null != cursor) {
- cursor.close();
- }
- }
- return list;
- }
-
- /**
- *
- */
- synchronized void updataInfos(int threadId, int compeleteSize, String urlstr, boolean isStart) {
- SQLiteDatabase database = getConnection();
- int start = (isStart?1:0);
- try {
- String sql = "update "+DatabaseHelper.DOWNLOADINGRECORD+" set compelete_size=?,is_start=? where url=? and thread_id=?";
- Object[] bindArgs = { compeleteSize,start,urlstr,threadId};
- database.execSQL(sql, bindArgs);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
-
- /**
- *
- */
- synchronized void resetInfos() {
- SQLiteDatabase database = getConnection();
- try {
- String sql = "update "+DatabaseHelper.DOWNLOADINGRECORD+" set is_start=?";
- Object[] bindArgs = {0};
- database.execSQL(sql, bindArgs);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
- /**
- *
- */
- synchronized void delete(String url) {
- SQLiteDatabase database = getConnection();
- try {
- database.delete(DatabaseHelper.DOWNLOADINGRECORD, "url=?", new String[] { url });
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
-
- synchronized void delete(String url,int threadId) {
- SQLiteDatabase database = getConnection();
- try {
- database.delete(DatabaseHelper.DOWNLOADINGRECORD, "url=?", new String[] { url });
- String sql = "delete from "+DatabaseHelper.DOWNLOADINGRECORD+" where thread_id=? and url=?";
- Object[] bindArgs = { threadId, url };
- database.execSQL(sql, bindArgs);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
-}
-PK
-
+:
+
+
+
+
+
@@ -4085,57 +931,58 @@ PK
SourceFile
-
-*
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import android.util.Log;
-
-public class UpdatePositionStage {
- //for <n use data;
- private static final String KK_MEDIA="/cache/";
- //private static final String N_MEDIA="/storage/emulated/0";
- private static final String N_MEDIA="/data/droidota";
- private static final String N_MEDIA_RECOVERY="/data/media/0";
- public final static int M400ZIE = 460 * 1024 * 1024;
- static public boolean isBigFile(File file){
- if(file==null||!file.exists()){
- return false;
- }else{
- try {
- FileInputStream fin=new FileInputStream(file);
- long value = fin.available();
- fin.close();
- return value>M400ZIE;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return false;
- }
- }
- }
- static public String getDefaultPostion(){
- String sdkStr = UpgradeInfo.getString("ro.build.version.sdk");
- int sdkInt = Integer.parseInt(sdkStr);
- if(sdkInt>=24/*for N*/)
- return N_MEDIA;
- else return KK_MEDIA;
- }
-
- /*static public String getRecoveryDir(){
- String sdkStr = UpgradeInfo.getString("ro.build.version.sdk");
- int sdkInt = Integer.parseInt(sdkStr);
- if(sdkInt>=24for N)
- return N_MEDIA_RECOVERY;
- else return KK_MEDIA;
- }*/
-}
-PK
-
+
+*
+
+
+
+
+cleartable
+
+
+
+
+SourceFile
+
+
+*+
+
+
+
+
+
+
+
+
+getcountry
+
+getDefault
+
+getCountry
+
+
+
+
+getMacAddr
+
+getService
+
+
+
+
+
+
+
+
+
+SourceFile
+
+
+
+
+
+
+
Exceptions
@@ -4159,7 +1006,7 @@ CommandRun
-
+
STRING_KEY
@@ -4205,443 +1052,9 @@ CommandRun
-
- * @par Copyright:
- * - Copyright 2012 Amlogic Inc as unpublished work
- * All Rights Reserved
- * - The information contained herein is the confidential property
- * of Amlogic. The use, copying, transfer or disclosure of such information
- * is prohibited except by express written agreement with Amlogic Inc.
- * @author tellen
- * @version 1.0
- * @date 2012/08/16
- * @par function description:
- * - 1 check device is amlogic cpu or not
- * @warning This class may explode in your face.
- * @note If you inherit anything from this class, you're doomed.
- */
-
-package com.amlogic.update.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.Key;
-
-import javax.crypto.Cipher;
-
-import android.util.Log;
-
-public class DesUtils {
- private static final String STRING_KEY = "gjaoun";
- private static final String LOG_TAG = "ChipCheck";
-
- private Cipher encryptCipher = null;
- private Cipher decryptCipher = null;
-
- //amlogic encrypt is 7c0f13b6d5986e65
- //AMLOGIC eccrypt is a6f8b4b74ed1ed75
- public static boolean isAmlogicChip() {
- // following code check if chip is amlogic
- String cupinfo = "7c0f13b6d5986e65";
- try {
- DesUtils des = new DesUtils(STRING_KEY);
- //Log.i(LOG_TAG, "encrypt amlogic: " + des.encrypt("AMLOGIC"));
- if (des.decrypt(GetCpuInfo(des)).indexOf(des.decrypt(cupinfo)) != -1) {
- Log.i(LOG_TAG, "matched cpu ");
- return true;
- } else {
- Log.e(LOG_TAG, " Sorry! Your cpu is not Amlogic,u can't run");
- return false;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return false;
- }
-
- static String byteArr2HexStr(byte[] arrB) throws Exception {
- int iLen = arrB.length;
- StringBuffer sb = new StringBuffer(iLen * 2);
-
- for (int i = 0; i < iLen; i++) {
- int intTmp = arrB[i];
- while (intTmp < 0) {
- intTmp = intTmp + 256;
- }
- if (intTmp < 16) {
- sb.append("0");
- }
-
- sb.append(Integer.toString(intTmp, 16));
- }
- return sb.toString();
- }
-
- static byte[] hexStr2ByteArr(String strIn) throws Exception {
- byte[] arrB = strIn.getBytes();
- int iLen = arrB.length;
- byte[] arrOut = new byte[iLen / 2];
-
- for (int i = 0; i < iLen; i = i + 2) {
- String strTmp = new String(arrB, i, 2);
- arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
- }
- return arrOut;
- }
-
- DesUtils() throws Exception {
- this(STRING_KEY);
- }
-
- DesUtils(String strKey) throws Exception {
- // Security.addProvider(new com.sun.crypto.provider.SunJCE());
- Key key = getKey(strKey.getBytes());
- encryptCipher = Cipher.getInstance("DES");
- encryptCipher.init(Cipher.ENCRYPT_MODE, key);
-
- decryptCipher = Cipher.getInstance("DES");
- decryptCipher.init(Cipher.DECRYPT_MODE, key);
- }
-
- byte[] encrypt(byte[] arrB) throws Exception {
- return encryptCipher.doFinal(arrB);
- }
-
- String encrypt(String strIn) throws Exception {
- return byteArr2HexStr(encrypt(strIn.getBytes()));
- }
-
- byte[] decrypt(byte[] arrB) throws Exception {
- return decryptCipher.doFinal(arrB);
- }
-
- String decrypt(String strIn) throws Exception {
- return new String(decrypt(hexStr2ByteArr(strIn)));
- }
-
- private Key getKey(byte[] arrBTmp) throws Exception {
- byte[] arrB = new byte[8];
- for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
- arrB[i] = arrBTmp[i];
- }
-
- Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES");
- return key;
- }
-
- // get cpu info
- static String GetCpuInfo(DesUtils des) {
- String result = null;
- CommandRun cmdexe = new CommandRun();
- try {
- String[] args = { "/system/bin/cat", "/proc/cpuinfo" };
- result = cmdexe.run(args, "/system/bin/");
- result = result.toLowerCase();
- try {
- result = des.encrypt(result);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // Log.i(LOG_TAG, result);
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return result;
- }
-
- static class CommandRun {
- public synchronized String run(String[] cmd, String workdirectory)
- throws IOException {
- String result = "";
- try {
- ProcessBuilder builder = new ProcessBuilder(cmd);
- InputStream in = null;
-
- if (workdirectory != null) {
- builder.directory(new File(workdirectory));
- builder.redirectErrorStream(true);
- Process process = builder.start();
- in = process.getInputStream();
- byte[] re = new byte[1024];
- while (in.read(re) != -1)
- // Log.i(LOG_TAG, new String(re));
- result = result + new String(re);
- }
-
- if (in != null) {
- in.close();
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return result;
- }
- }
-}
-PK
-
-
-
-getcountry
-
-getDefault
-
-getCountry
-
-
-
-
-getMacAddr
-
-getService
-
-
-
-
-
-
-
-
-
-SourceFile
-
-
-
-
-
-
-
- * @Package com.amlogic.update
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
-package com.amlogic.update.util;
-
-import android.app.ActivityManagerNative;
-import android.content.Context;
-import android.net.InterfaceConfiguration;
-import android.os.IBinder;
-import android.os.INetworkManagementService;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemProperties;
-
-/**
- * @ClassName UpgradeInfo
- * @Description TODO
- * @Date 2013-7-15
- * @Email
- * @Author
- * @Version V1.0
- */
-public class UpgradeInfo {
- /*
- * 1---ro.product.otaupdateurl should be defined for different server target
- * url ex:http://10.18.19.10:8080/otaupdate/update 1---ro.product.firmware
- * should auto-increasing according to specified specification
- */
- static final String UNKNOWN = "unknown";
- public static String postUrl; // ro.product.otaupdateurl
- public static String updating_apk_version; // = "1";
- public static String brand; // = "MID";
- public static String device; // = "g24ref";
- public static String board; // = "g24ref";
- public static String mac; // =
- // "00.11.22.33.44.55";
- public static String firmware /* = "00421001" */;
- public static String android; // = "4.2.1";
- public static String time; // =
- // "20120301.092251";
- public static String builder;
- public static String fingerprint;
- public static String country;
- private Context mContext;
-
- public UpgradeInfo(Context mContext) {
- this.mContext = mContext;
- onInit();
- }
-
- private void getcountry() {
- try {
- country = ActivityManagerNative.getDefault().getConfiguration().locale
- .getCountry();
- } catch (RemoteException e) {
- }
- }
-
- static String makePostString() {
- return null;
- }
-
- public static String getString(String property) {
- return SystemProperties.get(property, UNKNOWN);
- }
- public static boolean isDebugAble(){
- String debug = getString("rw.update.debug");
- if(debug.equals(true)){
- return true;
- }
- return false;
- }
- private String getMacAddr() {
- IBinder b = ServiceManager
- .getService(Context.NETWORKMANAGEMENT_SERVICE);
- INetworkManagementService networkManagement = INetworkManagementService.Stub
- .asInterface(b);
- if (networkManagement != null) {
- InterfaceConfiguration iconfig = null;
- try {
- iconfig = networkManagement.getInterfaceConfig("eth0");
- } catch (Exception e) {
- // e.printStackTrace();
- } finally {
- return "";
- }
- } else {
- return "";
- }
- }
-
- private String getVersionCode() {
- String packageName = mContext.getPackageName();
- int versionCode = 0;
- try {
- versionCode = mContext.getPackageManager().getPackageInfo(
- packageName, 0).versionCode;
- } catch (Exception e) {
- }
- return String.valueOf(versionCode);
- }
-
- private void onInit() {
- getcountry();
- updating_apk_version = getVersionCode();
- brand = getString("ro.product.brand");
- device = getString("ro.product.device");
- board = getString("ro.product.board");
- mac = getMacAddr();
- postUrl = getString("ro.product.otaupdateurl");
- firmware = getString("ro.product.firmware");
- android = getString("ro.build.version.release");
- time = getString("ro.build.date.utc");
- builder = getString("ro.build.user");
- fingerprint = getString("ro.build.fingerprint");
- }
-
-}
-PK
-
-
-
-
-cleartable
-
-
-
-
-SourceFile
-
-
-*+
-
-
-
-
-
-
- * Description:
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
-
-package com.amlogic.update.util;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-import java.util.List;
-
-class DatabaseHelper extends SQLiteOpenHelper {
-
- static final String DOWNTASKTABLE = "download_task";
- static final String DOWNLOADINGRECORD = "record_task";
-
- /**
- * @param context
- * @param name
- * @param version
- */
- DatabaseHelper(Context context, String name, int version) {
- super(context, name, null, version);
- }
-
- /**
- * @param context
- * @param name
- * @param version
- */
- DatabaseHelper(Context context) {
- super(context, "download.db", null, VERSION);
- }
-
- private static final int VERSION = 1;
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL("create table " + DOWNTASKTABLE
- + "(_id integer PRIMARY KEY AUTOINCREMENT, file_name char, "
- + "file_location char,file_md5 char,url char)");
- db.execSQL("create table "
- + DOWNLOADINGRECORD
- + "(_id integer PRIMARY KEY AUTOINCREMENT, thread_id integer, "
- + "start_pos integer, end_pos integer, compelete_size integer,url char,is_start integer)");
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
- }
-
- DatabaseHelper(Context context, String name) {
- this(context, name, VERSION);
- }
-
- void cleartable(String name) {
- SQLiteDatabase database = getWritableDatabase();
- try {
- database.delete(name, "_id>=?", new String[] { "0" });
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (null != database) {
- database.close();
- }
- }
- }
-
-}PK
-
-
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="lib" path="E:/Project/android-sdk_r24.3.3-windows/android-sdk-windows/platforms/android-19/android.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
-PK
-
+
<projectDescription>
- <name>updateL</name>
+ <name>updateJar</name>
<comment></comment>
<projects>
</projects>
@@ -4656,96 +1069,71 @@ PK
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-PK
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+PK
+
+
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="lib" path="E:/Project/android-sdk_r24.3.3-windows/android-sdk-windows/platforms/android-19/androidInner.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
+PK
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-p<
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
-
+
-
+
-
+
-
+
-
-
+
-
+
+
diff --git a/res/drawable/progressbar_horizontal_1.xml b/res/drawable/progressbar_horizontal_1.xml
index 8ea06c8..8d78887 100644
--- a/res/drawable/progressbar_horizontal_1.xml
+++ b/res/drawable/progressbar_horizontal_1.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
@@ -45,4 +58,4 @@
</clip>
</item>
-</layer-list> \ No newline at end of file
+</layer-list>
diff --git a/res/layout-hdpi/main_view.xml b/res/layout-hdpi/main_view.xml
index e9df47a..bb55c0e 100644
--- a/res/layout-hdpi/main_view.xml
+++ b/res/layout-hdpi/main_view.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
diff --git a/res/layout-xhdpi/main_view.xml b/res/layout-xhdpi/main_view.xml
index 0799066..de9379c 100644
--- a/res/layout-xhdpi/main_view.xml
+++ b/res/layout-xhdpi/main_view.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
diff --git a/res/layout/downloading_process.xml b/res/layout/downloading_process.xml
index 9a2888a..55f988e 100644
--- a/res/layout/downloading_process.xml
+++ b/res/layout/downloading_process.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:orientation="vertical"
diff --git a/res/layout/file_list.xml b/res/layout/file_list.xml
index 7d0d94e..3234e9e 100755..100644
--- a/res/layout/file_list.xml
+++ b/res/layout/file_list.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -13,4 +27,4 @@
android:layout_alignParentTop="true" >
</ListView>
-</RelativeLayout> \ No newline at end of file
+</RelativeLayout>
diff --git a/res/layout/install_ota.xml b/res/layout/install_ota.xml
index 9124b01..3f920b5 100644
--- a/res/layout/install_ota.xml
+++ b/res/layout/install_ota.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<com.droidlogic.otaupgrade.InstallPackage xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="@dimen/dialog_size"
diff --git a/res/layout/large_text.xml b/res/layout/large_text.xml
index a34d5a1..7174485 100755..100644
--- a/res/layout/large_text.xml
+++ b/res/layout/large_text.xml
@@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
- <TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="@dimen/text_titile_size"/> \ No newline at end of file
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="@dimen/text_titile_size"/>
diff --git a/res/layout/main_view.xml b/res/layout/main_view.xml
index c973158..b618561 100644
--- a/res/layout/main_view.xml
+++ b/res/layout/main_view.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@@ -242,4 +256,4 @@
android:background="@color/blue" />
</LinearLayout>
-</RelativeLayout> \ No newline at end of file
+</RelativeLayout>
diff --git a/res/layout/medium_text.xml b/res/layout/medium_text.xml
index 6e3bb55..6a775e4 100644
--- a/res/layout/medium_text.xml
+++ b/res/layout/medium_text.xml
@@ -1,7 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="@dimen/text_size">
-</TextView> \ No newline at end of file
+</TextView>
diff --git a/res/layout/mid.xml b/res/layout/mid.xml
index e309c59..57e03c9 100755..100644
--- a/res/layout/mid.xml
+++ b/res/layout/mid.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -7,29 +21,6 @@
android:paddingRight="@dimen/padding_dialog"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
-
- <!--<RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="30dip"
- android:paddingTop="10dip" >
-
- <ImageView
- android:id="@+id/dialog_title_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:background="@drawable/dialog_title_image" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:layout_marginLeft="10dip"
- android:layout_toRightOf="@id/dialog_title_image"
- android:text="@string/warnning_title"/>
- </RelativeLayout>-->
-
<View
android:layout_width="match_parent"
android:layout_height="20dp"
@@ -70,4 +61,4 @@
android:text="@string/sure" />
</RelativeLayout>
-</LinearLayout> \ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/update_checking.xml b/res/layout/update_checking.xml
index 194abac..0a02606 100755..100644
--- a/res/layout/update_checking.xml
+++ b/res/layout/update_checking.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@@ -30,4 +44,4 @@
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp" />
-</RelativeLayout> \ No newline at end of file
+</RelativeLayout>
diff --git a/res/layout/update_download.xml b/res/layout/update_download.xml
index fcb9b4b..962d4bc 100755..100644
--- a/res/layout/update_download.xml
+++ b/res/layout/update_download.xml
@@ -1,4 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@@ -65,4 +78,4 @@
android:layout_centerHorizontal="true"
android:visibility="gone" />
-</RelativeLayout> \ No newline at end of file
+</RelativeLayout>
diff --git a/res/menu/main.xml b/res/menu/main.xml
index 22cdebe..9ae4d75 100755..100644
--- a/res/menu/main.xml
+++ b/res/menu/main.xml
@@ -1,3 +1,17 @@
+<!-- Copyright (C) 2012 Amlogic, Inc
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
diff --git a/res/values/color.xml b/res/values/color.xml
index 6371ca9..32eda99 100644
--- a/res/values/color.xml
+++ b/res/values/color.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<resources>
<color name="white" >#FFFFFF</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index 8e6ce94..8e6ce94 100755..100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 94c9ed8..ef7edd3 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
+<!-- Copyright (C) 2012 Amlogic, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5bd9bed..a7e73d7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,3 +1,17 @@
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<resources>
<string name="app_name">UPDATE&amp;BACKUP</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 7f25762..27d36c3 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -1,4 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 Amlogic, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
@@ -39,4 +53,4 @@
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
-</resources> \ No newline at end of file
+</resources>
diff --git a/src/com/droidlogic/otaupgrade/ABCheckUpService.java b/src/com/droidlogic/otaupgrade/ABCheckUpService.java
index 107e0d0..635a11c 100644
--- a/src/com/droidlogic/otaupgrade/ABCheckUpService.java
+++ b/src/com/droidlogic/otaupgrade/ABCheckUpService.java
@@ -1,3 +1,20 @@
+/******************************************************************
+*
+*Copyright (C) 2016 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
+
package com.droidlogic.otaupgrade;
import java.io.BufferedReader;
diff --git a/src/com/droidlogic/otaupgrade/BackupActivity.java b/src/com/droidlogic/otaupgrade/BackupActivity.java
index 6c22e24..0ad2d4e 100644
--- a/src/com/droidlogic/otaupgrade/BackupActivity.java
+++ b/src/com/droidlogic/otaupgrade/BackupActivity.java
@@ -1,195 +1,188 @@
-/**
- * @Package com.amlogic.otauicase
- * @Description
- *
- * Copyright (c) Inspur Group Co., Ltd. Unpublished
- *
- * Inspur Group Co., Ltd.
- * Proprietary & Confidential
- *
- * This source code and the algorithms implemented therein constitute
- * confidential information and may comprise trade secrets of Inspur
- * or its associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which this
- * source code was originally received.
- */
-package com.droidlogic.otaupgrade;
-
-import android.app.Activity;
-
-import android.content.Intent;
-import android.os.Handler;
-import android.os.Bundle;
-import android.os.Environment;
-import android.widget.Toast;
-import com.amlogic.update.Backup;
-import com.amlogic.update.Backup.IBackupConfirmListener;
-import java.io.File;
-
-
-/**
- * @ClassName BackupActivity
- * @Description TODO
- * @Date 2013-7-16
- * @Email
- * @Author
- * @Version V1.0
- */
-public class BackupActivity extends Activity implements IBackupConfirmListener{
+/******************************************************************
+*
+*Copyright (C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
+package com.droidlogic.otaupgrade;
+
+import android.app.Activity;
+
+import android.content.Intent;
+import android.os.Handler;
+import android.os.Bundle;
+import android.os.Environment;
+import android.widget.Toast;
+import com.amlogic.update.Backup;
+import com.amlogic.update.Backup.IBackupConfirmListener;
+import java.io.File;
+
+
+public class BackupActivity extends Activity implements IBackupConfirmListener{
public static String BACKUP_FILE = "/data/data/com.droidlogic.otaupgrade/BACKUP";
-
- public static final String SdcardDir = "/storage/external_storage/sdcard1/";
- public static final int FUNCBACKUP = 1;
- public static final int FUNCRESTORE = 2;
- public static int func = 0;
- public Handler mHandler;
-
- /*private static void getBackUpFileName() {
- File devDir = new File(PrefUtils.DEV_PATH);
- File[] devs = devDir.listFiles();
-
- for (File dev : devs) {
- if (dev.isDirectory() && dev.canWrite()) {
- BACKUP_FILE = dev.getAbsolutePath();
- BACKUP_FILE += "/BACKUP";
-
- break;
- }
- }
- }*/
-
- @Override
- protected void onCreate(Bundle icicle) {
+
+ public static final String SdcardDir = "/storage/external_storage/sdcard1/";
+ public static final int FUNCBACKUP = 1;
+ public static final int FUNCRESTORE = 2;
+ public static int func = 0;
+ public Handler mHandler;
+
+ /*private static void getBackUpFileName() {
+ File devDir = new File(PrefUtils.DEV_PATH);
+ File[] devs = devDir.listFiles();
+
+ for (File dev : devs) {
+ if (dev.isDirectory() && dev.canWrite()) {
+ BACKUP_FILE = dev.getAbsolutePath();
+ BACKUP_FILE += "/BACKUP";
+
+ break;
+ }
+ }
+ }*/
+
+ @Override
+ protected void onCreate(Bundle icicle) {
//getBackUpFileName();
-
- super.onCreate(icicle);
- mHandler = new Handler();
- boolean flag = false;
- String act = getIntent().getAction();
-
- if (act.equals(LoaderReceiver.BACKUPDATA)) {
- func = FUNCBACKUP;
-
- if (!OnSDcardStatus()) {
- flag = true;
-
- Intent intent0 = new Intent(this, BadMovedSDcard.class);
- Activity activity = (Activity) this;
- startActivityForResult(intent0, 1);
- } else {
- Backup();
- }
- } else if (act.equals(LoaderReceiver.RESTOREDATA)) {
- func = FUNCRESTORE;
-
- if (!OnSDcardStatus()) {
- flag = true;
-
- Intent intent0 = new Intent(this, BadMovedSDcard.class);
- Activity activity = (Activity) this;
- startActivityForResult(intent0, 1);
- } else {
- if (!new File(BACKUP_FILE).exists()) {
- Toast.makeText ( BackupActivity.this.getApplicationContext(), getString ( R.string.prepare_waitting ), 5000 )
- .show();
- }
- Restore();
- }
- }
-
- if (!flag) {
- Intent intent = new Intent();
- setResult(1, intent);
- finish();
- }
- }
- public void onBackupComplete() {
- if ( android.os.Build.VERSION.SDK_INT > 20 ) {
- if (mHandler != null) {
- mHandler.post(new Runnable(){
- public void run(){
- Toast.makeText ( BackupActivity.this.getApplicationContext(), getString ( R.string.remove_hit ), 5000 )
- .show();
- }
- });
- }
- PrefUtils util = new PrefUtils(this);
- util.copyBKFile();
- }
- Intent intent = new Intent ( MainActivity.RESULT_BACKUP );
- intent.setClass ( this, MainActivity.class );
- startActivity ( intent );
- }
-
- public void onRestoreComplete() {
- Intent intent = new Intent ( MainActivity.RESULT_RESTORE );
- intent.setClass ( this, MainActivity.class );
- startActivity ( intent );
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- if ((data != null) && (requestCode == 1)) {
- if (resultCode == BadMovedSDcard.SDCANCEL) {
- this.finish();
- } else if (resultCode == BadMovedSDcard.SDOK) {
- if (func == FUNCBACKUP) {
- Backup();
- } else {
- Restore();
- }
-
- Intent intent = new Intent();
- setResult(1, intent);
- finish();
- }
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- }
-
- private boolean OnSDcardStatus() {
- File file = new File(BACKUP_FILE);
-
- return file.getParentFile().canWrite();
-
- //return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorage2State());
- }
-
- private void Backup() {
- new Thread() {
- final String[] args = {
- BACKUP_FILE, "backup", "-apk", "-system","-widget","-compress", "-noshared"
- };
-
- public void run() {
- Backup mBackup = new Backup(BackupActivity.this);
- mBackup.setConfirmListener ( BackupActivity.this );
- mBackup.main(args);
- }
- }.start();
- }
-
- private void Restore() {
- new Thread() {
- final String[] args = {
- BACKUP_FILE, "restore", "-apk", "-system","-widget","-compress", "-noshared"
- };
-
- public void run() {
- if (!new File(BACKUP_FILE).exists()) {
- PrefUtils pref = new PrefUtils(BackupActivity.this);
- pref.copyBackup(false);
- }
- Backup mBackup = new Backup(BackupActivity.this);
- mBackup.setConfirmListener ( BackupActivity.this );
- mBackup.main(args);
- }
- }.start();
- }
-}
+
+ super.onCreate(icicle);
+ mHandler = new Handler();
+ boolean flag = false;
+ String act = getIntent().getAction();
+
+ if (act.equals(LoaderReceiver.BACKUPDATA)) {
+ func = FUNCBACKUP;
+
+ if (!OnSDcardStatus()) {
+ flag = true;
+
+ Intent intent0 = new Intent(this, BadMovedSDcard.class);
+ Activity activity = (Activity) this;
+ startActivityForResult(intent0, 1);
+ } else {
+ Backup();
+ }
+ } else if (act.equals(LoaderReceiver.RESTOREDATA)) {
+ func = FUNCRESTORE;
+
+ if (!OnSDcardStatus()) {
+ flag = true;
+
+ Intent intent0 = new Intent(this, BadMovedSDcard.class);
+ Activity activity = (Activity) this;
+ startActivityForResult(intent0, 1);
+ } else {
+ if (!new File(BACKUP_FILE).exists()) {
+ Toast.makeText ( BackupActivity.this.getApplicationContext(), getString ( R.string.prepare_waitting ), 5000 )
+ .show();
+ }
+ Restore();
+ }
+ }
+
+ if (!flag) {
+ Intent intent = new Intent();
+ setResult(1, intent);
+ finish();
+ }
+ }
+ public void onBackupComplete() {
+ if ( android.os.Build.VERSION.SDK_INT > 20 ) {
+ if (mHandler != null) {
+ mHandler.post(new Runnable(){
+ public void run(){
+ Toast.makeText ( BackupActivity.this.getApplicationContext(), getString ( R.string.remove_hit ), 5000 )
+ .show();
+ }
+ });
+ }
+ PrefUtils util = new PrefUtils(this);
+ util.copyBKFile();
+ }
+ Intent intent = new Intent ( MainActivity.RESULT_BACKUP );
+ intent.setClass ( this, MainActivity.class );
+ startActivity ( intent );
+ }
+
+ public void onRestoreComplete() {
+ Intent intent = new Intent ( MainActivity.RESULT_RESTORE );
+ intent.setClass ( this, MainActivity.class );
+ startActivity ( intent );
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ if ((data != null) && (requestCode == 1)) {
+ if (resultCode == BadMovedSDcard.SDCANCEL) {
+ this.finish();
+ } else if (resultCode == BadMovedSDcard.SDOK) {
+ if (func == FUNCBACKUP) {
+ Backup();
+ } else {
+ Restore();
+ }
+
+ Intent intent = new Intent();
+ setResult(1, intent);
+ finish();
+ }
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ private boolean OnSDcardStatus() {
+ File file = new File(BACKUP_FILE);
+
+ return file.getParentFile().canWrite();
+
+ //return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorage2State());
+ }
+
+ private void Backup() {
+ new Thread() {
+ final String[] args = {
+ BACKUP_FILE, "backup", "-apk", "-system","-widget","-compress", "-noshared"
+ };
+
+ public void run() {
+ Backup mBackup = new Backup(BackupActivity.this);
+ mBackup.setConfirmListener ( BackupActivity.this );
+ mBackup.main(args);
+ }
+ }.start();
+ }
+
+ private void Restore() {
+ new Thread() {
+ final String[] args = {
+ BACKUP_FILE, "restore", "-apk", "-system","-widget","-compress", "-noshared"
+ };
+
+ public void run() {
+ if (!new File(BACKUP_FILE).exists()) {
+ PrefUtils pref = new PrefUtils(BackupActivity.this);
+ pref.copyBackup(false);
+ }
+ Backup mBackup = new Backup(BackupActivity.this);
+ mBackup.setConfirmListener ( BackupActivity.this );
+ mBackup.main(args);
+ }
+ }.start();
+ }
+}
diff --git a/src/com/droidlogic/otaupgrade/BadMovedSDcard.java b/src/com/droidlogic/otaupgrade/BadMovedSDcard.java
index e7a5bd3..385cfb2 100644
--- a/src/com/droidlogic/otaupgrade/BadMovedSDcard.java
+++ b/src/com/droidlogic/otaupgrade/BadMovedSDcard.java
@@ -1,9 +1,19 @@
-/**
-* Description:
-* @Copyright: Copyright (c) 2012
-* @Company: Amlogic
-* @version: 1.0
-*/
+/******************************************************************
+*
+*Copyright (C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.app.Activity;
diff --git a/src/com/droidlogic/otaupgrade/FileSelector.java b/src/com/droidlogic/otaupgrade/FileSelector.java
index b43e5f8..e8f72f3 100644
--- a/src/com/droidlogic/otaupgrade/FileSelector.java
+++ b/src/com/droidlogic/otaupgrade/FileSelector.java
@@ -1,13 +1,19 @@
-/**
- * @Package com.amlogic.otauicase
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
+/******************************************************************
+*
+*Copyright (C)2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.app.Activity;
diff --git a/src/com/droidlogic/otaupgrade/InstallPackage.java b/src/com/droidlogic/otaupgrade/InstallPackage.java
index 571d4c8..b28d5b0 100644
--- a/src/com/droidlogic/otaupgrade/InstallPackage.java
+++ b/src/com/droidlogic/otaupgrade/InstallPackage.java
@@ -1,9 +1,19 @@
-/**
-* Description:
-* @Copyright: Copyright (c) 2012
-* @Company: Amlogic
-* @version: 1.0
-*/
+/******************************************************************
+*
+*Copyright(C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.content.Context;
diff --git a/src/com/droidlogic/otaupgrade/LoaderReceiver.java b/src/com/droidlogic/otaupgrade/LoaderReceiver.java
index e49c1bc..62663c1 100644
--- a/src/com/droidlogic/otaupgrade/LoaderReceiver.java
+++ b/src/com/droidlogic/otaupgrade/LoaderReceiver.java
@@ -1,9 +1,19 @@
-/**
- * Description:
- * @Copyright: Copyright (c) 2012
- * @Company: Amlogic
- * @version: 1.0
- */
+/******************************************************************
+*
+*Copyright (C) 2016 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.content.BroadcastReceiver;
diff --git a/src/com/droidlogic/otaupgrade/MainActivity.java b/src/com/droidlogic/otaupgrade/MainActivity.java
index 4e63ced..b5dae44 100644
--- a/src/com/droidlogic/otaupgrade/MainActivity.java
+++ b/src/com/droidlogic/otaupgrade/MainActivity.java
@@ -1,18 +1,19 @@
-/**
- * @Package com.amlogic.otauicase
- * @Description
- *
- * Copyright (c) Inspur Group Co., Ltd. Unpublished
- *
- * Inspur Group Co., Ltd.
- * Proprietary & Confidential
- *
- * This source code and the algorithms implemented therein constitute
- * confidential information and may comprise trade secrets of Inspur
- * or its associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which this
- * source code was originally received.
- */
+/******************************************************************
+*
+*Copyright (C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.app.Activity;
diff --git a/src/com/droidlogic/otaupgrade/PrefUtils.java b/src/com/droidlogic/otaupgrade/PrefUtils.java
index 46a026a..4af3bed 100644
--- a/src/com/droidlogic/otaupgrade/PrefUtils.java
+++ b/src/com/droidlogic/otaupgrade/PrefUtils.java
@@ -1,13 +1,19 @@
-/**
- * @Package com.amlogic.otauicase
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
+/******************************************************************
+*
+*Copyright(C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.content.Context;
diff --git a/src/com/droidlogic/otaupgrade/UpdateActivity.java b/src/com/droidlogic/otaupgrade/UpdateActivity.java
index 6bba832..d160b71 100644
--- a/src/com/droidlogic/otaupgrade/UpdateActivity.java
+++ b/src/com/droidlogic/otaupgrade/UpdateActivity.java
@@ -1,13 +1,19 @@
-/**
- * @Package com.amlogic.otauicase
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
+/******************************************************************
+*
+*Copyright (C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.app.Activity;
diff --git a/src/com/droidlogic/otaupgrade/UpdateEngine.java b/src/com/droidlogic/otaupgrade/UpdateEngine.java
index fe5486f..c7e6828 100644
--- a/src/com/droidlogic/otaupgrade/UpdateEngine.java
+++ b/src/com/droidlogic/otaupgrade/UpdateEngine.java
@@ -1,6 +1,21 @@
+/******************************************************************
+*
+*Copyright (C) 2016 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
-
import android.content.Context;
import android.os.IBinder;
import android.os.Parcel;
@@ -157,4 +172,4 @@ public class UpdateEngine {
}
return REMOTE_EXCEPTION;
}
-} \ No newline at end of file
+}
diff --git a/src/com/droidlogic/otaupgrade/UpdateEngineCallback.java b/src/com/droidlogic/otaupgrade/UpdateEngineCallback.java
index c0721f3..fea3056 100644
--- a/src/com/droidlogic/otaupgrade/UpdateEngineCallback.java
+++ b/src/com/droidlogic/otaupgrade/UpdateEngineCallback.java
@@ -1,3 +1,19 @@
+/******************************************************************
+*
+*Copyright (C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.os.IUpdateEngineCallback;
@@ -130,4 +146,4 @@ public class UpdateEngineCallback extends IUpdateEngineCallback.Stub{
mWindowManager.removeView(rootView);
}
-} \ No newline at end of file
+}
diff --git a/src/com/droidlogic/otaupgrade/UpdateService.java b/src/com/droidlogic/otaupgrade/UpdateService.java
index 05e038b..0a3facc 100644
--- a/src/com/droidlogic/otaupgrade/UpdateService.java
+++ b/src/com/droidlogic/otaupgrade/UpdateService.java
@@ -1,13 +1,19 @@
-/**
- * @Package com.amlogic.otauicase
- * @Description Copyright (c) Inspur Group Co., Ltd. Unpublished Inspur Group
- * Co., Ltd. Proprietary & Confidential This source code and the
- * algorithms implemented therein constitute confidential
- * information and may comprise trade secrets of Inspur or its
- * associates, and any use thereof is subject to the terms and
- * conditions of the Non-Disclosure Agreement pursuant to which
- * this source code was originally received.
- */
+/******************************************************************
+*
+*Copyright (C) 2012 Amlogic, Inc.
+*
+*Licensed under the Apache License, Version 2.0 (the "License");
+*you may not use this file except in compliance with the License.
+*You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*Unless required by applicable law or agreed to in writing, software
+*distributed under the License is distributed on an "AS IS" BASIS,
+*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*See the License for the specific language governing permissions and
+*limitations under the License.
+******************************************************************/
package com.droidlogic.otaupgrade;
import android.app.Notification;