3

I am testing my app (debug build) on a Samsung Galaxy Tab A 10.1 (2019). The device resolution is 1200 x 1920. However, when I use getDisplayWidth() and getDisplayHeight() I get 900 x 1359 (= 1440 - status bar). So the app is running at a lower resolution and indeed the graphics look a bit coarse. But when I make a screenshot it has resolution 1200 x 1920. The Galaxy Tab A has no option to change the screen resolution and I found no way to solve this problem.

Is this a known problem and is there a solution?

Edit: A temporary solution is to change the package name (of a known app). Using NativeLogsReader.cn1lib we get

1) with the original package name:

--------- beginning of main
05-17 13:09:35.879 24347 24347 D ViewRootImpl@34e19e6[MainStub]: Relayout returned: 
old=[0,0][1200,1920] new=[0,0][900,1440] result=0x7 surface={true 3890690048} changed=true

2) with a changed package name:

--------- beginning of main
05-17 13:22:46.459 26231 26231 D ViewRootImpl@34e19e6[MainStub]: Relayout returned: 
old=[0,0][1200,1920] new=[0,0][1200,1920] result=0x7 surface={true 3890690048} changed=true

So with the original package name the resolution is reduced and with the changed package name the resolution stays native. I googled this problem and found no other examples or clues.

Edit 2: Device console output for the original package name (com.xx.yy) and the test package name (com.xx.yy2).

1) All output, filtered by package name:

a) original package name:

2020-05-18 11:12:48.174 3915-4148/? D/StorageManagerService: getExternalStorageMountMode : final mountMode=1, uid : 10163, packageName : com.xx.yy
2020-05-18 11:12:48.175 3915-4148/? I/ApplicationPolicy: isApplicationExternalStorageWhitelisted:com.xx.yy user:0
2020-05-18 11:12:48.175 3915-4148/? D/ActivityManager: package  com.xx.yy, user - 0 is SDcard whitelisted
2020-05-18 11:12:48.175 3915-4148/? I/ApplicationPolicy: isApplicationExternalStorageBlacklisted:com.xx.yy user:0
2020-05-18 11:12:48.175 3915-4148/? I/ApplicationPolicy: isApplicationExternalStorageBlacklisted:com.xx.yy user:0
2020-05-18 11:12:48.194 3915-3933/? I/ActivityManager: Start proc 13627:com.xx.yy/u0a163 for activelaunch com.xx.yy/.MainStub
2020-05-18 11:12:48.199 13627-13627/? I/com.xx.yy: Late-enabling -Xcheck:jni
2020-05-18 11:12:48.235 13627-13627/? I/com.xx.yy: report jit thread pid = 13632
2020-05-18 11:12:48.238 4834-4985/? I/SAPrinter: sendEvent :{cd=det3packageNamecom.xx.yy, t=ev, en=1001, pn=201, ts=1589793168238}
2020-05-18 11:12:48.249 3915-4194/? I/ActivityManager: START u0 {act=android.intent.action.MAIN typ=null flg=0x10200000 cmp=ComponentInfo{com.xx.yy/com.xx.yy.MainStub}} from uid 10010
2020-05-18 11:12:48.252 3915-4194/? I/ActivityManager: [IOP] sourceDir : /data/app/com.xx.yy-i4NuDIQRBO8c4W1IO7HhTA== in ActivityStacksupervisor
2020-05-18 11:12:48.266 3572-3572/? I/SurfaceFlinger: id=2615 createSurf (3840x3840),2 flag=4, AppWindowToken{e37293b token=Token{b713ca ActivityRecord{cd6e335 u0 com.xx.yy/.MainStub t69}}}#0
2020-05-18 11:12:48.272 3915-4311/? I/ActivityManager: DSS on for com.xx.yy and scale is 0.75

Note the 'scale is 0.75'.

b) test package name:

...(similar)...
2020-05-18 11:08:43.650 3915-5720/? I/ActivityManager: DSS on for com.xx.yy2 and scale is 1.0

Note the 'scale is 1.0'.

2) Specific debug app output:

a) original package name:

2020-05-18 13:31:07.695 21604-21604/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2020-05-18 13:31:07.696 21604-21604/? E/Zygote: accessInfo : 1
2020-05-18 13:31:07.701 21604-21604/? I/com.xx.yy: Late-enabling -Xcheck:jni
2020-05-18 13:31:07.741 21604-21604/? I/com.xx.yy: report jit thread pid = 21609
2020-05-18 13:31:07.835 21604-21604/com.xx.yy W/ActivityThread: Application com.xx.yy can be debugged on port 8100...
2020-05-18 13:31:07.842 21604-21604/com.xx.yy I/com.xx.yy: The ClassLoaderContext is a special shared library.
2020-05-18 13:31:08.252 21604-21604/com.xx.yy W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@b9352ba
2020-05-18 13:31:08.378 21604-21604/com.xx.yy I/DecorView: createDecorCaptionView >> DecorView@4039d47[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
2020-05-18 13:31:08.418 21604-21604/com.xx.yy D/OpenGLRenderer: Skia GL Pipeline
2020-05-18 13:31:08.632 21604-21604/com.xx.yy D/EmergencyMode: [EmergencyManager] android createPackageContext successful
2020-05-18 13:31:08.655 21604-21604/com.xx.yy D/InputTransport: Input channel constructed: fd=60
2020-05-18 13:31:08.656 21604-21604/com.xx.yy D/ViewRootImpl@34e19e6[MainStub]: setView = DecorView@4039d47[MainStub] TM=true MM=false
2020-05-18 13:31:08.669 21604-21604/com.xx.yy V/InputMethodManager: Not IME target window, ignoring
2020-05-18 13:31:08.672 21604-21637/com.xx.yy D/App: [EDT] 0:0:0,2 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29
2020-05-18 13:31:08.678 21604-21637/com.xx.yy D/App: [EDT] 0:0:0,9 - package com.xx.yy
2020-05-18 13:31:08.693 21604-21637/com.xx.yy D/App: [EDT] 0:0:0,20 - Native Logs Reader initialized correctly
2020-05-18 13:31:08.703 21604-21604/com.xx.yy D/ViewRootImpl@34e19e6[MainStub]: Relayout returned: old=[0,0][1200,1920] new=[0,0][900,1440] result=0x7 surface={true 3890690048} changed=true

Note the 'new=[0,0][900,1440]'.

b) test package name:

...(similar)...
2020-05-18 16:26:40.564 24283-24283/com.xx.yy2 D/ViewRootImpl@34e19e6[MainStub]: Relayout returned: old=[0,0][1200,1920] new=[0,0][1200,1920] result=0x7 surface={true 3890690048} changed=true

Note the 'new=[0,0][1200,1920]'.

Edit 3: New test with original package name. Initial situation: app runs at reduced resolution 900x1440.

Steps:
1. deinstall app
2. switch off wifi/internet
3. install app (from downloads)
4. optional: switch on wifi/internet
5. run app

Result: app has native resolution 1200x1920. Conclusion: reduced resolution is set during installation using an online check of the package name.

Edit 4: output of the CN1 Device Tester app:

Density: DENSITY_HIGH
Platform Name: and
User Agent: Dalvik/2.1.0 (Linux; U; Android 9; SM-T510 Build/PPR1.180610.011)
OS: Android
OS Version: 9
UDID: 01234567890abcde
MSISDN: null
Display Width X Height: 1200X1812
1mm In Pixels: 9.449
Language: en
Locale: US
Currency Symbol: $
Are Mutable Images Fast: false
Can Dial: false
Can Force Orientation: true
Has Camera: true
Badging: false
Desktop: false
Tablet: true
Gaussian Blur Support: true
Get All Contacts Fast: true
Multi Touch: true
PICKER_TYPE_DATE: true
PICKER_TYPE_DATE_AND_TIME: false
PICKER_TYPE_STRINGS: true
PICKER_TYPE_TIME: true
Native Share: true
Native Video Player Controls: true
Notification: true
Open Native Navigation: true
Screen Saver Disable: true
Simulator: false

Edit 5: I also looked at the console output of installing with and without an internet connection.

1) without internet connection:

...
2020-05-20 13:51:36.746 28438-28455/? D/GOS:NetworkConnector: getPkgData(), packageName : com.xx.yy
2020-05-20 13:51:36.808 28438-28455/? D/GOS:NetworkConnector: getPkgData(), request: https://service.game-mode.net/gamemode/v3/packages/?type=install&device_name=gta3xlwifi&package_names=com.xx.yy, response: null
2020-05-20 13:51:36.830 28438-28455/? D/GOS:PackageDAO: updateTimeStamp(): com.xx.yy
2020-05-20 13:51:36.874 28438-28455/? D/GOS:SystemEventReactor: addPkgDataFromServer(), A package was added : com.xx.yy as undefined
...

Note the 'com.xx.yy as undefined'.

2) with internet connection:

...
2020-05-20 13:36:31.944 23382-23415/? D/GOS:NetworkConnector: getPkgData(), packageName : com.xx.yy
2020-05-20 13:36:32.254 23382-23415/? D/GOS:NetworkConnector: doDirectly(), Response, responseCode: 200, URL: https://service.game-mode.net/gamemode/v3/packages/?type=install&device_name=gta3xlwifi&package_names=com.xx.yy, response: {"code":"201001","message":"Success","packages":[{"package_name":"com.xx.yy","category_code":"game","game_genre":"BOARD","device_group":"gta3xl","game_oracle_cache":true,"cache":true}]}
2020-05-20 13:36:32.254 23382-23415/? D/GOS:NetworkConnector: getPkgData(), request: https://service.game-mode.net/gamemode/v3/packages/?type=install&device_name=gta3xlwifi&package_names=com.xx.yy, response: {"code":"201001","message":"Success","packages":[{"package_name":"com.xx.yy","category_code":"game","game_genre":"BOARD","device_group":"gta3xl","game_oracle_cache":true,"cache":true}]}
...
2020-05-20 13:36:32.379 23382-23415/? D/GOS:SystemEventReactor: addPkgDataFromServer(), A package was added : com.xx.yy as game
...

Note the 'com.xx.yy as game'.

So there is a request to https://service.game-mode.net with the package name as a parameter. This led me to the following links:

Display density and size reduced by Samsung Game Optimization

Galaxy Note 5: Density Reduced Automatically

https://www.xda-developers.com/samsung-shuts-down-the-game-tuner-service/

In summary, there is an online registration of apps (package names) which is queried during installation. This may result in a reduced resolution for the app. The only known solution, the Samsung Game Tuner app, no longer exists.

Since the registration is owned by Samsung I asked them if they can change the status of my app. (It is a game AI with high CPU usage but little graphics - still I want high resolution graphics of course.)

J-J
  • 419
  • 2
  • 12
  • Do you invoke these during initialization or after the app fully finished loading? Did you run the device tester? https://www.codenameone.com/blog/device-tester.html – Shai Almog May 13 '20 at 02:19
  • I tried invoking them in different places. In init() and start() I get 900x1386. After showing the splash form and in subsequent forms I get 900x1359. I also tried the Device Tester and this does give the correct resolution of 1200x1848 (=1920-statusbar). So I am very puzzled and don't know how to proceed now. – J-J May 14 '20 at 15:57

2 Answers2

4

What is causing this problem is an online check to https://service.game-mode.net (parameter: package name) during installation on Samsung devices. This may cause a change of the default resolution, e.g. if the app is known as a 'game' (my app is a board game). This can be changed by the user using a game performance tuning service such as Game Launcher. This is available for all Samsung phones and most Samsung tablets. But as it happens not for my tablet, a Samsung Galaxy Tab A 10.1 2019 (SM-T510). After contacting Samsung Developers support they changed the settings for this device type, so that now my app runs in native resolution.

J-J
  • 419
  • 2
  • 12
0

If device tester works I'm guessing that the resolution on load is a fake one for compatibility (which is something a lot of devices do) and then a screen size change event is sent to update on that. You can add a screen size event listener to the form to monitor the size change event or just invoke getDisplayWidth() dynamically when you need it.

Generally it's a best practice to program defensively here and have code that dynamically re-creates the element if display width differs from the last display width used.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • In general I call getDisplayWidth() dynamically and it always gives the same value, provided the screen remains (locked) in the same orientation. I tried form.addSizeChangedListener() on several forms, but this only fires in case of an orientation change and it never leads to a change in resolution, only the reversal of width and height. So how is it possible that my app gets a fake 900x1440 resolution on load (which remains as long as the app runs) and the Device Tester gets the real 1200x1920 resolution? Both are CN1 apps that I built and installed the same way. Any clues? – J-J May 15 '20 at 15:29
  • I found a clue by an online search. It may be the case that my app is registered by Google as a CPU-heavy game and because of that it is run in a lower resolution. CPU-heavy is correct as it is a Draughts AI (same functionality as a Chess AI), but the graphics are not at all heavy. To make a long story short: if I change the package name the app runs in the correct resolution of 1200x1920. This is not a final solution but at least the problem seems not to be CN1-related. – J-J May 15 '20 at 19:34
  • Any suggestions to solve the problem with Google as mentioned in the above comment are welcome! – J-J May 15 '20 at 19:35
  • That's odd, do you have a reference for that? I'm unaware of this. – Shai Almog May 16 '20 at 05:00
  • I found this: https://forum.unity.com/threads/resolution-changes-on-android-device-after-build.821868/. As the proposed temporary solution of changing the package name works it seems credible. – J-J May 16 '20 at 08:28
  • I sent a mail to Google Play developer support. – J-J May 16 '20 at 13:43
  • I doubt you'll get anything from Google. Their support is the absolute worst. It also seems that thread doesn't seem to have a resolution either or any supporting evidence for the theories raised. Did you look at the logs in the console of the device. Try to compare a run with the lower resolution package to a run with a clean package and see where they differ. A hint might be printed to the console that can lead somewhere useful – Shai Almog May 17 '20 at 01:20
  • I don't know how to look at the logs in the console of the device, but I found NativeLogsReader.cn1lib and that definitely gives a clue. Please see the Edit in my question. – J-J May 17 '20 at 13:23
  • That shows there's a problem but doesn't include the cause. See this answer to viewing the logs: https://stackoverflow.com/questions/3707880/using-adb-logcat-with-a-real-phone-and-not-the-emulator – Shai Almog May 18 '20 at 02:37
  • Thanks for the link. I looked at the logs, see Edit 2 in my question.Then I found this link: https://jira.apache.org/jira/browse/CB-12910. Scaling to 0.75 is a known problem, something to do with Quirks Mode? Other clues I thought of: 1) installing the current Google Play version of my app ("owning" the package name) gives a warning "This app was built for an older version of Android and may not work properly." 2) My app seems to be hacked. Searching the package name gave multiple URLs where the APK of my paid app can be downloaded for free (didn't try). What do you make of this? – J-J May 18 '20 at 16:04
  • Quirks mode is a web thing. It shouldn't impact Codename One. Does this only apply to the webview within Codename One or to the actual app? Also what andoid.* build hints do you have? – Shai Almog May 19 '20 at 01:56
  • I don't use anything webview related, it applies to the actual app. I also don't use any android.* build hints except debug/release. Besides, both builds are identical except for one thing: the package name. The logs for both versions are also identical except for some generated id numbers, until the 'scale is 0.75' and 'new=[0,0][900,1440]' messages. For some reason ActivityManager and/or ViewRootImpl decide to downscale only the version with the original package name and not the version with the changed package name. I found no clue why. Nothing from Google support yet (3 days and counting). – J-J May 19 '20 at 13:30
  • Update: see Edit 3 for a new test. It appears that the reduced resolution is set during installation using an online check. This can be prevented by switching off wifi/internet during installation (from downloads). This is not a real solution. It leaves the possibility that apps can be "punished" even after they are published on Google Play, as mentioned in a link mentioned before (https://forum.unity.com/threads/resolution-changes-on-android-device-after-build.821868/). – J-J May 19 '20 at 19:25
  • If I look in the Google Play Console of my app in the release device catalog, it lists 510 Samsung devices but I cannot find an exact match for my Samsung Galaxy Tab A 10.1. Could it be that my device is not supported for my app (=package name) and this is "checked"? – J-J May 19 '20 at 20:10
  • Can you add the output of the device tester app? I want to verify that all the options in the manifest match the device specific values. – Shai Almog May 20 '20 at 02:35
  • See Edit 4 in the question. – J-J May 20 '20 at 08:00
  • See also Edit 5 for more clues. – J-J May 20 '20 at 14:43