I am developing an Android application for which I need to insert SMS messages to the Android device. I am facing performance issues with my code.
Currently, my code is taking 120 seconds to insert 500 messages while "SMS Backup and Restore" application takes 80 seconds to insert 500 messages.
Code:
Long start_time = System.currentTimeMillis();
//fetch thread id
Uri.Builder builder = thread_uri.buildUpon();
builder.appendQueryParameter("recipient", values.getAsString("address"));
Uri uri = builder.build();
Long threadId = 0L;
Cursor cursor = sms.query(uri, new String[]{"_id"},
null, null, null);
if (cursor.moveToFirst()) {
threadId = cursor.getLong(0);
}
cursor.close();
Log.d("nims","time to thread fetch:"+(System.currentTimeMillis()-start_time));
values.put("thread_id", threadId);
start_time = System.currentTimeMillis();
//insert SMS
sms.insert(sms_uri, values);
Log.d("nims","time to insert main sms:"+(System.currentTimeMillis()-start_time));
//insert dummy sms
start_time = System.currentTimeMillis();
ContentValues dummyValues = new ContentValues();
dummyValues.put("thread_id", threadId);
Uri dummySms = sms.insert(temp_sms_uri, dummyValues);
//Delete dummy sms
sms.delete(dummySms, null,
null);
Log.d("nims","time to insert and delete temp sms:"+(System.currentTimeMillis()-start_time));
Code debugging results:
I found that the code takes different time to insert individual SMS messages. I found that the insert time varies from 50 ms to 700 ms.
Execution time to delete dummy SMS varies from 70 ms to 350 ms.
I have following questions:
Why there is a change in insert time for SMS even if the SMS data is same?
What are the possible reasons for the performance drop of SMS insert code?
What alternate solutions I can try to optimize the performance?
I’d appreciate any suggestions on this issue. Thank you.
Related
Dear All,
Does anyone know what do the programs in the StartUp Folder do?
I have just hard reseted my XDA-II and I found following links in this folder
1. AFlashMan.lnk
2. BPInsert.lnk
3. BTIcon.lnk
4. CFlashMan.lnk
5. CheckAutoRun.lnk
6. HandsFree.lnk
7. IA_Caller_ID.lnk
8. MMReg.
9. NFlashMan.lnk
10. poutlook.lnk
11. SMSReceiver.lnk
12. Socket SDIO WLAN.lnk
13. stk.lnk
14. TFlashMan.lnk
15. USSD.lnk
These links are relative to the executed programs in Windows folder with the same names, some of them I can guess for example
HandsFree-Support HandsFree Calling.
IA_Caller_ID-Identify the Caller in Contacts
SMSReceiver-Send and receive SMS
Socket SDIO WLAN-Support Card SD Wi-Fi
BTIcon - The Bluetooth Manager Icon at the bottom right.
But what do the others do?? (What do the ?FlashMan.exe do???)
I deleted All the links that I dont khow what they do and it seems to me that nothing happned. Did I do the right?
Please comment
Thanks!
I think! the ?flashman.exe are the individual programs used to backup things to the non-volitale ROM.
AFlashman.exe = Appointments
CFlashman.exe = Contacts
TFlashman.exe = Tasks
NFlashman.exe = coNnections
Why they made this 4 seperate process is beyond me, I removed the ones I don't use, (I only backup the contacts). BPInsert I've also removed, doesn't seem to hurt Bluetooth.
MMReg = is probably Mutlimedia Messaging registration
poutlook = I think your address book, (something to do with that)
stk = is the SIM card toolkit, (you need it to run the SIM tools like syncing
USSD = I don't know that one myself?
Wow!
There's a lot of programs in the startup folder on your machine!
I only have:
aFlashman.lnk
cFlashman.lnk
clear_notify.exe
IIWPO_startup.exe
PhonExt.lnk
PocketNav.lnk
poutlook.lnk
Does anyone know if this means I won't have full functionality of my XDA?
(It's an XDA I - RS 4.21 ROM 4.01.16 (Tmobile))
I'm sure I remember having handsfree.lnk in there before I did the upgrade. What's happened to it? Should I be worried?
Hi all,
I hope i'm wrong, but you shouldn't have messed up with those links especially the ?flashman.exe as i believe they are responsible for the ROM to RAM flashing upon soft reset.
note: the number and names of the .lnk files are different between the XDA I and XDA II due to the additional s/w on XDA II (BT and WiFi for example)
As far as I know those FlashX files are for backing up contacts, tasks and appointments to non-volatile memory...
AFlashman.exe = Appointments
CFlashman.exe = Contacts
TFlashman.exe = Tasks
NFlashman.exe = coNnections
So if you don't use the Permanent Save feature (on Control Panel) you can safely delete them from the startup folder.
Best regards,
Rayan
IIWPO_startup.exe = Anti-theft program
xFlashMan.lnk = processes to synchronize u're contacts, calendar, tasks... in ROM (non-volatile backup)
poutlook.lnk = pocket outlook process (necessary for pocket word & excel)
SMSReceiver.lnk = process to monitor SMS reception & save incoming SMS in DB
stk.lnk = SIM Toolkit
USSD.lnk = the GSM service (monitors incoming calls, dialing numbers, etc...)
ezzkht said:
poutlook.lnk = pocket outlook process (necessary for pocket word & excel)
Click to expand...
Click to collapse
Actually this has to do with the permanent save - you can delete it and still synchronize with the PC & use tasks/contacts etc. At least I did ..
poutlook.lnk = permanent save?
i never knew about that! :?
are you sure its safe to terminate this process??? :roll:
poutlook starts up with 1 thread and is responsible for everything that occurs in tasks contacts and calendar. poutlook starts at least 1 new thread for each when they are started for the first time. I do not think it has anything to do with permanent save. If you kill it or send it a WM_CLOSE it ends along with the contacts, tasks and calendar with no apparent other side effects. I would like to know how it has anything to do with word and excel, they are pword.exe and pxl.exe for the process names. Ending the process for the flashman's has varying results. Sometimes the whole ppc freezez up. Sometimes the current window continues but once the app closes the os freezes.
Dose anyone know if there is somewhere in the registry where a list all non os exe file names or paths is?
I have the following code in one of my apps...
Code:
public static String[] getSkinPackageArray(Context ctx) {
Resources res = ctx.getResources();
String sharedUserId = res.getString(R.string.skin_shared_user_id);
PackageManager pckmgr = ctx.getPackageManager();
int uid = android.os.Process.getUidForName(sharedUserId);
if (uid >= 0) {
return pckmgr.getPackagesForUid(uid);
}
return null; //No packages found
}
... where 'ctx' is the application context.
There are two apps in this arrangement: the first is the 'main app' where the above code lives. The second is a 'skin app' which contains some layout and image resources that I'm trying to access.
The main app is NOT currently signed, and does NOT have a shared user id associated with it. It's a test version of an app that's already available in the Market, and I've read that when you add a shared user id to a Market app that didn't previously have one, all kinds of problems can occur.
The skin app IS signed, and DOES have a shared user id. The idea is that, in the future, all skin apps for my main app would have the same signature and shared user id, so I can get a list of them when my main app configuration activity runs.
Both apps are installed on my phone. And I've verified that '/data/system/packages.xml' has both packages and the shared user id defined. I also checked, double-checked, and triple-checked the spelling on my shared user id.
But when I make the call to getUidForName(), and pass it the shared user id, I'm getting a value of '-1'.
Any ideas what might be going on here? Would signing my main app (as it would be in a production environment) make a difference? Will this whole setup work ONLY if my main app runs with the same shared user id as the skin apps? Is there a problem with using the application context of my main app?
Thanks,
Corporate Dog
I am new to Android development, hence kindly forgive any unintentional mistakes, if made.
I have a native activity rendering using ES2.0. The app needs to start twitter authentication (it uses twitter4j).
I am starting a new activity with twitter auth url. It shows the login page. I give userId, password, the native browser says now it would be redirected to the previous page or something. Then I see a black screen which apparently is the default browser still on top of the application. If I go to home, and background processes, I see my app and the browser as separate activities which makes sense.
Now my question is , how do I code my app to return back to the application once the authentication ends?
Here is the code flow to start the new activity
1. Native code calls JNI function to start authorization
2. The Java function creates an AsyncTask, in doInBackground() it gets the request token using getOAuthRequestToken(URL) where URL = custom url "app1://callback".
3. in onPostExecute() , app starts new intent activity using this code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL()));
BaseGameActivity.startActivity(intent);
Log.debug("authenticate task post ends");
Hello ,
I want to be able to send SMS in language that has national language locking shift table , Turkish for example .
My goal is to be able to send SMS that includes 160 characters in one part in turkish language .
I did searched a lot and what i found is that there is a class called GsmAlphabet that includes all the Locking Shift Tables specially for Turkish :
/* A.3.1 Turkish National Language Locking Shift Table
01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....0.....1 */
"@\u00a3$\u00a5\u20ac\u00e9\u00f9\u0131\u00f2\u00c7\n\u011e\u011f\r\u00c5\u00e5\u0394_" ...
Also i have function that can convert a String into a byte array containing
the 7-bit packed GSM Alphabet representation of the string.
Can i achieve my goal with SmsManager and if yes, how ?
Now days i am using to split each message with SmsManager "divideMessage" function and then send it with "sendMultipartTextMessage" function ,
I understand that i cant use this function for my goal because they support only strings as input .
Hello,
I am trying to understand the behaviour of some Android malware applications especially the ones sending SMS and placing calls (actions with a cost for the mobile user).
I would like to setup a lab with Android devices where these applications will be installed and my goal is to identify the SMS sent (number, content) and the calls placed (numbers, duration, audio).
These kind of applications are hiding the SMS sent using this command :
smsManagerForSubscriptionId.sendTextMessage(str2, null, str, pendingIntent, null);
Click to expand...
Click to collapse
As seen in the Android documentation, they specify the destination, the text and a pending intent.
public void sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Click to expand...
Click to collapse
Is there any chance to "force" Android to log all the SMS sent by this method ?
Or maybe it is possible to :
- log all SMS sent/received via an adb connection ?
- catch the pending intent and log its content ?
- set a DEBUG mode at Android level to log all SMS sent ?
- place some low-level commands in shell on a rooted device to talk directly with the SIM ?
All ideas are welcome, thanks.
It should be quite easy to hook the function using Frida.