我遇到以下问题。如何在有根系统上写入* .kl文件并复制到系统上
我需要锁定我的平板电脑的特定应用程序。我在KioskMode中使用我的应用程序,但是我需要阻止一些按钮,“Switch_app”,“Volume_UP”,“Volume_DOWN”等。
我能够通过访问ES文件资源管理器来阻止这些按钮,手动文件保存并重新启动平板电脑。
但是,我想以编程方式更改此文件。
我已经试过如下:
{
using (StreamReader sr = new StreamReader("/system/usr/keylayout/Generic.kl"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("VOLUME"))
{
line = $"# {line}";
}
text += line + "\n";
System.Console.WriteLine(text);
}
}
CreateFile();
TransferFile();
};
void CreateFile()
{
string sdCard = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
string path = Path.Combine(sdCard, "MyFolder/Generic.kl");
// This text is added only once to the file.
if (!System.IO.File.Exists(path))
{
// Create a file to write to.
System.IO.File.WriteAllText(path, text);
}
}
而且所创建的文件传输到/系统的/ usr/Keylayout我用这个:
Java.Lang.Runtime.GetRuntime().Exec("su -c mount -o rw,remount,rw /system");
Java.Lang.Runtime.GetRuntime().Exec("su -c rm system/usr/keylayout/Generic.kl");
Java.Lang.Runtime.GetRuntime().Exec("su -c mv /storage/emulated/0/MyFolder/Generic.kl system/usr/keylayout/Generic.kl");
当我使用这些命令,文件被复制,但是当我重新启动平板电脑时,不再有物理按钮可以工作。所以我相信这是与删除旧文件并添加新文件有关的一些问题。
任何帮助将是非常欢迎以及想法。
谢谢大家。
谢谢亚历克斯P. 你帮了我很多,因为我面临的权限问题,现在我没有他们了。 你能给我一个问题吗?如果我需要禁用,我怎么写反向? –
删除VOLUME_DOWN - VOLUME_UP处的注释 –