Question regarding Vue-native - Android Q&A, Help & Troubleshooting

hello,
I'm working on a Vue-native project. I'm asking the question here because there is a limited community of developers using vue-native.
i'm working on a vue-native project where i need to create a hexadecimal to decimal and decimal back to hexadecimal converter. i have absolutely no clue about this numbering system. Is there any way I can create a converter in javascript or any other language?

Yes, pretty easily actually
JavaScript:
const base = 16;
let decNumber = 1234
let hexNumber = decNumber.toString(base)
console.log(hexNumber)
//"4d2"
typeof hexNumber
//"string"
and the other way around:
JavaScript:
const base = 16;
let hexNumber = "4d2"
let decNumber = parseInt(hexNumber, base)
console.log(decNumber)
//1234
typeof decNumber
//"number"
By changing "base" you can convert to other types:
JavaScript:
base = 2 //binary
base = 8 //octadecimal
base = 16 //hexadecimal

Thanks sir. This piece actually worked. I really appreciate it!..

denzelvieta said:
Thanks sir. This piece actually worked. I really appreciate it!..
Click to expand...
Click to collapse
istir said:
Yes, pretty easily actually
JavaScript:
const base = 16;
let decNumber = 1234
let hexNumber = decNumber.toString(base)
console.log(hexNumber)
//"4d2"
typeof hexNumber
//"string"
and the other way around:
JavaScript:
const base = 16;
let hexNumber = "4d2"
let decNumber = parseInt(hexNumber, base)
console.log(decNumber)
//1234
typeof decNumber
//"number"
By changing "base" you can convert to other types:
JavaScript:
base = 2 //binary
base = 8 //octadecimal
base = 16 //hexadecimal
Click to expand...
Click to collapse
Hello sir,
I just showed the answer to my client and this code does not return the correct answer for the large digits. For example, if i insert this number "1111111111111111" then this code returns "37450626705270707" which the actual answer is "1229782938247303441". My client gave me reference of this tool: https://binarytotext.net/hexadecimal-to-decimal/. Is there any way I can get the correct answer for the larger numbers?

There's nothing wrong with the code. Use Bignumber.js, it is used to handle big numbers in Javascript!!!

denzelvieta said:
Hello sir,
I just showed the answer to my client and this code does not return the correct answer for the large digits. For example, if i insert this number "1111111111111111" then this code returns "37450626705270707" which the actual answer is "1229782938247303441". My client gave me reference of this tool: https://binarytotext.net/hexadecimal-to-decimal/. Is there any way I can get the correct answer for the larger numbers?
Click to expand...
Click to collapse
I'm pretty sure this isn't an error in the code but rather "bug" in javascript.
As per this stackoverflow answer javascript uses IEEE-754 for storing numbers (which is mostly used for storing doubles, not integers). If you want to see what happens when you type in a really big number check out this tool (that's why you don't want to store eg. phone number as an integer).
This stackoverflow answer should probably give you a good idea what to do. This answer works for "1111111111111111".

Related

Getting IMEI within an EVC program

Does anyone know how to programmatically read the IMEI using embedded visual C. I have tried the TAPI lineGetGeneralInfo function but this always seems to return an error, as it requires TAPI extensions which don't seem to work. Is there any other function or API which returns this info?
Any help would be appreciated.
You need to use the SimGetRecordInfo() function. The IMEI is stored at address 0x6F07.
Steve
Thanks,
However this is the Sim's IMSI (International Mobile Subs Identifier) which identifies the country and home network. I am trying to get the phone's IMEI which is the electronic serial no of the phone (to use as part of a secure https validation procedure).
IMEI Code
#include <TAPI.h>
#include <ExTAPI.h>
#define TAPI_VERSION_1_0 0x00010003
#define TAPI_VERSION_1_4 0x00010004
#define TAPI_VERSION_2_0 0x00020000
void CALLBACK lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
void GetError(DWORD dwReturn);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HLINEAPP hLineAp = NULL;
DWORD dwNumDevs, dwDeviceID = 2;
HLINE hLine = NULL;
int i;
WCHAR szIMSI[180];
WCHAR szIMEI[180];
WCHAR szOutput[50];
LINEGENERALINFO lpLineInfo;
DWORD dwReturn, dwAPIVersion = TAPI_CURRENT_VERSION;
lineInitialize(&hLineAp, hInstance, lineCallbackFunc, NULL, &dwNumDevs);
lineNegotiateExtVersion(hLineAp, dwDeviceID, TAPI_VERSION_1_0, TAPI_CURRENT_VERSION, dwAPIVersion, NULL);
lineOpen(hLineAp, dwDeviceID, &hLine, dwAPIVersion, 0, 0, LINECALLPRIVILEGE_NONE, 0, 0);
lpLineInfo.dwTotalSize = 180;
dwReturn = lineGetGeneralInfo(hLine, &lpLineInfo);
if (!dwReturn)
{
if (lpLineInfo.dwSubscriberNumberSize > 2)
{
for (i = 0; i < (signed) lpLineInfo.dwSubscriberNumberSize/2; i++)
szIMSI = *((unsigned short *)(&lpLineInfo) + i + lpLineInfo.dwSubscriberNumberOffset/2);
szIMSI=NULL;
MessageBox(NULL,szIMSI,_T(" IMSI"),MB_OK);
}
else
if (lpLineInfo.dwSubscriberNumberSize)
MessageBox(NULL,_T("Please Enter PIN"),_T(" IMSI"),MB_OK);
else
MessageBox(NULL,_T("No SIM Card Present"),_T(" IMSI"),MB_OK);
for (i = 0; i < (signed) (lpLineInfo.dwSerialNumberSize/2); i++)
szIMEI = *((unsigned short *)(&lpLineInfo) + i + lpLineInfo.dwSerialNumberOffset/2);
szIMEI=NULL;
wsprintf(szOutput,_T("NULL"));
MessageBox(NULL,szIMEI,_T(" IMEI"),MB_OK);
}
else
GetError(dwReturn);
lineClose(hLine);
lineShutdown(hLineAp);
return 0;
}
void CALLBACK lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
}
void GetError(DWORD dwReturn)
{
switch (dwReturn)
{
case LINEERR_RESOURCEUNAVAIL:
MessageBox(NULL,_T("No SIM Card"),_T("Error"),MB_OK);
break;
case LINEERR_INVALLINEHANDLE:
MessageBox(NULL,_T("Line Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_STRUCTURETOOSMALL:
MessageBox(NULL,_T("Oops"),_T(" Error"),MB_OK);
break;
case LINEERR_INVALPOINTER:
MessageBox(NULL,_T("Line Pointer Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_UNINITIALIZED:
MessageBox(NULL,_T("Radio Not Turned On"),_T(" Error"),MB_OK);
break;
case LINEERR_NOMEM:
MessageBox(NULL,_T("Out of Memory"),_T(" Error"),MB_OK);
break;
case LINEERR_OPERATIONUNAVAIL:
MessageBox(NULL,_T("Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_OPERATIONFAILED:
MessageBox(NULL,_T("Please Turn Radio On"),_T(" Error"),MB_OK);
break;
default:
MessageBox(NULL,_T("Error"),_T(" Error"),MB_OK);
}
}
Works great
Thanks
hi all, i tried to above code but it gave me thos following error !
any one can help me plz ?
unresolved external symbol lineGetGeneralInfo referenced in function WinMain
thankx alot
hi alla again
these is nothing wrong else that i forgot to like the cellcore.lib lbrary to my project
the code compiled but it gave me the result of " Unavailable " !
so how do i can get the IMEI ?
i'm using ROM 3.16.13 ENG
best regards
Essa
Two possible answers:
A: Turn the phone on
B: HTC have changed the memory map allocation
I have some debug code behind the stuff I posted earlier to dump the entire contents of the lpLineInfo struct. i'l try and see what teh problem is.
On previous versions they omitted the IMEI or extended the HW id sections.
vpreHoose thanx alot for ur replay..
ur code is working fine the problem is that i didnt load the cellcore.lib for the evc compiler and the other problem is the DeviceID
in ur code u r using DeviceID = 2 while me i must use DeviceID = 0,
so i changed dwDeviceID = 2 to dwDeviceID = 0; and every thing is working fine
can u tell me how do i can get the caller number while mobile ringing ?
i would like to develope a software that assigne a ringing tone to each contact number.
thanx alot
Yea, I was a little bit lazy not to write it to loop through all deviceid's...
:roll:
Thanks very much to the person who provided the code. I'd been battling with lineGetGeneralStatus for days, no joy. Microsoft giving away nothing here. I found the missing line in my code from yours:
lpLineInfo.dwTotalSize = 180;
And now it works. If only MS had stated this, would have solved me a whole load of hastle.
There must be more and useful information on the ExTapi. Like how to use the functions so that they work. Does anybody have a reference??
Ben
I tried this code on my qtek 2020 but my application return the following error:
unavailable
why???
a favor to ask
can anyone convert the code to c#? would be much appreciated
Re: IMEI Code
will this code work in an emulator?
test
lollone said:
I tried this code on my qtek 2020 but my application return the following error:
unavailable
why???
Click to expand...
Click to collapse
I got the same problem, and then changed the value of dwDeviceID to 0
DWORD dwDeviceID = 0;
and now i get an another error:
Please Turn Radio On
Click to expand...
Click to collapse
while I am a Newbie with XDA, so i want to ask, what is the Radio and how to turn it on?
thanks a lot
Pai
pai said:
lollone said:
I tried this code on my qtek 2020 but my application return the following error:
unavailable
why???
Click to expand...
Click to collapse
I got the same problem, and then changed the value of dwDeviceID to 0
DWORD dwDeviceID = 0;
and now i get an another error:
Please Turn Radio On
Click to expand...
Click to collapse
while I am a Newbie with XDA, so i want to ask, what is the Radio and how to turn it on?
thanks a lot
Pai
Click to expand...
Click to collapse
I have solved this problem by only restart, i think the radio means Handy-Net
Smart phones ?
This method doesn't work on smart phones?!
On WM 2003 Smart phone it always gives unsupported operation

[Q] How select preferred network operators automatically?

Hallo,
I want to select preferred network operators automatically from device.
After I search for it, I found following:
Code:
final int EVENT_AUTO_SELECT_DONE = 300;
Message msg = mHandler.obtainMessage(EVENT_AUTO_SELECT_DONE);
phone.setNetworkSelectionModeAutomatic(msg);
So I need an instance of class "Phone". I tried this:
Code:
String phoneFactoryName = "com.android.internal.telephony.PhoneFactory";
String phoneName = "com.android.internal.telephony.Phone";
Class phoneFactoryClass = Class.forName(phoneFactoryName);
Class phoneClass = Class.forName(phoneName);
Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone");
Object phoneObject = getDefaultPhone.invoke(null);
But the method "getDefaultPhone" can only called by looper.
Next I tried this:
Code:
String phoneAppName = "com.android.phone.PhoneApp";
Class phoneAppClass = Class.forName(phoneAppName);
Method getInstanceMethod = phoneAppClass.getMethod("getInstance");
Object phoneObject = getInstanceMethod.invoke(null);
But I get a ClassNotFoundException.
Can anybody help me, please?
sorry ,i can't help you
Yes it can be instantiated. But you have to overcome a couple of hurdles:
In your AndroidManifest.xml set
Code:
android:sharedUserId="android.uid.phone"
within the manifest-Tag. This is required to prevent a SecurityException from being thrown when protected Intents are sent by the methods you may invoke (like android.intent.action.SIM_STATE_CHANGED).
Set
Code:
android:process="com.android.phone"
in your application-Tag. This is required to allow the invocation of getDefaultPhone / makeDefaultPhone.
To do all this your app must be signed with the system signature key.

[REF][SUGGESTION] clean up your codes for OC/UV and old kernel codes if possible

hi all,
first of all, i would like to say that i'm no expert in c, and this post is not intended to blame anyone but want to raise this concern only.
since i started to mod i9000's kernel source code, i found some unneeded conditional statements in the original source and modded OC/UV sections which can be avoided very easily and thus consuming less resources.
let's take a look in this example from the original source:
Code:
for (i = 0; i < LOOP_CNT; i++) {
tmp = __raw_readb(iem_base + S5PV310_APC_DBG_DLYCODE);
sum_result += tmp;
hpm[i] = tmp;
}
for (i = 0; i < LOOP_CNT; i++)
printk(KERN_INFO "ASV : hpm[%d] = %d value\n", i, hpm[i]);
the second for loop is definitely unnecessary, and it should be changed to something like:
Code:
for (i = 0; i < LOOP_CNT; i++) {
tmp = __raw_readb(iem_base + S5PV310_APC_DBG_DLYCODE);
sum_result += tmp;
hpm[i] = tmp;
printk(KERN_INFO "ASV : hpm[%d] = %d value\n", i, hpm[i]);
}
let's take a look at another extreme case, taken from the OC/UV section:
Code:
if (index < L6)
{
if (old_index == L0)
index = L1;
if (old_index == L1)
index = L2;
if (old_index == L2)
index = L3;
if (old_index == L3)
index = L4;
if (old_index == L4)
index = L5;
if (old_index == L5)
index = L6;
}
it is obvious that, if old_index=L0, it has to go thru the remaining 5 if statements which shouldnt be. isnt it be nice and more efficient to chg it to something like below or use switch case instead?
Code:
if (index < L6)
{
if (old_index == L0)
index = L1;
else if (old_index == L1)
index = L2;
else if (old_index == L2)
index = L3;
else if (old_index == L3)
index = L4;
...
...
...
...
}
since we all aim at producing better and faster kernels, i think this is a good practice to clean up the codes while we r modding
thx for your kind attention
and this is the most ridiculous part that i've ever seen in my life, which can be found in I9000 source also. if u have 10 frequencies set, then instead of running the loop 10 times, this will run 50 times in total
arch/arm/mach-s5pv310/cpufreq.c, inside static int s5pv310_update_dvfs_table()
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
s5pv310_freq_table[i-1].index = s5pv310_lookup_freq_table.index - 1;
s5pv310_freq_table[i-1].frequency = s5pv310_lookup_freq_table.frequency;
printk(KERN_INFO "index = %d, frequency = %d\n",
s5pv310_freq_table[i-1].index, s5pv310_freq_table[i-1].frequency);
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
s5pv310_volt_table[i-1].index = s5pv310_lookup_volt_table.index - 1;
s5pv310_volt_table[i-1].arm_volt = s5pv310_lookup_volt_table.arm_volt;
printk(KERN_INFO "index = %d, arm_volt = %d\n",
s5pv310_volt_table[i-1].index, s5pv310_volt_table[i-1].arm_volt);
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
s5pv310_apll_pms_table[i-1] = s5pv310_lookup_apll_pms_table;
printk(KERN_INFO "apll pms_table = 0x%08x\n", s5pv310_apll_pms_table[i-1]);
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
for (j = 0; j < 7; j++) {
clkdiv_cpu0[i-1][j] = clkdiv_cpu0_lookup[j];
printk("%d, ", clkdiv_cpu0[i-1][j]);
}
printk("\n");
}
for (i = 1; i < CPUFREQ_LEVEL_END; i++) {
for (j = 0; j < 2; j++) {
clkdiv_cpu1[i-1][j] = clkdiv_cpu1_lookup[j];
printk("%d, ", clkdiv_cpu1[i-1][j]);
}
printk("\n");
}
Interesting...
Sent from my GT-I9100 using XDA Premium.
This might be right. My C is bad, but some OC/UV patches look really quite 'whatever works' for me. I dont say its bad - having something is better than nothing.
Its always good if some skilled coders do reviews of such patches.
good finding and the samsung programmers are really ............... bad...
joecisd said:
good finding and the samsung programmers are really ............... bad...
Click to expand...
Click to collapse
i think it's not samsung's problem, instead, it should be unsolved/overlooked problems brought forward from linux kernel
yeaaa Hong Kong
Do you want make a kernel for us?
regards
Nice catches
Hope most devs are already taking care of this!
avetny said:
yeaaa Hong Kong
Do you want make a kernel for us?
regards
Click to expand...
Click to collapse
sorry, but maybe u don know me coz i'm a newbie here in the i9100 section
as in the i9000 forum, i usually prefer not to release files, except some quick fixes like sms sent time mod, but i'll tell u guys my findings, dirty tricks, and how to instead
sorry about that
glad to see that some of you guys already fixed, or started to fix those redundant conditional statements
and ultimately, hope that one day these will be collected as a whole and stored somewhere for everyone like our kernel source code repo here
ykk_five said:
glad to see that some of you guys already fixed, or started to fix those redundant conditional statements
and ultimately, hope that one day these will be collected as a whole and stored somewhere for everyone like our kernel source code repo here
Click to expand...
Click to collapse
I go try to clean up my code.
I only have a little C++ skills and no C but I give it a try ...
netchip said:
I go try to clean up my code.
I only have a little C++ skills and no C but I give it a try ...
Click to expand...
Click to collapse
maybe if you upload the code to somewhere (for example into a wiki, or pastebin???) we can check it. Personally I've 20years of programming exp in 4 languages, and I'm sure a lot of people like me is already here We can't make the ROM "a lot faster", but basic structural bugs can be wiped out in a short period of time (like the "if else if else if else" example in the first post).
PS: sry for my english
I'm also not an expert in C or kernel development, but i'm quite sure, that gcc is smart enough to check that some code is redundant and do that kind of optimizations in compile time (if you enable the optimize flags).
Feel free to give it a try, i'm also curious, but i think the final assembly code will be pretty much similar.
Sent from my GT-I9100 using xda premium
killerjohn said:
maybe if you upload the code to somewhere (for example into a wiki, or pastebin???) we can check it. Personally I've 20years of programming exp in 4 languages, and I'm sure a lot of people like me is already here We can't make the ROM "a lot faster", but basic structural bugs can be wiped out in a short period of time (like the "if else if else if else" example in the first post).
PS: sry for my english
Click to expand...
Click to collapse
Okay, I go.do.that
Sent from my GT-I9100
netchip said:
I go try to clean up my code.
I only have a little C++ skills and no C but I give it a try ...
Click to expand...
Click to collapse
yeah, i know. i was learning from your source in github last nite
killerjohn said:
maybe if you upload the code to somewhere (for example into a wiki, or pastebin???) we can check it. Personally I've 20years of programming exp in 4 languages, and I'm sure a lot of people like me is already here We can't make the ROM "a lot faster", but basic structural bugs can be wiped out in a short period of time (like the "if else if else if else" example in the first post).
PS: sry for my english
Click to expand...
Click to collapse
that's great. yes, most of them are structural problems actually
Guiper said:
I'm also not an expert in C or kernel development, but i'm quite sure, that gcc is smart enough to check that some code is redundant and do that kind of optimizations in compile time (if you enable the optimize flags).
Click to expand...
Click to collapse
i know gcc is quite smart but i doubt if it can handle the conditional statements automatically if something like:
if (a is a male) then a is a boy
if (a is a female) then a is a girl
so actually, a should be checked once only coz we all know that in our daily life. but sometimes we need a bit more complicated logics like:
if (a contains red) then color = red
if (a contains green) then color =green
if (a contains blue) then color =blue
if (a contains blue & green & blue) then color = gray/black/white (by assuming the portions of red, green and blue are equal)
perhaps this is not a good example, but i just want to point out that not every set of conditions are redundant sometimes and hence gcc may not be able to handle it, i think (i'm not a gcc expert neither, pls correct me if i'm wrong )
Feel free to give it a try, i'm also curious, but i think the final assembly code will be pretty much similar.
Click to expand...
Click to collapse
but i've modded some smali before and found that even a very simple for loop in java can produce a lot of goto statements in the assembly code which can be clean up also

[Q] What the correct way to read from thumb_image column on messages table (Whatsapp)

Hi all,
I build a software for myself that read from Whatsapp db (that stored on my android device)..
I trying to read from thumb_image column but cannot find the correct way ...
I write this software on c# language... and the code for read its column as follows:
//thumbImage is the value that stored in thumb_image column.
byte[] encodedbytes = System.Text.Encoding.Unicode.GetBytes(thumbImage);
string encoded = System.Convert.ToBase64String(encodedbytes);
byte[] utf8Decoded = System.Text.Encoding.UTF8.GetBytes(encoded);
File.WriteAllBytes("Images\\" + mdeiaName, utf8Decoded);
but it's not working, so i trying to use IronPython as following:
string pythonScript = @"import base64
class DecryptString(object):
def Decrypt(self, str):
return base64.b64encode(str).decode(""utf-8"")";
ScriptEngine engine = Python.CreateEngine();
ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);
ScriptScope scope = engine.CreateScope();
source.Execute(scope);
dynamic DecryptString = scope.GetVariable("DecryptString");
dynamic decryptString = DecryptString();
var result = decryptString.Decrypt(thumbImage);
File.WriteAllText("Images\\" + mdeiaName, result);
but without success...
Can somebody help me?

[Q] How to get ReponseData and Signature for android LVL

Hi,
I try to implement a server side verification of an application with LVL library.
I use this php code : http://code.google.com/p/android-market-license-verification/
In the file sample/verify.php, I have two lines to complete :
Code:
$responseData = '';
$signature = '';
I see in the google LVL that there is a function called verify which has these parameters :
public void verify(PublicKey publicKey, int responseCode, String signedData, String signature);
But I don't undestand where this function is called and by what function.
Also I want to get this datas.
How can I do that ?
Thank you,
Yeah!! Same here!
Can someone tell us?
Most apps use client side license verification, don't know why... This would be very useful!

Categories

Resources