huangcm
2025-04-09 02d4ce54b909bd733f12e9f3fa4c1b03cf2d6f45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package com.DeviceTest;
 
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
 
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.Permission;
import java.util.ArrayList;
import java.util.Arrays;
 
import com.DeviceTest.helper.ControlButtonUtil;
import com.DeviceTest.helper.SystemUtil;
import com.rockchip.newton.UserModeManager;
 
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PermissionInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
 
public class LedTestActivity extends Activity implements OnClickListener {
   NotificationManager notificationManager;
   private static final int NOTIFY_ID = 1000;
//
//    private static final String POWER_LED_PATH = "/sys/class/leds/power_led/";
//    private static final String POWER_LED_BRIGHT = POWER_LED_PATH
//            + "brightness";
//    // private static final String POWER_LED_FREQ = POWER_LED_PATH + "freq";
//    private static final String POWER_LED_PERIOD = POWER_LED_PATH + "period";
 
 
   
   protected void onCreate(Bundle savedInstanceState) {
 
       super.onCreate(savedInstanceState);
       setTitle(getTitle() + "----("
               + getIntent().getStringExtra(DeviceTest.EXTRA_TEST_PROGRESS) + ")");
       // requestWindowFeature(Window.FEATURE_NO_TITLE);
       getWindow().addFlags(FLAG_FULLSCREEN | FLAG_KEEP_SCREEN_ON);
       getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_FULLSCREEN);
       setContentView(R.layout.ledtest);
 
       notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 
       Button redButton = (Button) findViewById(R.id.red_btn);
       Button yellowButton = (Button) findViewById(R.id.green_btn);
       Button blueButton = (Button) findViewById(R.id.blue_btn);
//        final Button powerButton = (Button) findViewById(R.id.power_btn);
//
//        powerButton.setText("PowerLed");
//        powerButton.setOnClickListener(new OnClickListener() {
//
//            
//            public void onClick(View v) {
//                String cmd = "echo 255 > " + POWER_LED_BRIGHT + "\necho 255 > "
//                        + POWER_LED_PERIOD;
//                SystemUtil.execScriptCmd(cmd,
//                        DeviceTest.TEMP_FILE_PATH, true);
//                powerButton.setEnabled(false);
//            }
//        });
 
       redButton.setOnClickListener(this);
       yellowButton.setOnClickListener(this);
       blueButton.setOnClickListener(this);
 
       ControlButtonUtil.initControlButtonView(this);
 
       Notification notification;
 
       notification = new Notification();
       notification.flags |= Notification.FLAG_SHOW_LIGHTS;
       notification.ledARGB = Color.RED;
       notification.ledOffMS = 0;
       notification.ledOnMS = 1;
       redButton.setTag(notification);
 
       notification = new Notification();
       notification.flags |= Notification.FLAG_SHOW_LIGHTS;
       notification.ledARGB = Color.GREEN;
       notification.ledOffMS = 0;
       notification.ledOnMS = 1;
       yellowButton.setTag(notification);
 
       notification = new Notification();
       notification.flags |= Notification.FLAG_SHOW_LIGHTS;
       notification.ledARGB = Color.BLUE;
       notification.ledOffMS = 0;
       notification.ledOnMS = 1;
       blueButton.setTag(notification);
 
   }
 
   
   protected void onStop() {
       super.onStop();
       notificationManager.cancel(NOTIFY_ID);
//        SystemUtil.execScriptCmd("echo 0 > " + POWER_LED_PERIOD,
//                DeviceTest.TEMP_FILE_PATH, true);
   }
 
   
   protected void onResume() {
       super.onResume();
   }
 
   
   public void onPause() {
       super.onPause();
   }
 
   
   public void onClick(View v) {
       notificationManager.notify(NOTIFY_ID, (Notification) v.getTag());
   }
 
   public boolean dispatchKeyEvent(KeyEvent event) {
       if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
           return false;
       }
       return super.dispatchKeyEvent(event);
   }
 
}