Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27067] Android: UI sometimes disappears on Android 9.0 and higher when battery saver turns on/off

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2019-05-24T18:18:05.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.0.2
ComponentsAndroid
Labelsandroid, battery, engSchedule, manifest, tiapp.xml
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-05-07T21:53:34.000+0000
Updated2019-05-24T18:18:05.000+0000

Description

*Summary:* On Android 9.0 and higher, a Titanium window's UI may disappear when the system's battery optimizer turn on or off. This can happen if the XML activities defined in the "tiapp.xml" are missing "android:configChanges" value "uiMode". This issue can be reproduced consistently in an Android 9 (API 28) emulator. *Steps to reproduce:*

Create a new Titanium Classic "Default Project".

Build and run on an Android 9 (aka: API 28) emulator.

In the Android emulator's toolbar, click the "..." button.

An "Extended Controls" window will open next to the emulator.

Click on the "Battery" tab in this window.

Go to the "Charge level" and lower it to 10%.

Click the "Charge connection" drop-down and change it from "AC charger" to "None" (or vice-versa).

In the emulator, if it asks if you want to enable the battery optimizer, tap "Yes".

Notice that the Titanium app's UI disappears.

Press the Android "Back" button.

Relaunch the app. (The UI will appear as normal.)

Click the emulator's "Charge connection" drop-down and change it back to "AC charger".

Notice that the Titanium app's UI disappears again.

*Cause:* The "AndroidManifest.xml" that is being generated by Titanium's build system is missing a setting. We need to add "uiMode" to every Titanium <activity/> elements "android:configChanges" attribute. *Work-Around:* You can work-around this issue by adding the following "activity" XML settings to the "tiapp.xml" file. The key thing here is to add all of the missing "configChanges" values. Particularly the "uiMode" value which solves this ticket's specific issue.
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
	<android xmlns:android="http://schemas.android.com/apk/res/android">
		<manifest>
			<application>
				<activity android:name="org.appcelerator.titanium.TiActivity" android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"/>
				<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:theme="@style/Theme.Titanium.Translucent"/>
			</application>
		</manifest>
	</android>
</ti:app>

Comments

  1. Joshua Quick 2019-05-11

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10884
  2. Joshua Quick 2019-05-18

    PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10900
  3. Keerthi Mahalingam 2019-05-21

    FR passed. jenkin is failing test. waiting for resolving jenkin failure to merge
  4. Keerthi Mahalingam 2019-05-24

    Verified the fix on sdk 8.0.2.v20190522031334 and 8.1.0.v20190523084559. No Ui disappears. Works as expected. {CODE} Name = Mac OS X Version = 10.13.6 Architecture = 64bit # CPUs = 8 Memory = 17179869184 Node.js Node.js Version = 8.9.1 npm Version = 5.5.1 Titanium CLI CLI Version = 5.1.1 Titanium SDK SDK Version = 8.0.2.v20190522031334 and 8.1.0.v20190523084559 Emulator =Pixel xl android 9.pixel android 9 Device = s5 samsung android 6 Cli =7.0.11 {CODE}

JSON Source