download tool for xbmc Android app - Java for Android App Development

hi guys,
I am very very new to coding. I am trying to develop an app to download a zip file from my server, then unzip and place on the internal storage of my device, replacing the original file. I have found this java script which sounds like it does what i need it to but i cant seem to get to work in eclipse as to be honest i have no idea what im doing. Any help would be grateful or if any developer could create for me i am happy to pay or donate
Many thanks
Greg
ZipDownloader
*
* A simple app to demonstrate downloading and unpacking a .zip file
* as a background task.
*
* Copyright (c) 2011 Michael J. Portuesi (http://www.jotabout.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import java.io.File;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import com.jotabout.zipdownloader.util.DecompressZip;
import com.jotabout.zipdownloader.util.DownloadFile;
import com.jotabout.zipdownloader.util.ExternalStorage;
import com.jotabout.zipdownloader.R;
/**
* Example app to download and unpack a .zip file from an internet URL.
*
* @author portuesi
*
*/
public class MainActivity extends Activity {
//////////////////////////////////////////////////////////////////////////
// State
//////////////////////////////////////////////////////////////////////////
protected ProgressDialog mProgressDialog;
//////////////////////////////////////////////////////////////////////////
// Activity Lifecycle
//////////////////////////////////////////////////////////////////////////
/** Called when the activity is first created. */
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.main );
// Keep the screen (and device) active as long as this app is frontmost.
// This is to avoid going to sleep during the download.
// http://stackoverflow.com/questions/4376902/difference-between-wakelock-and-flag-keep-screen-on
getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON );
}
//////////////////////////////////////////////////////////////////////////
// Event handlers
//////////////////////////////////////////////////////////////////////////
/**
* Invoked when user presses "Start download" button.
*/
public void startDownload( View v ) {
String url = ((TextView) findViewById(R.id.url_field)).getText().toString();
new DownloadTask().execute( url );
}
//////////////////////////////////////////////////////////////////////////
// Background Task
//////////////////////////////////////////////////////////////////////////
/**
* Background task to download and unpack .zip file in background.
*/
private class DownloadTask extends AsyncTask<String,Void,Exception> {
@override
protected void onPreExecute() {
showProgress();
}
@override
protected Exception doInBackground(String... params) {
String url = (String) params[0];
try {
downloadAllAssets(url);
} catch ( Exception e ) { return e; }
return null;
}
@override
protected void onPostExecute(Exception result) {
dismissProgress();
if ( result == null ) { return; }
// something went wrong, post a message to user - you could use a dialog here or whatever
Toast.makeText(MainActivity.this, result.getLocalizedMessage(), Toast.LENGTH_LONG ).show();
}
}
//////////////////////////////////////////////////////////////////////////
// Progress Dialog
//////////////////////////////////////////////////////////////////////////
protected void showProgress( ) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setTitle( R.string.progress_title );
mProgressDialog.setMessage( getString(R.string.progress_detail) );
mProgressDialog.setIndeterminate( true );
mProgressDialog.setCancelable( false );
mProgressDialog.show();
}
protected void dismissProgress() {
// You can't be too careful.
if (mProgressDialog != null && mProgressDialog.isShowing() && mProgressDialog.getWindow() != null) {
try {
mProgressDialog.dismiss();
} catch ( IllegalArgumentException ignore ) { ; }
}
mProgressDialog = null;
}
//////////////////////////////////////////////////////////////////////////
// File Download
//////////////////////////////////////////////////////////////////////////
/**
* Download .zip file specified by url, then unzip it to a folder in external storage.
*
* @param url
*/
private void downloadAllAssets( String url ) {
// Temp folder for holding asset during download
File zipDir = ExternalStorage.getSDCacheDir(this, "tmp");
// File path to store .zip file before unzipping
File zipFile = new File( zipDir.getPath() + "/temp.zip" );
// Folder to hold unzipped output
File outputDir = ExternalStorage.getSDCacheDir( this, "unzipped" );
try {
DownloadFile.download( url, zipFile, zipDir );
unzipFile( zipFile, outputDir );
} finally {
zipFile.delete();
}
}
//////////////////////////////////////////////////////////////////////////
// Zip Extraction
//////////////////////////////////////////////////////////////////////////
/**
* Unpack .zip file.
*
* @param zipFile
* @param destination
*/
protected void unzipFile( File zipFile, File destination ) {
DecompressZip decomp = new DecompressZip( zipFile.getPath(),
destination.getPath() + File.separator );
decomp.unzip();
}
}

Related

How SEUS Flashing Works

OK, so been trying to figure out what happens when you use SEUS.
It checks for internet connection by loading this URL:
Code:
http://emma.extranet.sonyericsson.com/ns/no-cache
I've figured out quite a bit.
Sony Ericsson has implemented something called Tampered Device Service.
This checks if the devices has been tampered with.
This service works from this server:
Code:
tds.sonyericsson.com
Then for the actual firmware download.
This is done by downloading 2 *.ser.gz which tells SEUS what Software customization to get and is sessions specific.
The customization ser.gz file looks something like this:
Code:
CDA=1233-7027_NjKhzOzTUsfXvPg40lyh6aTl.ser.gz
And it's downloaded from:
Code:
emma.extranet.sonyericsson.com
It's done via some sort of search mechanism on the server.
That looks like this:
Code:
ns/usdoe1/2/script/search/TAC8=35941903/CDA=1233-7027_By5JACZqd1R7JOpLu6qvwK8N.ser.gz
After that it's downloading the actual firmware files.
They are downloaded in bin format which I haven't been able to unpack yet.
They are also downloaded from the emma server and is named something like:
Code:
277795427_k9ABo3YVh+8klYUKwllGLDcJ.bin - ~14.3 MB
277835617_ZpJseUr9e09U5h2Cz81+5vcT.bin ~149 MB
Then it does a netbios call which has some sort of HEX code.
And then check the Internet connection again:
Code:
http://emma.extranet.sonyericsson.com/ns/no-cache
Now it starts up a service called:
Code:
/fq/ServiceClientDbServlet
This service runs from this server:
Code:
ma3.extranet.sonyericsson.com
This last part is done twice in a row.
Inside one of the *ser.gz files is a *.ser file which contains some code and instructions. Some parts is encrypted but most of the code is not.
See the complete code in post #2
I don't quite know what to do with all this info yet.
But hopefully something useful will come of this.
Just wanted to share a bit of my knowledge, hope it's useful for some of you here.
Code:
import com.sonyericsson.cs.ma.tess.api.ServiceException;
import com.sonyericsson.cs.ma.tess.api.ServiceRuntimeException;
import com.sonyericsson.cs.ma.tess.api.TessFile;
import com.sonyericsson.cs.ma.tess.api.UI;
import com.sonyericsson.cs.ma.tess.api.device.IdentificationResult;
import com.sonyericsson.cs.ma.tess.api.inject.InjectConfigValue;
import com.sonyericsson.cs.ma.tess.api.inject.InjectRef;
import com.sonyericsson.cs.ma.tess.api.inject.IncludeFor;
import com.sonyericsson.cs.ma.tess.api.inject.ServiceMethod;
import com.sonyericsson.cs.ma.tess.api.logging.Logging;
import com.sonyericsson.cs.ma.tess.api.protocols.DataArea;
import com.sonyericsson.cs.ma.tess.api.protocols.ProtocolFactory;
import com.sonyericsson.cs.ma.tess.api.protocols.VersionResponse;
import com.sonyericsson.cs.ma.tess.api.protocols.s1.S1Protocol;
import com.sonyericsson.cs.ma.tess.api.protocols.s1.S1Protocol.ShutdownMode;
import com.sonyericsson.cs.ma.tess.api.secs.SECSUnitData;
import com.sonyericsson.cs.ma.tess.api.secs.SECSUtil;
import com.sonyericsson.cs.ma.tess.api.service.ServiceResult;
import com.sonyericsson.cs.ma.tess.api.service.ServiceResultType;
import com.sonyericsson.cs.ma.tess.api.service.ServiceType;
import com.sonyericsson.cs.ma.tess.api.statistics.DiagnosticsUtil;
import com.sonyericsson.cs.ma.tess.api.statistics.StatisticsUtil;
import com.sonyericsson.cs.ma.tess.api.statistics.StatisticsUtil.SoftwareComponent;
import com.sonyericsson.cs.ma.tess.api.ta.TAUnit;
import com.sonyericsson.cs.ma.tess.api.util.StringUtil;
import com.sonyericsson.cs.ma.tess.api.x10.MarlinCertificateUpdate;
import com.sonyericsson.cs.ma.tess.api.zip.ZipFileUtil;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.w3c.dom.Document;
/**
* S1 QSD8250 eSheep platform Main Services implementation.
*
* Services in this logic implemented for use in COMMERCIAL services!
*
*/
public class S1QSD8250eSheepMainServicesLIVE
{
@InjectRef
private ProtocolFactory aProtocolFactory;
@InjectRef
private UI aUI;
@InjectRef
private Logging aLogger;
@InjectRef
private IdentificationResult aIdentifiers;
@InjectRef
private ZipFileUtil aZipFileUtil;
@InjectRef
private static DiagnosticsUtil aDiagnostics;
@InjectRef
private StatisticsUtil aStatistics;
@InjectRef
private SECSUtil aSECS;
@InjectRef
private StringUtil aStringUtil;
@InjectRef
private ClientEnvironment aClientEnvironment;
@InjectRef
private MarlinCertificateUpdate marlinCertUpdate;
// File references
// Loader reference
@InjectConfigValue("cLOADER")
private TessFile aLoader;
// App-SW reference - Exclude from Activation
@IncludeFor([ServiceType.CUSTOMIZE, ServiceType.SOFTWARE_UPDATE,
ServiceType.SOFTWARE_UPDATE_CONTENT_REFRESH])
@InjectConfigValue("cAPP_SW")
private TessFile aAppSW;
// FSP Reference - Exclude from Activation
@IncludeFor([ServiceType.CUSTOMIZE, ServiceType.SOFTWARE_UPDATE,
ServiceType.SOFTWARE_UPDATE_CONTENT_REFRESH])
@InjectConfigValue("cFSP")
private TessFile aFSP;
// miscTA units
// Startup/Shutdown flag used for indicating successful flash.
@InjectConfigValue("cTA_FLASH_STARTUP_SHUTDOWN_RESULT")
private String aStrTaFlashStartShutdownResult;
// Startup/Shutdown flag used for indicating successful flash.
@InjectConfigValue("cTA_EDREAM_FLASH_IN_PROGRESS")
private String aStrTaEDreamFlashStartShutdownResult;
// SIMlock data unit
@InjectConfigValue("cTA_SIMLOCK_DATA")
private String aStrTaSimlockData;
// Loose temp data unit
@InjectConfigValue("cTA_LOOSE_TEMP")
private String aStrTaLooseTemp;
// TA_APPLICATION_BUFFER_DATA_ARRAY[2]
@InjectConfigValue("cTA_APPLICATION_BUFFER_DATA_ARRAY2")
private String aStrTaApplicationBufferDataArray2;
// TA_APPLICATION_BUFFER_DATA_ARRAY[3]
@InjectConfigValue("cTA_APPLICATION_BUFFER_DATA_ARRAY3")
private String aStrTaApplicationBufferDataArray3;
// TA_MARLIN_DRM_KEY_UPDATE_FLAG
@InjectConfigValue("cTA_MARLIN_DRM_KEY_UPDATE_FLAG")
private String aStrTaMarlinDRMKeyUpdateFlag;
// Parameter names
@InjectConfigValue("cTA_APPLICATION_BUFFER_DATA_ARRAY0_NAME")
private String aTaApplicationBufferDataArray0Name;
@InjectConfigValue("cTA_APPLICATION_BUFFER_DATA_ARRAY1_NAME")
private String aTaApplicationBufferDataArray1Name;
@InjectConfigValue("cTA_APPLICATION_BUFFER_DATA_ARRAY2_NAME")
private String aTaApplicationBufferDataArray2Name;
@InjectConfigValue("cTA_APPLICATION_BUFFER_DATA_ARRAY3_NAME")
private String aTaApplicationBufferDataArray3Name;
@InjectConfigValue("cTA_SIMLOCK_DATA_NAME")
private String aTaSimlockDataName;
@InjectConfigValue("cTA_LOOSE_TEMP_NAME")
private String aTaLooseTempName;
@InjectConfigValue("cVERSION_RESPONSE")
private String aVersionResponseName;
// miscTA unit values
// Startup/Shutdown flag, cTA_FLASH_STARTUP_SHUTDOWN_RESULT, values
@InjectConfigValue("cTA_FLASH_STARTUP_SHUTDOWN_RESULT_ONGOING_VALUE")
private String aTaFlashStartupShutdownResultOngoingValue;
@InjectConfigValue("cTA_FLASH_STARTUP_SHUTDOWN_RESULT_FINISHED_VALUE")
private String aTaFlashStartupShutdownResultFinishedValue;
// Startup/Shutdown flag, cTA_EDREAM_FLASH_STARTUP_SHUTDOWN_RESULT, values
@InjectConfigValue("cTA_EDREAM_FLASH_FLASH_IN_PROGRESS_ONGOING")
private String aTaEDreamFlashStartupShutdownResultOngoingValue;
@InjectConfigValue("cTA_EDREAM_FLASH_FLASH_IN_PROGRESS_COMPLETED")
private String aTaEDreamFlashStartupShutdownResultFinishedValue;
// Update.xml values
// File name
private static String UPDATE_XML_FILE_NAME = "update.xml";
// NOERASE tag value
private static String UPDATE_XML_NOERASE_TAG = "NOERASE";
// SIMLOCK tag value
private static String UPDATE_XML_SIMLOCK_TAG = "SIMLOCK";
// PRESERVECACHE tag value
private static String UPDATE_XML_PRESERVECACHE_TAG = "PRESERVECACHE";
// UI Progress texts
@InjectConfigValue("cSEND_DATA")
private String aSendDataText;
@InjectConfigValue("cSEND_DATA_DONE")
private String aSendDataDoneText;
@InjectConfigValue("cSERVICE_FINALIZING")
private String aServiceFinalizingText;
@InjectConfigValue("cSERVICE_FINALIZING_DONE")
private String aServiceFinalizingDoneText;
@InjectConfigValue("cSERVICE_INITIALIZATION")
private String aServiceInitializationText;
@InjectConfigValue("cSERVICE_INITIALIZATION_DONE")
private String aServiceInitializationDoneText;
/**
* ACTIVATION
*
*/
@ServiceMethod(ServiceType.ACTIVATION)
public ServiceResult activation() throws ServiceException
{
boolean vDoActivation = true;
showInitServiceText();
try
{
S1Protocol vS1 = aProtocolFactory.getProtocol(S1Protocol.class);
int vTaSimlockData = Integer.parseInt(aStrTaSimlockData);
int vTaLooseTemp = Integer.parseInt(aStrTaLooseTemp);
int vTaApplicationBufferDataArray2 =
Integer.parseInt(aStrTaApplicationBufferDataArray2);
int vTaApplicationBufferDataArray3 =
Integer.parseInt(aStrTaApplicationBufferDataArray3);
// Check if activation is needed?
// Send loader
vS1.sendFile(aLoader);
vS1.openDataArea(DataArea.MISC_TA);
// Read the SIMlock data from TA_SIMLOCK_DATA
byte[] vSIMlockData = vS1.readDataArea(vTaSimlockData);
if (vSIMlockData != null && vSIMlockData.length >= 20)
{
// Check 20 first bytes (if set to 0)
for (int vI = 0; vI < 20; vI++)
{
if (vSIMlockData[vI] != 0)
{
vDoActivation = false;
break;
}
}
}
else
{
aLogger
.error("Could not determine if activation is needed. Not possible to read enough data.");
throw new ServiceRuntimeException("Error when activating phone.");
}
// Do activation?
if (vDoActivation)
{
// Verify that the dongle is present
aSECS.ensureDongleReady();
String vIMEI = aIdentifiers.getIMEI();
SECSUnitData[] vInputData = getS1SIMLockSignatureInputData(vS1);
SECSUnitData[] vOutputData =
vS1.getS1SIMLockSignature(vInputData, vIMEI);
if (vOutputData != null && vOutputData.length > 6)
{
byte[] vEmpty = new byte[1];
vEmpty[0] = 0x00;
vS1.writeToDataArea(vTaApplicationBufferDataArray2, vEmpty);
vS1.writeToDataArea(
vTaApplicationBufferDataArray3,
vOutputData[3].getUnitData());
vS1
.writeToDataArea(vTaSimlockData, vOutputData[4]
.getUnitData());
vS1.writeToDataArea(vTaLooseTemp, vOutputData[5].getUnitData());
}
else
{
aLogger.error("Not enough data in response from SECS server.");
throw new ServiceRuntimeException(
"Error occured when communicating with server.");
}
}
else
{
aUI
.showText("ACTIVATION NOT NEEDED! This unit has been "
+ "activated already. The service is exiting without execution.");
}
showFinalizingText();
vS1.closeDataArea();
vS1.shutdownDevice(ShutdownMode.DISCONNECT);
}
catch (ServiceException pEx)
{
aLogger.error("Exception when executing ACTIVATION service.", pEx);
throw pEx;
}
return ServiceResult.SUCCESSFUL;
}
/**
* CUSTOMIZE
*
*/
@ServiceMethod(ServiceType.CUSTOMIZE)
public ServiceResult customize() throws ServiceException
{
showInitServiceText();
ServiceResult vServiceResult =
new ServiceResult(
ServiceResultType.SUCCESSFUL,
"Customize EXECUTED! ACTIVATION NEEDED!",
null);
try
{
S1Protocol vS1 = aProtocolFactory.getProtocol(S1Protocol.class);
int vTaSimlockData = Integer.parseInt(aStrTaSimlockData);
int vTaLooseTemp = Integer.parseInt(aStrTaLooseTemp);
showSendingDataText();
// Send loader
vS1.sendFile(aLoader);
vS1.openDataArea(DataArea.MISC_TA);
readDID(vS1);
updateMartinKey(vS1);
setFlashStartupShutdownFlagOngoing(vS1);
// Send App-SW
sendFile(vS1, aAppSW);
// Send FSP
if ("false".equalsIgnoreCase(aFSP.getProperty("SIMLockCustomized"))
&& "true".equalsIgnoreCase(aIdentifiers
.getIdentifier("SIMLockReusable")))
{
// quick-customize
String[] vExcludeTags = new String[1];
vExcludeTags[0] = UPDATE_XML_SIMLOCK_TAG;
String[] vFilesToExcludeFromFSP = parseFile(aFSP, vExcludeTags);
// Send FSP
sendZipFile(vS1, aFSP, vFilesToExcludeFromFSP);
vServiceResult =
new ServiceResult(
ServiceResultType.SUCCESSFUL,
"Quick Customize EXECUTED! NO ACTIVATION NEEDED!",
null);
}
else
{
// customize
// Tamper the simlock data
tamperSimlockData(vS1);
// Set the simlock data unit id to loose temp
aFSP.modifyData(vTaSimlockData, vTaLooseTemp);
sendFile(vS1, aFSP);
}
setFlashStartupShutdownFlagFinished(vS1);
showSendingDataTextDone();
showFinalizingText();
vS1.closeDataArea();
vS1.shutdownDevice(ShutdownMode.DISCONNECT);
storeSoftwareAfterStatistics();
}
catch (ServiceException pEx)
{
aLogger.error("Exception when executing CUSTOMIZE service.", pEx);
throw pEx;
}
return vServiceResult;
}
/**
* SOFTWARE UPDATE
*
*/
@ServiceMethod(ServiceType.SOFTWARE_UPDATE)
public ServiceResult softwareUpdate() throws ServiceException
{
showInitServiceText();
try
{
S1Protocol vS1 = aProtocolFactory.getProtocol(S1Protocol.class);
showSendingDataText();
// Send loader
vS1.sendFile(aLoader);
vS1.openDataArea(DataArea.MISC_TA);
readDID(vS1);
updateMartinKey(vS1);
// Search the APP-SW zip file for xml file and metadata. Exclude user
// data
String[] vExcludeTags = new String[1];
vExcludeTags[0] = UPDATE_XML_NOERASE_TAG;
String[] vFilesToExcludeFromAPPSW = parseFile(aAppSW, vExcludeTags);
// Search the FSP zip file for xml file and metadata. Exclude user data
// and simlock if existing
vExcludeTags = new String[2];
vExcludeTags[0] = UPDATE_XML_NOERASE_TAG;
vExcludeTags[1] = UPDATE_XML_SIMLOCK_TAG;
String[] vFilesToExcludeFromFSP = parseFile(aFSP, vExcludeTags);
setFlashStartupShutdownFlagOngoing(vS1);
// Send App-SW
// Anything to exclude?
if (vFilesToExcludeFromAPPSW != null
&& vFilesToExcludeFromAPPSW.length > 0)
{
sendZipFile(vS1, aAppSW, vFilesToExcludeFromAPPSW);
}
else
{
sendFile(vS1, aAppSW);
}
// Send FSP
sendZipFile(vS1, aFSP, vFilesToExcludeFromFSP);
setFlashStartupShutdownFlagFinished(vS1);
showSendingDataTextDone();
showFinalizingText();
vS1.closeDataArea();
vS1.shutdownDevice(ShutdownMode.DISCONNECT);
storeSoftwareAfterStatistics();
}
catch (ServiceException pEx)
{
aLogger
.error("Exception when executing SOFTWARE UPDATE service.", pEx);
throw pEx;
}
return ServiceResult.SUCCESSFUL;
}
/**
* SOFTWARE UPDATE CONTENT REFRESH
*
*/
@ServiceMethod(ServiceType.SOFTWARE_UPDATE_CONTENT_REFRESH)
public ServiceResult softwareUpdateContentRefresh() throws ServiceException
{
showInitServiceText();
try
{
S1Protocol vS1 = aProtocolFactory.getProtocol(S1Protocol.class);
showSendingDataText();
// Send loader
vS1.sendFile(aLoader);
vS1.openDataArea(DataArea.MISC_TA);
readDID(vS1);
updateMartinKey(vS1);
// Search the FSP zip file for xml file and metadata. Exclude
// simlock if existing
String[] vExcludeTags = new String[0];
aLogger.debug("isSwapEnabled is: "
+ aClientEnvironment.isSwapEnabled());
// Check the client environment.
if (!aClientEnvironment.isSwapEnabled())
{
aLogger.debug("Cache partition will be preserved.");
vExcludeTags = new String[1];
vExcludeTags[0] = UPDATE_XML_PRESERVECACHE_TAG;
}
// Temporarily catch the exception
String[] vFilesToExcludeFromAPPSW = parseFile(aAppSW, vExcludeTags);
vExcludeTags = new String[1];
vExcludeTags[0] = UPDATE_XML_SIMLOCK_TAG;
String[] vFilesToExcludeFromFSP = parseFile(aFSP, vExcludeTags);
setFlashStartupShutdownFlagOngoing(vS1);
// Anything to exclude?
if (vFilesToExcludeFromAPPSW != null
&& vFilesToExcludeFromAPPSW.length > 0)
{
sendZipFile(vS1, aAppSW, vFilesToExcludeFromAPPSW);
}
else
{
sendFile(vS1, aAppSW);
}
// Send FSP
sendZipFile(vS1, aFSP, vFilesToExcludeFromFSP);
setFlashStartupShutdownFlagFinished(vS1);
showSendingDataTextDone();
showFinalizingText();
vS1.closeDataArea();
vS1.shutdownDevice(ShutdownMode.DISCONNECT);
storeSoftwareAfterStatistics();
}
catch (ServiceException pEx)
{
aLogger
.error(
"Exception when executing SOFTWARE UPDATE CONTENT REFRESH service.",
pEx);
throw pEx;
}
return ServiceResult.SUCCESSFUL;
}
/**
* Private help method to get DID data from device, if available.
*
*/
private void readDID(S1Protocol pS1)
{
byte[] vEmptyUnit = new byte[0];
List<TAUnit> vUnits = new ArrayList<TAUnit>();
aLogger.debug("Reading diagnostic data.");
final int vLastUnit = 10009;
final int vFirstUnit = 10000;
for (int vUnit = vFirstUnit; vUnit <= vLastUnit; vUnit++)
{
try
{
byte[] vData = pS1.readDataArea(vUnit);
if (vData != null && vData.length > 0)
{
pS1.writeToDataArea(vUnit, vEmptyUnit);
vUnits.add(new TAUnit(vUnit, vData));
}
}
catch (ServiceException vServiceException)
{
}
}
if (vUnits.size() > 0)
{
byte[] vDiagnosticData;
try
{
aLogger.debug("Diagnostic data found, sending diagnostic data.");
vDiagnosticData = aDiagnostics.createDiagnosticData(vUnits);
aDiagnostics.storeDiagnostic(aIdentifiers.getIMEI(), aIdentifiers
.getApplicationSoftwareID(), aIdentifiers
.getApplicationSoftwareRev(), vDiagnosticData, "06");
}
catch (ServiceException pEx)
{
}
}
}
/**
* Private help method to tamper the simlock data.
*
*/
private void tamperSimlockData(S1Protocol pS1) throws ServiceException
{
int vTaSimlockData = Integer.parseInt(aStrTaSimlockData);
// Read the SIMlock data from TA_SIMLOCK_DATA
byte[] vSIMlockData = pS1.readDataArea(vTaSimlockData);
if (vSIMlockData != null && vSIMlockData.length > 0)
{
// Tamper 20 first bytes (set to 0)
// Make sure enough data is read
if (vSIMlockData.length >= 20)
{
for (int vI = 0; vI < 20; vI++)
{
vSIMlockData[vI] = 0;
}
}
else
{
throw new ServiceRuntimeException(
"Data read, but not enough to tamper.");
}
// Write back the tampered SIMlock data to TA_SIMLOCK_DATA
pS1.writeToDataArea(vTaSimlockData, vSIMlockData);
}
else
{
throw new ServiceRuntimeException("Could not read data.");
}
}
/**
* Private help method to get S1 SIMlock signature input data from device.
*
*/
private SECSUnitData[] getS1SIMLockSignatureInputData(S1Protocol pS1)
throws ServiceException
{
SECSUnitData[] vSECSUnitData = new SECSUnitData[7];
int vTaSimlockData = Integer.parseInt(aStrTaSimlockData);
int vTaLooseTemp = Integer.parseInt(aStrTaLooseTemp);
int vTaApplicationBufferDataArray3 =
Integer.parseInt(aStrTaApplicationBufferDataArray3);
byte[] vEmpty = new byte[1];
vEmpty[0] = 0x00;
vSECSUnitData[0] =
new SECSUnitData(aTaApplicationBufferDataArray0Name, vEmpty);
vSECSUnitData[1] =
new SECSUnitData(aTaApplicationBufferDataArray1Name, vEmpty);
vSECSUnitData[2] =
new SECSUnitData(aTaApplicationBufferDataArray2Name, vEmpty);
byte[] vInputUnitData = pS1.readDataArea(vTaApplicationBufferDataArray3);
vSECSUnitData[3] =
new SECSUnitData(aTaApplicationBufferDataArray3Name, vInputUnitData);
vInputUnitData = pS1.readDataArea(vTaSimlockData);
vSECSUnitData[4] = new SECSUnitData(aTaSimlockDataName, vInputUnitData);
vInputUnitData = pS1.readDataArea(vTaLooseTemp);
vSECSUnitData[5] = new SECSUnitData(aTaLooseTempName, vInputUnitData);
VersionResponse vVersionResponse = pS1.getVersionResponse();
byte[] vVersionResponseArray =
vVersionResponse.getVersionResponseAsBytes();
vInputUnitData = vVersionResponseArray;
vSECSUnitData[6] = new SECSUnitData(aVersionResponseName, vInputUnitData);
return vSECSUnitData;
}
/**
* Parses the specified file for a xml metadata file and the parses the xml
* file for the tags defined. Tag values are then returned as a string array.
*
*/
private String[] parseFile(TessFile pFile, String[] pTags)
throws ServiceException
{
ArrayList<String> vResult = new ArrayList<String>();
Document vUpdateXML =
aZipFileUtil.getXMLFile(pFile, UPDATE_XML_FILE_NAME);
if (vUpdateXML != null)
{
if (pTags != null)
{
for (String vTag : pTags)
{
String[] vFilesFound =
aZipFileUtil.getXMLTextContentByTagName(vUpdateXML, vTag);
if (vFilesFound != null && vFilesFound.length > 0)
{
aLogger.debug("Found files to exclude from "
+ pFile.getFileName()
+ " from tag "
+ vTag
+ " in "
+ UPDATE_XML_FILE_NAME
+ ":");
for (String vFileName : vFilesFound)
{
aLogger.debug(vFileName);
}
vResult.addAll(Arrays.asList(vFilesFound));
}
}
}
}
else
{
aLogger.debug("No " + UPDATE_XML_FILE_NAME + " found");
// throw new
throw new ServiceRuntimeException("Could not find a "
+ UPDATE_XML_FILE_NAME
+ " in the zip file, abort.");
}
return vResult.toArray(new String[vResult.size()]);
}
private void updateMartinKey(S1Protocol pS1) throws ServiceException
{
int vTaMarlinDRMKeyUpdateFlag =
Integer.parseInt(aStrTaMarlinDRMKeyUpdateFlag);
byte[] vFlagValue = null;
pS1.openDataArea(DataArea.MISC_TA);
// check the flag
try
{
vFlagValue = pS1.readDataArea(vTaMarlinDRMKeyUpdateFlag);
if (vFlagValue != null
&& aStringUtil
.convertByteArrayToString(vFlagValue)
.equalsIgnoreCase("01"))
{
// updated already
return;
}
}
catch (ServiceException vServiceException)
{
// exception indicates no update has been done
}
// check if update is available for this unit
if (marlinCertUpdate.isNewCertificateAvailable())
{
// update the cert
InputStream vTAFileInputStream =
marlinCertUpdate.getCertificateTAInputStream();
pS1.sendTAFileFromStream(vTAFileInputStream);
aLogger.debug("Marlin key updated.");
}
// set the flag as updated
pS1.writeToDataArea(vTaMarlinDRMKeyUpdateFlag, aStringUtil
.convertStringToByteArray("0x01"));
return;
}
/**
* Private help method to set the flash ongoing flag to ongoing.
*
* @throws ServiceException
*
*/
private void setFlashStartupShutdownFlagOngoing(S1Protocol pS1)
throws ServiceException
{
int vTaFlashStartupShutdownResult =
Integer.parseInt(aStrTaFlashStartShutdownResult);
int vTaEDreamFlashStartupShutdownResult =
Integer.parseInt(aStrTaEDreamFlashStartShutdownResult);
// Set the TA_FLASH_STARTUP_SHUTDOWN_RESULT (2227) flag to 0xA0000000 to
// indicate
// flash ongoing
pS1
.writeToDataArea(
vTaFlashStartupShutdownResult,
aStringUtil
.convertStringToByteArray(aTaFlashStartupShutdownResultOngoingValue));
// Set the 10100 flag specific for eDream
// Set the TA_EDREAM_FLASH_STARTUP_SHUTDOWN_RESULT (10100) flag to 0x01 to
// indicate
// flash ongoing
pS1
.writeToDataArea(
vTaEDreamFlashStartupShutdownResult,
aStringUtil
.convertStringToByteArray(aTaEDreamFlashStartupShutdownResultOngoingValue));
}
/**
* Private help method to set the flash ongoing flag to finished.
*
* @throws ServiceException
*
*/
private void setFlashStartupShutdownFlagFinished(S1Protocol pS1)
throws ServiceException
{
int vTaFlashStartupShutdownResult =
Integer.parseInt(aStrTaFlashStartShutdownResult);
int vTaEDreamFlashStartupShutdownResult =
Integer.parseInt(aStrTaEDreamFlashStartShutdownResult);
// Set the TA_FLASH_STARTUP_SHUTDOWN_RESULT (2227) flag to 0xAA000000 to
// indicate
// flash finished
pS1
.writeToDataArea(
vTaFlashStartupShutdownResult,
aStringUtil
.convertStringToByteArray(aTaFlashStartupShutdownResultFinishedValue));
// Set the 10100 flag specific for eDream
// Set the TA_EDREAM_FLASH_STARTUP_SHUTDOWN_RESULT (10100) flag to 0x00 to
// indicate flash finished
pS1
.writeToDataArea(
vTaEDreamFlashStartupShutdownResult,
aStringUtil
.convertStringToByteArray(aTaEDreamFlashStartupShutdownResultFinishedValue));
}
/**
* Private help method to store software and CDF ids and versions.
*
*/
private void storeSoftwareAfterStatistics()
{
String vAPPSWId = aAppSW.getProperty("Id");
String vAPPSWVer = aAppSW.getVersion();
String vCDFId = aFSP.getProperty("CDFId");
String vCDFVer = aFSP.getProperty("CDFVer");
if (vAPPSWId != null)
{
aStatistics.storeSoftwareAfter(
SoftwareComponent.SW1,
vAPPSWId,
vAPPSWVer);
}
if (vCDFId != null)
{
aStatistics.storeCustomizationAfter(vCDFId, vCDFVer);
}
}
private void sendZipFile(
S1Protocol pS1,
TessFile pFile,
String[] pFilesToExclude) throws ServiceException
{
aLogger.debug("Sending "
+ pFile.getFileName()
+ ", "
+ pFile.getVersion());
pS1.sendZipFile(pFile, pFilesToExclude);
}
private void sendFile(S1Protocol pS1, TessFile pFile)
throws ServiceException
{
aLogger.debug("Sending "
+ pFile.getFileName()
+ ", "
+ pFile.getVersion());
pS1.sendFile(pFile);
}
/**
* Private help method to display start sending data text.
*
*/
private void showSendingDataText()
{
aUI.showText(aSendDataText);
}
/**
* Private help method to display start sending data done text.
*
*/
private void showSendingDataTextDone()
{
aUI.showText(aSendDataDoneText);
}
/**
* Private help method to display start up and initialization text.
*
*/
private void showInitServiceText()
{
aUI.showText(aServiceInitializationText);
aUI.showText(aServiceInitializationDoneText);
aUI.showText("");
}
/**
* Private help method to display please wait text.
*
*/
private void showFinalizingText()
{
aUI.showText("");
aUI.showText(aServiceFinalizingText);
aUI.showText(aServiceFinalizingDoneText);
}
}
Reserved for future use.
wow seems u done some packet sniffing...
may be u should contact Bin4ry regarding this... he is involved in FreeXperia Project for Arc/Play...
i am sure he can shed some more light on this matter...
Figured out the *.bin files is the actual files that also goes in the blob_fs folder:
Code:
%programfiles%\Sony Ericsson\Update Service\db\
So they are decryptable using the known method.
Tampered Device Service does in fact check for Root and custom software.
Don't know if this will have an effect in the updating process from SEUS.
So, it's a bad news huh. Keep looking. Thanks for the info.
Sent from my X10i using XDA App
Confirmed that devices that has been rooted and modified in software will not be eligible for 2.3.3 update. You will have to flash back a stock unrooted firmware before updating to 2.3.3
Of course. SE said that in their blog. Better backup all data in SD Card and format it too. I don't think the SEUS' intelligent enough to check out that the SD Card contains CyanogenMod folder as busybox and xRecovery
EDIT: I tried to find the update 2.1 package in my computer after repaired my phone for several times and I can't find it. It's of course that it's deleted as soon as the update completed.
I believe SEUS works like the Flash Tool and Pay-Per-Update service through fastgsm.com and davince.
Flash Tool requires you to provide the firmware and place the sin files in the correct location.
Pay service requires a fee to install the correct sin files/firmware.
SEUS requires a CDA to determine which sin files/firmware to install.
I beg that the FlashTool works like SEUS cause without SEUS and other update services, where is FlashTool come from?
But what if SEUS change its method? Well, i still want to update and we will see how it goes.
Sent from my X10i using XDA App
Whatever method they choose, they can't close the door behind them. They need the access too. Flash Tool can be updated.
Nor would google allow that. JMHO
Yes, FT can be updated but it's development is kinda dead as of now, and we don't even have its source codes, so the other developers can't update it. Unless if Androxyde and Bin4ry want to work on FT again.
Hzu said:
Yes, FT can be updated but it's development is kinda dead as of now, and we don't even have its source codes, so the other developers can't update it. Unless if Androxyde and Bin4ry want to work on FT again.
Click to expand...
Click to collapse
Why are the devs acting like this is an issue? The Flash Tool already works on the ARC, so what are you worried about?
Work on Arc no mean it can work on X10, just like Arc has bootloader unlocked but no mean X10 can when update to 2.3.3
silveraero said:
Work on Arc no mean it can work on X10, just like Arc has bootloader unlocked but no mean X10 can when update to 2.3.3
Click to expand...
Click to collapse
You totally missed the point. The bootloader or root has NEVER mattered. When the NEVER has happened, then start your *****ing.
agentJBM said:
Why are the devs acting like this is an issue? The Flash Tool already works on the ARC, so what are you worried about?
Click to expand...
Click to collapse
What I mean is that IF SE changed their flashing method for the GB firmware and FT won't work for those who upgraded their X10 to GB. But another user has said that they won't since it requires them to start all over again.
Who knows, we're not the one who are developing the firmwares and we all should stop making assumptions(but some people aren't making assumptions, they are so sure they are right).
Hzu said:
What I mean is that IF SE changed their flashing method for the GB firmware and FT won't work for those who upgraded their X10 to GB. But another user has said that they won't since it requires them to start all over again.
Who knows, we're not the one who are developing the firmwares and we all should stop making assumptions(but some people aren't making assumptions, they are so sure they are right).
Click to expand...
Click to collapse
I am not pretending to know. However, you are failing to acknowledge that the Flash Tool is a modification of Update Service. The same method is used. Quit acting like this is nuclear science.
I told you, what IF they CHANGE the flashing method, then SEUS will also be updated with the new method.
Why am I repeating this anyway? Silly me.

Dynamically loading an external library at runtime

I am using and android 2.2 phone for testing and getting an error which is driving me crazy
07-27 01:24:55.692: W/System.err(14319): java.lang.ClassNotFoundException: com.shoaib.AndroidCCL.MyClass in loader [email protected]
Can someone help me what to do now..i have tried various suggested solutions on different posts
First I wrote the following class:
Code:
package org.shoaib.androidccl;
import android.util.Log;
public class MyClass {
public MyClass() {
Log.d(MyClass.class.getName(), "MyClass: constructor called.");
}
public void doSomething() {
Log.d(MyClass.class.getName(), "MyClass: doSomething() called.");
}
}
And I packaged it in a DEX file that I saved on my device's SD card as `/sdcard/testdex.jar`.
Then I wrote the program below, after having removed `MyClass` from my Eclipse project and cleaned it:
Code:
public class Main extends Activity {
[user=1299008]@supp[/user]ressWarnings("unchecked")
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
final String libPath = Environment.getExternalStorageDirectory() + "/testdex.jar";
final File tmpDir = getDir("dex", 0);
final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader());
final Class<Object> classToLoad = (Class<Object>) classloader.loadClass("org.shoaib.androidccl.MyClass");
final Object myInstance = classToLoad.newInstance();
final Method doSomething = classToLoad.getMethod("doSomething");
doSomething.invoke(myInstance);
} catch (Exception e) {
e.printStackTrace();
}
}
}
As far as I know you can't load external dex classes (and certainly not a jar file), the only ones that can be loaded are the ones packaged in the classes.dex file inside the APK and protected by its signature and certificate.
This would be quite a security flaw if your app could be "clean" at install but then download malicious classes and execute them.

Help with saving gestures!

Currently, i'm making an application that involves using GestureOverlayView. I've already created some default gestures using the GestureBuilder and have copied them into my res/raw folder in my application. My application also does customization, meaning that the user can create his or her own gestures and save them. I've read that it's impossible for me to just save the additionally made gestures from the users to the res/raw folder. I was told that i have some optionals: ExternalStorage (to SD card), InternalStorage, and SharedPreferences. Which method is probably the more optimal choice?
I've tried using these codes:
gestureLib.addGesture(scName.getText().toString(), gesture);
gestureLib.save();
setResult(RESULT_OK);
in an attempt to save them. Even though the gestures do save, but when i restart the application, they're gone. Please help! Thanks so much!
rx24race said:
Currently, i'm making an application that involves using GestureOverlayView. I've already created some default gestures using the GestureBuilder and have copied them into my res/raw folder in my application. My application also does customization, meaning that the user can create his or her own gestures and save them. I've read that it's impossible for me to just save the additionally made gestures from the users to the res/raw folder. I was told that i have some optionals: ExternalStorage (to SD card), InternalStorage, and SharedPreferences. Which method is probably the more optimal choice?
I've tried using these codes:
gestureLib.addGesture(scName.getText().toString(), gesture);
gestureLib.save();
setResult(RESULT_OK);
in an attempt to save them. Even though the gestures do save, but when i restart the application, they're gone. Please help! Thanks so much!
Click to expand...
Click to collapse
I haven't used gestures so far but for the saving:
In your SharedPreferences you can only save the standard types like int or string. I'm guessing you don't want to convert the gesture to string and backwards, so I'd say external storage in a folder with the name of your app(so the user can manually delete it) but you could also save the file in your app directory.
Look at This question , he uses the gesture library and saves it to the file with
Code:
GestureLibrary store = GestureLibraries.fromFile(mStoreFile);
store.addGesture("Gesture Password", mGesture);
store.save();
My application successfully saves now, but there's still a consistent problem. When i restart the application, the saved gestures are gone. Why is that?
rx24race said:
My application successfully saves now, but there's still a consistent problem. When i restart the application, the saved gestures are gone. Why is that?
Click to expand...
Click to collapse
When you restart your app, everything in its ram will be gone, so you always need to load the saved file and then import the gestures to the library again probably.
You'd want to do that in the onCreate() or onRestart().
In the above example,
Code:
store.load();
Is used to do that
It works now. Thanks a lot. I'm assuming that these gestures are being saved in the application itself, since that i can't find them in the SD card. Thanks for your time, by the way.
It works now. Thanks a lot. I'm assuming that these gestures are being saved in the application itself, since that i can't find them in the SD card. Thanks for your time, by the way.
Click to expand...
Click to collapse
Glad I could help you
BUMP! I've been struggling with a problem that i newly encountered. What i want to do is, i want to create a folder in the external directory and save ALL the gestures that the user creates. But the thing is, every time i save the gesture, it overwrites the existing one. How do i create a folder and put the new ones in it? Any help or hints would be nice
rx24race said:
BUMP! I've been struggling with a problem that i newly encountered. What i want to do is, i want to create a folder in the external directory and save ALL the gestures that the user creates. But the thing is, every time i save the gesture, it overwrites the existing one. How do i create a folder and put the new ones in it? Any help or hints would be nice
Click to expand...
Click to collapse
You've got to use a different string for every gesture in that line:
Code:
store.addGesture("this should be a different string every time", mGesture);
Then you should be able to put them into one file.
nikwen said:
You've got to use a different string for every gesture in that line:
Code:
store.addGesture("this should be a different string every time", mGesture);
Then you should be able to put them into one file.
Click to expand...
Click to collapse
I definitely have a different name for the every gesture that i save
Here's the code:
Code:
package com.epicunlock.rx24race;
import java.io.File;
import java.util.ArrayList;
import android.app.Activity;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;
public class createShortcut extends Activity implements
OnGesturePerformedListener {
boolean found = false;
EditText scName;
GestureOverlayView gestures;
GestureLibrary lib;
File mStoreFile;
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.createshortcutlayout);
scName = (EditText) findViewById(R.id.etName);
gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
mStoreFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/com.epicunlock.rx24race");
if (!mStoreFile.exists()) {
mStoreFile.mkdirs();
}
lib = GestureLibraries.fromFile(mStoreFile);
lib.load();
}
[user=439709]@override[/user]
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// TODO Auto-generated method stub
found = false;
ArrayList<Prediction> predictions = lib.recognize(gesture);
for (String s : lib.getGestureEntries()) {
Log.v("GESTURE", s);
}
Log.v("TAG", "Gesture has been detected");
for (Prediction p : predictions) {
Log.v("TAG", p.toString());
Log.v("^ Score", "" + p.score);
}
for (Prediction p : predictions) {
if (p.score > 2.0) {
Toast.makeText(this, p.name, Toast.LENGTH_SHORT).show();
found = true;
}
}
if (!found) {
Log.v("TAG", "Gesture has been saved");
Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
lib = GestureLibraries.fromFile(mStoreFile);
lib.addGesture(scName.getText().toString(), gesture);
lib.save();
setResult(RESULT_OK);
}
}
}
As you can see, i have every gesture named after its own unique scName (EditText).
What's happening right now is that i successfully creates a folder name "com.epicunlock.rx24race" inside Android/data, but nothing is ever saved in it
rx24race said:
I definitely have a different name for the every gesture that i save
Here's the code:
Code:
package com.epicunlock.rx24race;
import java.io.File;
import java.util.ArrayList;
import android.app.Activity;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;
public class createShortcut extends Activity implements
OnGesturePerformedListener {
boolean found = false;
EditText scName;
GestureOverlayView gestures;
GestureLibrary lib;
File mStoreFile;
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.createshortcutlayout);
scName = (EditText) findViewById(R.id.etName);
gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
mStoreFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/com.epicunlock.rx24race");
if (!mStoreFile.exists()) {
mStoreFile.mkdirs();
}
lib = GestureLibraries.fromFile(mStoreFile);
lib.load();
}
[user=439709]@override[/user]
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// TODO Auto-generated method stub
found = false;
ArrayList<Prediction> predictions = lib.recognize(gesture);
for (String s : lib.getGestureEntries()) {
Log.v("GESTURE", s);
}
Log.v("TAG", "Gesture has been detected");
for (Prediction p : predictions) {
Log.v("TAG", p.toString());
Log.v("^ Score", "" + p.score);
}
for (Prediction p : predictions) {
if (p.score > 2.0) {
Toast.makeText(this, p.name, Toast.LENGTH_SHORT).show();
found = true;
}
}
if (!found) {
Log.v("TAG", "Gesture has been saved");
Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
lib = GestureLibraries.fromFile(mStoreFile);
lib.addGesture(scName.getText().toString(), gesture);
lib.save();
setResult(RESULT_OK);
}
}
}
As you can see, i have every gesture named after its own unique scName (EditText).
What's happening right now is that i successfully creates a folder name "com.epicunlock.rx24race" inside Android/data, but nothing is ever saved in it
Click to expand...
Click to collapse
As far as I know the file you save it to mustn't be a directory, but a file.
Try that:
Code:
mStoreFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/com.epicunlock.rx24race");
if (!mStoreFile.exists()) {
mStoreFile.mkdirs();
}
[COLOR="Red"]File gestureFile = new File(mStoreFile, "gestures");
lib = GestureLibraries.fromFile(gestureFile);[/COLOR]
lib.load();
and
Code:
if (!found) {
Log.v("TAG", "Gesture has been saved");
Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
[COLOR="Red"]File gestureFile = new File(mStoreFile, "gestures");
lib = GestureLibraries.fromFile(gestureFile);[/COLOR]
lib.addGesture(scName.getText().toString(), gesture);
lib.save();
setResult(RESULT_OK);
}
nikwen said:
As far as I know the file you save it to mustn't be a directory, but a file.
Try that:
Code:
mStoreFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/com.epicunlock.rx24race");
if (!mStoreFile.exists()) {
mStoreFile.mkdirs();
}
[COLOR="Red"]File gestureFile = new File(mStoreFile, "gestures");
lib = GestureLibraries.fromFile(gestureFile);[/COLOR]
lib.load();
and
Code:
if (!found) {
Log.v("TAG", "Gesture has been saved");
Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
[COLOR="Red"]File gestureFile = new File(mStoreFile, "gestures");
lib = GestureLibraries.fromFile(gestureFile);[/COLOR]
lib.addGesture(scName.getText().toString(), gesture);
lib.save();
setResult(RESULT_OK);
}
Click to expand...
Click to collapse
I've tried something similar to this before too, but the same problem still exists. it keeps overwriting the previous one. It's never able to save multiple gestures.
What i have:
Code:
package com.epicunlock.rx24race;
import java.io.File;
import java.util.ArrayList;
import android.app.Activity;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;
public class createShortcut extends Activity implements
OnGesturePerformedListener {
boolean found = false;
EditText scName;
GestureOverlayView gestures;
GestureLibrary lib, storage;
File path;
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.createshortcutlayout);
scName = (EditText) findViewById(R.id.etName);
gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
path = new File(Environment.getExternalStorageDirectory() + "/Android/data/com.epicunlock.rx24race/");
if (!path.exists()) {
path.mkdirs();
}
File gestureFile = new File(path, "gestures");
lib = GestureLibraries.fromFile(gestureFile);
lib.load();
}
[user=439709]@override[/user]
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// TODO Auto-generated method stub
found = false;
ArrayList<Prediction> predictions = lib.recognize(gesture);
for (String s : lib.getGestureEntries()) {
Log.v("GESTURE", s);
}
Log.v("TAG", "Gesture has been detected");
for (Prediction p : predictions) {
Log.v("TAG", p.toString());
Log.v("^ Score", "" + p.score);
}
for (Prediction p : predictions) {
if (p.score > 2.0) {
Toast.makeText(this, p.name, Toast.LENGTH_SHORT).show();
found = true;
}
}
if (!found) {
Log.v("TAG", "Gesture has been saved");
Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
File gestureFile = new File(path, "gestures");
lib = GestureLibraries.fromFile(gestureFile);
lib.addGesture(scName.getText().toString(), gesture);
lib.save();
setResult(RESULT_OK);
}
}
}
I just fixed the problem: "Can't save multiple gestures."
This is how i fixed it. But can anyone tell me what difference it made?
Code:
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.createshortcutlayout);
scName = (EditText) findViewById(R.id.etName);
gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
path = new File(Environment.getExternalStorageDirectory() + "/Android/data/com.epicunlock.rx24race/");
if (!path.exists()) {
path.mkdirs();
}
[B]if (lib == null) {
gestureFile = new File(path, "gestures");
lib = GestureLibraries.fromFile(gestureFile);
}[/B]
lib.load();
}

[GUIDE] How to get Busybox Info,Root Info , Dex

There are some app required root busy box deodex i have wrote some java that will help you to know that the phone is rooted , busy box available , deodex
First You need to make New Java Named Logger
Content are below
Code:
/*
* This File is Part of Almas Api
*
* Copyright (c) 2015 Sahid S Almas
*
* This code are licensed under the terms of the Apache License Version 2.0
* You may use this code according to either of these licenses as is most appropriate
* for your project on a case-by-case basis.
*/
package sahidsalmas.api.internel;
import android.util.Log;
import java.util.ArrayList;
public class Logger {
private ArrayList<String> mDebugLogs = new ArrayList<>();
private ArrayList<String> mErrorLogs = new ArrayList<>();
private ArrayList<String> mInfoLogs = new ArrayList<>();
private int DLogs = 0;
private int ELogs = 0;
private int ILogs = 0;
private String TAG_NAME;
public Logger(String nam) {
setTAG_NAME(nam);
}
public void addDLogs(String logs) {
DLogs++;
mDebugLogs.add(logs);
}
public void addELogs(String logs) {
ELogs++;
mErrorLogs.add(logs);
}
public void addILogs(String logs) {
ILogs++;
mInfoLogs.add(logs);
}
public void execute() {
if (DLogs > 0) {
for (int i = 0 ; i < DLogs;i++) {
Log.d(getTAG_NAME(),mDebugLogs.get(i));
}
}
if (ELogs > 0) {
for (int i = 0 ; i < ELogs;i++) {
Log.e(getTAG_NAME(),mErrorLogs.get(i));
}
}
if (ILogs > 0) {
for (int i = 0 ; i < ILogs;i++) {
Log.i(getTAG_NAME(),mInfoLogs.get(i));
}
}
}
private String getTAG_NAME() {
return TAG_NAME;
}
private void setTAG_NAME(String TAG_NAME) {
this.TAG_NAME = TAG_NAME;
}
}
Make RootInfo Java
Content are below
Code:
/*
* This File is Part of Almas Api
*
* Copyright (c) 2015 Sahid S Almas
*
* This code are licensed under the terms of the Apache License Version 2.0
* You may use this code according to either of these licenses as is most appropriate
* for your project on a case-by-case basis.
*/
package sahidsalmas.api.internel;
import java.io.File;
import java.util.ArrayList;
public class RootInfo {
static Logger mLogger = new Logger("RootInfo");
/**
* Logger used to logs to the android system
*/
public static boolean isRooted() {
Process mProcess = null;
boolean mRoot;
try {
// This is executing on terminal
mProcess = Runtime.getRuntime().exec("su");
mRoot = true;
mLogger.addDLogs("Rooted Phone");
// If the execute successfully then it return to true
} catch (Exception e) {
// if is not successfully then it return to false
mRoot = false;
mLogger.addELogs("Unrooted Phone");
} finally {
if (mProcess != null) {
try {
mProcess.destroy();
} catch (Exception ignored) {
}
}
}
mLogger.execute();
return mRoot;
}
public static boolean isRooted2() {
/*
* This is the another method to know
* that the phone is rooted or not
*/
mLogger.addDLogs("Trying to know that the phone is rooted " +
"or not by another method");
File mFile = new File("/system/bin/su");
File mFile1 = new File("/system/xbin/su");
boolean isRooted = false;
ArrayList<File> mFileList = new ArrayList<>();
mFileList.add(mFile);
mFileList.add(mFile1);
/*
* In the mFileList we added to file
* to arrary to run loop and check does it
* exists or not exists return to the isRooted2();
*/
for (int i = 0 ; i < mFileList.size();i++) {
if (mFileList.get(i).exists()) {
isRooted = true;
mLogger.addDLogs("The phone is rooted");
}
else {
isRooted = false;
mLogger.addELogs("The phone is not rooted");
}
}
mLogger.execute();
return isRooted;
}
}
Make BusyboxInfo Java
Content are below
Code:
/*
* This File is Part of Almas Api
*
* Copyright (c) 2015 Sahid S Almas
*
* This code are licensed under the terms of the Apache License Version 2.0
* You may use this code according to either of these licenses as is most appropriate
* for your project on a case-by-case basis.
*/
package sahidsalmas.api.internel;
import java.io.File;
import java.util.ArrayList;
public class BusyboxInfo {
static Logger mLogger = new Logger("BusyBox");
/**
* Logger used to logs to the android system
*/
public static boolean isBusyBoxAvai() {
Process mProcess = null;
boolean mBusyBox;
try {
// This is executing on terminal
mProcess = Runtime.getRuntime().exec("busybox");
mBusyBox = true;
mLogger.addDLogs("BusyBox found");
// If the execute successfully then it return to true
} catch (Exception e) {
// if is not successfully then it return to false
mBusyBox = false;
mLogger.addELogs("Busybox not found");
} finally {
if (mProcess != null) {
try {
mProcess.destroy();
} catch (Exception ignored) {
}
}
}
mLogger.execute();
return mBusyBox;
}
public static boolean isBusyBoxAvai2() {
/*
* This is the another method to know
* that the phone is rooted or not
*/
mLogger.addDLogs("Trying to know that the phone is busybox " +
"is available or not");
File mFile = new File("/system/bin/buxybox");
File mFile1 = new File("/system/xbin/buxybox");
boolean Bu = false;
ArrayList<File> mFileList = new ArrayList<>();
mFileList.add(mFile);
mFileList.add(mFile1);
/*
* In the mFileList we added to file
* to arrary to run loop and check does it
* exists or not exists return to the isRooted2();
*/
for (int i = 0 ; i < mFileList.size();i++) {
if (mFileList.get(i).exists()) {
Bu = true;
mLogger.addDLogs("BusyBox found");
}
else {
Bu = false;
mLogger.addELogs(" BusyBox not found ");
}
}
mLogger.execute();
return Bu;
}
}
Make DexInfo Java
Content are below
Code:
/*
* This File is Part of Almas Api
*
* Copyright (c) 2015 Sahid S Almas
*
* This code are licensed under the terms of the Apache License Version 2.0
* You may use this code according to either of these licenses as is most appropriate
* for your project on a case-by-case basis.
*/
package sahidsalmas.api.internel;
import java.io.File;
public class DexInfo {
/*
* This Java Only Say that the system apk are odex or deodex
* it does not make system apps to odex or deodex
*/
public static Logger mLogger = new Logger("DexInfo");
public static boolean isDeodex() {
boolean Deodex = false;
mLogger.addDLogs("Trying to know that phone is deodex or not");
File mFileDirec = new File("/system/app/");
File[] AllFiles;
AllFiles = mFileDirec.listFiles();
for (File AllFile : AllFiles) {
if (AllFile.getPath().endsWith(".odex"))
Deodex = false;
else {
Deodex = true;
}
}
if (Deodex) {
mLogger.addDLogs("The system apk are deodex");
}
else {
mLogger.addDLogs("The system apk are not deodex");
}
mLogger.execute();
return Deodex;
}
public static boolean isOdex() {
boolean Odex = false;
mLogger.addDLogs("Trying to know that phone is odex or not");
File mFileDirec = new File("/system/app/");
File[] AllFiles;
AllFiles = mFileDirec.listFiles();
for (File AllFile : AllFiles) {
if (AllFile.getPath().endsWith(".odex")) {
Odex = true;
} else {
Odex = false;
}
}
if (Odex) {
mLogger.addDLogs("The system apk are odex");
}
else {
mLogger.addDLogs("The system apk are not odex");
}
mLogger.execute();
return Odex;
}
}
How to use
In this java all the method are static just you need to call like this
Code:
RootInfo.isRooted();
RootInfo.isRooted2();
BusyboxInfo.isBusyBoxAvai2();
BusyboxInfo.isBusyBoxAvai();
DexInfo.isDeodex();
DexInfo.isOdex();

Java&WinRAR-(dirthack) to get files >4GB to USB-Disk for Kodi

Hi together,
last year I've installed a 1st-Gen FireTV with Kodi in combination with a 4TB USB HDD for my parents RV. Don't exactly remember how I got the 4TB disk to fat32, but google should provide the answer, since it did for me than. The bigger issue anyway was to get files bigger than 4GB on the disk. The trick for my was to find out, that Kodi can access *.rar archives as if it was a file. So I wrote a java "dirtyhack": It uses a combination of java and WinRAR. Java to determine if a file is bigger than 4GB or not. If it is smaller, just copy the file, if it is bigger, call WinRAR with the right parameters to create a splittet archive consisting of parts smaller than 4GB on the HDD.
So first you choose a source-folder, than select a destination-folder (should be the Disk ) and all files get copied recursively.
As I'm currently updating the HDD and have unsuccessfully searched for an easier way (after I've installed all updates on the ftv *doh!*) I thought I could share my Code, so here you go:
Code:
import javax.swing.*;
import java.io.IOException;
import java.io.*;
/**
* @author der-gee
*
*/
public class Copy {
static int amountFiles = 0;
static long limit = 4294967295L;
/**
* Lists all files from a given folder, recursively
*
* @param dir
* Prints a list of files > 4GB and sums them up
*/
public static void listDir(File dir) {
File[] files = dir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
listDir(files[i]); // calls itself
} else {
if (files[i].length() > limit) {
System.out.println(files[i].getAbsolutePath());
amountFiles++;
}
}
}
}
}
/**
* Shows a select file dialog and returns the choosen one ^^
*
* @param title
* Title to be shown by the "choose file dialog"
* @return The directory as file
*/
static public File getFolder(String title) {
JFileChooser chooser;
chooser = new JFileChooser();
chooser.setCurrentDirectory(File.listRoots()[0]);
chooser.setDialogTitle(title);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setAcceptAllFileFilterUsed(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
return chooser.getSelectedFile();
} else {
System.out.println("No Selection ");
return null;
}
}
/**
* Copies directories and files smaller than 4GB
*
* @param src
* @param dest
* @throws IOException
*/
public static void copyFolder(File src, File dest) throws IOException {
if (src.isDirectory()) {
// if directory not exists, create it
if (!dest.exists()) {
dest.mkdir();
System.out.println("Directory copied from " + src + " to "
+ dest);
}
// list all the directory contents
String files[] = src.list();
for (String file : files) {
// construct the src and dest file structure
File srcFile = new File(src, file);
File destFile = new File(dest, file);
// recursive copy
copyFolder(srcFile, destFile);
}
} else {
// if file, then copy it
// Use bytes stream to support all file types
// If file is t large for Fat32 -> rar it
if (src.length() >= limit)
rarThis(src, dest);
else {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length;
// copy the file content in bytes
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
in.close();
out.close();
System.out.println("File copied from " + src + " to " + dest);
System.out.println("Size from: " + src + ":" +src.length());
}
}
}
/**
* Should use a combination of cmd and winrar to create splitted archives,
* so that they can be stored to a fat32 drive.
*
* @param src
* @param dest
*/
public static void rarThis(File src, File dest) {
String[] command = {
"\"" + "C:\\Program Files\\WinRAR\\rar.exe" + "\"",
"a", "-m0", //a = Archive, -m0 = compressionMode store
"-v3.999g", "-y", //v = VolSize, y = always answer yes
"-ep", //ep = noPath in archive
"\"" + dest.getAbsolutePath().replace("mkv", "rar") + "\"",
"\"" + src.getAbsolutePath() + "\"" };
Runtime rt = Runtime.getRuntime();
try {
Process rar = rt.exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(rar.getInputStream()));
String line;
while ((line = reader.readLine()) != null)
System.out.println("WinRAR: " + line);
rar.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
}
}
/**
* Main program. Initiates the whole thing :)
*
* @param s
* @throws IOException
*/
public static void main(String s[]) throws IOException {
System.out.println("Size limit: " + limit);
File sourcePath = getFolder("Source");
if (sourcePath != null) {
listDir(sourcePath);
System.out.println("Amount files > 4GB: " + amountFiles);
}
File targetPath = getFolder("Destination");
copyFolder(sourcePath, targetPath);
System.out.println("Finished!");
}
}
I wrote this for Windows, using the x64 Version of WinRar, so if you are using the 32-bit version, you have to adjust the rar folder in the rarThis function. Feel free to use and share. If you have improvements, please share
Interesting. When I came to this problem of HD files larger than 4 GB I decided to use the NTFS format and then use Paragon to mount the external HDD on my rooted Fire TV.
PhoenixMark said:
Interesting. When I came to this problem of HD files larger than 4 GB I decided to use the NTFS format and then use Paragon to mount the external HDD on my rooted Fire TV.
Click to expand...
Click to collapse
Hehe, I would have done the same, but I checked for root after upgrading to the very last fw version
PhoenixMark said:
Interesting. When I came to this problem of HD files larger than 4 GB I decided to use the NTFS format and then use Paragon to mount the external HDD on my rooted Fire TV.
Click to expand...
Click to collapse
Was this on the latest rooted firmware? I have a AFTV2 running the latest prerooted rom from rbox
deanr1977 said:
Was this on the latest rooted firmware? I have a AFTV2 running the latest prerooted rom from rbox
Click to expand...
Click to collapse
I'm using 5.0.5 because I like using FireStarter, but I don't see why you can't still do this on 5.0.5.1 as well as there is a pre rooted rom for it. Only difference is you need the A to A USB cable to root 5.0.5.1.

Categories

Resources