{"id":7148,"date":"2024-04-13T10:01:01","date_gmt":"2024-04-13T02:01:01","guid":{"rendered":""},"modified":"2024-04-13T10:01:01","modified_gmt":"2024-04-13T02:01:01","slug":"Android\u4e0a\u5c42\u8bfb\u5199\u6587\u4ef6\u8282\u70b9,Android\u4e0a\u5c42\u600e\u4e48\u8bfb\u5199proc\u8282\u70b9\uff08\u793a\u4f8b\uff09","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7148.html","title":{"rendered":"Android\u4e0a\u5c42\u8bfb\u5199\u6587\u4ef6\u8282\u70b9,Android\u4e0a\u5c42\u600e\u4e48\u8bfb\u5199proc\u8282\u70b9\uff08\u793a\u4f8b\uff09"},"content":{"rendered":"
\n

Android\u4e0a\u5c42\u600e\u6837\u8bfb\u5199proc\u8282\u70b9(\u793a\u4f8b)<\/p>\n

import android.app.Activity;<\/p>\n

import android.os.Bundle;<\/p>\n

import android.widget.CompoundButton;<\/p>\n

import android.widget.CompoundButton.OnCheckedChangeListener;<\/p>\n

import android.widget.ToggleButton;<\/p>\n

import android.os.SystemProperties;<\/p>\n

import android.util.Log;<\/p>\n

import android.widget.Toast; \/\/wang<\/p>\n

import java.util.Timer;<\/p>\n

import java.util.TimerTask;<\/p>\n

import android.os.PowerManager;<\/p>\n

import java.io.*;<\/p>\n

import android.os.Looper;<\/p>\n

public class DebugOptionActivity extends Activity<\/p>\n

{
\n <\/p>\n

private static final String TAG = \"tpDebug\";<\/p>\n

private int checkValue = 0;<\/p>\n

@Override<\/p>\n

public void onCreate(Bundle savedInstanceState)<\/p>\n

{
\n <\/p>\n

super.onCreate(savedInstanceState);<\/p>\n

setContentView(R.layout.debug);<\/p>\n

ToggleButton toggle = (ToggleButton)findViewById(R.id.toggle);<\/p>\n

try{
\n <\/p>\n

File readFile = new File(\"proc\/tp_debug\/debug_switch\");<\/p>\n

FileReader inCmd = new FileReader(readFile);<\/p>\n

try{
\n <\/p>\n

checkValue = inCmd.read();<\/p>\n

if(checkValue != 0)<\/p>\n

{
\n <\/p>\n

toggle.setChecked(true);<\/p>\n

}<\/p>\n

else<\/p>\n

{
\n <\/p>\n

toggle.setChecked(false);<\/p>\n

}<\/p>\n

}catch (IOException e){
\n <\/p>\n

e.printStackTrace();<\/p>\n

}<\/p>\n

} catch (FileNotFoundException e){
\n <\/p>\n

e.printStackTrace();<\/p>\n

}<\/p>\n

\/\/ToggleButton toggle = (ToggleButton)findViewById(R.id.toggle);<\/p>\n

toggle.setOnCheckedChangeListener(new OnCheckedChangeListener()<\/p>\n

{
\n <\/p>\n

public void onCheckedChanged(CompoundButton arg0, boolean arg1)<\/p>\n

{
\n <\/p>\n

if (arg1)<\/p>\n

{
\n <\/p>\n

\/\/open<\/p>\n

File awakeTimeFile = new File(\"proc\/tp_debug\/debug_switch\");<\/p>\n

FileWriter fr;<\/p>\n

try {
\n <\/p>\n

fr = new FileWriter(awakeTimeFile);<\/p>\n

fr.write(\"1\");<\/p>\n

fr.close();<\/p>\n

}<\/p>\n

catch (IOException e) {
\n <\/p>\n

e.printStackTrace();<\/p>\n

}<\/p>\n

}<\/p>\n

else<\/p>\n

{
\n <\/p>\n

\/\/close<\/p>\n

File awakeTimeFile = new File(\"proc\/tp_debug\/debug_switch\");<\/p>\n

FileWriter fr;<\/p>\n

try<\/p>\n

{
\n <\/p>\n

fr = new FileWriter(awakeTimeFile);<\/p>\n

fr.write(\"0\");<\/p>\n

fr.close();<\/p>\n

} catch (IOException e) {
\n <\/p>\n

e.printStackTrace();<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

});<\/p>\n

}<\/p>\n

}<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Android\u4e0a\u5c42\u8bfb\u5199\u6587\u4ef6\u8282\u70b9,Android\u4e0a\u5c42\u600e\u4e48\u8bfb\u5199proc\u8282\u70b9\uff08\u793a\u4f8b\uff09Android\u4e0a\u5c42\u600e\u6837\u8bfb\u5199proc\u8282\u70b9(\u793a\u4f8b)importandroid.app.Activit...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7148"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7148"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7148\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}