搜尋此網誌

2011年6月29日

Android audio system & test

蒐集 Android audio system 的介紹文章,列出 audio test 的範圍

Audio test scope:

  1. User layer: Input action or application
    • Audio play / record (Local / Remote / Streaming)
    • Phone voice
    • BT
    • System tones
    • MobileTV
    • Game
    • 3rd party applications
  2. User layer: Output check
    • Error code
    • Mixer
    • Device management (Earpiece, SPK, MIC, WiredHeadset, Headphone, BT_SCO, ...)
    • Patterns (Audio / Video / Picture / Streaming)
    • Audio path (Control by AudioPolicy)
    • Volume / Gain control
    • Media action (Quit, Init, Start, Stop, Pause, Mute, Reset, Loop, Seek, ...)
    • Media type
    • Pattern format (Sample rate, Channel, Quality...)
    • Source type (Voice call, System, Ring, Music, Alarm, DTMF, ...)
    • System resource
  3. SDK / Framework:
    • MediaPlayer
    • AsyncPlayer
    • PVPlayer
    • SonivoxPlayer
    • VorbisPlayer
    • JETPlayer
    • AudioTrack
    • SoundPool
    • Tonegenerator
    • Ringtone
    • ALSA / OpenCore

Audio system ref URLs:

  • http://www.360doc.com/content/10/0421/22/155970_24257702.shtml
  • http://www.360doc.com/content/10/0221/10/155970_16311527.shtml
  • http://www.360doc.com/content/10/0210/17/155970_15614592.shtml
  • http://www.360doc.com/content/10/0226/17/155970_16906749.shtml
  • http://www.360doc.com/content/10/0226/16/155970_16906274.shtml
  • http://www.360doc.com/content/10/0221/10/155970_16311460.shtml
  • http://www.360doc.com/content/10/0225/17/155970_16800093.shtml
  • http://blog.csdn.net/DroidPhone/archive/2010/10/19/5951999.aspx
  • http://blog.csdn.net/DroidPhone/archive/2010/10/18/5949280.aspx
  • http://blog.csdn.net/DroidPhone/archive/2010/10/14/5941344.aspx
  • http://www.cnblogs.com/innost/archive/2011/01/09/1931457.html
  • http://www.cnblogs.com/innost/archive/2011/01/15/1936425.html
  • http://hi.baidu.com/offt/blog/item/e4182b6c856f55c980cb4aea.html
  • http://hi.baidu.com/ktpeng/blog/item/fe7b3029ca42e4eee6cd40db.html

2011年6月28日

Android download file by HTTP

從網路上看到的程式,有兩種不同的寫法。已經測試過沒問題

方法一:


package com.quantatw.androidsnippet;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

public class AndroidSnippet extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

//TextView textView1 = (TextView)findViewById(R.id.textView1);

HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
try {
File root = Environment.getExternalStorageDirectory();
BufferedOutputStream bout = new BufferedOutputStream(
new FileOutputStream(
root.getAbsolutePath() + "/winhex.zip"));

request.setURI(new URI("http://www.x-ways.net/winhex.zip"));
HttpResponse response = client.execute(request);
StatusLine status = response.getStatusLine();
//textView1.append("status.getStatusCode(): " + status.getStatusCode() + "\n");
Log.d("Test", "Statusline: " + status);
Log.d("Test", "Statuscode: " + status.getStatusCode());

HttpEntity entity = response.getEntity();
//textView1.append("length: " + entity.getContentLength() + "\n");
//textView1.append("type: " + entity.getContentType() + "\n");
Log.d("Test", "Length: " + entity.getContentLength());
Log.d("Test", "type: " + entity.getContentType());

entity.writeTo(bout);

bout.flush();
bout.close();
//textView1.append("OK");

} catch (URISyntaxException e) {
// TODO Auto-generated catch block
//textView1.append("URISyntaxException");
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
//textView1.append("ClientProtocolException");
} catch (IOException e) {
// TODO Auto-generated catch block
//textView1.append("IOException");
}
}

}


方法二:


package com.quantatw.androidsnippet;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

public class AndroidSnippet extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

try {
//set the download URL, a url that points to a file on the internet
//this is the file to be downloaded

long beforeTime=System.currentTimeMillis();

URL url = new URL("http://www.x-ways.net/winhex.zip");

//create the new connection
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

//set up some things on the connection
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);

//and connect!
urlConnection.connect();

//set the path where we want to save the file
//in this case, going to save it on the root directory of the
//sd card.
File SDCardRoot = Environment.getExternalStorageDirectory();
Log.d("Test", "sdcard path: "+SDCardRoot);
//create a new file, specifying the path, and the filename
//which we want to save the file as.
File file = new File(SDCardRoot,"winhex.zip");

//this will be used to write the downloaded data into the file we created
FileOutputStream fileOutput = new FileOutputStream(file);

//this will be used in reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();

//this is the total size of the file
int totalSize = urlConnection.getContentLength();
Log.d("Test", "File size: "+totalSize);
//variable to store total downloaded bytes
int downloadedSize = 0;

//create a buffer...
byte[] buffer = new byte[1024];
int bufferLength = 0; //used to store a temporary size of the buffer

//now, read through the input buffer and write the contents to the file
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
//add the data in the buffer to the file in the file output stream (the file on the sd card
fileOutput.write(buffer, 0, bufferLength);
//add up the size so we know how much is downloaded
downloadedSize += bufferLength;
//this is where you would do something to report the prgress, like this maybe
//updateProgress(downloadedSize, totalSize);
//Log.d("Test", "Download size: "+downloadedSize);

}
//close the output stream when done
fileOutput.close();
long afterTime=System.currentTimeMillis();
long timeDistance=afterTime-beforeTime;
Log.d("Test", "Download time: "+timeDistance);
//SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//Date date = new Date();
//Log.d("Test", "Download time: "+bartDateFormat.format(date));

//catch some possible errors...
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}


}

/*
public void updateProgress(int currentSize, int totalSize){
TextView mProgressText = (TextView)findViewById(R.id.textView1);
mProgressText.setText(Long.toString((currentSize/totalSize)*100)+"%");
}
*/


}


記得要宣告 AndroidManifest.xml 的 user-permission

android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.READ_PHONE_STATE
android.permission.WRITE_EXTERNAL_STORAGE

2011年6月9日

Android snippets / Android 範例與教學蒐集 / Android tutorials

教學類 (Tutorial series):
Blog:

Snippets類:
  • http://www.androidsnippets.com/
  • http://www.damonkohler.com/2009/02/android-recipes.html
  • http://www.anddev.org/code-snippets-for-android-f33/
  • http://blog.tutorials-android.com/
  • http://www.openintents.org/en/intentstable

Library:
  • http://www.openintents.org/en/libraries


資訊類 (Portal / Market Information):

論壇類 (Forum):

Slide:

APK market:

2011年6月8日

Android Browser auto test / Android 瀏覽器自動化測試方法思考

目前還沒有 Black-box 的完全方法 (待測物與測試程式不需要經過特殊手段或處理),通常都要 re-sign 程式,或者需要 root 權限
會持續 survey 找出比較合理的方式
在尋找過程中,值得紀錄的一件事情是通常單元測試要指定一個 target package,且要存在於 Eclipse 中。但是 Robotium 網站提供一個方法可以避開,值得推薦。因為解決這個小問題,所以可以測試的對象大增,而只剩下 re-sign key 的問題而已。

目前找到的方案:
ID
Method
Description
Type
Note
Test Result
1
By Android instrumentation
Instrumentation
Semi-Blackbox or Blackbox
1.      Follow http://ppt.cc/IP-~
2.      Instrumentation code
TBC (Do not know if have signed key problem)
2
TestDroid
Semi-Blackbox
Need AUT in Eclipse at this moment.
TBC
3
Selenium

Semi-Blackbox
TBC
TBC
4
Robotium
Semi-Blackbox
1.          Follow http://ppt.cc/IP-~
2.          Instrumentation code
3.          Re-sign key
OK
5
Sikuli

Semi-Blackbox
1.          Install Sikuli IDE
2.          Setup screenpast or remote control
OK

開發時的環境: (: Probably yes)
ID
Method
Need rooted phone
Need AUT in Eclipse
Need re-sign key
Need external library
Need external plugin / tool
Others
1
Android instrument class
X
V
X
X
Run by Eclipse or adb shell
2
TestDroid
X: Current ver
: Next ver
V: Current ver
X: Next ver
X
V
V
V
V
V
Eclipse plugin and based on Robotium
3
Selenium
V
X (Has also)
Rich environment
4
Robotium
V
X

5
Sikuli
X
X
X
V




2011年6月3日

Testdroid recorder in Android

剛剛發現一個好玩的東西,可以利用 record 的方式來建立 Android Robotium 測試程式
可是感覺待測程式一定得由 Eclipse 可以 build 的才可以
而不能針對一個獨立的 application 進行這樣的測試

http://bitbar.com/testdroid-recorder-alpha-getting-started