AOSP Automotive on Pixel 3 XL, change the default screen orientation - android

I've just built and flashed AOSP Automotive on Google Pixel 3 XL using this manual: https://source.android.com/devices/automotive/start/pixelxl
It works fine, but starts in portrait mode by default. For my custom Launcher I need to have it in landscape though.
I tried to change the following settings in core/res/res/values/config.xml
- <bool name="config_allowAllRotations">false</bool>
+ <bool name="config_allowAllRotations">true</bool>
- <integer name="config_carDockRotation">-1</integer>
+ <integer name="config_carDockRotation">2</integer>
But it did not take any effect after re-flashing system.img
I also tried to apply the following properties in init.rc without any effect
# screen rotation attempt
setprop ro.sf.hwrotation 0
setprop config.override_forced_orient flase
I am on Android 10, build QQ3A.200705.002.
Any hint would be highly appreciated.. Thanks!

The fix got merged into AOSP master. There's no need to patch sources anymore, just sync your repository. Then, set def_user_rotation at frameworks/base/packages/SettingsProvider/res/values/defaults.xml as mentioned below and it should work.
Previous answer
There is a pair of config settings for default orientation in frameworks/base/packages/SettingsProvider/res/values/defaults.xml:
def_accelerometer_rotation - determines default value of accelerometer_rotation from the other thread (it's set to false by default, so you should be fine)
def_user_rotation - should determine default value of user_rotation (so you can set it to value 1-4)
The problem is... the latter doesn't seem to be supported! The good part is AOSP is open source and you can fix it (precisely, fix DatabaseHelper.java). Here is a patch I prepared for you (to apply against frameworks/base):
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
## -846,8 +846,8 ## class DatabaseHelper extends SQLiteOpenHelper {
try {
stmt = db.compileStatement("INSERT INTO system(name,value)"
+ " VALUES(?,?);");
- loadBooleanSetting(stmt, Settings.System.USER_ROTATION,
- R.integer.def_user_rotation); // should be zero degrees
+ loadIntegerSetting(stmt, Settings.System.USER_ROTATION,
+ R.integer.def_user_rotation);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
## -2265,6 +2265,8 ## class DatabaseHelper extends SQLiteOpenHelper {
loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
R.bool.def_accelerometer_rotation);
+ loadIntegerSetting(stmt, Settings.System.USER_ROTATION, R.integer.def_user_rotation);
+
loadDefaultHapticSettings(stmt);
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
After building and flashing patched system image (with the patch above and defaults.xml changes), you can verify if the settings got correctly initialized:
adb shell settings get system user_rotation (should not be null)
adb shell settings get system accelerometer_rotation (should be 0)
Please let me know if it helped with your device - it did with mine. You may also need to set config.override_forced_orient to true, but it wasn't necessary with my Pixel 3a.

Related

Android Debug Bridge force RTL option to apply without root

I have learned that using the ADB one can force the layout guides to show using the following commands:
adb shell setprop debug.layout true
adb shell service call activity 1599295570 # SYSPROPS_TRANSACTION
This allows developers to see the layout grid thanks to the SYSPROPS_TRANSACTION code.
The examples of which can be found here
However if I want to change something like RTL (right to left) - the SYSPROPS_TRANSACTION call does not force the re-render, I suspect because it needs to restart the activity, given that a rotation of the device will work:
adb shell setprop debug.force_rtl true
adb shell settings put system user_rotation 3 # landscape
adb shell settings put system user_rotation 0 # portrait
While I don't mind invalidating the activity I don't think I should have to be this "manual" about it. Is there a mechanism to refresh the screen without doing the rotation?
I have looked in the AOSP and found this:
private void writeToForceRtlLayoutSetting(boolean isEnabled) {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
DisplayProperties.debug_force_rtl(isEnabled);
}
which is roughly the equivalent of:
adb shell settings put global debug.force_rtl 1.0 #or 0.0 for off
But I have noticed if I do this one and a rotation it does NOT change
I have been trying to find the appropriate broadcast intent so that it would work, but I can't find one that just tells the screen to re-render
adb shell am broadcast <SOMETHING HERE WOULD BE NICE>
I took a page out of the DarkModePreference and tried to tell it that the battery charge state had changed, but you can't do that from ADB:
adb shell am broadcast android.os.action.POWER_SAVE_MODE_CHANGED
But no luck there either - no refresh happening
NOTE:
It's interesting that the layout bounds and RTL elements are grouped in the android source code, yet don't use the same behaviour when changed
I noticed that if I use
adb shell wm size
I can read the size of the window, and as a bonus, when setting it, it causes a redraw regarding right to left. So now what I do is read the window size, save it, change it a little, set it to the changed value and set it back. My script looks something like:
run("adb shell settings put global debug.force_rtl 1.0")
old_size = run("adb shell wm size")
run("adb shell wm size 100x100")
run("adb shell wm size " + old_size)
And it will force the right to left. It's a bit hacky but it works.

Set no-touch option to Chrome OS emulator

Good morning. I need to test my application in Chrome OS, but without the "touch screen"
I used this guide to run a emulation of Chrome OS:
https://www.groovypost.com/howto/chrome-os-android-studio/
Ok, I succeeded to run it, I activated the debugging mode and I activated the adb debugging....finally everything is working and I can run my application on it.
The problem is, I want to test it without touchscreen.
I found the hw.screen property inside
~/.android/avd/<machine-name>.avd/hardware-qemu.ini
that was set to hw.screen = multi-touch.
WOW, exactly what I want, let's change it to no-touch.
Inside ~/Android/Sdk/emulator/lib/hardware-properties.ini you can see
# Touch screen type
name = hw.screen
type = string
enum = touch, multi-touch, no-touch
default = multi-touch
abstract = Touch screen type
description = Defines type of the screen.
so, no-touch is a valid option.
The problem is, even if I change it, every time I restart the emulator, it is set back to multi-touch.
I also tried to change the option directly in ~/Android/Sdk/emulator/lib/hardware-properties.ini, that should contain the default option, but no luck...
Someone can tell me who is overwriting this property each time I start the emulation?
How can I remove the touch screen in the emulation?
Launch the emulator from the command line and use the flag -screen no-touch. This is because the emulator overrides the config in the .ini file. That gives no touch screen but the mouse wasn't usable, at least on Windows.
See the docs for more details

Android avd emulator - how to save "Do you want to save the current state for the next quick boot?" in config.ini file

When creating an avd, starting it for the first time and then trying to close the emulator, the user will be prompted with a dialog reading:
Do you want to save the current state for the next quick boot?
Note: Saving the snapshot may take longer because free RAM is low.
I would like to save this parameter, before starting the emulated device, within its config.ini file.
However I'm not clear on which option it is.
Things I tried:
Adding these lines to the config.ini
fastboot.chosenSnapshotFile=
fastboot.forceChosenSnapshotBoot=no
fastboot.forceColdBoot=no
fastboot.forceFastBoot=yes
Creating an additional file within the config.ini directory of the avd called quickbootChoice.ini that simply reads:
saveOnExit = true
Non of which helped, on every first shutdown of the emulated device this dialog pops up...
Thanks in advance
According to https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android/android-emu/android/skin/qt/tool-window.cpp the popup does not appear if the method returns based on this:
if (saveOnExitChoice == SaveSnapshotOnExit::Always &&
(fc::isEnabled(fc::QuickbootFileBacked) ||
(!savesWereSlow && !hasLowRam))) {
return true;
}
Setting QuickbootFileBacked = on in .android/advancedFeatures.ini fixed it for me. See https://androidstudio.googleblog.com/2018/08/android-emulator-28.html.
You can configure this setting in Android Studio, see this answer for instructions: Android emulator - Don't save state by default
If you are starting the emulator from the command line. Then provide the -no-snapshot-save parameter, to prevent it from saving.
emulator #Nexus_5X_API_23 -no-snapshot-save
reference: https://developer.android.com/studio/run/emulator-commandline

JavaFxPorts TextField Issue - Android Keyboard wont function

I developed a simple javafx application to be ported in Android Environment, however I cant type any characters in the TextField. I guess its a bug, how to fix this one?
Th problem on galaxy S5 android 5.0.1 is not present but on galaxy tab 4 android 5.0.2 it doesn't work i type but none is displyed.
Tried with normal textfield. And the problem persist also I have added the properties .
Another strange rhig is that the space where recognizer. And the del button . The text not
THe code by example is very easy
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
TextField tt= new TextField();
tt.setTranslateY(-150);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(tt);
borderpane.setCenter(stackPane);
Scene scene = new Scene(borderpane, width, height);
stage.setScene(scene);
Assuming that CustomTextField is just a custom TextField, this is a known issue, not related to the CustomTextField itself, given that it works in other device.
If you debug it:
./adb logcat -v threadtime
you surely find an exception that explains the issue: a StackOverFlow exception.
On older devices it can be solved adding this: create a java.custom.properties file, and include in it this property:
monocle.stackSize=128000
You may also include this one:
monocle.platform=Android
(it will be soon included by default in the next version)
Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.
Build and deploy the project on your mobile and check again.

Android logcat message: SurfaceTextureClient

My app is generating this logcat message almost every second:
SurfaceTextureClient [STC::queueBuffer] (this:0x5e774a58) fps:2.00, dur:1496.57, max:499.96, min:498.21
and it's just a hello world with a custom logo in the actionbar and saves things in SharedPreferences. My activity layout is a LinearLayout with two edittexts and one button. No strange things.
This is the only style I use:
<style name="MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar"></style>
I've searched in google but I have found nothing.
When I touch the button this appears:
Provider/Settings invalidate [system]: current 1 != cached 0
Provider/Settings from db cache, name = sound_effects_enabled , value = 0
It's annoying.
EDIT
Maybe is my smarphone. I've installed the same app in a tablet and the messages don't appear. Maybe I have touch something in settings? It's very strange. (My phone is a Jiayu 3gs with Android 4.2.1, but until today nothing wrong had happened).
Ok, the message appears in the general log so it's not associated with my app.
I'm starting to think that I have a virus. I have a lot of messages of this kind without doing anything in the phone:
ADB_SERVICES create_local_service_socket() name=shell:ls -l /
ADB_SERVICES adb: unable to open /proc/14420/oom_adj
ADB_SERVICES adb fdevent_process list (31) (20) (77)
ADB_SERVICES closing because is_eof=1 r=1 s->fde.force_eof=0
SurfaceFlinger [SurfaceFlinger] fps:2.002652,dur:1498.01,max:499.41,min:499.22
UsbDeviceManager onReceive - BATTERY_CHANGED - mPlugType: 2, mSettingUsbCharging: false, mConnected: true, mSettingUsbBicr: false
And I have a lot of files in my / with date creation of 1970-01-01 01:00. Files like init, init.modem.rc, init.rc, init.usb.rc, ..., emmc#android, ..
Maybe I'm just paranoid.
Furthermore I can't access to all options in "Developer options settings". This is all I can see:
Different phones have different kind and amount of log messages. Not much you can do about it, besides filtering the output based on the tag you use.

Categories

Resources