bcoder

adb remount 相关

 分类:Uncategorized 阅读 (2,090)  No Responses »
3月 302018
 

1.adb remount的作用就是重新挂载安卓的系统分区,使系统分区可读写

2.执行该功能其他的方法:

adb shell su #进入安卓命令行

mount -o rw,remount /system #将文件系统remount为读写权限

记得完事后remount回只读: mount -o ro,remount /system

3.另外一种方法

adb shell su #进入安卓命令行

mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system

 Posted by on 2018-03-30
3月 222018
 

慢慢学习了很多Linux命令

感觉还是很方便的

但是参数语法太多

实在是记不住

还是多总结记录比较好

省的再去查man,浪费时间

  • cut
  • grep
  • sort
  • uniq
  • wc
  • tee
  • tr
  • col
  • join
  • paste
  • expand
  • xargs   
  • awk
 Posted by on 2018-03-22
3月 212018
 

查看当前目前总占用空间

du -sh ./

查看当前目录下的所有文件或者子目录的占用空间

du -sh *

将目录下的文件或者子目录按从大到小排序

du -s *|sort -nr

将目录下的文件或者子目录按从大到小排序,并取前5行

du -s *|sort -nr|head -5

 Posted by on 2018-03-21

Android中获取当前时间/毫秒数

 分类:Android, Java 阅读 (4,553)  Android中获取当前时间/毫秒数已关闭评论
3月 192018
 

获取当前时间对应的毫秒数

System.currentTimeMillis()

对于某些定制设备,在开机时机器的时间可能会发生变化,这个数据就会有比较大的跳跃,比如开机时对应的日期是0(1970-1-1),某些系统服务启动后会变成当前实际时间2018-03-01,这个函数返回的值就会有个大的变化

获取开机以来的毫秒数,是开机以来的绝对时间

SystemClock.elapsedRealtime()

获取开机以来非休眠状态的毫秒数

SystemClock.uptimeMillis()

 Posted by on 2018-03-19
3月 062018
 

本文运行环境,数据库:Mysql,操作系统:Linux
在命令行中查询sql语句后,一般情况下每行显示一条记录,一条记录有多个列,假如某一列的数据特别长,这种表格的方式就很难查看数据,如果想让所有的列都分行显示,每行显示一列的数据也很简单,就是在sql查询语句的末尾加一个 \G就可以了.

如下:select * from tbldates\G;

显示效果如下:

 

 Posted by on 2018-03-06
2月 202018
 

 具体请看下面的表格:

♠ frameworks/base/core/java/android/app/ActivityManagerNative.java

§ ActivityManagerNative.getDefault() 很简单,获取gDefault
§ gDefault 一个静态变量,是ActivityManagerService 的代理对象

♠ frameworks/base/services/java/com/android/server/am/ActivityManagerService.java

ActivityRecord.isInStackLocked(token); 查询当前Activity是否还在Activity栈中?
如果还在继续执行Binder.clearCallingIdentity();保存此Activity在Binder中的id,稍候就会使用overridePendingAppTransition执行恢复的操作。
如果当前Activity的状态是活动状态或者将要暂停状态,执行WindowManagerService的overridePendingAppTransition

♠ frameworks/base/services/java/com/android/server/wm/WindowManagerService.java

调用AppTransition的overridePendingAppTransition方法(将动画的设置信息都放在AppTransition中了)
然后WindowManagerService在进行Activity切换的时候就会根据AppTransition的动画设置来显示切换动画了。

 

总结:

1. 执行overridePendingTransition时的调用顺序ActivityManageService->WindowManageService

2. 最终设置的是WindowManagerService的overridePendingAppTransition

3. 和Windows编程中显示模式窗口不同,执行startActivity时并没有立即暂停当前Activity,而是通过Handler在下一个MessageQueue的处理中暂停的当前Activity

 Posted by on 2018-02-20

MonkeyDevice

 分类:Android, Java 阅读 (1,212)  No Responses »
1月 302018
 

  MonkeyDevice用于控制安卓设备或者安卓模拟器,发送UI事件、发送广播、获取设备信息、安装删除应用和运行应用等。

  一般情况下使用MonkeyRunner.waitForConnection()可获取此类的实例,如下:

  下面是MonkeyDevice提供的一些方法列表:

Methods 描述 描述
void broadcastIntent (string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, iterable flags)

Broadcasts an Intent to this device, as if the Intent were coming from an application.

描述
void drag (tuple start, tuple end, float duration, integer steps)

Simulates a drag gesture (touch, hold, and move) on this device’s screen.

描述
object getProperty (string key)

Given the name of a system environment variable, returns its value for this device. The available variable names are listed in the detailed description of this method.

描述
object getSystemProperty (string key)

. The API equivalent of adb shell getprop <key>. This is provided for use by platform developers.

描述
void installPackage (string path)

Installs the Android application or test package contained in packageFile onto this device. If the application or test package is already installed, it is replaced.

描述
dictionary instrument (string className, dictionary args)

Runs the specified component under Android instrumentation, and returns the results in a dictionary whose exact format is dictated by the component being run. The component must already be present on this device.

描述
void press (string name, dictionary type)

Sends the key event specified by type to the key specified by keycode.

描述
void reboot (string into)

Reboots this device into the bootloader specified by bootloadType.

void removePackage (string package)

Deletes the specified package from this device, including its data and cache.

描述
object shell (string cmd)

Executes an adb shell command and returns the result, if any.

描述
void startActivity (string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, flags)

Starts an Activity on this device by sending an Intent constructed from the supplied arguments.

描述
MonkeyImage takeSnapshot()

Captures the entire screen buffer of this device, yielding a MonkeyImage object containing a screen capture of the current display.
描述
void touch (integer x, integer y, integer type)

Sends a touch event specified by type to the screen location specified by x and y.

描述
void type (string message)

Sends the characters contained in message to this device, as if they had been typed on the device’s keyboard. This is equivalent to callingpress() for each keycode in message using the key event type DOWN_AND_UP.

描述
void wake ()

Wakes the screen of this device.

描述
1月 182018
 

  C++出现: 1 duplicate symbol for architecture x86_64可能的问题如下:

  1. 你可能在一个头文件中定义了一个变量或者函数,但是这个头文件被多个cpp文件include了
  2. 你可能把一个静态变量(static)定义了多次
  3. 你可能在一个cpp文件中将一个函数定义了多次

  可以查看详细的错误信息,看看是哪个变量或者函数被重复定义了。

  本人这此遇到此问题是因为把一个静态变量的定义放在头文件里了,应该放到cpp文件里就没问题了。

 

 Posted by on 2018-01-18

gradle打印依赖树

 分类:Android, Java 阅读 (11,889)  No Responses »
1月 132018
 

  本文适用于OSX和Linux系统,Windows系统用户可用来参考

  在Android Studio中进行了三方库的前期测试调研工作,然后要把工程转移到Android系统工程中,使用Android.mk进行编译,所有的三方jar包只能手动添加到工程中了。在使用Android Studio的dependency的时候除了显示添加到其中的三方库,三方库可能还会调用其他的依赖库,那怎么才能知道到底用了哪些库呢,只能使用gradle了。

  在命令行cd到工程所在的根目录,然后使用如下命令打印as工程中的库的依赖关系,其中app为要查看的模块的名称

  如果执行成功的话就会打印一大堆信息,其中一部分内容就是不同的gradle任务的类库依赖关系,类似如下形式:

已经下载的类库存在哪里?

  默认情况下gradle下载的文件在用户目录下的.gradle目录中,可以通过如下命令进行该目录

  然后通过find命令查找你想要的库就可以了,比如要查gson的jar包,可以用如下命令:

 

 Posted by on 2018-01-13