ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2013年7月23日 星期二

server 的 gitweb 又活了

上次server 換硬碟後 gitweb 就掛了,大概是 copy 的動作不完全,所以 gitweb error log 一堆 png 找不到。
最近因為修復 git difftool ( http://mygitcommand.blogspot.tw/2013/07/git-difftool-readonly.html ) 所以移除過 git,
連帶 gitweb, git-daemon 也一併被除,
所以只好重裝。

結果就好了,這次重新設定 gitweb 的repo 到 git-daemon root,不限定某個 project

2013年7月11日 星期四

2013年7月10日 星期三

OMXPlayer, MediaSanner, MediaPlayer, VideoView...

OMXPlayer is an Interface Only:
-- framework/base/include/media/OMXPlayer.h
class OMXPlayer : public MediaPlayerInterface
{
public:
                        OMXPlayer(int nMediaType = 0);
    virtual             ~OMXPlayer();

    virtual status_t    initCheck();
    virtual status_t    setDataSource(const char *url, const KeyedVector *headers);
    virtual status_t    setDataSource(int fd, int64_t offset, int64_t length);
    virtual status_t    setVideoSurface(const sp& surface);
    virtual status_t    setVideoSurface(const android::sp& surface);
    virtual status_t    setVideoSurfaceTexture(const android::sp& surfaceTexture);
    virtual status_t    prepare();
    virtual status_t    prepareAsync();
    virtual status_t    start();
    virtual status_t    stop();
    virtual status_t    pause();
    virtual bool        isPlaying();
....

實做的大概是: frameworks/base/media/libmediaplayerservice/MediaPlayerService.cpp

..
實際上,這也是個空殼而已,真的 player 是在 prebuild .so 。在 device 下的 propriety/libs 下有一些 _omx_player_..


用較簡單的 Gallery 來看,啟動到最後,是 MovieView.java
這是一個 Activity,onCreate 後就直接播放影片了。

MovieView 只有實做三個 callback:
  • onCreate : new MovieViewControl
  • onPause : call MovieViewControl.onPause
  • onResume : call MovieViewControl.onResume
  • onWindowFocusChanged : call MovieViewControl.onResume/li>

Video 播放直接關聯到 VideoView 這個 layout,
在 res/layout/movie_view.xml 中放入一個 object:
    <VideoView android:id="@+id/surface_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerInParent="true" />

然後在 source:
    private final VideoView mVideoView;
     .....
       mVideoView = (VideoView) rootView.findViewById(R.id.surface_view);
 
取得 VideoView 元件後,就可以對 VideoView 操作:
如果有時作幾個 需要的interface,就可以接著設定:
        mVideoView.setOnErrorListener(this);
        mVideoView.setOnCompletionListener(this);

設定要撥的file (uri),和 control.
        mVideoView.setVideoURI(mUri);
        mMediaController = new MediaController(context);
        mVideoView.setMediaController(mMediaController);
然後,就可以開始播放:
        mVideoView.start();


另外一個是在 development/samples/ApiDemos/src/com/example/android/apis/media/MeduaPlayerDemo_Video.java

還有有關 scanfile 的 sample code,在 development/samples 下也有...
development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java

這一段code:
        File path = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES);
        File file = new File(path, "DemoPicture.jpg");

        ....
        ....
            // Tell the media scanner about the new file so that it is
            // immediately available to the user.
            MediaScannerConnection.scanFile(this,
                    new String[] { file.toString() }, null,
                    new MediaScannerConnection.OnScanCompletedListener() {
                public void onScanCompleted(String path, Uri uri) {
                    Log.i("ExternalStorage", "Scanned " + path + ":");
                    Log.i("ExternalStorage", "-> uri=" + uri);
                }
            });


所以可以把 file path 丟到這裡scan 轉成 media Uri
?


最後拿 developement/sample 的 MediaPlayerDemo_Video.java 來測試。
原來是用 file path,改成用 scan 後的 Uri。

diff 是:

Gallery3D 決定 storage 在不在的 code..

因為已經 trace 過三次,每次還是忘記,所以記一下好了...

src/com/cooliris/media/ImageManager.java:
    public static boolean hasStorage(boolean requireWriteAccess) {
        String state = Environment.getExternalStorageState();
        if (Environment.MEDIA_MOUNTED.equals(state)) {
            if (requireWriteAccess) {
                boolean writable = checkFsWritable();
  ....

所以去找 Environmemt.getExternalStorageState()..
core/java/android/os/Environment.java
    public static String getExternalStorageState() {
        return getMediaState(EXTERNAL_STORAGE_DIRECTORY_EXTSD.getPath());
    }

所以改這個 EXTSD, SD 就可以決定是用哪一個 SD slot 作判斷依據 (或是用 usb..)


但是如果要 MediaScanner Scan 的話,要改:

2013年7月9日 星期二

不用 build sdk,讓 app 使用擴充 framework api 的方法 -- eclipse 中加入 libs

要是修改了 android framework,而 app 要使用這些 新的 api。
eclipse 一定會 complain 說 找不到這些 api。

正確的方法大概是build sdk 出來安裝到 eclipse。
但是 build sdk 很花時間(其實是不會作)。

比較簡單的方法就是找出 framework 中這些使用到的 api build 出來的 jar 檔,
把他當作是 libs 加到 app 的 project 中。

framework/core build 出來的 jar都會在 out/target/common/obj/JAVA_LIBRARIES/...
依照classs 分別放在不同的目錄中,都叫做 class.jar

舉例來說...

假設擴充了 sdcard, udisk 的路數量,增加了 api:
./java/android/os/Environment.java:540:    public static String getExternalExtSD2StorageState() {


用 grep 搜尋 lib folder ,在 framework_intermediates 下的 binary 找到 match。
所以把 framework_intermediates/class.jar copy 到 eclipse project folder 下的 libs 目錄(自己 create)。

然後規劃 eclipse 的 build path 要包含這個 class.jar:
  • 先 refresh 一次 project,讓 eclipse 顯示剛剛 copy 的 libs/class.jar
  • 在 libs/class.jar 按右鍵,選 build-path -- add build-path
這樣在 project 的 Referenced Libraries 下就會出現 class.jar,可以展開來看裡面包含的 class。

這樣就可以 build 了。

有時候可能要copy 很多個 class.jar,就要記得 rename..

2013年7月2日 星期二

變更 set date, time 的 dialog 大小..

先在 framework/base/core/res/res/drawable-hdpi 看到 timepicker_down_normal.9.png 這個圖。
然後 framework/base/core/res/res/layout/number_picker.xml 使用到 timepicker_down_normal.9.png
然後 framework/base/core/java/android/widget/NumberPicker.java: inflater.inflate(R.layout.number_picker, this, true)
然後就一堆...
  • core/java/android/widget/TimePicker.java
  • core/java/android/widget/DatePicker.java
DateTimeSettings -- TimePickerDialog(layout/time_picker_dialog) -- TimePicker

2013年6月22日 星期六

Sensation 開始,,


花 790 買 ADATA 32G C10 的 microsd card

發現...mic 音量太小...

稍微操作一下,就會熱,操作久一點的話 (about 5min),連面板都感覺得到熱度。

反應有點頓。

面板邊邊很容易誤觸。

音量button 和 usb 孔在同一側,車架架具不可以太寬。

標籤

網誌存檔