Read Whole SMS! - Windows Mobile Development and Hacking General

I have some problem In the RIL program when I try to get the whole Message...
this is a pointer to Array of Byte..passed to hexdump function..
prmMsg->msgInDeliver.rgbMsg
prmMsg is a RILMESSAGE structure..
If the body of the message is only one char I can read that char...
otherwise no!!
Can anyone Help me??
TCHAR *hexdump(unsigned char *data, int n)
{
static TCHAR buf[1000];
TCHAR *p;
p=buf;
while (n--)
{
p += _sntprintf(p, 4, TEXT("%c"), *data);
}
return buf;
}

Anyone have any Idea???????
Please......

I have the same problem Mister lollone,
I'm not able to read message...
when I shift array ..I read a random part of a memory..
but I cannot read the right sequence of char..
I don't know if anyone have accomplish that..

I don't know why the second and third byte are shifted..
at the first was added 1 bit ....
BYTE rgbMsg[MAXLENGTH_MSG];
why???
anyone know the solution....it's impossible!!!

RILMESSAGE
I have the same problem.......HELP US (qtek8080)

Maybe the problem is caused by Unicode. SMS messages can be sent using Unicode. Because it is double byte, treating it as a standard null terminated string would terminate after the first byte because it would encounter a null byte next.

Solution
Here the solution on how to read SMS:
TCHAR *hexdump(unsigned char *data, int n)
{
static TCHAR buf[1000];
unsigned char use=0;
unsigned char add=0;
unsigned char step=7;
unsigned char lo=0;
char tmp;
unsigned char shdgt=255;
int bpow=0;
unsigned char badd=0;
int pi=0;
int dt=0;
int dgt=0;
while (n--)
{
use = data[dt];
if ( step == 7 ) {
shdgt = shdgt >> 1;
lo = use & shdgt;
tmp= lo;
}
else {
shdgt = shdgt >> 1;
lo = use & shdgt;
tmp = lo << (7 - step);
tmp = tmp | add;
}
// get the digit that have to be used in the next char
dgt = 0;
add = 0;
for (int i=step; i<8; i++) {
bpow = pow(2,i);
badd = pow(2,dgt);
if ( use & bpow)
add = add + badd;
dgt++;
}
buf[pi]=tmp;
pi++;
if ( step == 1 ){
// have an extra char to write
buf[pi]=add;
// reset variables
add = 0;
step= 7;
shdgt=255;
pi++;
}
else
{
step--;
}
dt++;
}
return buf;
}
:wink: :wink:

Grazie mille ora lo proverò

OK i am a begginer at programming in eVC++ i would like to create an application like urs but i dont seem to be able to make it work, i'm a great programmer but eVC++ is bad for me.
Could somebody please post a working source code cos i have serious problems and it is critical for me to get a hold on this kind of source code to help me understand.
Thanks all for ur help !!!!!

Related

CreateDispatch error $800700C1 - evc4.0 Automation sample ?

Hi !
I testing make Out of procces server on XDA II (MDA II) in eVc++4. I have problems
with this. If i called in client this :
IComMDA m_ComMda;
COleException m_Error;
if (m_ComMda.CreateDispatch(_T("ComMDA.Document"),&m_Error))
{
AfxMessageBox(_T("CreateDispatch - TRUE"),MB_OK,0);
return TRUE;
}
else
{
AfxMessageBox(_T("CreateDispatch - FALSE"),MB_OK,0);
return FALSE;
}
the error occur
==> CreateDispatch returning scode = severity: SEVERITY_ERROR, facility:
FACILITY_WIN32 ($800700C1).
IComMDA is class created from typelibrary :
class IComMDA : public COleDispatchDriver
{
public:
IComMDA() {} // Calls COleDispatchDriver default constructor
IComMDA(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
IComMDA(const IComMDA& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
// Attributes
public:
// Operations
public:
BOOL InitInterface();
};
interface is declared :
[ uuid(713B5595-EF1F-4961-A179-E374E0C82903), version(1.0) ]
library ComMDA
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
// Primary dispatch interface for CComMDADoc
[ uuid(901AD61B-9974-448a-9E79-7898E0C80FFE) ]
dispinterface IComMDA
{
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CComMDADoc)
//}}AFX_ODL_PROP
methods:
// NOTE - ClassWizard will maintain method information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_METHOD(CComMDADoc)
[id(1)] boolean InitInterface();
//}}AFX_ODL_METHOD
};
// Class information for CComMDADoc
[ uuid(E523187A-FFB7-46e9-AA64-A6CB1BEAF9BB) ]
coclass Document
{
[default] dispinterface IComMDA;
};
//{{AFX_APPEND_ODL}}
//}}AFX_APPEND_ODL}}
};
Class is registered as :
CString strServerName;
CString strLocalServerName;
CString strLocalShortName;
CString strLocalFilterName;
CString strLocalFilterExt;
if (!m_pDocTemplate->GetDocString(strServerName,
CDocTemplate::regFileTypeId) || strServerName.IsEmpty())
{
return;
}
if (!m_pDocTemplate->GetDocString(strLocalServerName,
CDocTemplate::regFileTypeName))
strLocalServerName = strServerName; // use non-localized name
if (!m_pDocTemplate->GetDocString(strLocalShortName,
CDocTemplate::fileNewName))
strLocalShortName = strLocalServerName; // use long name
if (!m_pDocTemplate->GetDocString(strLocalFilterName,
CDocTemplate::filterName))
ASSERT(nAppType != OAT_DOC_OBJECT_SERVER);
if (!m_pDocTemplate->GetDocString(strLocalFilterExt,
CDocTemplate::filterExt))
ASSERT(nAppType != OAT_DOC_OBJECT_SERVER);
ASSERT(strServerName.Find(' ') == -1); // no spaces allowed
int nIconIndex = 0;
POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition();
for (int nIndex = 1; pos != NULL; nIndex++)
{
CDocTemplate* pTemplate = AfxGetApp()->GetNextDocTemplate(pos);
if (pTemplate == m_pDocTemplate)
{
nIconIndex = nIndex;
pos = NULL; // set exit condition
}
}
BOOL bResult = FALSE;
if (TRUE)
{
// call global helper to modify system registry
// progid, shortname, and long name are all equal in this case
if (!(bResult = AfxOleRegisterServerClass(m_clsid, strServerName,
strLocalShortName, strLocalServerName, nAppType,
rglpszRegister, rglpszOverwrite, nIconIndex,
strLocalFilterName, strLocalFilterExt)))
{
// not fatal (don't fail just warn)
AfxMessageBox(AFX_IDP_FAILED_TO_AUTO_REGISTER);
}
}
else
{
bResult = AfxOleUnregisterServerClass(m_clsid, m_lpszProgID, m_lpszProgID,
m_lpszProgID, OAT_DISPATCH_OBJECT);
}
return;
------------------------------------------------
type library is registered as AfxOleRegisterTypeLib(AfxGetInstanceHandle(),
clsid);
where >// {713B5595-EF1F-4961-A179-E374E0C82903}
static const GUID clsid =
{ 0x713b5595, 0xef1f, 0x4961, { 0xa1, 0x79, 0xe3, 0x74, 0xe0, 0xc8, 0x29,
0x3 } };
Thanks for your help.

eVc++ DLL used on .NET? Error

Hello,
I have written a DLL on eVC++. And now I want to use this DLL in a .NET program. But by "Add Reference" I got an error, that says:
This is not a .NET assembly.
So my question is, is it possible to using a eVC++ DLL on .NET?
If yes, what should I do, and if not, is there another way to do with this problem?
Thanks all
from http://www.csharphelp.com/archives/archive52.html
Code:
Call Unmanaged Code. Part 1 - Simple DLLImport
By Vyacheslav Biktagirov
Managed world is beautiful, I have all classes I want in FrameWork.. But what if I want call some unmanaged code? For instance, I have DLL written in C++, and want use it from C#.
Let's look some code. Our DLL exports some function, in CDecl convention, that sums two integers:
extern "C" __declspec(dllexport) __cdecl int sum(int a,int b);
And, of course, we want reuse this code in C#. We must recall, that it is no "direct" way to call unmanaged code, but we must inform the compiler, what we want to call, how, and where is needed code located.
[DllImport("TestDll.dll", EntryPoint="sum",
ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
static extern int sum(int a,int b);
and now we can call it like normal C# function.
x=5;
y=7;
z=sum(x,y); // x will receive 12
Here is full C# client code - tested for Beta2.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace WindowsApplication6
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox3;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 192);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(144, 64);
this.button1.TabIndex = 0;
this.button1.Text = "call sum";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(40, 120);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(72, 22);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "2";
//
// label1
//
this.label1.Location = new System.Drawing.Point(128, 128);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(16, 16);
this.label1.TabIndex = 2;
this.label1.Text = "+";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(152, 120);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(56, 22);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "3";
//
// label2
//
this.label2.Location = new System.Drawing.Point(224, 120);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(24, 23);
this.label2.TabIndex = 4;
this.label2.Text = "=";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(248, 120);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(112, 22);
this.textBox3.TabIndex = 5;
this.textBox3.Text = "5";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(576, 322);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox3,this.label2,this.textBox2,this.label1,this.textBox1,this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
#region My Code
#region Dll Imports
[DllImport("TestDll.dll", EntryPoint="sum",
ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
static extern int sum(int a,int b);
#endregion
#region Button Click Events
private void button1_Click(object sender, System.EventArgs e)
{
textBox3.Text=(int.Parse(textBox1.Text)+int.Parse(textBox2.Text)).ToString();
}
#endregion
#endregion
}
}
It sounds very simple, becouse "int" is isomorphic type, says, int in C# and ind C++ is identical. What we can do, when we want operate non-isomorhic types, like String? Recall, that .NET string is some Class, while C++ string is char*,or wchar_t*,or BSTR, .. String may be embedded in a structure, or pointed by pointer, or even something more exotic. Let's call some string function.
[DllImport("Advapi32.dll", EntryPoint="GetUserName", ExactSpelling=false,
SetLastError=true)]
static extern bool GetUserName(
[MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer,
[MarshalAs(UnmanagedType.LPArray)] Int32[] nSize );
This function receives two parameters: char* and int*. Becouse we must allocate char* buffer and receive string by pointer, we can't use UnmanagedType.LPStr attribute, so we pass ANSI string as byte array. int* is more simple-it's 1-element Int32 array. Let's call it:
private void button2_Click(object sender, System.EventArgs e)
{
byte[] str=new byte[20];
Int32[] len=new Int32[1];
len[0]=20;
GetUserName(str,len);
MessageBox.Show(System.Text.Encoding.ASCII.GetString(str));
}
We allocate 20 bytes for receiving ANSI string,one element in Int32 array, set 20 as max string length and call it. For receiving string from byte array I used Text.Encoding.ASCII class.

[Guide] Accessing all Build.prop values without Root

Hi.
I was developing an app in which I needed to access some of the build.prop values without accessing root.
After some days finally I found a good & working solution.
So, for whom they need it later, I decided to share it here.
All you have to do is this :
1. Make a process which executes "getprop" from the "/system/bin/getprop" directory and initialize the String which we want to get (ro.board.platform in example).
2. Make a BufferedReader which gets the value (String) by retrieving the data from a inputStreamReader().
3.Convert the BufferedReader to String.
Help your selves.
Code:
Process p = null;
String board_platform = "";
try {
p = new ProcessBuilder("/system/bin/getprop", "ro.board.platform").redirectErrorStream(true).start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line=br.readLine()) != null){
board_platform = line;
}
p.destroy();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thanks man!.,,..
But are we really in such a need of getprop? If I remember correctly, on all Android devices /system partition is world-readable. So we can just read it build.prop like a normal text file and then parse it.
Dr.Alexander_Breen said:
But are we really in such a need of getprop? If I remember correctly, on all Android devices /system partition is world-readable. So we can just read it build.prop like a normal text file and then parse it.
Click to expand...
Click to collapse
Maybe you're right.
But before the Tut، I collected some info on build.prop.
I read different files from different devices with different ROMs.
And I gained a result : The file differs from ROM to ROM and from device to device.
I had thought of this knowing that in device Nexus 4 "ro.x.y" is in line "z" forexample :
1. Create BufferedReader to read the build.prop file.
2.
// Let's consider ro.x.y : outcome in build.prop
int x = 0;
String y ="";
If ((y = br.readLine()) != null) {
x++;
String line = y;
if (x = z){
// So we have found ro.x.y
String result = line;
result = result.replaceAll("ro.x.y", "");
result = result.replaceAll(" :", "");
}
}
Using this procedure we have retreived the ro.x.y value in Nexus 4.
But does anybody promise that ro.x.y is in line "z" in all devices?
The answer is NO as I mentioned above.
Maybe someone has changed his build.prop file and ... .
I hope it helps.
Shouldn't the title be [Guide], not [Guilde]?
nikwen said:
Shouldn't the title be [Guide], not [Guilde]?
Click to expand...
Click to collapse
Thanks sir.
Didn't notice at all.
And here is C# Translation for the code:
------------------------------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------------------------------
Code:
private Process p = null;
private string AdbPath = Path.Combine(Path.GetTempPath(), "RegawMOD", "AndroidLib", "adb");
------------------------------------------------------------------------------------------------
Process Definition
------------------------------------------------------------------------------------------------
Code:
try
{
p = new Process();
ProcessStartInfo sInfo = new ProcessStartInfo("cmd");
sInfo.RedirectStandardOutput = true;
sInfo.RedirectStandardInput = true;
sInfo.CreateNoWindow = true;
sInfo.UseShellExecute = false;
sInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo = sInfo;
p.OutputDataReceived += p_OutputDataReceived;
p.EnableRaisingEvents = true;
p.Start();
p.BeginOutputReadLine();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error starting adb process", MessageBoxButton.OK, MessageBoxImage.Error);
}
------------------------------------------------------------------------------------------------
p_OutputDataReceived Definition
------------------------------------------------------------------------------------------------
Code:
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
string line = "";
try
{
if (!(line = e.Data).Trim().Length.Equals(0) && !line.Contains("/system/bin/getprop ro.board.platform"))
{
this.Dispatcher.BeginInvoke(new Action(() => txt.AppendText(line + "\n")));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error Reading Output", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
------------------------------------------------------------------------------------------------
Passing command to our little adb process
------------------------------------------------------------------------------------------------
Code:
if (p != null)
{
p.StandardInput.WriteLine(AdbPath + " shell /system/bin/getprop ro.board.platform");
}
------------------------------------------------------------------------------------------------
Side Notes:
------------------------------------------------------------------------------------------------
Code above will result in active shell, it's a simulation for executing commands via CMD
What you need to do is the following:
Change "AdbPath" content to match the path of your adb executable.
"txt" is the Textbox that will show the output, put your own object.
Remove this line " !line.Contains("/system/bin/getprop ro.board.platform);" from "p_OutputDataReceived" to have an idea why I included it in the first place, it's not a must to have it but it will make output look nicer.
In the "Passing command to our little adb process" section, you can replace " shell /system ...etc" with your own object to make the app flexible and be able to execute any command the user type [example: .p.StandardInput.WriteLine(String.Join(" ", AdbPath , CommandTextBox.Text));]
This is almost the same code I execute in Droid Manager for the active shell, I just added few more lines to serve my active shell demands
My device is rooted, nevertheless it doesn't matter which language we are using, as long as we are executing the same command, then it should work with non rooted devices too just like OP says
I use AndroidLib that's why my Adb path points to AndroidLib's adb executable.
------------------------------------------------------------------------------------------------
Good luck
------------------------------------------------------------------------------------------------
Edit:
Dr.Alexander_Breen said:
But are we really in such a need of getprop? If I remember correctly, on all Android devices /system partition is world-readable. So we can just read it build.prop like a normal text file and then parse it.
Click to expand...
Click to collapse
@Dr.Alexander_Breen Yes /system is read only and we can read the file, but if you read it like a text file you will have to break text apart to get the value and not key + value. and you will have to go line by line to reach the key you want, so by using "getprop" you will get the value without having to write extra lines of code to make the app show you value only. As for me I prefer it that way, no need to make the app execute more lines of code just to get a part of the string.
torpedo mohammadi said:
Using this procedure we have retreived the ro.x.y value in Nexus 4.
But does anybody promise that ro.x.y is in line "z" in all devices?
The answer is NO as I mentioned above.
Maybe someone has changed his build.prop file and ... .
I hope it helps.
Click to expand...
Click to collapse
Well, we are supposed to write smart parser which is indifferent to line number, it searches by key name...and gets the value. However, that is the reinvention of the wheel - getprop does exactly the same.
Just saying that the same result is available without the getprop. But it will be (or will not if you're really good in regular expressions) harder, yes.
Alternatively, you can use reflection to access Android's internal android.os.SystemProperties class.
Here is the class I use to reflect it in Pimp My Rom :
Code:
package com.androguide.pimpmyrom.helpers;
import android.content.Context;
import java.io.File;
import java.lang.reflect.Method;
import dalvik.system.DexFile;
/*
Class using reflection to grant access to the private hidden android.os.SystemProperties class
*/
public class SystemPropertiesReflection {
/**
* This class cannot be instantiated
*/
private SystemPropertiesReflection() {
}
/**
* Get the value for the given key.
*
* @return an empty string if the key isn't found
* @Throws IllegalArgumentException if the key exceeds 32 characters
*/
public static String get(Context context, String key) throws IllegalArgumentException {
String ret = "";
try {
ClassLoader cl = context.getClassLoader();
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class[] paramTypes = new Class[1];
paramTypes[0] = String.class;
Method get = SystemProperties.getMethod("get", paramTypes);
//Parameters
Object[] params = new Object[1];
params[0] = new String(key);
ret = (String) get.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = "";
//TODO
}
return ret;
}
/**
* Get the value for the given key.
*
* [user=2056652]@return[/user] if the key isn't found, return def if it isn't null, or an empty string otherwise
* [user=948141]@Throw[/user]s IllegalArgumentException if the key exceeds 32 characters
*/
public static String get(Context context, String key, String def) throws IllegalArgumentException {
String ret = def;
try {
ClassLoader cl = context.getClassLoader();
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = String.class;
Method get = SystemProperties.getMethod("get", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new String(def);
ret = (String) get.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Get the value for the given key, and return as an integer.
*
* [user=955119]@param[/user] key the key to lookup
* [user=955119]@param[/user] def a default value to return
* [user=2056652]@return[/user] the key parsed as an integer, or def if the key isn't found or
* cannot be parsed
* [user=948141]@Throw[/user]s IllegalArgumentException if the key exceeds 32 characters
*/
public static Integer getInt(Context context, String key, int def) throws IllegalArgumentException {
Integer ret = def;
try {
ClassLoader cl = context.getClassLoader();
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = int.class;
Method getInt = SystemProperties.getMethod("getInt", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new Integer(def);
ret = (Integer) getInt.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Get the value for the given key, and return as a long.
*
* [user=955119]@param[/user] key the key to lookup
* [user=955119]@param[/user] def a default value to return
* [user=2056652]@return[/user] the key parsed as a long, or def if the key isn't found or
* cannot be parsed
* [user=948141]@Throw[/user]s IllegalArgumentException if the key exceeds 32 characters
*/
public static Long getLong(Context context, String key, long def) throws IllegalArgumentException {
Long ret = def;
try {
ClassLoader cl = context.getClassLoader();
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = long.class;
Method getLong = SystemProperties.getMethod("getLong", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new Long(def);
ret = (Long) getLong.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Get the value for the given key, returned as a boolean.
* Values 'n', 'no', '0', 'false' or 'off' are considered false.
* Values 'y', 'yes', '1', 'true' or 'on' are considered true.
* (case insensitive).
* If the key does not exist, or has any other value, then the default
* result is returned.
*
* [user=955119]@param[/user] key the key to lookup
* [user=955119]@param[/user] def a default value to return
* [user=2056652]@return[/user] the key parsed as a boolean, or def if the key isn't found or is
* not able to be parsed as a boolean.
* [user=948141]@Throw[/user]s IllegalArgumentException if the key exceeds 32 characters
*/
public static Boolean getBoolean(Context context, String key, boolean def) throws IllegalArgumentException {
Boolean ret = def;
try {
ClassLoader cl = context.getClassLoader();
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = boolean.class;
Method getBoolean = SystemProperties.getMethod("getBoolean", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new Boolean(def);
ret = (Boolean) getBoolean.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Set the value for the given key.
*
* [user=948141]@Throw[/user]s IllegalArgumentException if the key exceeds 32 characters
* [user=948141]@Throw[/user]s IllegalArgumentException if the value exceeds 92 characters
*/
public static void set(Context context, String key, String val) throws IllegalArgumentException {
try {
[user=1299008]@supp[/user]ressWarnings("unused")
DexFile df = new DexFile(new File("/system/app/Settings.apk"));
[user=1299008]@supp[/user]ressWarnings("unused")
ClassLoader cl = context.getClassLoader();
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class SystemProperties = Class.forName("android.os.SystemProperties");
//Parameters Types
[user=1299008]@supp[/user]ressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = String.class;
Method set = SystemProperties.getMethod("set", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new String(val);
set.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
//TODO
}
}
}
Then, you can create a static method like the following in order to avoid NPEs if the property we're asking for isn't present and such:
Code:
public static String getSystemProp(Context context, String prop, String default) {
String result = null;
try {
result = SystemPropertiesReflection.get(context, prop);
} catch (IllegalArgumentException iae) {
Log.e(TAG, "Failed to get prop: " + prop);
}
return result == null ? default : result;
}
And simply invoke it to get the returned property, for example:
Code:
String prop = getSystemProp(this, "ro.sf.lcd_density", "213");
EDIT : sorry to the guys that were @ mentionned by the code's annotations
@ whoever's code I decide to use: Thanks, I'll make use of this in my library I'll put you in the credits :good:
I'm using the code in the OP and it's returning the default value, but not the actual value... This is really weird...
EDIT: Ok, so it won't update values until I reboot the device. Is there any workaround?
Tezlastorme said:
EDIT: Ok, so it won't update values until I reboot the device. Is there any workaround?
Click to expand...
Click to collapse
The system properties are not reloaded after you edit the build.prop, you need a reboot, or you've to read from build.prop file.
vektor88 said:
The system properties are not reloaded after you edit the build.prop, you need a reboot, or you've to read from build.prop file.
Click to expand...
Click to collapse
But whenever I read directly from build.prop something screws up, like build.prop becomes empty or deletes itself. In my last test my sdcard became corrupted and build.prop became blank.
Sent from my Galaxy Nexus
Tezlastorme said:
But whenever I read directly from build.prop something screws up, like build.prop becomes empty or deletes itself. In my last test my sdcard became corrupted and build.prop became blank.
Sent from my Galaxy Nexus
Click to expand...
Click to collapse
Use setprop and getprop in addition to the changes you make to the build.prop, this way you can get the current value without the hassle or performance loss of having to parse the whole build.prop for each value you want to read.
For example, if you change ro.whatever=true to ro.whatever=false, also do a setprop ro.whatever false so that you can retrieve the value from getprop ro.whatever
Dr.Alexander_Breen said:
But are we really in such a need of getprop? If I remember correctly, on all Android devices /system partition is world-readable. So we can just read it build.prop like a normal text file and then parse it.
Click to expand...
Click to collapse
If this is true (and i think it is), why <ou don't simply use the Java Properties class to read the prop file?
developer.android.com/reference/java/util/Properties.html
Sorry for answering in this old Thread, but i dont see why you read the properties file by yourself.
amfa84 said:
If this is true (and i think it is), why <ou don't simply use the Java Properties class to read the prop file?
developer.android.com/reference/java/util/Properties.html
Sorry for answering in this old Thread, but i dont see why you read the properties file by yourself.
Click to expand...
Click to collapse
Yeah, it should work, in theory.. But in practice it screw things up a lot. It ends up deleting the whole contents of build.prop or not reading correctly and it's very unpredictable :-/
And yes I was using the Properties class (and still do)
Sent from my sushi grade tuna
---------- Post added at 08:48 AM ---------- Previous post was at 08:47 AM ----------
Androguide.fr said:
Use setprop and getprop in addition to the changes you make to the build.prop, this way you can get the current value without the hassle or performance loss of having to parse the whole build.prop for each value you want to read.
For example, if you change ro.whatever=true to ro.whatever=false, also do a setprop ro.whatever false so that you can retrieve the value from getprop ro.whatever
Click to expand...
Click to collapse
Btw I tried this ^^ and it didn't work
Sent from my sushi grade tuna
Tezlastorme said:
Yeah, it should work, in theory.. But in practice it screw things up a lot. It ends up deleting the whole contents of build.prop or not reading correctly and it's very unpredictable :-/
And yes I was using the Properties class (and still do)
Sent from my sushi grade tuna
---------- Post added at 08:48 AM ---------- Previous post was at 08:47 AM ----------
Btw I tried this ^^ and it didn't work
Sent from my sushi grade tuna
Click to expand...
Click to collapse
Then you're not doing it right, it does work, and it's very easy to test, just open Terminal emulator, and try the following:
Code:
setprop ro.test.prop true
getprop ro.test.prop
# returns
true
As I said, this will not modify the build.prop, but if everytime you modify the build.prop you also use setprop, then you can avoir the big performance overhead of having to parse the whole build.prop just to get the value of a single prop.
The best way to me remains accessing the private android.os.SystemProperties class through reflection. I believe I had already posted the class in this thread earlier, but here it is:
PHP:
package com.androguide.pimpmyromv2.helpers;
import android.content.Context;
import java.io.File;
import java.lang.reflect.Method;
import dalvik.system.DexFile;
/**
* Class using reflection to grant access to the private hidden android.os.SystemProperties class
*/
public class SystemPropertiesReflection {
/**
* This class cannot be instantiated
*/
private SystemPropertiesReflection() {
}
/**
* Get the value for the given key.
*
* @return an empty string if the key isn't found
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static String get(Context context, String key) throws IllegalArgumentException {
String ret = "";
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[1];
paramTypes[0] = String.class;
Method get = SystemProperties.getMethod("get", paramTypes);
//Parameters
Object[] params = new Object[1];
params[0] = new String(key);
ret = (String) get.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = "";
//TODO
}
return ret;
}
/**
* Get the value for the given key.
*
* @return if the key isn't found, return def if it isn't null, or an empty string otherwise
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static String get(Context context, String key, String def) throws IllegalArgumentException {
String ret = def;
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = String.class;
Method get = SystemProperties.getMethod("get", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new String(def);
ret = (String) get.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Get the value for the given key, and return as an integer.
*
* @param key the key to lookup
* @param def a default value to return
* @return the key parsed as an integer, or def if the key isn't found or
* cannot be parsed
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static Integer getInt(Context context, String key, int def) throws IllegalArgumentException {
Integer ret = def;
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = int.class;
Method getInt = SystemProperties.getMethod("getInt", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new Integer(def);
ret = (Integer) getInt.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Get the value for the given key, and return as a long.
*
* @param key the key to lookup
* @param def a default value to return
* @return the key parsed as a long, or def if the key isn't found or
* cannot be parsed
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static Long getLong(Context context, String key, long def) throws IllegalArgumentException {
Long ret = def;
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = long.class;
Method getLong = SystemProperties.getMethod("getLong", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new Long(def);
ret = (Long) getLong.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Get the value for the given key, returned as a boolean.
* Values 'n', 'no', '0', 'false' or 'off' are considered false.
* Values 'y', 'yes', '1', 'true' or 'on' are considered true.
* (case insensitive).
* If the key does not exist, or has any other value, then the default
* result is returned.
*
* @param key the key to lookup
* @param def a default value to return
* @return the key parsed as a boolean, or def if the key isn't found or is
* not able to be parsed as a boolean.
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static Boolean getBoolean(Context context, String key, boolean def) throws IllegalArgumentException {
Boolean ret = def;
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = boolean.class;
Method getBoolean = SystemProperties.getMethod("getBoolean", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new Boolean(def);
ret = (Boolean) getBoolean.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
//TODO
}
return ret;
}
/**
* Set the value for the given key.
*
* @throws IllegalArgumentException if the key exceeds 32 characters
* @throws IllegalArgumentException if the value exceeds 92 characters
*/
public static void set(Context context, String key, String val) throws IllegalArgumentException {
try {
@SuppressWarnings("unused")
DexFile df = new DexFile(new File("/system/app/Settings.apk"));
@SuppressWarnings("unused")
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = Class.forName("android.os.SystemProperties");
//Parameters Types
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = String.class;
Method set = SystemProperties.getMethod("set", paramTypes);
//Parameters
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new String(val);
set.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
//TODO
}
}
}
one x new in android
torpedo mohammadi said:
Hi.
I was developing an app in which I needed to access some of the build.prop values without accessing root.
After some days finally I found a good & working solution.
So, for whom they need it later, I decided to share it here.
All you have to do is this :
1. Make a process which executes "getprop" from the "/system/bin/getprop" directory and initialize the String which we want to get (ro.board.platform in example).
2. Make a BufferedReader which gets the value (String) by retrieving the data from a inputStreamReader().
3.Convert the BufferedReader to String.
Help your selves.
Code:
Process p = null;
String board_platform = "";
try {
p = new ProcessBuilder("/system/bin/getprop", "ro.board.platform").redirectErrorStream(true).start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line=br.readLine()) != null){
board_platform = line;
}
p.destroy();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Click to expand...
Click to collapse
Hi, Is anyone nood friendly to explain me or some tutorial where and how to put this comand, to change my build.prop without unlocking bootloader on my HOX tegra 3..grateful for any response
---------- Post added at 01:25 PM ---------- Previous post was at 01:13 PM ----------
torpedo mohammadi said:
Hi.
I was developing an app in which I needed to access some of the build.prop values without accessing root.
After some days finally I found a good & working solution.
So, for whom they need it later, I decided to share it here.
All you have to do is this :
1. Make a process which executes "getprop" from the "/system/bin/getprop" directory and initialize the String which we want to get (ro.board.platform in example).
2. Make a BufferedReader which gets the value (String) by retrieving the data from a inputStreamReader().
3.Convert the BufferedReader to String.
Help your selves.
Code:
Process p = null;
String board_platform = "";
try {
p = new ProcessBuilder("/system/bin/getprop", "ro.board.platform").redirectErrorStream(true).start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line=br.readLine()) != null){
board_platform = line;
}
p.destroy();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Click to expand...
Click to collapse
Hi, Is anyone nood friendly to explain me or some tutorial where and how to put this comand, to change my build.prop without unlocking bootloader on my HOX tegra 3..grateful for any response
Hey,
Sorry for bumping this old thread.
How a non-developer user could use this to change/add build.prop lines?
I got a complete stock Nexus 5X that I'd like to add some new lines into build.prop without root.
Is it possible?
Thanks in advance!
How to integrate that to show in textView?

[Q] How to convert extended ASCII character to number in Android?

Hi!
Can you help me, please? I'm working on an Android app. I get some characters from a file on the Internet and put it to a TextView. These characters are ASCII characters. Then I read these characters one by one and convert it to numbers with the following code:
Code:
char my_char2;
char my_char3;
int myNum = 0;
for (int k = 170; k < len; k++) {
if (c.charAt(k) == '0' && c.charAt(k+1) == '.') {
my_char2 = c.charAt(k+13);
my_char3 = c.charAt(k+14);
myNum = my_char2 * 256 + my_char3;
}
}
Then I write it to an another TextView:
Code:
crlNumber.setText("" + myNum);
The problem is that this can only convert standard ASCII characters(from 0 to 127) except of the new line character(character number 10), carriage return character(character number 13) and the cancel character(character number 24).
But I need to convert also the extended ASCII characters(from 128 to 255) and the 3 characters mentioned above.
What should I do?
Thanks for helping.
Do these help?
http://stackoverflow.com/questions/13826781/java-extended-ascii-table-usage
http://stackoverflow.com/questions/5535988/string-to-binary-and-vice-versa-extended-ascii
nikwen said:
Do these help?
http://stackoverflow.com/questions/13826781/java-extended-ascii-table-usage
http://stackoverflow.com/questions/5535988/string-to-binary-and-vice-versa-extended-ascii
Click to expand...
Click to collapse
A little. I have tried the following code below. It didn't show me the number of the extended ascii characters. But I think I should somehow read the text not as a String, but as a byte, and then I think, it should work(maybe I am wrong). If it is right, please, can you tell me, how should I do it?
Code:
final String textSource = "path to my file";
URL textUrl;
try {
textUrl = new URL(textSource);
BufferedReader bufferReader = new BufferedReader(
new InputStreamReader(textUrl.openStream()));
String StringBuffer;
String stringText = "";
while ((StringBuffer = bufferReader.readLine()) != null) {
stringText += StringBuffer;
}
bufferReader.close();
textMsg.setText(stringText);
String PT = textMsg.getText().toString();
CharSequence c = new String(PT);
String string0 = "";
String string1 = "";
char my_char2;
char my_char3;
String binary = "";
String binary2 = "";
int myNum2 = 0;
int decimalValue1 = 0;
int decimalValue2 = 0;
for (int k = 170; k < len; k++) {
if (c.charAt(k) == '0' && c.charAt(k+1) == '.') {
my_char2 = c.charAt(k+13);
my_char3 = c.charAt(k+14);
string0 = Character.toString(my_char2);
string1 = Character.toString(my_char3);
char[] buffer = string0.toCharArray();
byte[] b = new byte[buffer.length];
for (int i = 0; i < b.length; i++) {
b[i] = (byte) buffer[i];
binary = Integer,toBinaryString(b[i] & 0xFF);
decimalValue1 = Integer.parseInt(binary, 2);
}
char[] buffer2 = string1.toCharArray();
byte[] b2 = new byte[buffer2.length];
for (int i = 0; i < b2.length; i++) {
b2[i] = (byte) buffer2[i];
binary2 = Integer.toBinaryString(b2[i] & 0xFF);
decimalValue2 = Integer.parseInt(binary2, 2);
}
myNum2 = decimalValue1 * 256 + decimalValue2;
}
}
crlNumber.setText("" + binary2 + "," + decimalValue1 + "," + decimalValue2 + "," + myNum2);
}
adamhala007 said:
A little. I have tried the following code below. It didn't show me the number of the extended ascii characters. But I think I should somehow read the text not as a String, but as a byte, and then I think, it should work(maybe I am wrong). If it is right, please, can you tell me, how should I do it?
Code:
final String textSource = "path to my file";
URL textUrl;
try {
textUrl = new URL(textSource);
BufferedReader bufferReader = new BufferedReader(
new InputStreamReader(textUrl.openStream()));
String StringBuffer;
String stringText = "";
while ((StringBuffer = bufferReader.readLine()) != null) {
stringText += StringBuffer;
}
bufferReader.close();
textMsg.setText(stringText);
String PT = textMsg.getText().toString();
CharSequence c = new String(PT);
String string0 = "";
String string1 = "";
char my_char2;
char my_char3;
String binary = "";
String binary2 = "";
int myNum2 = 0;
int decimalValue1 = 0;
int decimalValue2 = 0;
for (int k = 170; k < len; k++) {
if (c.charAt(k) == '0' && c.charAt(k+1) == '.') {
my_char2 = c.charAt(k+13);
my_char3 = c.charAt(k+14);
string0 = Character.toString(my_char2);
string1 = Character.toString(my_char3);
char[] buffer = string0.toCharArray();
byte[] b = new byte[buffer.length];
for (int i = 0; i < b.length; i++) {
b[i] = (byte) buffer[i];
binary = Integer,toBinaryString(b[i] & 0xFF);
decimalValue1 = Integer.parseInt(binary, 2);
}
char[] buffer2 = string1.toCharArray();
byte[] b2 = new byte[buffer2.length];
for (int i = 0; i < b2.length; i++) {
b2[i] = (byte) buffer2[i];
binary2 = Integer.toBinaryString(b2[i] & 0xFF);
decimalValue2 = Integer.parseInt(binary2, 2);
}
myNum2 = decimalValue1 * 256 + decimalValue2;
}
}
crlNumber.setText("" + binary2 + "," + decimalValue1 + "," + decimalValue2 + "," + myNum2);
}
Click to expand...
Click to collapse
Hm, I don't know. According to this answer, you can change the encoding on the desktop, otherwise you will just see question marks.
But according to the accepted answer here, this should be done automatically on a Linux system. And Android is Linux based. Did you try it on an Android device or just on your computer?
Bytes shouldn't work. In Java they are signed, so their range is -128 ... 127.
nikwen said:
Hm, I don't know. According to this answer, you can change the encoding on the desktop, otherwise you will just see question marks.
But according to the accepted answer here, this should be done automatically on a Linux system. And Android is Linux based. Did you try it on an Android device or just on your computer?
Bytes shouldn't work. In Java they are signed, so their range is -128 ... 127.
Click to expand...
Click to collapse
Yes, I tried it on my Android device. Maybe, the best choice would be then to use that certificate code which you suggested me in one of my previous threads, but the problem is, that I am beginner in Android developing and I read it and I didn't know how to use it in my code. So I thougt, if I got the 2 ASCII characters and converted it to decimal numbers, it would also work. And it also works until I have the standard ASCII characters. When there is an extended ASCII character, it shows me the number 65533.
adamhala007 said:
Yes, I tried it on my Android device. Maybe, the best choice would be then to use that certificate code which you suggested me in one of my previous threads, but the problem is, that I am beginner in Android developing and I read it and I didn't know how to use it in my code. So I thougt, if I got the 2 ASCII characters and converted it to decimal numbers, it would also work. And it also works until I have the standard ASCII characters. When there is an extended ASCII character, it shows me the number 65533.
Click to expand...
Click to collapse
But I think I have found out something.
Code:
string0 = Character.toString(my_char2);
string1 = Character.toString(my_char3);
int one = 0;
int two = 0;
String ascii1="\u001f";
String ascii2="\u0018";
String aa = "";
String bb = "";
if(string0.equals(ascii1)){
one = one + 31;
aa = aa + one;
}else{
one = 1;
}
if(string1.equals(ascii2)){
two = two + 24;
bb = bb + two;
}else{
two = 1;
}
textPrompt.setText("" + aa + bb);
But this needs a little correction, because this way it doesn't show me anything, but if I write
Code:
textPrompt.setText("" + aa);
inside my first if statement it shows me correctly 31. What can be the mistake I have made?
convert ASCII character
I'm a self android learner. I want to convert ascii code to character. Here is the code I used.
String s = "1000001";
int num = Integer.parseInt(s, 2);
TextView textView = new TextView(this);
textView.setText(String.valueOf(num));
setContentView(textView);
Here s is 1000001(65 in decimal) 65 is ascii value of 'A'. I want to get 'A' in my output screen.variable num has the value 65. please help me

[Q]What is the method name of this code block?

Hey guys I can't figure out the method name of this code block.
There are 2 more methods jus before it with the same "public BatteryMeterView".
the part in red what I want to change. Am using xposed code for it. Plz help asap.
Code:
public BatteryMeterView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final Resources res = context.getResources();
TypedArray levels = res.obtainTypedArray(R.array.batterymeter_color_levels);
TypedArray colors = res.obtainTypedArray(R.array.batterymeter_color_values);
final int N = levels.length();
mColors = new int[2*N];
for (int i=0; i<N; i++) {
mColors[2*i] = levels.getInt(i, 0);
mColors[2*i+1] = colors.getColor(i, 0);
}
levels.recycle();
colors.recycle();
mShowPercent = ENABLE_PERCENT && 0 != Settings.System.getInt(
[COLOR=Red][B]context.getContentResolver(), "status_bar_show_battery_percent", 0);[/B][/COLOR]
mWarningString = context.getString(R.string.battery_meter_very_low_overlay_symbol);
mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mFramePaint.setColor(res.getColor(R.color.batterymeter_frame_color));
mFramePaint.setDither(true);
mFramePaint.setStrokeWidth(0);
mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE);
mFramePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));
mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBatteryPaint.setDither(true);
mBatteryPaint.setStrokeWidth(0);
mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
[COLOR=Red][B] mTextPaint.setColor(0xFFFFFFFF);[/B][/COLOR]
Typeface font = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
mTextPaint.setTypeface(font);
mTextPaint.setTextAlign(Paint.Align.CENTER);
mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mWarningTextPaint.setColor(mColors[1]);
font = Typeface.create("sans-serif", Typeface.BOLD);
mWarningTextPaint.setTypeface(font);
mWarningTextPaint.setTextAlign(Paint.Align.CENTER);
mChargeColor = getResources().getColor(R.color.batterymeter_charge_color);
mBoltPaint = new Paint();
mBoltPaint.setAntiAlias(true);
mBoltPaint.setColor(res.getColor(R.color.batterymeter_bolt_color));
mBoltPoints = loadBoltPoints(res);
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
SArnab©® said:
Hey guys I can't figure out the method name of this code block.
There are 2 more methods jus before it with the same "public BatteryMeterView".
the part in red what I want to change. Am using xposed code for it. Plz help asap.
Click to expand...
Click to collapse
Well the method is the constructor of the View, so it's name is exactly
Code:
BatteryMeterView(Context context, AttributeSet attrs, int defStyle)[\CODE]
Make sure you have the parameters as well since Java methods are only identical if they have the same return type, name and parameters. Not so sure how you would hook that method with xposed since I never did anything with it, but my guess would be to just copy the code from here to the method that runs before the hooked method, and then don't call that method at all. That way your method is larger but as the variables which you want to change are initialized right there it's the only way to do it.

Categories

Resources