School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS – The Android Support Library,

Slides:



Advertisements
Similar presentations
Programming with Android: Data management
Advertisements

Bruce Scharlau, University of Aberdeen, 2012 Data storage options for mobiles Mobile Computing.
SQLite is a software library. It is: self-contained + Serverless + zero-configuration transactional = SQL database engine. Most widely deployed. The source.
 data/data-storage.html#pref data/data-storage.html#pref 
Cosc 5/4730 Permissions. Note that all of start with android.premission. Location: – ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, ACCESS_LOCATION_EXTRA_COMMANDS,
Single Application Persistent Data Storage.  Files  SharedPreferences  SQLite database.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Data Persistence in Android
Data Storage: Part 1 (Preferences)
SQLite Database. SQLite Public domain database – Advantages Small (about 150 KB) – Used on devices with limited resources Each database contained within.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Introduction to Android Swapnil Pathak Advanced Malware Analysis Training Series.
Google Maps Android API v2 吳俊興 國立高雄大學 資訊工程學系 CSF645 – Mobile Computing 行動計算
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Content Providers & Services.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Cosc 5/4730 Android Content Providers and Intents.
Data Storage: Part 4 (Content Providers). Content Providers Content providers allow the sharing of data between applications. Inter-process communication.
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
Data Storage: Part 2 (File System). Internal Storage versus External Storage Internal storage − for private data –By default, files saved to the internal.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Recitation.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Android Storage. There are several options for storage of data with Android We can put data into a preferences file. We can put data into a ‘normal’ file.
Nilesh Singh Local Data Storage option Android provides several options for you to save persistent application data. - Shared preferences - Creation.
Data persistence How to save data using SharedPreferences, Files, and SQLite database 1Data persistence.
9 Persistence - SQLite CSNB544 Mobile Application Development Thanks to Utexas Austin.
CS378 - Mobile Computing Persistence. Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed.
Persistence Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
Mobile Software Development ISCG 7424 Department of Computing UNITEC John Casey and Richard Rabeder SQLite and Permissions.
Android - SQLite Database 12/10/2015. Introduction SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with.
SQlite. SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation.
USING HARDWARE DEVICES When building a mobile application, it's important that you always test your application on a real device before releasing it.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Cosc 4735 Permissions Asking for them in API 23+.
CHAPTER 9 File Storage Shared Preferences SQLite.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
Data Storage in Android Димитър Н. Димитров. Why talk about data? Why not 3D graphics or network connectivity? Data as fundamental term in computer science.
1. 2 The Address Book app provides convenient access to contact information that’s stored in a SQLite database on the device. You can: scroll through.
1 Introduction to the Android Platform and SDK Jacek Surazski.
Data Persistence Chapter 9. Objectives Learn about data storage methods Understand use of Shared Preferences Understand file-based storage and the differences.
CS499 – Mobile Application Development
Making content providers
Android Application -Architecture.
CS371m - Mobile Computing Runtime Permissions.
Permissions.
Mobile Applications (Android Programming)
Mobile Applications (Android Programming)
Data Storage: Part 2 (File System)
CS371m - Mobile Computing Persistence.
Android Application Data Storage 1.
SQLite in Android Landon Cox March 2, 2017.
Mobile Software Development for Android - I397
Android Application SQLite 1.
Reactive Android Development
Android.
MAD.
Android Database using SQLite
Android 4: Saving Data Kirk Scott.
Mobile Application Development Chapter 5 [Persistent Data in Android]
Android 18: Saving Data Kirk Scott.
Mobile Device Development
CIS 470 Mobile App Development
CS371m - Mobile Computing Intents.
CS371m - Mobile Computing Runtime Permissions.
CMPE419 Mobile Application Development
Mobile Computing With Android ACST 4550 Android Database Storage
Android Developer Fundamentals V2
Mobile Programming Dr. Mohsin Ali Memon.
Preference Activity class
Presentation transcript:

School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS – The Android Support Library, Persistent Storage, and Permissions Dr. Rainer Wasinger, Dr. James Montgomery School of Engineering and ICT

School of Engineering and Information and Communication Technology Mobile Device Operating System Updates 2 The frequency of OS updates can differ substantially per device manufacturer.

School of Engineering and Information and Communication Technology Mobile Device Operating System Updates 3

School of Engineering and Information and Communication Technology Mobile Device Operating System Updates 4

School of Engineering and Information and Communication Technology Mobile Device Operating System Updates 5

School of Engineering and Information and Communication Technology The Android Support Library What is it? –Originally released in 2011 as the Android Compatibility Library. –A collection of libraries that provides backward-compatible versions of the Android framework APIs. They are a collection, and divided into two categories: Compatibility libraries. Component libraries. What does it do? –Backports capabilities added to newer versions of Android. –Provides access to new widgets, containers, and other classes that Google wishes to make available for Android developers. Why is it needed? –To help support the huge number and variety of devices running different versions of Android OS. Consider: Smartphones, tablets, watches, televisions, cars, and the automated home. –Helps apps to be designed with a measure of consistency in the functionality and UX across across many devices. –Google considers the use of support libraries as best practice and includes these in most of its sample code and the Android Studio project templates. 6

School of Engineering and Information and Communication Technology The Android Support Library Two categories: –Compatibility libraries: These focus on back porting features from newer framework releases so that devices running previous releases can take advantage of the newer APIs. The most-used compatibilities are: v4 ( com.android.support:support-v4: ), which supports back to API 4 (Android OS 1.6), including things like Fragment and Loader. v7 ( com.android.support:appcompat-v7: ), which supports back to API 7 (Android OS 2.1), including things like ActionBar, Toolbar, and Material Design support. –Component libraries: These are smaller more modular libraries that enable developers to add features that are otherwise not part of the standard framework. Design support library ( com.android.support:design: ), providing support for various material design components and patterns such as navigation drawers, foating action buttons, snackbars, and tabs. Note: If you are including the v4 support and v7 appcompat libraries in your application, you should specify a minimum SDK version of "7" (and not "4"). The highest support library level you include in your application determines the lowest API version in which it can operate. 7

School of Engineering and Information and Communication Technology Using the Support Libraries These libraries are available via the Android SDK Manager. We include them in the Gradle build file: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } And can then access them via code: package au.edu.utas.propertyapp; import android.support.v7.app.AppCompatActivity;... public class PropertyApp extends AppCompatActivity implements OnItemSelectedListener { 8

School of Engineering and Information and Communication Technology Using the Support Libraries 9 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "au.edu.utas.propertyapp" minSdkVersion 8 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' } Notice also the properties: compileSdkVersion buildToolsVersion minSdkVersion targetSdkVersion

School of Engineering and Information and Communication Technology Persistent Storage Several options to save persistent application data: –Shared Preferences –Internal Storage –External Storage –SQLite Databases –Network Connection Parsers: XML and JSON. –Android supports both XML parsing (e.g. org.xmlpull.v1XmlPullParser) and JSON parsing (android.util.JsonReader) Raw resources, XML resources, and Assets 10

School of Engineering and Information and Communication Technology Persistent Storage – Shared Preferences Provides a general framework to save and retrieve persistent key-value pairs of primitive data types. This is the simplest method for storing data. To use, we retrieve a SharedPreferences object as follows: SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); where : PREFS_NAME is the preferences file we wish to access, and MODE_PRIVATE means the created file can only be accessed by the calling application. To write or read values, we first call edit() to get the SharedPreferences.Editor SharedPreferences.Editor editor = settings.edit(); We can then write values using methods like putString() editor.putBoolean("silentMode", mSilentMode); And read values using methods like getString() editor.getBoolean("silentMode", mSilentMode); 11

School of Engineering and Information and Communication Technology Persistent Storage – Shared Preferences public class Calculator extends Activity { public static final String PREFS_NAME = protected void onCreate(Bundle state){ super.onCreate(state);... // Restore preferences SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); boolean silent = settings.getBoolean("silentMode", false); setSilent(silent); protected void onStop(){ super.onStop(); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("silentMode", mSilentMode); // Commit the edits! editor.commit(); } 12

School of Engineering and Information and Communication Technology Persistent Storage – Shared Preferences Multiple ways to retrieve SharedPreferences: –SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); Use this if you need multiple preference files –SharedPreferences settings = getPreferences(Context.MODE_PRIVATE); Use this if you need only one preference file. Also using a PreferenceManager, which can be used to help create preference hierarchies from XML files. 13

School of Engineering and Information and Communication Technology Persistent Storage – Internal Storage Files can also be stored on a device’s internal storage or external storage. –Internal storage: The on-board flash storage of a device, which is not accessible by the user, except via installed apps. –External storage: Shared storage that is accessible by the user (e.g. by mounting it as a drive on a host computer via a USB cable). This storage includes both primary external storage that may be inbuilt and removable storage media such as an SD card. 14 Internal StorageExternal Storage Is always available.Is not always available (e.g. when an SD card is removed). Files are accessible only by your app. It’s world-readable, so may be edited outside of your control. When the user uninstalls your app, the system removes all of your app’s files from internal storage as well. When the user uninstalls your app, the system only removes your app’s files if you save them using getExternalFilesDir().

School of Engineering and Information and Communication Technology Persistent Storage – Internal Storage To create a private file in internal storage and write to it: String FILENAME = "hello_file"; String writeString = "hello world!"; FileOutputStream fos; try { fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); fos.write(writeString.getBytes()); fos.close(); } catch (Exception e) { e.printStackTrace(); } 15

School of Engineering and Information and Communication Technology Persistent Storage – Internal Storage To read a private file from internal storage: String FILENAME = "hello_file"; FileInputStream fis; InputStreamReader isr; BufferedReader bufferedReader; StringBuffer stringBuffer = new StringBuffer(""); try { fis = openFileInput(FILENAME); isr = new InputStreamReader(fis); bufferedReader = new BufferedReader (isr); String readString = bufferedReader.readLine(); while (readString!=null) { stringBuffer.append(readString); readString = bufferedReader.readLine(); } isr.close(); fis.close(); } catch (Exception e) { e.printStackTrace(); } 16

School of Engineering and Information and Communication Technology Persistent Storage – External Storage To read and write to external storage, your app must first acquire the following permissions: –READ_EXTERNAL_STORAGE –WRITE_EXTERNAL_STORAGE This is done by modifying the Android Manifest file:... If you need to both read and write files, then you need to request only the WRITE_EXTERNAL_STORAGE permission, because it implicitly requires read access as well. 17

School of Engineering and Information and Communication Technology Persistent Storage – External Storage Because it is possible that the external storage is not readable or writeable, we need to check the state of the external storage first: public boolean isExternalStorageWritable() { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { return true; } return false; } public boolean isExternalStorageReadable() { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { return true; } return false; } Other states returned by getExternalStorageState: –MEDIA_UNKNOWN, MEDIA_REMOVED, MEDIA_UNMOUNTED, MEDIA_CHECKING, MEDIA_NOFS, MEDIA_MOUNTED, MEDIA_MOUNTED_READ_ONLY, MEDIA_SHARED, MEDIA_BAD_REMOVAL, or MEDIA_UNMOUNTABLE. 18

School of Engineering and Information and Communication Technology Persistent Storage – External Storage Generally, files that the user will save through your app will typically be saved to a “public” location on the device. Some of the shared public directories include: –Music/, Pictures/, and Ringtones/ public File getAlbumStorageDir(String albumName) { // Get the directory for the user's public pictures directory. File file = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), albumName); if (!file.mkdirs()) { Log.e(LOG_TAG, "Directory not created"); } return file; } 19

School of Engineering and Information and Communication Technology Persistent Storage – SQLite Databases Android provides full support for SQLite databases. Databases that you create are accessible by name to your application, but not outside the application. To create a database, we use a subclass of SQLiteOpenHelper and then override the onCreate() method: public class PropertyDB { private static final String DATABASE_NAME = "propertydata"; private static final int DATABASE_VERSION = 2; private static final String PROPERTY_TABLE= "property_data"; public static final String KEY_ROWID = "_id"; public static final String KEY_PROPERTY_ID= "property_id"; public static final String KEY_ADDRESS = "address"; public static final String KEY_PRICE = "price"; private static final String PROPERTY_TABLE_CREATE = "create table " + PROPERTY_TABLE + " (" + KEY_ROWID + " integer primary key autoincrement, " + KEY_PROPERTY_ID + " long integer not null, " + KEY_ADDRESS + " string not null, " + KEY_PRICE + " string not null, " private SQLiteDatabase mDb; private DatabaseHelper mDbHelper;... 20

School of Engineering and Information and Communication Technology Persistent Storage – SQLite Databases SQLiteOpenHelper is used to wrap up the logic to create and upgrade a database. You need to implement three methods at minimum – the constructor, onCreate, and onUpgrade: private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { //This creates the database. super(context, DATABASE_NAME, null, DATABASE_VERSION); public void onCreate(SQLiteDatabase db) { db.execSQL(PROPERTY_TABLE_CREATE); public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + PROPERTY_TABLE); onCreate(db); } public void reset(SQLiteDatabase db) { db.execSQL("DROP TABLE IF EXISTS " + PROPERTY_TABLE); onCreate(db); } 21

School of Engineering and Information and Communication Technology Persistent Storage – SQLite Databases Accessing the database: mDbHelper = new DatabaseHelper(mCtx); mDb = mDbHelper.getWritableDatabase(); Reading information from the database: public Cursor getProperty(String id) { Cursor c = mDb.query(PROPERTY_TABLE, null, KEY_PROPERTY_ID + "=" + id, null, null, null, null); return c; } Adding to the database: public void addProperty(Property p) { ContentValues propValues = new ContentValues(); // Build our property values propValues.put(KEY_PROPERTY_ID, p.getPropertyID()); propValues.put(KEY_ADDRESS, p.getAddress()); propValues.put(KEY_PRICE, p.getPrice()); // Insert into the database mDb.insert(PROPERTY_TABLE, null, propValues); } Closing the database: mDb.close(); 22

School of Engineering and Information and Communication Technology Persistent Storage Raw resources, XML resources, and Assets –Raw resources are one way to deploy a file. They get put in the application.apk file as part of the packaging process and are accessed using the getResources() function shown below. –XML resources and Assets are two other ways to package files into an application’s.apk file. // Get the static XML resource file for reading. InputStream is = null; if (toRent) { is = context.getResources().openRawResource(R.raw.searchresults_camperdown_rent); } else { //toBuy is = context.getResources().openRawResource(R.raw.searchresults_camperdown_buy); } 23

School of Engineering and Information and Communication Technology Android System Permissions Android applications have no permissions associated with them by default, meaning they can not do anything that would adversely impact the user experience or any data on the device. To make use of protected features, one or more tags must be included in the AndroidManifest.xml file. 24 Example application from Google Play: “Locale” (pre Android 6.0)

School of Engineering and Information and Communication Technology System Permissions (cont.) All of the permissions required to generate the security details in the “Locale” example are: 25

School of Engineering and Information and Communication Technology System Permissions – AndroidManifest.xml <manifest xmlns:android=" package="apt.tutorial.two“ android:versionCode="1“ android:versionName="1.0">... <category android:name="android.intent.category.LAUNCHER" /> 26 See for a full list of permissions. There are currently over 100 that have been defined.

School of Engineering and Information and Communication Technology System Permissions (as at Apr.2016): 137 ACCESS_CHECKIN_PROPERTIES, ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, ACCESS_LOCATION_EXTRA_COMMANDS, ACCESS_NETWORK_STATE, ACCESS_NOTIFICATION_POLICY, ACCESS_WIFI_STATE, ACCOUNT_MANAGER, ADD_VOIC , BATTERY_STATS, BIND_ACCESSIBILITY_SERVICE, BIND_APPWIDGET, BIND_CARRIER_MESSAGING_SERVICE, BIND_CARRIER_SERVICES, BIND_CHOOSER_TARGET_SERVICE, BIND_DEVICE_ADMIN, BIND_DREAM_SERVICE, BIND_INCALL_SERVICE, BIND_INPUT_METHOD, BIND_MIDI_DEVICE_SERVICE, BIND_NFC_SERVICE, BIND_NOTIFICATION_LISTENER_SERVICE, BIND_PRINT_SERVICE, BIND_REMOTEVIEWS, BIND_TELECOM_CONNECTION_SERVICE, BIND_TEXT_SERVICE, BIND_TV_INPUT, BIND_VOICE_INTERACTION, BIND_VPN_SERVICE, BIND_WALLPAPER, BLUETOOTH, BLUETOOTH_ADMIN, BLUETOOTH_PRIVILEGED, BODY_SENSORS, BROADCAST_PACKAGE_REMOVED, BROADCAST_SMS, BROADCAST_STICKY, BROADCAST_WAP_PUSH, CALL_PHONE, CALL_PRIVILEGED, CAMERA, CAPTURE_AUDIO_OUTPUT, CAPTURE_SECURE_VIDEO_OUTPUT, CAPTURE_VIDEO_OUTPUT, CHANGE_COMPONENT_ENABLED_STATE, CHANGE_CONFIGURATION, CHANGE_NETWORK_STATE, CHANGE_WIFI_MULTICAST_STATE, CHANGE_WIFI_STATE, CLEAR_APP_CACHE, CONTROL_LOCATION_UPDATES, DELETE_CACHE_FILES, DELETE_PACKAGES, DIAGNOSTIC, DISABLE_KEYGUARD, DUMP, EXPAND_STATUS_BAR, FACTORY_TEST, FLASHLIGHT, GET_ACCOUNTS, GET_ACCOUNTS_PRIVILEGED, GET_PACKAGE_SIZE, GET_TASKS, GLOBAL_SEARCH, INSTALL_LOCATION_PROVIDER, INSTALL_PACKAGES, INSTALL_SHORTCUT, INTERNET, KILL_BACKGROUND_PROCESSES, LOCATION_HARDWARE, MANAGE_DOCUMENTS, MASTER_CLEAR, MEDIA_CONTENT_CONTROL, MODIFY_AUDIO_SETTINGS, MODIFY_PHONE_STATE, MOUNT_FORMAT_FILESYSTEMS, MOUNT_UNMOUNT_FILESYSTEMS, NFC, PACKAGE_USAGE_STATS, PERSISTENT_ACTIVITY, PROCESS_OUTGOING_CALLS, READ_CALENDAR, READ_CALL_LOG, READ_CONTACTS, READ_EXTERNAL_STORAGE, READ_FRAME_BUFFER, READ_INPUT_STATE, READ_LOGS, READ_PHONE_STATE, READ_SMS, READ_SYNC_SETTINGS, READ_SYNC_STATS, READ_VOIC , REBOOT, RECEIVE_BOOT_COMPLETED, RECEIVE_MMS, RECEIVE_SMS, RECEIVE_WAP_PUSH, RECORD_AUDIO, REORDER_TASKS, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, REQUEST_INSTALL_PACKAGES, RESTART_PACKAGES, SEND_RESPOND_VIA_MESSAGE, SEND_SMS, SET_ALARM, SET_ALWAYS_FINISH, SET_ANIMATION_SCALE, SET_DEBUG_APP, SET_PREFERRED_APPLICATIONS, SET_PROCESS_LIMIT, SET_TIME, SET_TIME_ZONE, SET_WALLPAPER, SET_WALLPAPER_HINTS, SIGNAL_PERSISTENT_PROCESSES, STATUS_BAR, SYSTEM_ALERT_WINDOW, TRANSMIT_IR, UNINSTALL_SHORTCUT, UPDATE_DEVICE_STATS, USE_FINGERPRINT, USE_SIP, VIBRATE, WAKE_LOCK, WRITE_APN_SETTINGS, WRITE_CALENDAR, WRITE_CALL_LOG, WRITE_CONTACTS, WRITE_EXTERNAL_STORAGE, WRITE_GSERVICES, WRITE_SECURE_SETTINGS, WRITE_SETTINGS, WRITE_SYNC_SETTINGS, WRITE_VOIC 27

School of Engineering and Information and Communication Technology System Permissions – Before Android 6.0 Example: Facebook Permissions 28

School of Engineering and Information and Communication Technology System Permissions – Before Android Example: Facebook Permissions (cont.)

School of Engineering and Information and Communication Technology 30 System Permissions – Before Android 6.0 Example: Facebook Permissions (cont.)

School of Engineering and Information and Communication Technology System Permissions – From Android Example: Facebook Permissions

School of Engineering and Information and Communication Technology System Permissions – What changed? Permissions are granted differently in Android 6.0 (API Level 23) and higher. On Android 6.0 (API Level 23) and higher: –If the device is running Android 6.0 or higher AND the app’s targetSdkVersion is 23 or higher, the app requests permissions from the user at run-time. –The user can revoke the permissions at any time, so the app needs to check whether it has the permissions every time it runs. On Android 5.1 (API Level 22) and lower: -If the device is running Android 5.1 or lower OR the app’s targetSdkVersion is 22 or lower, the system asks the user to grant the permissions when the user installs the app (as seen in the earlier “Locale” and “Facebook” examples). -Once the user installs the app, the only way to revoke the permission is to uninstall the app. This is a huge change!!! 32

School of Engineering and Information and Communication Technology System Permissions – Protection Levels System permissions are divided into several protection levels, two of which are normal and dangerous. –Normal Protection Level: These are permissions that a user ‘might’ care about, but probably not. When we request the Internet permission in the manifest, the user is not informed about the permission at install time (on Android 6.0 and higher). Those permissions classified as normal are: ACCESS_LOCATION_EXTRA_COMMANDS, ACCESS_NETWORK_STATE, ACCESS_NOTIFICATION_POLICY, ACCESS_WIFI_STATE, BLUETOOTH, BLUETOOTH_ADMIN, BROADCAST_STICKY, CHANGE_NETWORK_STATE, CHANGE_WIFI_MULTICAST_STATE, CHANGE_WIFI_STATE, DISABLE_KEYGUARD, EXPAND_STATUS_BAR, GET_PACKAGE_SIZE, INSTALL_SHORTCUT, INTERNET, KILL_BACKGROUND_PROCESSES, MODIFY_AUDIO_SETTINGS, NFC, READ_SYNC_SETTINGS, READ_SYNC_STATS, RECEIVE_BOOT_COMPLETED, REORDER_TASKS, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, REQUEST_INSTALL_PACKAGES, SET_ALARM, SET_TIME_ZONE, SET_WALLPAPER, SET_WALLPAPER_HINTS, TRANSMIT_IR, UNINSTALL_SHORTCUT, USE_FINGERPRINT, VIBRATE, WAKE_LOCK, WRITE_SYNC_SETTINGS 33

School of Engineering and Information and Communication Technology System Permissions – Protection Levels –Dangerous Protection Level: These are permissions where the app wants data or resources that involve the user’s private information or could potentially affect the user’s stored data or the operation of other apps. In Android 6.0+, permissions considered to be dangerous not only have to be requested via elements in the manifest, but also have to ask the user to grant those permissions at runtime. Note 1: If an app lists normal permissions in its manifest, the system automatically grants those permissions. Note 2: If an app requests a dangerous permission listed in its manifest, and the app already has another dangerous permission in the same permission group, the system immediately grants the permission without any interaction from the user. 34

School of Engineering and Information and Communication Technology System Permissions – Protection Levels There are 9 dangerous permission groups that Android 6.0 manages as user-controllable permissions: 35 Permission GroupPermission CALENDARREAD_CALENDAR, WRITE_CALENDAR CAMERA CONTACTSGET_ACCOUNTS, READ_CONTACTS, WRITE_CONTACTS LOCATIONACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION MICROPHONERECORD_AUDIO PHONEADD_VOIC , CALL_PHONE, PROCESS_OUTGOING_CALLS, READ_CALL_LOG, READ_PHONE_STATE, USE_SIP, WRITE_CALL_LOG SENSORSBODY_SENSORS SMSREAD_CELL_BROADCASTS, READ_SMS, RECEIVE_SMS, RECEIVE_MMS, RECEIVE_WAP_PUSH, SEND_SMS STORAGEREAD_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE

School of Engineering and Information and Communication Technology System Permissions – Code Examples … more on System Permissions in the next lecture 36