我开发了一个应用程序并将其转换为系统应用程序。在这个应用程序中,我想要更改三个全局变量:window
,Window
和ANIMATOR_DURATION_SCALE
。但是在我通过我的应用程序修改valuein后,我必须再次输入设置(这是谷歌开发的系统应用程序)应用程序以使修改工作,否则修改将无效。
这是我的代码:
WINDOW_ANIMATION_SCALE
检查Switch时,我修改了MainActivity中的值
TRANSITION_ANIMATION_SCALE
并且日志显示代码已成功修改该值。
答案 0 :(得分:0)
使用此"设置app magic" (original taken from AOSP source)立即查看更改:
SystemPropPoker().execute()
同时添加此课程
class SystemPropPoker extends AsyncTask<Void, Void, Void> {
private static final String TAG = SystemPropPoker.class.getName();
@SuppressWarnings("unchecked")
@Override
protected Void doInBackground(@NonNull Void... params) {
String[] services;
try {
Class serviceManagerClass = Class.forName("android.os.ServiceManager");
Method listServicesMethod = serviceManagerClass.getMethod("listServices");
services = (String[]) listServicesMethod.invoke(null);
for (String service : services) {
Method checkServiceMethod = serviceManagerClass.getMethod("checkService", String.class);
IBinder obj = (IBinder) checkServiceMethod.invoke(null, service);
if (obj != null) {
Parcel data = Parcel.obtain();
final int SYSPROPS_TRANSACTION = ('_'<<24)|('S'<<16)|('P'<<8)|'R'; //copy from source code in android.os.IBinder.java
try {
obj.transact(SYSPROPS_TRANSACTION, data, null, 0);
} catch (Exception e) {
Log.i(TAG, "Someone wrote a bad service '" + service
+ "' that doesn't like to be poked: " + e);
}
data.recycle();
}
}
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
参考:How to easily "Show Layout bounds" for Android debugging?