Help Please??? This app compiles but I cant figure out why it wont run!!! - C++ or Other Android Development Languages

Hello all! I am currently in the last few weeks of Intro to Java 8 and my last project is this:
18.14 (Palindromes) A palindrome is a string that is spelled the same way forward and backward. Some examples of palindromes are “radar,” “able was i ere i saw elba” and (if spaces are ignored) “a man a plan a canal panama.” Write a recursive method testPalindrome that returns boolean value true if the string stored in the array is a palindrome and false otherwise . The method should ignore spaces and punctuation in the string.
The program has to be written in Java, because its for a Java 8 Intro class I actually finished the program and compiled it with no problem... But when I run it, I get this:
Error: Main method not found in class Palindrome, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
I just can't figure out what I did wrong! I've been going over the code for days and I'm pretty sure this particular app doesn't need a main method for functionality... Any suggestions would be greatly appreciated!!!
Here's my code:
// Palindrome.java
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
// Palindrome class
public class Palindrome extends JApplet implements ActionListener
{
JLabel prompt;
JTextField input;
// set up GUI
public void init()
{
prompt = new JLabel("Enter a string:");
input = new JTextField(20);
input.addActionListener(this);
Container container = getContentPane();
container.setLayout(new FlowLayout());
container.add(prompt);
container.add(input);
} // end init method
// actionPerformed method
public void actionPerformed(ActionEvent actionEvent)
{
String string = actionEvent.getActionCommand();
char[] copy = new char[string.length() + 1];
int counter = 0;
// loop through the string
for (int index = 0; index < string.length(); index++)
{
// uses charAt method to return character
// at the specified subscript
char character = string.charAt(index);
copy[counter++] = character;
} //end loop
// calls testPalindrome method, if it
// is it displays "Palindrome". If its
// not it displays "Not a palindrome".
if (testPalindrome(copy, 0, counter - 1) == 1)
showStatus("Palindrome");
else
showStatus("Not a palindrome");
} // end actionParformed method
// testPalindrome method, recursively test
// if the array is a palindrome
public int testPalindrome(char array[], int left, int right)
{
while (array== ' ' || array== '.' ||
array== ';' || array== ':' ||
array== '?' || array== '!' ||
array== '-' || array== ',')
left++;
while (array== ' ' || array== '.' ||
array== ';' || array== ':' ||
array== '?' || array== '!' ||
array== '-' || array== ',')
right--;
if (left == right || left > right)
return 1;
else if (array!= array)
return 0;
else
return testPalindrome(array, left + 1, right - 1);
} // end testPalindrome method
} // end Palindrome class
For some reason when I submit this it gets rid of all the formatting and spacing... For that reason, I will attach my file so if you're interested in helping, it'll be much easier to download the java file and see it how it is originally... I really appreciate the help. This program should work. I've tried several ways of changing things around and I just can't get it to work. Please help? I know that I'm probably gonna feel like an idiot when someone finally tells me what I'm missing!!!​

Hehe, I've got "bad" news for you, you do need a Main() in every Java program. So just listen to the compiler, do implement:
Code:
public static void main(String[] args) {
// start my code here...
}
in your class and voila.

Related

[HELP] Adding a Toast message to Decompress activity

Hi everyone,
I am currently working on my first app which grabs a ZIP from the internet and the extracts it to a certain location. Everything works great but I can not figure out how to show a Toast message when the extraction operation is done.
The code I am using for unzipping is:
Code:
package mmarin.test.download;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
*
* @author jon
*/
public class Decompress{
private String _zipFile;
private String _location;
byte[] buffer = new byte[1024];
int length;
public Decompress(String zipFile, String location) {
_zipFile = zipFile;
_location = location;
_dirChecker("");
}
public void unzip() {
try {
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "Unzipping " + ze.getName());
if(ze.isDirectory()) {
_dirChecker(ze.getName());
} else {
FileOutputStream fout = new FileOutputStream(_location + ze.getName());
while ((length = zin.read(buffer))>0) {
fout.write(buffer, 0, length);
}
zin.closeEntry();
fout.close();
}
}
zin.close();
} catch(Exception e) {
Log.e("Decompress", "unzip", e);
}
}
private void _dirChecker(String dir) {
File f = new File(_location + dir);
if(!f.isDirectory()) {
f.mkdirs();
}
}
}
I am calling the Decompress activity through a button:
Code:
Button decompress = (Button)findViewById(R.id.button1);
decompress.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
String zipFile = Environment.getExternalStorageDirectory() + "/IPM/Splash.zip";
String unzipLocation = Environment.getExternalStorageDirectory() + "/IPM/Splash/";
Decompress d = new Decompress(zipFile, unzipLocation);
d.unzip();
}
});
I found this here: http://www.jondev.net/articles/Unzipping_Files_with_Android_(Programmatically) and it works great.
As I said above, only issue is displaying a message that everything is done.
Can someone please help me out?
Thank you!
Please use the Q&A Forum for questions &
Read the Forum Rules Ref Posting
Moving to Q&A
Put the toast after zin.close()
www.stackoverflow.com
Here you can find what you want
Xperian using xda app
http://stackoverflow.com/questions/9824772/toast-after-email-intent-message
Check this
Xperian using xda app
RoberGalarga said:
Put the toast after zin.close()
Click to expand...
Click to collapse
Hey,
I tried this but it doesn't work. I used this statement:
Code:
Toast.makeText(this, "Extraction complete", "LENGTH_SHORT").show();
and I got this error message: The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (Decompress, String, String).
Help?
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (Decompress, String, String)
What the above line means is that you need to pass a Context object, a CharSequence object and an int. You are passing the wrong object types (Decompress, String, String).
The example you saw used the Toast in the activity class itself, that is why the first value passed was a this. The "LENGTH_SHORT" is actually a constant Toast.LENGTH_SHORT.
I am guessing you are making the button object in your main activity class. So i'd suggest making an additional method for the activity class that looks like this
Code:
public void displayToast(CharSequence cs)
{
Toast.makeText(this, cs, Toast.LENGTH_SHORT).show();
}
and then make the following change to your code
Code:
Button decompress = (Button)findViewById(R.id.button1);
decompress.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
String zipFile = Environment.getExternalStorageDirectory() + "/IPM/Splash.zip";
String unzipLocation = Environment.getExternalStorageDirectory() + "/IPM/Splash/";
Decompress d = new Decompress(zipFile, unzipLocation);
d.unzip();
// Add the following line
displayToast("Unzip complete");
}
});
Let me know if it worked for you.
The_R said:
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (Decompress, String, String)
What the above line means is that you need to pass a Context object, a CharSequence object and an int. You are passing the wrong object types (Decompress, String, String).
The example you saw used the Toast in the activity class itself, that is why the first value passed was a this. The "LENGTH_SHORT" is actually a constant Toast.LENGTH_SHORT.
I am guessing you are making the button object in your main activity class. So i'd suggest making an additional method for the activity class that looks like this
Code:
public void displayToast(CharSequence cs)
{
Toast.makeText(this, cs, Toast.LENGTH_SHORT).show();
}
and then make the following change to your code
Code:
Button decompress = (Button)findViewById(R.id.button1);
decompress.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
String zipFile = Environment.getExternalStorageDirectory() + "/IPM/Splash.zip";
String unzipLocation = Environment.getExternalStorageDirectory() + "/IPM/Splash/";
Decompress d = new Decompress(zipFile, unzipLocation);
d.unzip();
// Add the following line
displayToast("Unzip complete");
}
});
Let me know if it worked for you.
Click to expand...
Click to collapse
PERFECT! You're amazing!

[Q] Get Android build number in app

Hi there,
I am writing an app and for one of the features I need the firmware build number.
I know I can get the firmware version(like 4.1.1) with android.os.build but I need the build number of a rom(like "Rom version 1.0") thats stored in build.prop. I know I can parse the whole build.prop file and extract the 1 string of information but is there another way to get is faster and that it doesnt require root to use?
Grtz,
Thirith
Solved it
I solved my own question
Here is how I did it(in case somebody wants to achieve the same thing):
Code:
TextView tv = (TextView)findViewById(R.id.text1);
String input = "getprop |awk -F : '/build.display.id/ { print $2 }'";
execCommandLine(input, tv);
void execCommandLine(String command, TextView tv)
{
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
// Running the Script
try
{
proc = runtime.exec("su");
osw = new OutputStreamWriter(proc.getOutputStream());
osw.write(command);
osw.flush();
osw.close();
}
// If return error
catch (IOException ex)
{
// Log error
Log.e("execCommandLine()", "Command resulted in an IO Exception: " + command);
return;
}
// Try to close the process
finally
{
if (osw != null)
{
try
{
osw.close();
}
catch (IOException e){}
}
}
try
{
proc.waitFor();
}
catch (InterruptedException e){}
// Display on screen if error
if (proc.exitValue() != 0)
{
Log.e("execCommandLine()", "Command returned error: " + command + "\n Exit code: " + proc.exitValue());
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(command + "\nWas not executed sucessfully!");
builder.setNeutralButton("OK", null);
AlertDialog dialog = builder.create();
dialog.setTitle("Script Error");
dialog.show();
}
BufferedReader reader = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
try {
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String exit = output.toString();
if(exit != null && exit.length() == 0) {
exit = "Command executed Successfully but no output was generated";
}
tv.setText(exit);
}
Hi, thanks for making your code public!
Just got an error when trying your code into my app.
Line
Code:
execCommandLine(input, tv);
runs into this error:
Multiple markers at this line
- input cannot be resolved to a type
- Return type for the method is missing
- Syntax error on token ",", delete this
token
Click to expand...
Click to collapse
How do I fix it?
Ok, did a mistake with integrating the code. My whole activity:
Code:
package de.yanniks.cm_updatechecker;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import de.yanniks.cm_updatechecker.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class UpdateChecker extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.updatecheck);
TextView tv = (TextView)findViewById(R.id.installedversion);
String input = "getprop |awk -F : '/build.display.id/ { print $2 }'";
execCommandLine(input, tv);}
void execCommandLine(String command, TextView tv)
{
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
// Running the Script
try
{
proc = runtime.exec("su");
osw = new OutputStreamWriter(proc.getOutputStream());
osw.write(command);
osw.flush();
osw.close();
}
// If return error
catch (IOException ex)
{
// Log error
Log.e("execCommandLine()", "Command resulted in an IO Exception: " + command);
return;
}
// Try to close the process
finally
{
if (osw != null)
{
try
{
osw.close();
}
catch (IOException e){}
}
}
try
{
proc.waitFor();
}
catch (InterruptedException e){}
// Display on screen if error
if (proc.exitValue() != 0)
{
Log.e("execCommandLine()", "Command returned error: " + command + "\n Exit code: " + proc.exitValue());
AlertDialog.Builder builder = new AlertDialog.Builder(UpdateChecker.this);
builder.setMessage(command + "\nWas not executed sucessfully!");
builder.setNeutralButton("OK", null);
AlertDialog dialog = builder.create();
dialog.setTitle("Script Error");
dialog.show();
}
BufferedReader reader = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
try {
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String exit = output.toString();
if(exit != null && exit.length() == 0) {
exit = "Command executed Successfully but no output was generated";
}
tv.setText(exit);
}
}
A better solution is to use my SystemProperties.get("build.display.id") directly instead of forking a native binary.
Code:
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class SystemProperties {
public static final int PROP_NAME_MAX= 32; // sic
public static final int PROP_VALUE_MAX= 92; // sic
public static final int PROP_AREA_MAGIC= 0x504f5250; // "PROP"
public static final int PROP_AREA_VERSION= 0x45434f76; // "vOCE" (API level 3..8 at least)
public static final String PROP_SERVICE_NAME= "property_service";
public static final String WORKSPACE= "ANDROID_PROPERTY_WORKSPACE";
// prop_area struct
public static final int PA_COUNT= 0;
public static final int PA_SERIAL= 4;
public static final int PA_MAGIC= 8;
public static final int PA_VERSION= 12;
public static final int PA_RESERVED= 16;
public static final int PA_TOC= 32;
public static final int PA_INFO_NAME= 0;
public static final int PA_INFO_SERIAL= PA_INFO_NAME+PROP_NAME_MAX;
public static final int PA_INFO_VALUE= PA_INFO_SERIAL+4;
private static MappedByteBuffer mMap= null;
private static boolean init() throws IllegalArgumentException,
SecurityException,
NoSuchFieldException,
IllegalAccessException,
IOException {
FileDescriptor fd;
MappedByteBuffer mbb= null;
String workspace= System.getenv(WORKSPACE);
if (workspace == null) {
throw new IllegalArgumentException(WORKSPACE + " not set");
}
String[] wsArray= workspace.split(",");
int osFd= 0;
int len= 0;
try {
osFd= new Integer(wsArray[0]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(e.getMessage());
}
try {
len= new Integer(wsArray[1]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(e.getMessage());
}
//Log.i(TAG, "Read fd " + Integer.toString(osFd) + " for " + len + " bytes.");
fd= new FileDescriptor();
Class<?> c= fd.getClass();
Field f= c.getDeclaredField("descriptor");
f.setAccessible(true);
f.setInt(fd, osFd);
FileInputStream in= new FileInputStream(fd);
FileChannel fc= in.getChannel();
mbb= fc.map(FileChannel.MapMode.READ_ONLY, 0, len);
mbb.order(ByteOrder.LITTLE_ENDIAN);
if (mbb.getInt(PA_MAGIC) != PROP_AREA_MAGIC) {
throw new IllegalArgumentException("Wrong kind of magic " + Integer.toString(mbb.getInt(PA_MAGIC), 16));
}
if (mbb.getInt(PA_VERSION) != PROP_AREA_VERSION) {
throw new IllegalArgumentException("Incorrect version " + Integer.toString(mbb.getInt(PA_VERSION), 16));
}
mMap= mbb;
return(true);
}
public static String get(String key) throws IllegalArgumentException,
SecurityException,
NoSuchFieldException,
IllegalAccessException,
IOException {
if (mMap == null) {
if (!init())
return(null);
}
int index= property_find(key);
//Log.i(TAG, "Found entry at " + Integer.toString(index));
if (index < 0)
return(null);
return(getString(index+PA_INFO_VALUE));
}
private static int property_find(String name) {
int count= mMap.getInt(PA_COUNT);
int tok= -1;
//Log.i(TAG, "Key " + name);
next: while(count-- > 0) {
tok++;
int entry= mMap.getInt(PA_TOC + tok*4);
//Log.i(TAG, "Entry " + tok + ": " + Integer.toString(entry, 16));
if ((entry >> 24) != name.length())
continue;
int index= (entry & 0xFFFFFF);
//Log.i(TAG, "Index " + index);
for (int i=0; i<name.length(); i++) {
//Log.i(TAG, "Cmp(" + entry + ":" + index + ":" + i + "): " + (char)(mbb.get(index+i)) + " -- " + name.charAt(i));
if ((char)(mMap.get(index+i)) != name.charAt(i)) {
continue next;
}
}
// found
return(index);
}
return(-1);
}
private static String getString(int index) {
byte b[]= new byte[PROP_VALUE_MAX];
int i= 0;
do {
b[i]= mMap.get(i+index);
} while (b[i++] != 0);
return(new String(b, 0, i-1));
}
}
Sorry 'bout the terrible indentation. Cut'n'paste isn't my code's best friend, obviously.

(REQ) How to Add Kill Long Press Kill Apps+ Long press volume keys to skip tracks

Does anyone know which jar files and smali files/codes( lines) for adding music control and long press back button to kill apps ?
I need name of files and smali codes.
I need it, too
i think its android-policy.jar or services.jar maybe.
i need it too
AW: (REQ) How to Add Kill Long Press Kill Apps+ Long press volume keys to skip tracks
me too
This is what would be added for Settings:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
Code:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
public class DevelopmentSettings extends PreferenceActivity
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back";
private CheckBoxPreference mKillAppLongpressBack;
addPreferencesFromResource(R.xml.development_prefs);
mKillAppLongpressBack = (CheckBoxPreference) findPreference(KILL_APP_LONGPRESS_BACK);
}
@Override
protected void onResume() {
super.onResume();
mKillAppLongpressBack.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) != 0);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
} else if (preference == mKillAppLongpressBack) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK,
mKillAppLongpressBack.isChecked() ? 1 : 0);
}
And for frameworks:
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Code:
Runnable mBackLongPress = new Runnable() {
public void run() {
if (Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 0) {
return;
}
try {
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
IActivityManager mgr = ActivityManagerNative.getDefault();
List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses();
for (RunningAppProcessInfo appInfo : apps) {
int uid = appInfo.uid;
// Make sure it's a foreground USER application
if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID
&& appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// Kill the entire pid
Toast.makeText(mContext, com.android.internal.R.string.app_killed_message, Toast.LENGTH_SHORT).show();
Process.killProcess(appInfo.pid);
break;
}
}
I SAW IT FROM SAMSUNG PHONE, NOT SURE ABOUT OUR SONY
TELL ME IF IT WORKS
TeamIndia said:
This is what would be added for Settings:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
Code:
packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
public class DevelopmentSettings extends PreferenceActivity
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back";
private CheckBoxPreference mKillAppLongpressBack;
addPreferencesFromResource(R.xml.development_prefs);
mKillAppLongpressBack = (CheckBoxPreference) findPreference(KILL_APP_LONGPRESS_BACK);
}
@Override
protected void onResume() {
super.onResume();
mKillAppLongpressBack.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) != 0);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
} else if (preference == mKillAppLongpressBack) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK,
mKillAppLongpressBack.isChecked() ? 1 : 0);
}
And for frameworks:
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Code:
Runnable mBackLongPress = new Runnable() {
public void run() {
if (Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 0) {
return;
}
try {
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
IActivityManager mgr = ActivityManagerNative.getDefault();
List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses();
for (RunningAppProcessInfo appInfo : apps) {
int uid = appInfo.uid;
// Make sure it's a foreground USER application
if (uid >= Process.FIRST_APPLICATION_UID && uid <= Process.LAST_APPLICATION_UID
&& appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
// Kill the entire pid
Toast.makeText(mContext, com.android.internal.R.string.app_killed_message, Toast.LENGTH_SHORT).show();
Process.killProcess(appInfo.pid);
break;
}
}
I SAW IT FROM SAMSUNG PHONE, NOT SURE ABOUT OUR SONY
TELL ME IF IT WORKS
Click to expand...
Click to collapse
no its completely different...bcz we dont u use kill concept smali...
so we have to mod android.policy.jar
settings.apk
and fw-res.apk..
iam almost making a tut for it...will add it in my tut thread soon..

[Q] My research on rooting Blade Apex 2

Hello XDA, i have been looking for a way to root the ZTE Blade Apex2 from Orange Spain (also known as Orange Hi 4G), and i found some interesting things about how the system manages the partitions and how the OTA update is done.
Packed inside Recovery.img in /etc/recovery.fstab we can read this:
Code:
# mount point fstype device [device2] [length=]
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,barrier=1 wait
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered wait,check
As you can see, the property BARRIER is enabled on all the mountpoints "interesting" to be accesed, so we CANT remount this mountpoints.
So i changed my mind to look for another way to try to make the trick, and unexpectedly, i found a nice glitch on the way how the official updater does the ota update process.
I decrypted the app itself from the decompyleandroid web, and got surprised.
The first thing called my attention is that the reboot on recovery to install the ota update, DONT check the signature of the file, its done by the otaupdater itself, so, we can try a replace file trick to change the target file.
Another interesting thing i found, is in the otaupdater, found this interesting piece of code:
Code:
[HIDE]package com.orange.authentication.utunneling.ttg;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
public class TtgX509TrustManager
implements X509TrustManager
{
private static final String KEYSTORE = "AAAAAQAAABSR52UCnjiSFiwLKyzthZxY4sJ0ZQAABdEBAAh2ZXJpc2lnbgAAASw2S2EsAAAAAAAFWC41MDkAAAMGMIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQABMA0GCSqGSIb3DQEBBQUAA4G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gSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrghB92f4Hz6getxB5Z/uniTTGMA0GCSqGSIb3DQEBBQUAA4GBAGN0Lz1Tqi+X7CYRZhr+8d5BJxnSf9jBHPniOFY6H5CuOcUgdav4bC1nHynCIdcUiGNLsJsnY5H48KMBJLb7j+M9AgtvVP7UzNvWhb98lR5eYhHB2QmcQrmy1KotmDojYMyimvFu6M+O0Ro8XhnF15s1sAIjJOUFuNWI4+D6ufRfAF0Slrj4O266ePon5MC54zEX3hju";
[B][I][SIZE="3"][COLOR="Red"]private static final char PASSPHRASE[] = "orange".toCharArray();[/COLOR][/SIZE][/I][/B]
private X509TrustManager mTrustManager;
public TtgX509TrustManager(boolean flag)
throws GeneralSecurityException, IOException
{
if (flag)
{
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(newInputStream(decodeBase64("AAAAAQAAABSR52UCnjiSFiwLKyzthZxY4sJ0ZQAABdEBAAh2ZXJpc2lnbgAAASw2S2EsAAAAAAAFWC41MDkAAAMGMIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4XDTk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AYb4RQEHFwMwVjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL2NwczAqBggrBgEFBQcCAjAeGhxodHRwczovL3d3dy52ZXJpc2lnbi5jb20vcnBhMDQGA1UdHwQtMCswKaAnoCWGI2h0dHA6Ly9jcmwudmVyaXNpZ24uY29tL3BjYTMtZzIuY3JsMA4GA1UdDwEB/wQEAwIBBjBtBggrBgEFBQcBDARhMF+hXaBbMFkwVzBVFglpbWFnZS9naWYwITAfMAcGBSsOAwIaBBSP5dMahqyNjmvDz4Bq1EgYLHsZLjAlFiNodHRwOi8vbG9nby52ZXJpc2lnbi5jb20vdnNsb2dvLmdpZjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRQ2xhc3MzQ0EyMDQ4LTEtNTIwHQYDVR0OBBYEFKXvCxHOwEEDo0plkEiyHOBXLX1HMIHnBgNVHSMEgd8wgdyhgcekgcQwgcExCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrghB92f4Hz6getxB5Z/uniTTGMA0GCSqGSIb3DQEBBQUAA4GBAGN0Lz1Tqi+X7CYRZhr+8d5BJxnSf9jBHPniOFY6H5CuOcUgdav4bC1nHynCIdcUiGNLsJsnY5H48KMBJLb7j+M9AgtvVP7UzNvWhb98lR5eYhHB2QmcQrmy1KotmDojYMyimvFu6M+O0Ro8XhnF15s1sAIjJOUFuNWI4+D6ufRfAF0Slrj4O266ePon5MC54zEX3hju")), PASSPHRASE);
TrustManagerFactory trustmanagerfactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustmanagerfactory.init(keystore);
javax.net.ssl.TrustManager atrustmanager[] = trustmanagerfactory.getTrustManagers();
if (atrustmanager == null || atrustmanager.length != 1 || !(atrustmanager[0] instanceof X509TrustManager))
{
throw new IllegalArgumentException("Invalid keystore");
}
mTrustManager = (X509TrustManager)atrustmanager[0];
}
}
private static ByteBuffer decodeBase64(String s)
{
ByteBuffer bytebuffer = ByteBuffer.allocate((6 * s.length()) / 8);
int i = 0;
int j = 0;
for (int k = 0; k < s.length(); k++)
{
int l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(s.charAt(k));
if (l == -1)
{
continue;
}
i = l | i << 6;
for (j += 6; j >= 8;)
{
j -= 8;
bytebuffer.put((byte)(i >> j));
}
}
bytebuffer.flip();
return bytebuffer;
}
private static InputStream newInputStream(ByteBuffer bytebuffer)
{
return new InputStream(bytebuffer) {
final ByteBuffer val$buffer;
public int read()
throws IOException
{
this;
JVM INSTR monitorenter ;
boolean flag = buffer.hasRemaining();
if (flag) goto _L2; else goto _L1
_L1:
byte byte1 = -1;
_L4:
this;
JVM INSTR monitorexit ;
return byte1;
_L2:
byte byte0 = buffer.get();
byte1 = byte0;
if (true) goto _L4; else goto _L3
_L3:
Exception exception;
exception;
throw exception;
}
public int read(byte abyte0[], int i, int j)
throws IOException
{
this;
JVM INSTR monitorenter ;
int k;
k = Math.min(j, buffer.remaining());
buffer.get(abyte0, i, k);
this;
JVM INSTR monitorexit ;
return k;
Exception exception;
exception;
throw exception;
}
{
buffer = bytebuffer;
super();
}
};
}
public void checkClientTrusted(X509Certificate ax509certificate[], String s)
throws CertificateException
{
if (mTrustManager != null)
{
mTrustManager.checkClientTrusted(ax509certificate, s);
}
}
public void checkServerTrusted(X509Certificate ax509certificate[], String s)
throws CertificateException
{
if (mTrustManager != null)
{
mTrustManager.checkServerTrusted(ax509certificate, s);
}
}
public X509Certificate[] getAcceptedIssuers()
{
if (mTrustManager != null)
{
return mTrustManager.getAcceptedIssuers();
} else
{
return new X509Certificate[0];
}
}
}[/HIDE]
Orange is so kind to provide us not only the certificate, but the key itself
Im uploading the sources of the otaupdater application that Orange is using on our Blade Apex2 aka Orange Hi 4G.
P.S. This phone allows us to upgrade and downgrade all the times needed, so dont hesitate to ask, just booting on recovery menu lets me flash previous firmware versions.
Hopes any developer find some time to take a look on it, im ready to test anything.

How to support icons in FileDialog

So i found this perfect code to be able to select zip from sd, but the list looks so basic and I would like to add icons (like one common icon for all dirs), however it seems too hard to do on my own, here is the code:
Code:
private void loadFileList(File path) {
this.currentPath = path;
List<String> r = new ArrayList<String>();
if (path.exists()) {
if (path.getParentFile() != null) r.add(PARENT_DIR);
FilenameFilter filter = new FilenameFilter() {
@SuppressLint("DefaultLocale")
public boolean accept(File dir, String filename) {
File sel = new File(dir, filename);
if (!sel.canRead()) return false;
if (selectDirectoryOption) return sel.isDirectory();
else {
boolean endsWith = fileEndsWith != null ? filename.toLowerCase().endsWith(fileEndsWith) : true;
return endsWith || sel.isDirectory();
}
}
};
String[] fileList1 = path.list(filter);
for (String file : fileList1) {
r.add(file);
}
}
fileList = (String[]) r.toArray(new String[]{});
}

Categories

Resources