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.
Related
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
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.
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
I have a large number of activities each calling some of the other and I am getting really confused as to which activity is calling which other activity . Show call hierarchy in eclipse does not show me this. Is there any way I get to see from where a current activity is being called.
You can check what the current Activity Stack looks like using ADB.
In Linux, you can use:
adb shell dumpsys activity | grep -i run
This will give you a nicely formatted hierarchy of currently running Activities.
EDIT: I'm assuning you have ADB in your PATH. If not then you'll have to specify the full path to adb (which is located in the android sdk folder).
I'm not sure of a completely work-free method, but you could do intent.putExtra("source", TAG) in all the places where you do createActivity() and then Log.d(TAG, "Intent started from: " + getIntent().getStringExtra("source", "unknown")) in all your onCreate()s.
Or, on a Windows machine:
C:\Program Files (x86)\Android\android-sdk\platform-tools\adb shell dumpsys activity | find /i "run"
Modify the path to adb.exe, if needed
How do I hide the system bar in android 3.0(honeycomb)?
The systembar cannot be removed (on non-rooted devices). You can go into "lights out mode" which dims it and only shows dots where the buttons are using the following code (ref):
View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
This was also asked before here, remember to search first.
We tinkered around with Honeycomb and found a way to hide and restore the bar, although root is required here. You can find a detailed answer in our article here.
I tested some ways to kill system bar:
Kill by adb shell: - su; ps, look for com.android.systemui; kill - success, sys-bar removed.
Settings, "Sytem UI" force stop - success, sys-bar removed.
Root explorer, delete /system/app/systemui.apk - got circle of error messages "com.android.systemui crashed, blabla...". Reboot, tablet started without system bar, no any errors, so success.
My app:
Code:
android.os.Process.killProcess(android.os.Process.getUidForName("com.android.systemui"));
failed, as expected, because my app can not kill process started by another app.
My app:
permission - android.permission.KILL_BACKGROUND_PROCESSES
Code:
final Context context = getApplicationContext();
servMng = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
servMng.killBackgroundProcesses("com.android.systemui");
Failed, no idea why.
Run script in my app to execute "ps", look for PID and execute "kill", not tested.
Hiding the systembar in honeycomb can be done with Hide Bar. The home page is at http://ppareit.github.com/HideBar/. The code can be found at https://github.com/ppareit/HideBar.