我正在开发一个需要3件事的Android应用程序: -
你必须知道: - 我的手机是Moto E(已植根),希望第二步完成。尝试了一些代码,但这对moto E不起作用。 当连接USB时,它提供2作为响应,当与墙壁插座充电器连接时,它表示1
任何帮助都会得到赞赏
P.S: - 使用连接笔记本电脑的USB线连接自动启动但不使用插座充电器
更新-1 :1-发现fastboot oem off-mode-charge 0
与Nexus 7合作但未在Moto e上合作。
2-连接到路由器(USB加密狗端口)时的Moto e启动
答案 0 :(得分:9)
最后我得到了解决方案,您可以通过删除system/bin/charge_only_mode
文件来实现此目的。请自行承担风险,并在删除之前备份该文件。当它连接到墙壁充电器并且现在它正常工作时,我得到了所需的结果。
一切顺利!
答案 1 :(得分:2)
Moto e4和Pixel 2 XL:
让您的设备进入bootloader(fastboot)并从使用Android Tools通过USB连接的计算机上运行以下命令:
fastboot oem off-mode-charge 0
答案 2 :(得分:1)
我还尝试用sh脚本替换charge_only_mode,重新启动手机,但只有一个带有M的红圈(在Motorola Bionic上)。将剧本更改为下面的工作......现在我得到红色的圆圈,用M表示几秒钟,然后是一个空白的屏幕,另一个带有M的红色圆圈,然后它就会启动。
#!/system/bin/sh
su -c "/system/bin/reboot -n outofcharge"
答案 3 :(得分:1)
在我的设备Lenovo K7000-Plus上,需要修改的文件位于kpoc_charger
/system/bin
。
Ipod文件无法在我的手机上使用Android 6.0 ROM,但kpoc_charger完美无缺。
此致
哈迪
答案 4 :(得分:1)
对于联想A2010手机,以下工作:
现在使用total-commander编辑原始文件kpoc_charger,用以下代码替换所有行:
#!/system/bin/sh
/system/bin/reboot
答案 5 :(得分:0)
当手机从插座充电时,我想要手机通电 自动无需按任何电源按钮。 (不与墙合作 插座,但通过笔记本电脑连接USB电缆时工作。
您只能通过修改手机的操作系统文件来实现此目的。基本上在/system/bin/chargemon
处有启动脚本/二进制文件,您可以用不执行任何操作的脚本替换它。 请自行承担风险,因为这可能会导致设备永久损坏。此外,制造商保修将失效。
答案 6 :(得分:0)
我找到了另一种方式(感谢DavidThompson256 http://forum.xda-developers.com/showthread.php?t=1187631)
首先确保您的手机已植根(我发现iRoot非常好),然后在手机上安装RootExplorer.apk(或类似手机)。
尝试编辑“/ system / bin / playlpm”并使用以下命令替换其内容:(不要忘记先备份)。
#!/system/bin/sh
/system/bin/reboot
(我知道内容是二进制的,只需删除它们并写下这两行并保存文件)
注意:修改该文件时,不会对其权限应用任何更改,但如果您要创建另一个文件,请记住完全按照原样设置权限。
最后,请自行承担风险。它对我有用。 (Samsung Discovery S730M)
答案 7 :(得分:0)
我能够通过更新init.rc
文件来使其工作
我找到了on charger
触发器,并在其下面添加了以下几行:
setprop ro.bootmode "normal"
setprop sys.powerctl "reboot"
整个触发器块看起来像这样
on charger
class_start charger
setprop ro.bootmode "normal"
setprop sys.powerctl "reboot"
然后您需要重新包装并刷新更新后创建的启动映像。
通过USB连接设备
打开设备电源并进入引导加载程序模式
adb reboot bootloader
要在快速启动中执行Flash引导映像,请执行以下命令
fastboot flash boot new-boot.img
注意:即使使用电源按钮或软件关闭功能关闭设备,此修复程序也会导致设备插入电源后重新启动。
来源:https://forum.xda-developers.com/showthread.php?p=77766638#post77766638
您可以在此处查看包含针对我的项目的这些更改的提交:
答案 8 :(得分:-1)
我认为应该有功率传感器,如果你可以在这段代码中添加它,相信它会起作用
public class Main extends Activity {
private SensorManager mSensorManager;
private PowerManager mPowerManager;
private WindowManager mWindowManager;
private WakeLock mWakeLock;
private Button button;
private TextView textView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
// Get an instance of the SensorManager
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
// Get an instance of the PowerManager
mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
// Get an instance of the WindowManager
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mWindowManager.getDefaultDisplay();
// Create a bright wake lock
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
.getName());
setContentView(R.layout.main);
textView = (TextView)findViewById(R.id.textView1);
button = (Button)findViewById(R.id.button1);
button.setOnClickListener(mButtonStopListener);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("onCreate", e.getMessage());
}
} // END onCreate
View.OnClickListener mButtonStopListener = new OnClickListener() {
public void onClick(View v) {
try {
mWakeLock.release();
textView.setText("mWakeLock.release()");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("onPause",e.getMessage());
}
}
};
@Override
protected void onResume() {
super.onResume();
/*
* when the activity is resumed, we acquire a wake-lock so that the
* screen stays on, since the user will likely not be fiddling with the
* screen or buttons.
*/
try {
mWakeLock.acquire();
textView.setText("mWakeLock.acquire()");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("onResume", e.getMessage());
}
}
@Override
protected void onPause() {
super.onPause();
// and release our wake-lock
try {
mWakeLock.release();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("onPause",e.getMessage());
}
}
}
答案 9 :(得分:-1)
所以我试图用第三代Moto G实现这个目标。根据Rohit的答案,它有一个charge_only_mode文件,但只是移动/重命名它并没有让手机重新启动。相反,它只是坐在那里有一个摩托罗拉标志。将charge_only_mode替换为此处引用的任一脚本时,我得到了相同的结果。
然而,我确实让它上班了。我将/ system / bin / reboot复制到/ system / bin / charge_only_mode,这就行了。