Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

hooah posted:

But the second way creates a new object every time, right? Is the language ease worth the overhead in this case?

Generally the answer to these sorts of questions is: don't worry about it unless it becomes a problem.

Adbot
ADBOT LOVES YOU

madkapitolist
Feb 5, 2006
I have a tetris APK that works on my phone, but not on my tablet. Any idea what is going on? Both devices are running android 5.1.1.

It will launch, then immediately crash, the app stays in the tray.

I have the logcat here

http://pastebin.com/DCnYfpMe

Tunga
May 7, 2004

Grimey Drawer
I'm not seeing anything super helpful in the log. It's failing to find a binder at the end which could relate to a cross-process background service being killed for some reason but that may just be the final result of an actual error that's occurring earlier somewhere and causing the service to die.

Edit: The OS source code that throw that error suggests that it's the window that is missing, so most likely this isn't the actual cause of the issue but is what happens after something failed to initiate properly.

It could just be that it's trying to use a specific feature that the device tablet support. Could also be something to do with portrait vs. landscape.

Edit edit: There's also some low level stuff (NDK) happening and some things referencing tegra. The game might be GPU-specific or there might be different APKs for different GPU types.

Tunga fucked around with this message at 23:40 on Jul 21, 2015

OzyMandrill
Aug 12, 2013

Look upon my words
and despair

The error is the earlier one - the binder stuff is because the window has already been closed due to:
code:
F/art     (10062): art/runtime/thread.cc:1143] No pending exception expected: java.lang.StackOverflowError: stack size 1036KB
 
F/art     (10062): art/runtime/thread.cc:1143]   at void com.ideaworks3d.airplay.AirplayThread.runNative(java.lang.String, java.lang.String) (AirplayThread.java:-2)
 
F/art     (10062): art/runtime/thread.cc:1143]   at void com.ideaworks3d.airplay.AirplayThread.run() (AirplayThread.java:987)
= Stack overflow error from com.ideaworks3d.airplay.AirplayThread.runNative(java.lang.String, java.lang.String)

And yeah, stack size has exceeded 1MB (default pthread stack size for NDK), which it probably shouldn't.

Pilsner
Nov 23, 2002

Not specifically developer oriented, but here goes: Does anyone know the syntax that dates (with timestamps) can have in SMS's in order for them to be "clickable" so that a person can create an appointment in their calendar from it? I seem to recall from back when I had an iPhone, that if I got an SMS like this:

"We confirm your dentist appoint on 21/7/2015 8:00"

... it would have the date and time underlined and be able to create an appointment in my calendar when I tapped on it.

Tunga
May 7, 2004

Grimey Drawer
The platform autolink tag doesn't match dates, so any such functionality would be implemented with app-specific logic.

hooah
Feb 6, 2006
WTF?
How do I go about generating a signed apk that I can install on my phone? I followed the directions here, but when I tried to install that I got a super helpful message: "App not installed". What might I have missed?

Tunga
May 7, 2004

Grimey Drawer
Do you already have a debug version of the same app installed? You can't install two apps with the same package name but signed with different keys.

hooah
Feb 6, 2006
WTF?
That was true, but after uninstalling the debug version and successfully installing the release version, it still doesn't show up in the app drawer.

hooah
Feb 6, 2006
WTF?
Still having that problem, but also an additional stumbling block.

I'm trying to add location to the logging. I've gone through Making Your App Location-Aware, but for some reason onConnect doesn't get called. I thought maybe it was failing to connect, so I threw a breakpoint in onConnectionFailed, but that isn't getting called either. What else could I try to figure out what's going on? Here's the location-relevant parts of my class;

Java code:
public class DisplayData extends Activity implements GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener{
    
    private GoogleApiClient mGoogleApiClient;
    private Location mLastLocation;
    private LocationRequest mLocationRequest;
    private String mLatitudeText;
    private String mLongitudeText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(LocationServices.API).build();
    }

    @Override
    protected void onPause(){
        super.onPause();
        mGoogleApiClient.disconnect();
        mWrangler.sleep();
    }

    protected void onResume(){
        super.onResume();
        mGoogleApiClient.connect();
        mWrangler.wake();
        mWriting = true;
    }

    @Override
    public void onConnected(Bundle connectionHint) {
        mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                mGoogleApiClient);
        if (mLastLocation != null) {
            mLatitudeText = (String.valueOf(mLastLocation.getLatitude()));
            mLongitudeText = (String.valueOf(mLastLocation.getLongitude()));
        }
    }

    @Override
    public void onConnectionSuspended(int x) {
    }

    @Override
    public void onConnectionFailed(ConnectionResult result){
        int x = 0;
    }

    protected void createLocationRequest() {
        mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(UPDATE_DELAY);
        mLocationRequest.setFastestInterval(100);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    }
}

kitten smoothie
Dec 29, 2001

You aren't setting the connection callback so the API client doesn't know who to call the onConnect or onConnecitonFailed on. Check this out from Google's example, specifically this chunk:

code:
mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();

kitten smoothie fucked around with this message at 23:52 on Jul 27, 2015

hooah
Feb 6, 2006
WTF?
:doh:

I didn't really understand all the builder parts (because I was lazy). Getting location now! I have an organizational question regarding that tutorial - why did they break out the client-building code into a function? Isn't it only going to be called once?

Next thing: I'm trying to implement a share button for the log files so the ultimate users don't have to dig into the file system to send them. I read the first two sections of this tutorial, but then it goes off into receiving file share intents, rather than sending the URI. Do I just do a share intent a la this tutorial and send over the URI?

hooah
Feb 6, 2006
WTF?
I'm getting a little further along with sharing. Currently I'm trying to send the first file in the directory as an email attachment. I have implemented the share menu item like so:

Java code:
if (id == R.id.menu_item_share) {
    ArrayList<String> filenameList = new ArrayList<String>();
    Intent intentShareFile = new Intent(Intent.ACTION_SEND);
    File dataDir = this.getApplicationContext().getFilesDir();
    for (String filename : dataDir.list()) {
        filenameList.add(filename);
    }
    String firstFilename = dataDir.list()[0];
    Log.d(TAG, firstFilename);
    intentShareFile.setType(URLConnection.guessContentTypeFromName(firstFilename));
    intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + firstFilename));
    intentShareFile.putExtra(Intent.EXTRA_SUBJECT, "Sharing file...");
    intentShareFile.putExtra(Intent.EXTRA_TEXT, "Sharing file...");

    startActivity(Intent.createChooser(intentShareFile, "Share File"));
}
Which brings up the sharing selector just fine. However, when I select Gmail, I get a toast that says "Couldn't attach file". The debug log says the file name is "7 30 8 18.txt", which is what I expect. What's going wrong?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Your file is in app private storage. Gmail doesn't have permission to access it. You can either change the permissions, or use a FileProvider to vend the file securely.

hooah
Feb 6, 2006
WTF?
Ah, that makes sense. I've gotten that straightened out, and read through the tutorial at the top of the FileProvider documentation. However, when I choose Gmail as the recipient of the intent, the content URI gets put into the To: field, rather than the file getting attached. I tried using Drive instead and got a toast saying "Upload was unsuccessful: request contained no data". Here's my current code dealing with that menu item:

Java code:
if (id == R.id.menu_item_share) {
    Intent intentShareFile = new Intent(Intent.ACTION_SEND);
    File dataDir = this.getApplicationContext().getFilesDir();
    String firstFilename = dataDir.list()[0];
    Log.d(TAG, firstFilename);
    File firstFile = new File(dataDir, firstFilename);
    Uri logUri = FileProvider.getUriForFile(getApplicationContext(),
            "com.example.spart_000.accel_demo.fileprovider", firstFile);
    intentShareFile.setType(URLConnection.guessContentTypeFromName(firstFilename));
    intentShareFile.setData(logUri);
    intentShareFile.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    startActivity(Intent.createChooser(intentShareFile, "Share File"));
}

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
I'm not even going to try to diagnose this. Just put your file in publicly visible external storage.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
For an ACTION_SEND intent, you should put the content uri in the EXTRA_STREAM extra rather than in the intent data.

hooah
Feb 6, 2006
WTF?

Volmarias posted:

I'm not even going to try to diagnose this. Just put your file in publicly visible external storage.

How would that help? The URI seems to be accessible, it was just getting put in the wrong part of the intent.

Jabor posted:

For an ACTION_SEND intent, you should put the content uri in the EXTRA_STREAM extra rather than in the intent data.

This worked like a charm, thank you.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

hooah posted:

How would that help? The URI seems to be accessible, it was just getting put in the wrong part of the intent.


This worked like a charm, thank you.

If you use a public external storage directory, there's no per-app permissions, so you wouldn't need a FileProvider, you could just give the file uri from there.

Glad to hear you got it working though!

hooah
Feb 6, 2006
WTF?
I've discovered that you should calibrate the linear acceleration sensor each time the app's run. I though "ok, I'll just slap a message on the main activity and a button to calibrate the sensor". To do this, I moved the creation of my SensorWrangler object (wrapper for the acceleration and rotational sensors) from DisplayData to MainActivity. Then obviously I have to either tell the DisplayData class about the offsets or pass the SensorWrangler to that activity. I tried the latter by having SensorWrangler implement Serializable, but got an error "Parcelable encountered IOException writing serializable object (name = com.example.me.accel_demo.SensorWrangler)". Does this mean I can't pass that object, since the Sensor objects aren't serializable?

Tunga
May 7, 2004

Grimey Drawer
There may be a member variable or similar on SensorWrangler of a type that isn't Serializable. I believe that would cause the error you're seeing.

If the offset is just numbers or similar it'll most likely be easier to stick a couple of ints in the Intent bundle and then construct and setup the object with that.

(Also, on Android consider using Parcelable instead of Serializable, it's generally more efficient.)

Edit: If you're running a thing that monitors sensor input and accessing it from different activities the way I would do that is to have the sensor stuff running in a service and then each activity binds to it when it needs to use it. But this may not be compatible with your current architecture.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Can't you just do it as part of the wrangler's initialisation or something? Maybe have a static flag that tells you whether the calibration has been run yet, and run that method if you need to. Or is this a 'lay it flat' thing?

I don't know which offsets you mean, but if you have to offset each value to produce the true calibrated value every time, why not do that in the getData method in the wrangler? That's sort of the idea with encapsulation, you have issues like that hidden within the thing that cares about them. The technical stuff is dealt with internally, and then it just produces the simple output as usual, and none of your other components need to change or even know about it

hooah
Feb 6, 2006
WTF?

Tunga posted:

If the offset is just numbers or similar it'll most likely be easier to stick a couple of ints in the Intent bundle and then construct and setup the object with that.

This was my other option, but it seems that that requires setting up another SensorListener in the MainActivity for the sole purpose of getting the offset. If that's what it takes, then that's fine.

quote:

Edit: If you're running a thing that monitors sensor input and accessing it from different activities the way I would do that is to have the sensor stuff running in a service and then each activity binds to it when it needs to use it. But this may not be compatible with your current architecture.

This might be a good route to take eventually.

baka kaba posted:

Can't you just do it as part of the wrangler's initialisation or something? Maybe have a static flag that tells you whether the calibration has been run yet, and run that method if you need to. Or is this a 'lay it flat' thing?

The calibration is a "lay it flat" thing, so it needs to be done before the data collection starts, at the latest.

Ireland Sucks
May 16, 2004

Does anyone know where I can find GDB compiled for an ARM host? Remote debugging isn't working but uploading gdb to my device and debugging from there does work. Unfortunately the latest version I can find is 7.2 which has a bug causing a segfault during the transition to THUMB mode.

If all else fails I guess I can compile it from an intel machine but it is probably going to take me all day to get everything set up for that and I'd love to not do that if I can :(

hooah
Feb 6, 2006
WTF?
For some reason, Google's own CountDownTimer (https://developer.android.com/reference/android/os/CountDownTimer.html) example code doesn't quite work as expected. I changed the start value from 30,000 to 5,000 (5 seconds vs. 30), and the timer starts at 4, but stays on 1 for two seconds, so it's still a 5-second timer. I know the problem is with the somewhat lazy way they're outputting the whole number, but I can't think of a nice way to make the timer look the way you'd expect.

Tunga
May 7, 2004

Grimey Drawer
In the source code of CountdownTimer it checks if the time remaining is smaller than the tick time and if it does then it just waits. This happens before it checks whether a tick is due, so if the last tick gets delayed by even 1ms then it simply won't fire.

I'd imagine the easiest way to fix this is just to have the thing fire every 100ms or similar instead, and still just display the whole seconds.

If you want a better solution than that, implement your own correctly behaving countdown timer using a Runable and enjoy the fact that you can write better code than Google.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Hi all!

I'm putting together an inventory of common (or even not-so-common) Android application security issues. Things like mishandling intent/activity activation, putting private stuff in logcat, data-at-rest vulnerabilities and so forth. I've found a couple of decent resources, such as the AppSec pen test overview (https://appsec-labs.com/android_attacks-tests/) but I thought I'd ask if people had other good places to look.

(Related: I'm hiring Android systems/app security expertise.)

hooah
Feb 6, 2006
WTF?
I'm working with another student on this app, and he's mainly doing the data analysis stuff. He told me today that sometimes the same simple movement (perhaps sliding the phone in one axis on the table) will appear on different axes in his visualizations, and other times different movements will appear on the same axis. We've both looked at the linear acceleration documentation, and it doesn't say anything about this. Where should we start looking to figure this out?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

hooah posted:

I'm working with another student on this app, and he's mainly doing the data analysis stuff. He told me today that sometimes the same simple movement (perhaps sliding the phone in one axis on the table) will appear on different axes in his visualizations, and other times different movements will appear on the same axis. We've both looked at the linear acceleration documentation, and it doesn't say anything about this. Where should we start looking to figure this out?

Look at the orientation of your phone as you move it. If you move it sideways, that will give you a different bump than moving it longways.

I also would not be surprised in the slightest at an OEM screwing up which axis gets reported.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

The sensors in Android devices are, you'll be shocked to hear, of variable quality! The linear acceleration sensor is actually a fusion of the accelerometer and some gravity-detecting gear, like the magnetometer, a gyroscope if your device has one, or maybe other hardware. Exactly how it's implemented (and the quality of the results you'll get) is really up to the device, and some hardware is better than others.

Also the accelerometer is basically a tiny spring (kinda), it boings back and forth when you move the device. They're really sensitive and jittery, and I wouldn't be surprised if you're seeing motion in other axes when you think you've only moved along one - if you're sliding it think impact vibration, friction, sliiight rotations of the device and a path that isn't absolutely laser-precise along the axis you intended. These shouldn't be big differences if you're being careful, especially once it gets going. Anyway you're probably gonna want to look into filtering out all this noise

Not really about what you're asking specifically, but the start of this gives you an idea of some of the nonsense you have to worry about
http://www.kircherelectronics.com/blog/index.php/11-android/sensors/17-gyroscope-linear-acceleration

Now you're realising what you got yourself into :cigar:

Doctor w-rw-rw-
Jun 24, 2008

Subjunctive posted:

Hi all!

I'm putting together an inventory of common (or even not-so-common) Android application security issues. Things like mishandling intent/activity activation, putting private stuff in logcat, data-at-rest vulnerabilities and so forth. I've found a couple of decent resources, such as the AppSec pen test overview (https://appsec-labs.com/android_attacks-tests/) but I thought I'd ask if people had other good places to look.

(Related: I'm hiring Android systems/app security expertise.)

Not sure how relevant it is, but I just remembered one particularly hilarious Android exploit for devices using Samsung's Exynos chipset: /dev/exynos-mem was readable and world-writable which referenced – you guessed it – device memory.

In case you don't already have it in your list of attacks, here's more info on that vulnerability: http://blog.azimuthsecurity.com/2013/02/re-visiting-exynos-memory-mapping-bug.html

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Doctor w-rw-rw- posted:

Not sure how relevant it is, but I just remembered one particularly hilarious Android exploit for devices using Samsung's Exynos chipset: /dev/exynos-mem was readable and world-writable which referenced – you guessed it – device memory.

In case you don't already have it in your list of attacks, here's more info on that vulnerability: http://blog.azimuthsecurity.com/2013/02/re-visiting-exynos-memory-mapping-bug.html

:aaa:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Oh man, you just heard about that? A friend of mine still works for Samsung, and had to explain Unix permissions to their security team and why this was such a bad thing. I poo poo you not.

Apparently they've gotten a little better since then, though apparently not by much.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Volmarias posted:

Oh man, you just heard about that? A friend of mine still works for Samsung, and had to explain Unix permissions to their security team and why this was such a bad thing. I poo poo you not.

Apparently they've gotten a little better since then, though apparently not by much.

Yeah, I haven't been paying attention to Android for a couple of years, and now I feel like I need to go back and binge-watch all the episodes.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Subjunctive posted:

Yeah, I haven't been paying attention to Android for a couple of years, and now I feel like I need to go back and binge-watch all the episodes.

It's definitely entertaining in a train wreck sort of way. The current issue of the month is vulnerabilities in the stagefright media library allowing to RCE at system level via a well hung crafted MMS message to most devices, the realization of what exactly a carrier driven emergency security patch schedule looks like, and the fact that there are some devices that will probably never be patched.

kitten smoothie
Dec 29, 2001

Oh, and don't forget that the patch didn't fully patch the problem.

I'm really curious how many full time Android developers carry iPhones as their personal device, because we have a bigger window into the sausage factory.

Tunga
May 7, 2004

Grimey Drawer

kitten smoothie posted:

I'm really curious how many full time Android developers carry iPhones as their personal device, because we have a bigger window into the sausage factory.
Anecdotally, not very many, but definitely more than the other way around.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Volmarias posted:

It's definitely entertaining in a train wreck sort of way. The current issue of the month is vulnerabilities in the stagefright media library allowing to RCE at system level via a well hung crafted MMS message to most devices, the realization of what exactly a carrier driven emergency security patch schedule looks like, and the fact that there are some devices that will probably never be patched.

Yeah, I've been following Stagefright stuff since I got back into Android security recently. It's a beaut. There are always going to be devices that will never be patched (including iPhones), of course.

At least this seems to have lit a fire under Samsung WRT update schedule?

kitten smoothie
Dec 29, 2001

Subjunctive posted:

Yeah, I've been following Stagefright stuff since I got back into Android security recently. It's a beaut. There are always going to be devices that will never be patched (including iPhones), of course.

At least this seems to have lit a fire under Samsung WRT update schedule?

On one hand it's sad that we'll have "Patch Tuesday" for Android, but at least poo poo might start getting patched.

In other news, the 6.0 SDK is up in the SDK manager.

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

kitten smoothie posted:

On one hand it's sad that we'll have "Patch Tuesday" for Android, but at least poo poo might start getting patched.

Better than "Patch November", yeah.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply