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
Related
I'm looking to create a simple app that just populates a list from a url displaying json.
Here's the source from the webpage.
PHP:
$json = array('one', 'two', 'three', 'four');
echo json_encode($json);
Obviously the final webpage will show different data but it will be very similar.
All i want is for the app to load that URL, get the data and populate it into a listactivity.
Nothing i've found so far seems to work. What should I look up to help me achieve this?
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");
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.
I am a kodi addon developer and I believe I have skills more than average when it comes to Python. I am the sole maintainer of the AliveGR addon, the most popular greek addon around the world.
On Android I still suck... I am able to call an android activity from within Kodi with very specific intent, data uri and package name, but how can I call the default app for twitter, facebook or even a web browser?
Example:
Code:
control.execute('StartAndroidActivity("package_name","android.intent.action.VIEW","","url")')
Where package_name could be 'com.google.chrome' and url could be 'facebook.com'
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.