private static final String TAG = "LocationManagerService"; public static final boolean D = Log.isLoggable(TAG, Log.DEBUG);
透過adb 開啟
adb shell setprop log.tag.LocationManagerService DEBUG
private static final String TAG = "LocationManagerService"; public static final boolean D = Log.isLoggable(TAG, Log.DEBUG);
private Bitmap openPic(String file) {
if (file == null)
return null;
if (DEB_PIC) Log.d(TAG,"openPic() file = " + file);
File f = new File(file);
if (f.exists()) {
return BitmapFactory.decodeFile(file);
} else {
Log.d(TAG,"openPic() "+ file+" not exists");
return null;
}
}
private void savePic(Bitmap b,String strFileName) {
//Log.e(TAG, "savePic()");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(strFileName);
if (null != fos) {
b.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.flush();
fos.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void getPic() {
Bitmap mScreenBitmap;
Matrix mDisplayMatrix;
mDisplayMatrix = new Matrix();
DisplayMetrics metrics = new DisplayMetrics();
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
if (wm == null) {
Log.d(TAG,"getPic() wm = null");
return;
}
wm.getDefaultDisplay().getRealMetrics(metrics);
float[] dims = {metrics.widthPixels, metrics.heightPixels};
float degrees = getDegreesForRotation(wm.getDefaultDisplay().getRotation());
boolean requiresRotation = (degrees > 0);
if (requiresRotation) {
// Get the dimensions of the device in its native orientation
mDisplayMatrix.reset();
mDisplayMatrix.preRotate(-degrees);
mDisplayMatrix.mapPoints(dims);
dims[0] = Math.abs(dims[0]);
dims[1] = Math.abs(dims[1]);
}
mScreenBitmap = SurfaceControl.screenshot((int) dims[0], (int) dims[1]);
if (mScreenBitmap == null) {
Log.d(TAG,"getPic() mScreenBitmap = null");
return;
}
if (requiresRotation) {
// Rotate the screenshot to the current orientation
Bitmap ss = Bitmap.createBitmap(metrics.widthPixels, metrics.heightPixels, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(ss);
c.translate(ss.getWidth() / 2, ss.getHeight() / 2);
c.rotate(degrees);
c.translate(-dims[0] / 2, -dims[1] / 2);
c.drawBitmap(mScreenBitmap, 0, 0, null);
c.setBitmap(null);
// Recycle the previous bitmap
mScreenBitmap.recycle();
mScreenBitmap = ss;
}
// Optimizations
mScreenBitmap.setHasAlpha(false);
mScreenBitmap.prepareToDraw();
}
private String getTopActivity() {
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
if (am == null) {
Log.d(TAG,"Go() am = null");
return null;
}
// get the info from the currently running task
List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1);
//Log.d("topActivity", "CURRENT Activity ::"
// + taskInfo.get(0).topActivity.getClassName());
ComponentName componentInfo = taskInfo.get(0).topActivity;
//Log.d(TAG, "getPackageName = " + componentInfo.getPackageName());
return componentInfo.getPackageName();
}
private void touch(int x, int y) {
try {
Runtime.getRuntime().exec("input tap "+x+" "+y);
} catch (Throwable t) {
}
}
public class SettingsContentObserver extends ContentObserver {
int previousVolume;
Context context;
public SettingsContentObserver(Context c, Handler handler) {
super(handler);
Log.d(TAG,"SettingsContentObserver()");
context=c;
AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
}
@Override
public boolean deliverSelfNotifications() {
Log.d(TAG,"deliverSelfNotifications()");
return super.deliverSelfNotifications();
}
@Override
public void onChange(boolean selfChange) {
Log.d(TAG,"onChange()");
super.onChange(selfChange);
AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
int currentVolume = audio.getStreamVolume(AudioManager.STREAM_SYSTEM);
Log.d(TAG,"onChange() currentVolume = "+currentVolume);
}
}
}
@Override
public void onCreate() {
super.onCreate();
Log.i(TAG, "onCreate()");
mSettingsContentObserver = new SettingsContentObserver(this,new Handler());
getContentResolver().registerContentObserver(android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver );
}
@Override
public void onDestroy() {
Log.d(TAG,"onDestroy()");
getContentResolver().unregisterContentObserver(mSettingsContentObserver);
}
def getPic():
os.chdir(adb)
os.system("adb shell screencap -p /sdcard/screen.png")
os.system("adb pull /sdcard/screen.png "+pic_dir+"pic.png")
os.system("adb shell rm /sdcard/screen.png")
def touch(x,y):
os.chdir(adb)
os.system("adb shell input tap "+str(x)+" "+str(y))
Brush name
|
Brush aliases
|
File name
|
bash, shell
|
shBrushBash.js
| |
cpp, c
|
shBrushCpp.js
| |
css
|
shBrushCss.js
| |
js, jscript, javascript
|
shBrushJScript.js
| |
java
|
shBrushJava.js
| |
perl, pl
|
shBrushPerl.js
| |
php
|
shBrushPhp.js
| |
py, python
|
shBrushPython.js
| |
xml, xhtml, xslt, html, xhtml
|
shBrushXml.js
|
<pre class="brush: java"></pre">public class Hello {
public static int gvar;
public static void say(String s) {
int x = 10;
System.out.print(s+x);
}
public static void main(String[] argv) {
float y = 0;
say("Hello, world\n");
}
}
<pre class="brush: python"></pre"> print("Hello, world!")