vendredi 9 mai 2014

Androïd programmation : Tentative (KO) d'arrêt de processus avec su (tél non rooté)

            Process p = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(p.getOutputStream());
            String killCommand = "am force-stop com.android.smspush";
            os.writeBytes(killCommand + "\n");
            os.writeBytes("exit\n");
            os.flush();

mercredi 7 mai 2014

Débuter avec le TelephonyManager et l'ActivityManager sur Androïd

package com.reunisoft.gsmhack.gsmhack;

import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.telephony.CellIdentityGsm;
import android.telephony.CellInfo;
import android.telephony.CellInfoGsm;
import android.telephony.CellLocation;
import android.telephony.CellSignalStrengthGsm;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.text.Layout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

// A DVA FREE OPEN SOURCE DEMO
public class MainActivity extends ActionBarActivity {

    int i = 0;

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        refreshAllInfos();

        final Button button = (Button)findViewById(R.id.button);
        button.setText("Refresh");
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                refreshAllInfos();
            }
        });
    }

    public void refreshAllInfos() {
        try {
            TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            String str = "IMEI=" + telephonyManager.getDeviceId() + "\r\n";
            str += "Line 1 number=" + telephonyManager.getLine1Number() + "\r\n";
            str += "Network Op = " + telephonyManager.getNetworkOperatorName() + "\r\n";

            boolean roaming = telephonyManager.isNetworkRoaming();
            str += "Roaming = " + String.valueOf(roaming) + "\r\n";
            str += "Soft version = " + telephonyManager.getDeviceSoftwareVersion() + "\r\n";

            final GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
            str += "Cell ID = " + cellLocation.getCid() + "\r\nActive processes ID = ";

            ActivityManager manager =  (ActivityManager)getSystemService(ACTIVITY_SERVICE);
            final List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = manager.getRunningAppProcesses();
            for(int i=0;i<runningAppProcesses.size();i++){
                ActivityManager.RunningAppProcessInfo rapi = (ActivityManager.RunningAppProcessInfo) runningAppProcesses.get(i);
                str += rapi.pid + "/";
            }
          
            updateTextView(str);
        }
        catch (Exception e){
            updateTextView(e.getMessage());
        }

    }

    public void updateTextView(String toThis) {
        TextView textView = (TextView) findViewById(R.id.textView);
        textView.setText(toThis);
        return;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /* Called when the application is minimized */
    @Override
    protected void onPause()
    {
        super.onPause();
    }

    /* Called when the application resumes */
    @Override
    protected void onResume()
    {
        super.onResume();
    }

}

Nouvelle application Androïd : LotoFun

LotoFun est une application Androïd qui vous donne huit numéros au hasard compris entre 1et 49 lorsque vous lancez l'application. Un bouton "Quitter" permets alors de sortir de l'application.

Vous pouvez télécharger la dernière version de LotoFun pour Androïd en cliquant sur le lien ci-dessous (directement depuis votre périphérique Androïd) :


Il est probable que vous ayez à modifier les paramètres de sécurité de votre système Androïd, afin d'autoriser les applications ne provenant pas de Google Play Store.

mardi 6 mai 2014

Programmation Androïd ; Les bases du Wifi

Android Manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.reunisoft.lotofun.lotofunmodule01" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.reunisoft.lotofun.lotofunmodule01.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-feature android:name="android.hardware.wifi" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />

</manifest>

Dans le MainActivity.java :
package com.reunisoft.lotofun.lotofunmodule01;

import android.net.wifi.WifiManager;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
import android.content.Context;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        EditText editText = (EditText) findViewById(R.id.editText);

        try {
            WifiManager myWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
            boolean wasEnabled = myWifiManager.isWifiEnabled();

            myWifiManager.setWifiEnabled(true);
            while (!myWifiManager.isWifiEnabled()) {
                editText.setText("Enabling Wifi...", TextView.BufferType.NORMAL);
            }

            if (myWifiManager.isWifiEnabled() == true) {
                editText.append("Wifi is enabled");

            }
            else
                editText.append("Wifi is not enabled");

        }
        catch (Exception e) {
            editText.setText(e.getMessage(), TextView.BufferType.NORMAL);
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}


vendredi 21 mars 2014

Sony Xperia Tipo Dual, la galère continue

Quelle galère, j'ai racheté un deuxième Sony Xperia Tipo Dual il y a quelques mois et il a de plus en plus de mal à se connecter en GPS, non seulement en voiture lorsque j'utilise Waze mais aussi en VTT quand j'utilise l'application Runtastic Mountain Bike.

La première fois que j'avais eu ce problème, si je me souviens bien, j'avais réinitialisé mon téléphone à l'aide de l'outil Sony PC Companion et cela avait résolu le problème de GPS, mais cette fois, après la même réinitialisation, le GPS n'a pas capté une seule fois en une matinée, alors que j'étais en extérieur et en ville, donc en zone dégagée.

Aussi, je dois dire qu'en terme de synchronisation de données de contacts et d'agenda avec Google Agenda, et bien je n'y arrive plus du tout, alors que sur mon ancien Xperia cela semblait fonctionner, sans compter l'embrouille de l'interface de Sony PC Companion etc...

Sony Xperia, un téléphone miniaturisé, avec deux cartes SIM, mais à l'Android complètement buggué, ce qui induit pour nous les utilisateurs : Perte de temps, Confusion technique et... Envie de jeter son téléphone en l'air !



Mise à jour de 17:08 (même date le 21/03/2014)

J'ai décidé de prendre le taureau par les cornes :
- J'ai téléchargé GPS Test sur Google Play Store
- J'ai pris mon "booster" Bricoteck, je suis allé dehors et je l'ai allumé en mode chargeur USB
- J'ai connecté mon téléphone Sony Xperia Tipo Dual au booster
- J'ai démarré GPS Test, puis j'ai cliqué sur "Clear AGPS" et "Update AGPS"
- Des satellites sont bien détectés. Au bout de la détection du 7ème ou 8ème, la précision (Accuracy) baisse et cela est rassurant
- Je lance Runtastic Mountain Bike et je démarre une session et je fais un bon kilomètre en VTT
- Damned ! Je m'arrête au bout de un kilomètre et à la fin de la session, Runtastic n'a rien enregistré !
- Je lance GPS Test, effectue un Clear AGPS et un Update AGPS
- Le GPS détecte bien au moins 7 à 8 satellites assez rapidement (zone très dégagée)
- Je parcours 3,5 km et la session Runtastic Mountain Bike est bien enregistrée ! OUF !

Conclusion :
Il faut être un "GPS Hacker" pour pouvoir utiliser Runtastic Mountain Bike sur Sony Xperia Tipo Dual !

Solution pour utiliser Runtastic Mountain Bike sur Sony Xperia Tipo Dual (Android) :
- Lancer GPS Test, et effectuer un Clear AGPS et un Update AGPS
- Quand le GPS détecte bien au moins 7 à 8 satellites, démarrer une session Runtastic Mountain Bike

jeudi 17 octobre 2013

mercredi 16 octobre 2013

lundi 14 octobre 2013

C# / Console / Cryptage et décryptage RSA

Thanks to the following article writer http://www.codestructs.com/tag-blogger-com-1999-blog-2555797619867133640-post-8272894101105901249 from which I took the code to paste it in a console C# application under SharpDevelop 4.3.3.


/*
 * Created by SharpDevelop.
 * User: 0r4cl3D1gg4
 * Date: 14/10/2013
 * Time: 20:31
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Security.Cryptography;
using System.Text;

namespace CSharpRsaTest
{
    class Program
    {
        public static void Main(string[] args)
        {
            RSAParameters PublicKeyInfo;
            RSAParameters PrivateKeyInfo;
            byte[] EncryptedByte;
            byte[] DecryptedByte;

            /* Initialize RSA and Get Private and Public KeyInfo in paramters */
            RSACryptoServiceProvider Rsa = new RSACryptoServiceProvider();
            Rsa.KeySize = 1024;
          
            /* Generating Info that Contain Public Key Info and Private Key Info*/
            PublicKeyInfo = Rsa.ExportParameters(false);
            PrivateKeyInfo = Rsa.ExportParameters(true);
          
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

            /* Encrypt Data using Public Key Info */
            rsa.ImportParameters(PublicKeyInfo);
            UnicodeEncoding ue = new UnicodeEncoding();
          
            String strStringToEncrypt="This blog is cool";
            Console.WriteLine("String to encrypt = " + strStringToEncrypt);
            Console.WriteLine("Length of string to encrypt = " + strStringToEncrypt.Length.ToString());
          
            byte[] DataToEncrypt = ue.GetBytes(strStringToEncrypt);
            EncryptedByte = rsa.Encrypt(DataToEncrypt, false);

            /* Show Encrypted Data into Text Box */
            String strEncryptedByte = ue.GetString(EncryptedByte);
          
            Console.WriteLine("Length of encrypted byte array = " + EncryptedByte.GetLength(0));
          
            for (int i=0;i<EncryptedByte.GetLength(0);i++){
                Console.Write(EncryptedByte[i].ToString());
                if (i<EncryptedByte.GetLength(0)-1){
                    Console.Write(":");
                }
            }
          
            Console.WriteLine("");
            Console.WriteLine("Content of encrypted byte array = ");
            Console.WriteLine(strEncryptedByte);
          
            rsa.Dispose();

            Console.WriteLine("");
            Console.WriteLine("Decrypting");
          
            rsa = new RSACryptoServiceProvider();
            rsa.ImportParameters(PrivateKeyInfo);

            ue = new UnicodeEncoding();

            /* Decrypt Data and Show in Same TextBox */
            DecryptedByte  = rsa.Decrypt(EncryptedByte, false);

            /* Show Decrypted Data into TextBox */
            Console.WriteLine("Decrypted text = " + ue.GetString(DecryptedByte));
            rsa.Dispose();
          
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

samedi 7 septembre 2013

(Oracle AIA) Veille technologique : "Infor’s Challenges: Is the glass half-full or half-empty?"

http://www.computer.org/portal/web/Enterprise-Thinking/content?g=6416743&type=blogpost&urlTitle=infor%E2%80%99s-challenges%3A-is-the-glass-half-full-or-half-empty-

"Both are always harder than they seem to be.  The trick for Infor is to avoid the mistakes that Infor CEO Charles Phillips’ former company, Oracle, made with its Application Integration Architecture (AIA). Faced with a similar problem – the need to provide business process and technology innovation spanning multiple product lines –  Oracle came up with an extremely top-heavy, master-data centric approach that required customers to build and maintain a canonical data model, inside AIA, that would make AIA the hub of process and application integration. "

(Oracle AIA) Veille technologique : "The Customer Comes Second…..Oracle’s Engineered for Investors Software Stack"

http://www.eaconsult.com/2011/10/10/the-customer-comes-second%E2%80%A6-oracle%E2%80%99s-engineered-for-investors-software-stack/

"Four (or five, depending on how you count it) main product lines, each with its own code base. And literally dozens of other products, acquired with the goal of improving shareholder value, most of which also came with their own proprietary software or data models. Hundreds of business processes, many overlapping and redundant from one product to the next. And a big, hairy-chested middleware “suite” – Fusion Middleware – that is itself a conglomeration of technologies – a little Java here, some BEA and BPEL there, some MDM, some analytics , some DBMS technology, the more the merrier, all jammed into a one-size-fits-no-one morass of integration options. To simplify things, they also have an integration system called AIA that is used infrequently for the very reason that it’s an expensive, complex, technically challenging, and hard to cost-justify Tower of Babel erected to a false deity, the Oracle integrated software stack."