Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove artifacts of install over network code

  • Loading branch information...
commit ca52f261f08606cc6dbe610cd39fbdc2ab04f55a 1 parent a575e9f
@daleharvey daleharvey authored
View
6 src/com/couchbase/libcouch/CouchDB.java
@@ -9,7 +9,6 @@
public class CouchDB {
- private static String releaseUrl;
private static String releaseName;
private static ICouchService couchService;
@@ -23,7 +22,7 @@
public void onServiceConnected(ComponentName className, final IBinder service) {
try {
couchService = ICouchService.Stub.asInterface(service);
- couchService.initCouchDB(couchClient, releaseUrl, releaseName);
+ couchService.initCouchDB(couchClient, releaseName);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -36,8 +35,7 @@ public void onServiceDisconnected(ComponentName className) {
}
};
- public static ServiceConnection getService(Context ctx, String url, String release, ICouchClient client) {
- releaseUrl = url;
+ public static ServiceConnection getService(Context ctx, String release, ICouchClient client) {
releaseName = release;
couchClient = client;
ctx.bindService(new Intent(ctx, CouchService.class), mConnection, Context.BIND_AUTO_CREATE);
View
47 src/com/couchbase/libcouch/CouchInstaller.java
@@ -15,13 +15,6 @@
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.utils.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
-
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
@@ -43,7 +36,7 @@ public static String indexFile() {
return dataPath() + "/installedfiles.index";
}
- public static void doInstall(String url, String pkg, Handler handler, CouchService service)
+ public static void doInstall(String pkg, Handler handler, CouchService service)
throws IOException {
if(!checkInstalled(pkg)) {
@@ -68,7 +61,7 @@ public static void doInstall(String url, String pkg, Handler handler, CouchServi
deleteDirectory(erlangDir);
}
- installPackage(url, pkg, handler, service);
+ installPackage(pkg, handler, service);
}
Message done = Message.obtain();
@@ -79,7 +72,7 @@ public static void doInstall(String url, String pkg, Handler handler, CouchServi
/*
* This fetches a given package from amazon and tarbombs it to the filsystem
*/
- private static void installPackage(String baseUrl, String pkg, Handler handler, CouchService service)
+ private static void installPackage(String pkg, Handler handler, CouchService service)
throws IOException {
Log.v(TAG, "Installing " + pkg);
@@ -91,33 +84,11 @@ private static void installPackage(String baseUrl, String pkg, Handler handler,
Map<String, String> allInstalledFileTypes = new HashMap<String, String>();
Map<String, String> allInstalledLinks = new HashMap<String, String>();
- InputStream instream = null;
-
- // If no URL is provided, load tarball from assets.
- if (baseUrl == null) {
- // XXX Stupid android 2.1 bug
- // XXX Cannot load compressed assets >1M and
- // XXX most files are automatically compressed,
- // XXX Certain files are NOT auto compressed (eg. jpg).
- instream = service.getAssets().open(pkg + ".tgz" + ".jpg");
- }
-
- else {
- HttpClient pkgHttpClient = new DefaultHttpClient();
- HttpGet tgzrequest = new HttpGet(baseUrl + pkg + ".tgz");
- HttpResponse response = pkgHttpClient.execute(tgzrequest);
- StatusLine status = response.getStatusLine();
- Log.d(TAG, "Request returned status " + status);
-
- if (status.getStatusCode() == 200) {
- HttpEntity entity = response.getEntity();
- instream = entity.getContent();
- }
-
- else {
- throw new IOException();
- }
- }
+ // XXX Stupid android 2.1 bug
+ // XXX Cannot load compressed assets >1M and
+ // XXX most files are automatically compressed,
+ // XXX Certain files are NOT auto compressed (eg. jpg).
+ InputStream instream = service.getAssets().open(pkg + ".tgz" + ".jpg");
// Ensure /sdcard/Android/data/com.my.app/db exists
File externalPath = new File(externalPath() + "/db/");
@@ -129,7 +100,6 @@ private static void installPackage(String baseUrl, String pkg, Handler handler,
new GZIPInputStream(instream));
TarArchiveEntry e = null;
- int files = 0;
float filesInArchive = 0;
float filesUnpacked = 0;
@@ -183,7 +153,6 @@ private static void installPackage(String baseUrl, String pkg, Handler handler,
Runtime.getRuntime().exec("chmod 755 " + fullName);
// This tells the ui how much progress has been made
- files++;
Message progress = new Message();
progress.arg1 = (int) ++filesUnpacked;
progress.arg2 = (int) filesInArchive;
View
8 src/com/couchbase/libcouch/CouchService.java
@@ -90,10 +90,10 @@ public IBinder onBind(Intent intent) {
public class CouchServiceImpl extends ICouchService.Stub {
@Override
- public void initCouchDB(ICouchClient cb, final String url, final String pkg) throws RemoteException {
+ public void initCouchDB(ICouchClient cb, final String pkg) throws RemoteException {
client = cb;
if (!CouchInstaller.checkInstalled(pkg)) {
- installCouch(url, pkg);
+ installCouch(pkg);
} else {
if (couch.started == true) {
couchStarted();
@@ -121,13 +121,13 @@ void startCouch() {
couch.start("/system/bin/sh", CouchInstaller.dataPath() + "/couchdb/bin/couchdb", "", mHandler);
}
- void installCouch(final String url, final String pkg) {
+ void installCouch(final String pkg) {
final CouchService service = this;
new Thread() {
@Override
public void run() {
try {
- CouchInstaller.doInstall(url, pkg, mHandler, service);
+ CouchInstaller.doInstall(pkg, mHandler, service);
} catch (Exception e) {
e.printStackTrace();
}
View
2  src/com/couchbase/libcouch/ICouchService.aidl
@@ -7,7 +7,7 @@ interface ICouchService
/* Starts couchDB, calls "couchStarted" callback when
* complete
*/
- void initCouchDB(ICouchClient callback, String url, String pkg);
+ void initCouchDB(ICouchClient callback, String pkg);
/*
*
Please sign in to comment.
Something went wrong with that request. Please try again.