Mobile App Development 2021W Lecture 12

From Soma-notes
Jump to navigation Jump to search

Video

Video from the lecture given on February 24, 2021 is now available.

Notes

Lecture 12
----------

 - assignment/tutorial questions
 - installing Android Studio
 - defining characteristics of mobile platforms

To lock an angle to 45 degree increments...

divide by 45, round, then multiply by 45

 - you want to do this where the angle is changed by a drag gesture
   (not where it is inputted via the keyboard)


17 degrees + 45 degrees is 62 degrees, not a multiple of 45

angles should be 0, 45, 90, etc.

So for question 5, you need to have an array you can index properly.
 - it may be easier to change the assets to have the same name
   as the strings used in the menus, that is permissible


Running Android studio
 - on Linux, easy (I used the snap)
 - on Windows, a bit tricky to get simulator running
    - need to disable Hyper-V, which isn't so simple because
      many things use it (but by default it is off in Win10 home)
    - and, make sure virtualization is enabled in your BIOS

Android Studio isn't currently supported on M1 macs
 - but IntelliJ is, so you can do everything except run the simulator
   (I believe)
 - there are preview builds of Android Studio


What's so different about mobile application development?
 - as compared with (most) current desktop and server development?

* multitouch interfaces (but Windows 8/10 supports that too, some Linux)
  - touch first interfaces, limited mouse support (traditionally)
* "walled gardens" - you can't install arbitrary code (beyond a web browser)
  - more like game consoles than desktops
* the original iPhone had *no* support for 3rd party apps
  - everything not coming from Apple had to run in a browser

Mobile app development is really different from desktops because of the security model
 - which is actually different from traditional game consoles
 - all code needs to be signed (to verify integrity and authenticity)
    - this has become standard
 - code is sandboxed, with privileged operations gated behind access controls
   - Android: permissions asked at install time, some at run time now
   - iOS: all 3rd party apps have same limited access, can ask
     for some runtime permissions

Compare 3rd party keyboards on iOS and Android
 - Android has had them since (almost) the beginning
   - can do everything that 1st party keyboards do
 - iOS 3rd party keyboards are relatively recent
   - even today, they can't be used for sensitive tasks like entering passwords unless you specifically say to (but not Apple ID passwords)

A keyboard can steal all typed input
 - iOS is very paranoid about them
 - android says, sure, go ahead

Note which ecosystem has more malware!

fundamental difference between iOS and Mac malware
 - macs let you install anything, iOS doesn't

Android is more widespread, so that is part of why there is more malware

But also, Android allows for more customization
 - those lower-level permissions can also be used by malware

(BTW don't run antivirus on a Mac, they almost all cause more problems than they solve)

And on Windows, just use Microsoft's AV.

 - yes, there are still risks, but nobody catches all malware

AV in general is a messed up product category
 - lots of snake oil
 - nobody catches the new threats

The real problem is security requires deep OS access
 - and deep OS access is exactly what malware wants too

So letting any third party have such access reduces platform security
 - iOS is the extreme example of this

M1 macs aren't really new from a software perspective
 - mostly recompiled code
 - code was already being compiled for ARM since iOS and MacOS share so much code

This is all why apps installed from app stores on Windows and Mac have less access to the system than regular apps
 - Linux snaps are this way by default as well

less access -> more security -> less user control
 (I don't like this...)

Android devices have a really poor record of security updates, and fundamental
platform design choices make them harder to lock down
 - but if you're really careful about what you install, much of this can be mitigated.  Third party tools can help too, but some can cause more problems than they solve

Mobile apps by default have less access than desktop apps
 - all desktop apps can access everything on your system, at least
   in your account (which is the data you care about)
 - mobile device apps get limited access

again, desktop apps are catching up to mobile devices in locking things down
 - really, mobile devices came after the desktop, so they learned from the choices that were made on the desktop
    - why Apple didn't allow apps to be installed at first, and then
      has only given access in a limited way

Other difference is the particular APIs you use
 - but that isn't always so different
 - SwiftUI is supported on desktop and mobile, for example


More hints for Assignment 2
 - question 5, remember how to do a circular list
    - modulo length of the list

array of 5 items, want to always get the next item, wrapping around when we get to the end

a[0]...a[4] are the elements

So, we always access a[i % 5], so (i mod 5), which is the remainder of dividing i by 5, so will always be a value between 0 and 4.

Note that 5 mod 5 = 0, 6 mod 5 = 1, so it wraps around