2

I am little confused about System.Global. According to this document (third point under Important Behavioral Changes) it says that few of the features like turning airplane mode on/off have been include in System.Global in Android 4.2 and higher so its now read only we cannot write it.

Along with airplane mode there is also Bluetooth turn on/off feature included in System.Global which means we shouldn't be able to toggle Bluetooth on/off programmatically since its read only.

But I have some app in my Nexus 7 which runs on version 4.4.2 where the app can easily turn on/off Bluetooth on voice command (one such app is 'Assistant')

How is it possible if the features in System.Global are read only?

Any explanation on this topic will be very much appreciated. Thanks in advance :)

ik024
  • 3,566
  • 7
  • 38
  • 61

2 Answers2

2

System settings are generally read-only for normal apps. The "Assistant" or "Settings" applications are bundled with the platform and have special permissions. Bluetooth does expose the ability to turn a given "adapter" off and on via the BluetoothAdapter class.

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33
  • What do you mean by special permission? Can we provide those permission in our app (i mean the normal apps which are not bundled with platform as u said) – ik024 Feb 05 '14 at 12:52
  • If we can turn on/off bluetooth using BluetoothAdapter then why is it mentioned under System.Global which is read only. Any insight on this? – ik024 Feb 05 '14 at 12:55
  • 1
    Apps which are bundled with the platform (i.e. system and OEM apps) have access to APIs which are outside of the SDK. This is how the Phone app, Settings app, etc. get access to protected components. This is a security design of the Android platform. – Larry Schiefer Feb 05 '14 at 15:03
  • Just to know more - how can we make our app bundled with the platform? – ik024 Feb 06 '14 at 04:24
  • 1
    You would have to build your own platform. When an OEM creates and Android platform (i.e. Samsung, LG, HTC, Motorola, etc.) they create the flash images which contain the kernel, Android and pre-bundled apps. The carriers (T-Mobile, AT&T, Verizon, Orange, Virgin Mobile, etc.) also have an opportunity to include pre-bundled apps with the devices. So unless you are creating a new device, this is not available to you. – Larry Schiefer Feb 06 '14 at 14:49
  • thanks a lot for this useful info :) I really appreciate it :) – ik024 Feb 07 '14 at 04:37
2

Starting with Android 5.0, it's possible to access some of the settings.

You can use the method setGlobalSetting() in the DevicePolicyManager for that.

However, the caller app must be device owner which is not available to apps deployed on Google Play.

To deploy and activate a device owner, you must perform an NFC data transfer from a programming app to the device while the device is in its unprovisioned state. This data transfer sends the same information as in the provisioning intent described in Managed provisioning.

Source: Android 5.0 APIs

Hartok
  • 2,147
  • 20
  • 37