Skip to content

Commit 8fcbd4a

Browse files
authored
feat(android): add camera/microphone foreground service constants (#12170)
Fixes TIMOB-28051
1 parent 98ff0e7 commit 8fcbd4a

File tree

2 files changed

+152
-14
lines changed

2 files changed

+152
-14
lines changed

android/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java

+4
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,10 @@ public class AndroidModule extends KrollModule
541541
@Kroll.constant
542542
publicstaticfinalintFOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION =
543543
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION;
544+
@Kroll.constant
545+
publicstaticfinalintFOREGROUND_SERVICE_TYPE_MICROPHONE = ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
546+
@Kroll.constant
547+
publicstaticfinalintFOREGROUND_SERVICE_TYPE_CAMERA = ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA;
544548

545549
protectedRProxyr;
546550
privateLinkedList<BroadcastReceiverProxy> registeredBroadcastReceiverProxyList = newLinkedList<>();

apidoc/Titanium/Android/Android.yml

+148-14
Original file line numberDiff line numberDiff line change
@@ -1827,65 +1827,199 @@ properties:
18271827
summary: |
18281828
A special value indicates to use all types set in manifest file.
18291829
description: |
1830-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MANIFEST).
1830+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1831+
1832+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MANIFEST)
1833+
documentation for more details.
18311834
type: Number
18321835
permission: read-only
18331836
since: "8.3.0"
18341837

18351838
- name: FOREGROUND_SERVICE_TYPE_NONE
1836-
summary: |
1837-
The default foreground service type if not been set in manifest file.
1839+
summary: The default foreground service type.
18381840
description: |
1839-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_NONE).
1841+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1842+
1843+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_NONE)
1844+
documentation for more details.
18401845
type: Number
18411846
permission: read-only
18421847
since: "8.3.0"
18431848

18441849
- name: FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
18451850
summary: |
1846-
Constant corresponding to mediaPlayback in the R.attr.foregroundServiceType attribute. Music, video, news or other media playback.
1851+
Allows music, video, news or other media playback while the app is in the background.
18471852
description: |
1848-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK).
1853+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1854+
1855+
To use this constant, you must also set your `<service/>` element to the
1856+
`foregroundServieType` attribute value as shown below.
1857+
1858+
``` xml
1859+
<ti:app>
1860+
<android>
1861+
<services>
1862+
<service url="<YourService.js>" android:foregroundServiceType="mediaPlayback"/>
1863+
</services>
1864+
</android>
1865+
</ti:app>
1866+
```
1867+
1868+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK)
1869+
documentation for more details.
18491870
type: Number
18501871
permission: read-only
18511872
since: "8.3.0"
18521873

18531874
- name: FOREGROUND_SERVICE_TYPE_PHONE_CALL
18541875
summary: |
1855-
Constant corresponding to phoneCall in the R.attr.foregroundServiceType attribute. Ongoing phone call or video conference.
1876+
Allows ongoing phone call or video conferencing access while the app is in the background.
18561877
description: |
1857-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_PHONE_CALL).
1878+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1879+
1880+
To use this constant, you must also set your `<service/>` element to the
1881+
`foregroundServieType` attribute value as shown below.
1882+
1883+
``` xml
1884+
<ti:app>
1885+
<android>
1886+
<services>
1887+
<service url="<YourService.js>" android:foregroundServiceType="phoneCall"/>
1888+
</services>
1889+
</android>
1890+
</ti:app>
1891+
```
1892+
1893+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_PHONE_CALL)
1894+
documentation for more details.
18581895
type: Number
18591896
permission: read-only
18601897
since: "8.3.0"
18611898

18621899
- name: FOREGROUND_SERVICE_TYPE_LOCATION
18631900
summary: |
1864-
Constant corresponding to location in the R.attr.foregroundServiceType attribute. GPS, map, navigation location update.
1901+
Allows accessing location from the GPS, map, etc. while the app is in the background.
18651902
description: |
1866-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_LOCATION).
1903+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1904+
1905+
To use this constant, you must also set your `<service/>` element to the
1906+
`foregroundServieType` attribute value as shown below.
1907+
1908+
``` xml
1909+
<ti:app>
1910+
<android>
1911+
<services>
1912+
<service url="<YourService.js>" android:foregroundServiceType="location"/>
1913+
</services>
1914+
</android>
1915+
</ti:app>
1916+
```
1917+
1918+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_LOCATION)
1919+
documentation for more details.
18671920
type: Number
18681921
permission: read-only
18691922
since: "8.3.0"
18701923

18711924
- name: FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
18721925
summary: |
1873-
Constant corresponding to connectedDevice in the R.attr.foregroundServiceType attribute. Auto, bluetooth, TV or other devices connection, monitoring and interaction.
1926+
Allows connecting to Android Auto, bluetooth, TV or other devices while app is in the background.
18741927
description: |
1875-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE).
1928+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1929+
1930+
To use this constant, you must also set your `<service/>` element to the
1931+
`foregroundServieType` attribute value as shown below.
1932+
1933+
``` xml
1934+
<ti:app>
1935+
<android>
1936+
<services>
1937+
<service url="<YourService.js>" android:foregroundServiceType="connectedDevice"/>
1938+
</services>
1939+
</android>
1940+
</ti:app>
1941+
```
1942+
1943+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE)
1944+
documentation for more details.
18761945
type: Number
18771946
permission: read-only
18781947
since: "8.3.0"
18791948

18801949
- name: FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
18811950
summary: |
1882-
Constant corresponding to mediaProjection in the R.attr.foregroundServiceType attribute. Managing a media projection session, e.g for screen recording or taking screenshots.
1951+
Allows managing a media projection session for screen recording or taking screenshots
1952+
while app is in the background.
18831953
description: |
1884-
See [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION in the Android API Reference](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION).
1954+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1955+
1956+
To use this constant, you must also set your `<service/>` element to the
1957+
`foregroundServieType` attribute value as shown below.
1958+
1959+
``` xml
1960+
<ti:app>
1961+
<android>
1962+
<services>
1963+
<service url="<YourService.js>" android:foregroundServiceType="mediaProjection"/>
1964+
</services>
1965+
</android>
1966+
</ti:app>
1967+
```
1968+
1969+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)
1970+
documentation for more details.
18851971
type: Number
18861972
permission: read-only
18871973
since: "8.3.0"
18881974

1975+
- name: FOREGROUND_SERVICE_TYPE_MICROPHONE
1976+
summary: Allows the microphone to be used while the app is in the background.
1977+
description: |
1978+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
1979+
1980+
To use this constant, you must also set your `<service/>` element to the
1981+
`foregroundServieType` attribute value as shown below.
1982+
1983+
``` xml
1984+
<ti:app>
1985+
<android>
1986+
<services>
1987+
<service url="<YourService.js>" android:foregroundServiceType="microphone"/>
1988+
</services>
1989+
</android>
1990+
</ti:app>
1991+
```
1992+
1993+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_MICROPHONE)
1994+
documentation for more details.
1995+
type: Number
1996+
permission: read-only
1997+
since: "9.3.0"
1998+
1999+
- name: FOREGROUND_SERVICE_TYPE_CAMERA
2000+
summary: Allows the camera to be used while the app is in the background.
2001+
description: |
2002+
This constant is passed to the <Titanium.Android.Service.foregroundNotify> method.
2003+
2004+
To use this constant, you must also set your `<service/>` element to the
2005+
`foregroundServieType` attribute value as shown below.
2006+
2007+
``` xml
2008+
<ti:app>
2009+
<android>
2010+
<services>
2011+
<service url="<YourService.js>" android:foregroundServiceType="camera"/>
2012+
</services>
2013+
</android>
2014+
</ti:app>
2015+
```
2016+
2017+
See Google's [ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA](https://developer.android.com/reference/android/content/pm/ServiceInfo.html#FOREGROUND_SERVICE_TYPE_CAMERA)
2018+
documentation for more details.
2019+
type: Number
2020+
permission: read-only
2021+
since: "9.3.0"
2022+
18892023
- name: FLAG_AUTO_CANCEL
18902024
summary: Cancel the notification when it is clicked by the user.
18912025
description: |

0 commit comments

Comments
 (0)
close