Merge branch 'gingerbread' into gingerbread-release
This commit is contained in:
2
apps/Tag/.gitignore
vendored
Normal file
2
apps/Tag/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.swp
|
||||
|
||||
@@ -12,6 +12,8 @@ LOCAL_PACKAGE_NAME := TagApp
|
||||
|
||||
# LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_PROGUARD_ENABLED := disabled
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
|
||||
@@ -22,14 +22,15 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.apps.tag">
|
||||
<application android:label="Tags">
|
||||
<activity android:name="Tags" android:icon="@drawable/ic_launcher_nfc">
|
||||
<activity android:name="TagBrowserActivity"
|
||||
android:icon="@drawable/ic_launcher_nfc"
|
||||
android:theme="@style/Tags.TagBrowserTheme" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="TagSelector"></activity>
|
||||
<activity android:name="TagList"></activity>
|
||||
<activity android:name="SaveTag"></activity>
|
||||
<receiver android:name=".TagBroadcastReceiver">
|
||||
|
||||
BIN
apps/Tag/res/drawable/ic_menu_desk_clock.png
Normal file
BIN
apps/Tag/res/drawable/ic_menu_desk_clock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
BIN
apps/Tag/res/drawable/ic_menu_tag.png
Normal file
BIN
apps/Tag/res/drawable/ic_menu_tag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- When selected, use grey -->
|
||||
<item android:drawable="@drawable/ic_tab_artists_grey"
|
||||
android:state_selected="true" />
|
||||
<!-- When not selected, use white-->
|
||||
<item android:drawable="@drawable/ic_tab_artists_white" />
|
||||
</selector>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 791 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,21 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/tabhost"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="5dp">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp" />
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
<!--
|
||||
Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -13,13 +14,10 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<style name="Tags.TagBrowserTheme" parent="@android:style/Theme.NoTitleBar">
|
||||
</style>
|
||||
|
||||
|
||||
<EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="18sp"
|
||||
android:autoText="true"
|
||||
android:capitalize="sentences"
|
||||
android:text="@string/hello_activity_text_text" />
|
||||
|
||||
</resources>
|
||||
@@ -16,16 +16,22 @@
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import android.util.Log;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.trustedlogic.trustednfc.android.NdefMessage;
|
||||
import com.trustedlogic.trustednfc.android.NdefRecord;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utilities for dealing with conversions to and from NdefRecords.
|
||||
@@ -132,7 +138,7 @@ public class NdefUtil {
|
||||
String prefix = URI_PREFIX_MAP.get(payload[0]);
|
||||
byte[] fullUri = Bytes.concat(
|
||||
prefix.getBytes(Charsets.UTF_8),
|
||||
Arrays.copyOfRange(payload, 1, payload.length - 1));
|
||||
Arrays.copyOfRange(payload, 1, payload.length));
|
||||
|
||||
return new URI(new String(fullUri, Charsets.UTF_8));
|
||||
}
|
||||
@@ -147,4 +153,87 @@ public class NdefUtil {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts payload text from Text type ndef record.
|
||||
*
|
||||
* @param record A ndef record. Must be {@link NdefRecord#TYPE_TEXT}.
|
||||
* @return text payload.
|
||||
*/
|
||||
public static String toText(NdefRecord record) {
|
||||
Preconditions.checkArgument(record.getTnf() == NdefRecord.TNF_WELL_KNOWN_TYPE);
|
||||
Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.TYPE_TEXT));
|
||||
try {
|
||||
|
||||
byte[] payload = record.getPayload();
|
||||
|
||||
/*
|
||||
* payload[0] contains the "Status Byte Encodings" field, per
|
||||
* the NFC Forum "Text Record Type Definition" section 3.2.1.
|
||||
*
|
||||
* bit7 is the Text Encoding Field.
|
||||
*
|
||||
* if (Bit_7 == 0): The text is encoded in UTF-8
|
||||
* if (Bit_7 == 1): The text is encoded in UTF16
|
||||
*
|
||||
* Bit_6 is reserved for future use and must be set to zero.
|
||||
*
|
||||
* Bits 5 to 0 are the length of the IANA language code.
|
||||
*/
|
||||
|
||||
String textEncoding = ((payload[0] & 0200) == 0) ? "UTF-8" : "UTF-16";
|
||||
int languageCodeLength = payload[0] & 0077;
|
||||
|
||||
return new String(payload,
|
||||
languageCodeLength + 1,
|
||||
payload.length - languageCodeLength - 1,
|
||||
textEncoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// should never happen unless we get a malformed tag.
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isText(NdefRecord record) {
|
||||
try {
|
||||
toText(record);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Iterable<String> getTextFields(NdefMessage message) {
|
||||
return Iterables.filter(getObjects(message), String.class);
|
||||
}
|
||||
|
||||
public static Iterable<URI> getURIs(NdefMessage message) {
|
||||
return Iterables.filter(getObjects(message), URI.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the provided {@code NdefMessage}, extracting all known
|
||||
* objects from the message. Typically this list will consist of
|
||||
* {@link String}s corresponding to NDEF text records, or {@link URI}s
|
||||
* corresponding to NDEF URI records.
|
||||
* <p>
|
||||
* TODO: Is this API too generic? Should we keep it?
|
||||
*/
|
||||
private static Iterable<Object> getObjects(NdefMessage message) {
|
||||
try {
|
||||
List<Object> retval = new ArrayList<Object>();
|
||||
for (NdefRecord record : message.getRecords()) {
|
||||
if (isURI(record)) {
|
||||
retval.add(toURI(record));
|
||||
} else if (isText(record)) {
|
||||
retval.add(toText(record));
|
||||
} else if (SmartPoster.isPoster(record)) {
|
||||
retval.add(SmartPoster.from(record));
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import com.trustedlogic.trustednfc.android.NdefMessage;
|
||||
import com.trustedlogic.trustednfc.android.NfcManager;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
@@ -24,12 +27,9 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
import com.trustedlogic.trustednfc.android.NdefMessage;
|
||||
import com.trustedlogic.trustednfc.android.NfcManager;
|
||||
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
* An {@code Activity} which handles a broadcast of a new tag that the device just discovered.
|
||||
*/
|
||||
public class SaveTag extends Activity implements DialogInterface.OnClickListener {
|
||||
|
||||
@@ -78,7 +78,9 @@ public class SaveTag extends Activity implements DialogInterface.OnClickListener
|
||||
private static String toHexString(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder(3 * bytes.length);
|
||||
for (byte b : bytes) {
|
||||
sb.append("(byte) 0x").append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]).append(", ");
|
||||
sb.append("(byte) 0x")
|
||||
.append(hexDigits[(b >> 4) & 0xf])
|
||||
.append(hexDigits[b & 0xf]).append(", ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
95
apps/Tag/src/com/android/apps/tag/SmartPoster.java
Normal file
95
apps/Tag/src/com/android/apps/tag/SmartPoster.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.trustedlogic.trustednfc.android.NdefMessage;
|
||||
import com.trustedlogic.trustednfc.android.NdefRecord;
|
||||
import com.trustedlogic.trustednfc.android.NfcException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A representation of an NFC Forum "Smart Poster".
|
||||
*/
|
||||
public class SmartPoster {
|
||||
|
||||
/**
|
||||
* NFC Forum Smart Poster Record Type Definition section 3.2.1.
|
||||
*
|
||||
* "The Title record for the service (there can be many of these in
|
||||
* different languages, but a language MUST NOT be repeated).
|
||||
* This record is optional."
|
||||
|
||||
*/
|
||||
private final String titleRecord;
|
||||
|
||||
/**
|
||||
* NFC Forum Smart Poster Record Type Definition section 3.2.1.
|
||||
*
|
||||
* "The URI record. This is the core of the Smart Poster, and all other
|
||||
* records are just metadata about this record. There MUST be one URI
|
||||
* record and there MUST NOT be more than one."
|
||||
*/
|
||||
private final URI uriRecord;
|
||||
|
||||
private SmartPoster(URI uri, @Nullable String title) {
|
||||
uriRecord = Preconditions.checkNotNull(uri);
|
||||
titleRecord = title;
|
||||
}
|
||||
|
||||
public URI getURI() {
|
||||
return uriRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of the smartposter. This may be {@code null}.
|
||||
*/
|
||||
public String getTitle() {
|
||||
return titleRecord;
|
||||
}
|
||||
|
||||
public static SmartPoster from(NdefRecord record) {
|
||||
Preconditions.checkArgument(record.getTnf() == NdefRecord.TNF_WELL_KNOWN_TYPE);
|
||||
Preconditions.checkArgument(Arrays.equals(record.getType(), NdefRecord.TYPE_SMART_POSTER));
|
||||
try {
|
||||
NdefMessage subRecords = new NdefMessage(record.getPayload());
|
||||
URI uri = Iterables.getOnlyElement(NdefUtil.getURIs(subRecords));
|
||||
Iterable<String> textFields = NdefUtil.getTextFields(subRecords);
|
||||
String title = null;
|
||||
if (!Iterables.isEmpty(textFields)) {
|
||||
title = Iterables.get(textFields, 0);
|
||||
}
|
||||
|
||||
return new SmartPoster(uri, title);
|
||||
} catch (NfcException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPoster(NdefRecord record) {
|
||||
try {
|
||||
from(record);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,9 @@ import android.os.Bundle;
|
||||
import android.widget.TabHost;
|
||||
|
||||
/**
|
||||
* A minimal "Hello, World!" application.
|
||||
* A browsing {@code Activity} that displays the saved tags in categories under tabs.
|
||||
*/
|
||||
public class Tags extends TabActivity {
|
||||
/**
|
||||
* Called with the activity is first created.
|
||||
*/
|
||||
public class TagBrowserActivity extends TabActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -42,26 +39,19 @@ public class Tags extends TabActivity {
|
||||
TabHost tabHost = getTabHost();
|
||||
Intent i = new Intent().setClass(this, TagList.class);
|
||||
|
||||
Intent iSavedList = new Intent().setClass(this, TagList.class);
|
||||
Intent iSavedList = new Intent().setClass(this, TagList.class)
|
||||
.putExtra(TagList.SHOW_SAVED_ONLY, true);
|
||||
Intent iRecentList = new Intent().setClass(this, TagList.class);
|
||||
Intent iMyTagList = new Intent().setClass(this, TagList.class);
|
||||
|
||||
|
||||
TabHost.TabSpec spec1 = tabHost.newTabSpec("1")
|
||||
.setIndicator("Saved", res.getDrawable(R.drawable.ic_tab_artists))
|
||||
.setIndicator("Saved", res.getDrawable(R.drawable.ic_menu_tag))
|
||||
.setContent(iSavedList);
|
||||
tabHost.addTab(spec1);
|
||||
|
||||
TabHost.TabSpec spec2 = tabHost.newTabSpec("2")
|
||||
.setIndicator("Recent", res.getDrawable(R.drawable.ic_tab_artists))
|
||||
.setIndicator("Recent", res.getDrawable(R.drawable.ic_menu_desk_clock))
|
||||
.setContent(iRecentList);
|
||||
tabHost.addTab(spec2);
|
||||
|
||||
TabHost.TabSpec spec3 = tabHost.newTabSpec("3")
|
||||
.setIndicator("My Tag", res.getDrawable(R.drawable.ic_tab_artists))
|
||||
.setContent(iMyTagList);
|
||||
tabHost.addTab(spec3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,21 @@
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.trustedlogic.trustednfc.android.NdefMessage;
|
||||
import com.trustedlogic.trustednfc.android.NdefRecord;
|
||||
import com.trustedlogic.trustednfc.android.NfcException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
* Database utilities for the saved tags.
|
||||
*/
|
||||
public class TagDBHelper extends SQLiteOpenHelper {
|
||||
|
||||
@@ -39,61 +40,79 @@ public class TagDBHelper extends SQLiteOpenHelper {
|
||||
+ "_id INTEGER NOT NULL, "
|
||||
+ "bytes BLOB NOT NULL, "
|
||||
+ "date TEXT NOT NULL, "
|
||||
+ "saved TEXT NOT NULL default 0," // boolean
|
||||
+ "PRIMARY KEY(_id)"
|
||||
+ ")";
|
||||
|
||||
private static final String INSERT =
|
||||
"INSERT INTO NdefMessage (bytes, date) values (?, ?)";
|
||||
"INSERT INTO NdefMessage (bytes, date, saved) values (?, ?, ?)";
|
||||
|
||||
private static final byte[] REAL_NFC_MSG = new byte[] {
|
||||
(byte) 0xd1,
|
||||
(byte) 0x02,
|
||||
(byte) 0x2b,
|
||||
(byte) 0x53,
|
||||
(byte) 0x70,
|
||||
(byte) 0x91,
|
||||
(byte) 0x01,
|
||||
(byte) 0x17,
|
||||
(byte) 0x54,
|
||||
(byte) 0x02,
|
||||
(byte) 0x65,
|
||||
(byte) 0x6e,
|
||||
(byte) 0x4e,
|
||||
(byte) 0x46,
|
||||
(byte) 0x43,
|
||||
(byte) 0x20,
|
||||
(byte) 0x46,
|
||||
(byte) 0x6f,
|
||||
(byte) 0x72,
|
||||
(byte) 0x75,
|
||||
(byte) 0x6d,
|
||||
(byte) 0x20,
|
||||
(byte) 0x54,
|
||||
(byte) 0x79,
|
||||
(byte) 0x70,
|
||||
(byte) 0x65,
|
||||
(byte) 0x20,
|
||||
(byte) 0x34,
|
||||
(byte) 0x20,
|
||||
(byte) 0x54,
|
||||
(byte) 0x61,
|
||||
(byte) 0x67,
|
||||
(byte) 0x51,
|
||||
(byte) 0x01,
|
||||
(byte) 0x0c,
|
||||
(byte) 0x55,
|
||||
(byte) 0x01,
|
||||
(byte) 0x6e,
|
||||
(byte) 0x78,
|
||||
(byte) 0x70,
|
||||
(byte) 0x2e,
|
||||
(byte) 0x63,
|
||||
(byte) 0x6f,
|
||||
(byte) 0x6d,
|
||||
(byte) 0x2f,
|
||||
(byte) 0x6e,
|
||||
(byte) 0x66,
|
||||
(byte) 0x63
|
||||
/**
|
||||
* A real NFC tag containing an NFC "smart poster". This smart poster
|
||||
* consists of the text "NFC Forum Type 4 Tag" in english combined with
|
||||
* the URL "http://www.nxp.com/nfc"
|
||||
*/
|
||||
public static final byte[] REAL_NFC_MSG = new byte[] {
|
||||
(byte) 0xd1, // MB=1 ME=1 CF=0 SR=1 IL=0 TNF=001
|
||||
(byte) 0x02, // Type Length = 2
|
||||
(byte) 0x2b, // Payload Length = 43
|
||||
(byte) 0x53, (byte) 0x70, // Type = {'S', 'p'} (smart poster)
|
||||
|
||||
// begin smart poster payload
|
||||
// begin smart poster record #1
|
||||
(byte) 0x91, // MB=1 ME=0 CF=0 SR=1 IL=0 TNF=001
|
||||
(byte) 0x01, // Type Length = 1
|
||||
(byte) 0x17, // Payload Length = 23
|
||||
(byte) 0x54, // Type = {'T'} (Text data)
|
||||
(byte) 0x02, // UTF-8 encoding, language code length = 2
|
||||
(byte) 0x65, (byte) 0x6e, // language = {'e', 'n'} (english)
|
||||
|
||||
// Begin text data within smart poster record #1
|
||||
(byte) 0x4e, // 'N'
|
||||
(byte) 0x46, // 'F'
|
||||
(byte) 0x43, // 'C'
|
||||
(byte) 0x20, // ' '
|
||||
(byte) 0x46, // 'F'
|
||||
(byte) 0x6f, // 'o'
|
||||
(byte) 0x72, // 'r'
|
||||
(byte) 0x75, // 'u'
|
||||
(byte) 0x6d, // 'm'
|
||||
(byte) 0x20, // ' '
|
||||
(byte) 0x54, // 'T'
|
||||
(byte) 0x79, // 'y'
|
||||
(byte) 0x70, // 'p'
|
||||
(byte) 0x65, // 'e'
|
||||
(byte) 0x20, // ' '
|
||||
(byte) 0x34, // '4'
|
||||
(byte) 0x20, // ' '
|
||||
(byte) 0x54, // 'T'
|
||||
(byte) 0x61, // 'a'
|
||||
(byte) 0x67, // 'g'
|
||||
// end Text data within smart poster record #1
|
||||
// end smart poster record #1
|
||||
|
||||
// begin smart poster record #2
|
||||
(byte) 0x51, // MB=0 ME=1 CF=0 SR=1 IL=0 TNF=001
|
||||
(byte) 0x01, // Type Length = 1
|
||||
(byte) 0x0c, // Payload Length = 12
|
||||
(byte) 0x55, // Type = { 'U' } (URI)
|
||||
|
||||
// begin URI data within smart poster record #2
|
||||
(byte) 0x01, // URI Prefix = 1 ("http://www.")
|
||||
(byte) 0x6e, // 'n'
|
||||
(byte) 0x78, // 'x'
|
||||
(byte) 0x70, // 'p'
|
||||
(byte) 0x2e, // '.'
|
||||
(byte) 0x63, // 'c'
|
||||
(byte) 0x6f, // 'o'
|
||||
(byte) 0x6d, // 'm'
|
||||
(byte) 0x2f, // '/'
|
||||
(byte) 0x6e, // 'n'
|
||||
(byte) 0x66, // 'f'
|
||||
(byte) 0x63 // 'c'
|
||||
// end URI data within smart poster record #2
|
||||
// end smart poster record #2
|
||||
// end smart poster payload
|
||||
};
|
||||
|
||||
public TagDBHelper(Context context) {
|
||||
@@ -120,22 +139,24 @@ public class TagDBHelper extends SQLiteOpenHelper {
|
||||
NdefUtil.toUriRecord(URI.create("http://www.android.com"))
|
||||
});
|
||||
|
||||
insert(db, msg1);
|
||||
insert(db, msg2);
|
||||
insert(db, msg1, false);
|
||||
insert(db, msg2, true);
|
||||
|
||||
try {
|
||||
// A real message obtained from an NFC Forum Type 4 tag.
|
||||
NdefMessage msg3 = new NdefMessage(REAL_NFC_MSG);
|
||||
insert(db, msg3);
|
||||
insert(db, msg3, false);
|
||||
} catch (NfcException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void insert(SQLiteDatabase db, NdefMessage msg) {
|
||||
private void insert(SQLiteDatabase db, NdefMessage msg, boolean isSaved) {
|
||||
SQLiteStatement stmt = db.compileStatement(INSERT);
|
||||
stmt.bindString(1, new String(msg.toByteArray())); // TODO: This should be a blob
|
||||
stmt.bindString(2, new Date().toString());
|
||||
String isSavedStr = isSaved ? "1" : "0";
|
||||
stmt.bindString(3, isSavedStr);
|
||||
stmt.executeInsert();
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
@@ -27,32 +27,36 @@ import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
* An {@code Activity} that displays a flat list of tags that can be "opened".
|
||||
*/
|
||||
public class TagList extends ListActivity implements DialogInterface.OnClickListener {
|
||||
|
||||
private SQLiteDatabase db;
|
||||
private Cursor cursor;
|
||||
static final String SHOW_SAVED_ONLY = "show_saved_only";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Toast.makeText(getBaseContext(), "entered method", Toast.LENGTH_SHORT).show();
|
||||
|
||||
boolean showSavedOnly = getIntent().getBooleanExtra(SHOW_SAVED_ONLY, false);
|
||||
db = new TagDBHelper(getBaseContext()).getReadableDatabase();
|
||||
cursor = db.query("NdefMessage", new String[] { "_id", "bytes" }, null, null, null, null, null);
|
||||
String selection = showSavedOnly ? "saved=1" : null;
|
||||
cursor = db.query(
|
||||
"NdefMessage",
|
||||
new String[] { "_id", "bytes", "date" },
|
||||
selection,
|
||||
null, null, null, null);
|
||||
SimpleCursorAdapter sca =
|
||||
new SimpleCursorAdapter(this,
|
||||
android.R.layout.two_line_list_item,
|
||||
cursor,
|
||||
new String[] { "bytes" },
|
||||
new int[] { android.R.id.text1 });
|
||||
new String[] { "bytes", "date" },
|
||||
new int[] { android.R.id.text1, android.R.id.text2 });
|
||||
|
||||
setListAdapter(sca);
|
||||
registerForContextMenu(getListView());
|
||||
Toast.makeText(getBaseContext(), "exit method", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +95,6 @@ public class TagList extends ListActivity implements DialogInterface.OnClickList
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) { }
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* @author nnk@google.com (Nick Kralevich)
|
||||
*/
|
||||
public class TagListAdapter extends BaseAdapter {
|
||||
|
||||
private Context context;
|
||||
|
||||
TagListAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private static final String[] listItems = {
|
||||
"Welcome! T2000 Festival",
|
||||
"Free songs by Hula 88",
|
||||
"Welcome to FreeBucks",
|
||||
"BooBox Movie Coupons"
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return listItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItem(int position) {
|
||||
return listItems[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
TextView tv = new TextView(context);
|
||||
tv.setText(getItem(position));
|
||||
return tv;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A minimal "Hello, World!" application.
|
||||
*/
|
||||
public class TagSelector extends Activity {
|
||||
private static final int DIALOG = 1;
|
||||
private static final String[] elements = { "hello world" };
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final TextView tv = new TextView(this);
|
||||
tv.setText("hello world");
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
tv.setText("clicked!");
|
||||
showAlert();
|
||||
}
|
||||
});
|
||||
|
||||
setContentView(tv);
|
||||
|
||||
// Set the layout for this activity. You can find it
|
||||
// in res/layout/hello_activity.xml
|
||||
// setContentView(R.layout.hello_activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id, Bundle bundle) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Welcome ");
|
||||
builder.setCancelable(true);
|
||||
builder.setItems(elements, null);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
private void showAlert() {
|
||||
showDialog(DIALOG);
|
||||
}
|
||||
}
|
||||
|
||||
51
apps/Tag/tests/src/com/android/apps/tag/NdefUtilTest.java
Normal file
51
apps/Tag/tests/src/com/android/apps/tag/NdefUtilTest.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.trustedlogic.trustednfc.android.NdefRecord;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class NdefUtilTest extends AndroidTestCase {
|
||||
public void testToText() throws UnsupportedEncodingException {
|
||||
checkWord("Hello", "en-US", true);
|
||||
checkWord("Hello", "en-US", false);
|
||||
checkWord("abc\\u5639\\u563b", "cp1251", true);
|
||||
checkWord("abc\\u5639\\u563b", "cp1251", false);
|
||||
}
|
||||
|
||||
private static void checkWord(String word, String encoding, boolean isUtf8) throws UnsupportedEncodingException {
|
||||
String utfEncoding = isUtf8 ? "UTF-8" : "UTF-16";
|
||||
|
||||
byte[] encodingBytes = encoding.getBytes("US-ASCII");
|
||||
byte[] text = word.getBytes(utfEncoding);
|
||||
|
||||
int utfBit = isUtf8 ? 0 : (1 << 7);
|
||||
char status = (char) (utfBit + encodingBytes.length);
|
||||
|
||||
byte[] data = Bytes.concat(
|
||||
new byte[] { (byte) status },
|
||||
encodingBytes,
|
||||
text
|
||||
);
|
||||
|
||||
NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN_TYPE, NdefRecord.TYPE_TEXT, new byte[0], data);
|
||||
assertEquals(word, NdefUtil.toText(record));
|
||||
}
|
||||
}
|
||||
33
apps/Tag/tests/src/com/android/apps/tag/SmartPosterTest.java
Normal file
33
apps/Tag/tests/src/com/android/apps/tag/SmartPosterTest.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.apps.tag;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import com.trustedlogic.trustednfc.android.NdefMessage;
|
||||
|
||||
/**
|
||||
* Tests for {@link SmartPoster}.
|
||||
*/
|
||||
public class SmartPosterTest extends AndroidTestCase {
|
||||
public void testSmartPoster() throws Exception {
|
||||
NdefMessage msg = new NdefMessage(TagDBHelper.REAL_NFC_MSG);
|
||||
|
||||
SmartPoster poster = SmartPoster.from(msg.getRecords()[0]);
|
||||
assertEquals("NFC Forum Type 4 Tag", poster.getTitle());
|
||||
assertEquals("http://www.nxp.com/nfc", poster.getURI().toString());
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,14 @@ import android.test.ActivityInstrumentationTestCase2;
|
||||
* Make sure that the main launcher activity opens up properly, which will be
|
||||
* verified by {@link #testActivityTestCaseSetUpProperly}.
|
||||
*/
|
||||
public class TagsTest extends ActivityInstrumentationTestCase2<Tags> {
|
||||
public class TagsTest extends ActivityInstrumentationTestCase2<TagBrowserActivity> {
|
||||
|
||||
/**
|
||||
* Creates an {@link ActivityInstrumentationTestCase2} for the {@link Tags} activity.
|
||||
* Creates an {@link ActivityInstrumentationTestCase2} for the
|
||||
* {@link TagBrowserActivity} activity.
|
||||
*/
|
||||
public TagsTest() {
|
||||
super(Tags.class);
|
||||
super(TagBrowserActivity.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
BIN
ndk/platforms/android-9/arch-arm/lib/libOpenSLES.so
Executable file
BIN
ndk/platforms/android-9/arch-arm/lib/libOpenSLES.so
Executable file
Binary file not shown.
52
ndk/platforms/android-9/arch-arm/symbols/libOpenSLES.so.txt
Normal file
52
ndk/platforms/android-9/arch-arm/symbols/libOpenSLES.so.txt
Normal file
@@ -0,0 +1,52 @@
|
||||
SL_IID_3DCOMMIT
|
||||
SL_IID_3DDOPPLER
|
||||
SL_IID_3DGROUPING
|
||||
SL_IID_3DLOCATION
|
||||
SL_IID_3DMACROSCOPIC
|
||||
SL_IID_3DSOURCE
|
||||
SL_IID_ANDROIDCONFIGURATION
|
||||
SL_IID_ANDROIDEFFECT
|
||||
SL_IID_ANDROIDEFFECTCAPABILITIES
|
||||
SL_IID_ANDROIDEFFECTSEND
|
||||
SL_IID_ANDROIDSIMPLEBUFFERQUEUE
|
||||
SL_IID_AUDIODECODERCAPABILITIES
|
||||
SL_IID_AUDIOENCODER
|
||||
SL_IID_AUDIOENCODERCAPABILITIES
|
||||
SL_IID_AUDIOIODEVICECAPABILITIES
|
||||
SL_IID_BASSBOOST
|
||||
SL_IID_BUFFERQUEUE
|
||||
SL_IID_DEVICEVOLUME
|
||||
SL_IID_DYNAMICINTERFACEMANAGEMENT
|
||||
SL_IID_DYNAMICSOURCE
|
||||
SL_IID_EFFECTSEND
|
||||
SL_IID_ENGINE
|
||||
SL_IID_ENGINECAPABILITIES
|
||||
SL_IID_ENVIRONMENTALREVERB
|
||||
SL_IID_EQUALIZER
|
||||
SL_IID_LED
|
||||
SL_IID_METADATAEXTRACTION
|
||||
SL_IID_METADATATRAVERSAL
|
||||
SL_IID_MIDIMESSAGE
|
||||
SL_IID_MIDIMUTESOLO
|
||||
SL_IID_MIDITEMPO
|
||||
SL_IID_MIDITIME
|
||||
SL_IID_MUTESOLO
|
||||
SL_IID_NULL
|
||||
SL_IID_OBJECT
|
||||
SL_IID_OUTPUTMIX
|
||||
SL_IID_PITCH
|
||||
SL_IID_PLAY
|
||||
SL_IID_PLAYBACKRATE
|
||||
SL_IID_PREFETCHSTATUS
|
||||
SL_IID_PRESETREVERB
|
||||
SL_IID_RATEPITCH
|
||||
SL_IID_RECORD
|
||||
SL_IID_SEEK
|
||||
SL_IID_THREADSYNC
|
||||
SL_IID_VIBRA
|
||||
SL_IID_VIRTUALIZER
|
||||
SL_IID_VISUALIZATION
|
||||
SL_IID_VOLUME
|
||||
slCreateEngine
|
||||
slQueryNumSupportedEngineInterfaces
|
||||
slQuerySupportedEngineInterfaces
|
||||
2774
ndk/platforms/android-9/include/SLES/OpenSLES.h
Normal file
2774
ndk/platforms/android-9/include/SLES/OpenSLES.h
Normal file
File diff suppressed because it is too large
Load Diff
242
ndk/platforms/android-9/include/SLES/OpenSLES_Android.h
Normal file
242
ndk/platforms/android-9/include/SLES/OpenSLES_Android.h
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OPENSL_ES_ANDROID_H_
|
||||
#define OPENSL_ES_ANDROID_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android common types */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
typedef sl_int64_t SLAint64; /* 64 bit signed integer */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android Effect interface */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDEFFECT;
|
||||
|
||||
/** Android Effect interface methods */
|
||||
|
||||
struct SLAndroidEffectItf_;
|
||||
typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf;
|
||||
|
||||
struct SLAndroidEffectItf_ {
|
||||
|
||||
SLresult (*CreateEffect) (SLAndroidEffectItf self,
|
||||
SLInterfaceID effectImplementationId);
|
||||
|
||||
SLresult (*ReleaseEffect) (SLAndroidEffectItf self,
|
||||
SLInterfaceID effectImplementationId);
|
||||
|
||||
SLresult (*SetEnabled) (SLAndroidEffectItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLboolean enabled);
|
||||
|
||||
SLresult (*IsEnabled) (SLAndroidEffectItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLboolean *pEnabled);
|
||||
|
||||
SLresult (*SendCommand) (SLAndroidEffectItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLuint32 command,
|
||||
SLuint32 commandSize,
|
||||
void *pCommandData,
|
||||
SLuint32 *replySize,
|
||||
void *pReplyData);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android Effect Send interface */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDEFFECTSEND;
|
||||
|
||||
/** Android Effect Send interface methods */
|
||||
|
||||
struct SLAndroidEffectSendItf_;
|
||||
typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf;
|
||||
|
||||
struct SLAndroidEffectSendItf_ {
|
||||
SLresult (*EnableEffectSend) (
|
||||
SLAndroidEffectSendItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLboolean enable,
|
||||
SLmillibel initialLevel
|
||||
);
|
||||
SLresult (*IsEnabled) (
|
||||
SLAndroidEffectSendItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLboolean *pEnable
|
||||
);
|
||||
SLresult (*SetDirectLevel) (
|
||||
SLAndroidEffectSendItf self,
|
||||
SLmillibel directLevel
|
||||
);
|
||||
SLresult (*GetDirectLevel) (
|
||||
SLAndroidEffectSendItf self,
|
||||
SLmillibel *pDirectLevel
|
||||
);
|
||||
SLresult (*SetSendLevel) (
|
||||
SLAndroidEffectSendItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLmillibel sendLevel
|
||||
);
|
||||
SLresult (*GetSendLevel)(
|
||||
SLAndroidEffectSendItf self,
|
||||
SLInterfaceID effectImplementationId,
|
||||
SLmillibel *pSendLevel
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android Effect Capabilities interface */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES;
|
||||
|
||||
/** Android Effect Capabilities interface methods */
|
||||
|
||||
struct SLAndroidEffectCapabilitiesItf_;
|
||||
typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf;
|
||||
|
||||
struct SLAndroidEffectCapabilitiesItf_ {
|
||||
|
||||
SLresult (*QueryNumEffects) (SLAndroidEffectCapabilitiesItf self,
|
||||
SLuint32 *pNumSupportedEffects);
|
||||
|
||||
|
||||
SLresult (*QueryEffect) (SLAndroidEffectCapabilitiesItf self,
|
||||
SLuint32 index,
|
||||
SLInterfaceID *pEffectType,
|
||||
SLInterfaceID *pEffectImplementation,
|
||||
SLchar *pName,
|
||||
SLuint16 *pNameSize);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android Configuration interface */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDCONFIGURATION;
|
||||
|
||||
/** Android Configuration interface methods */
|
||||
|
||||
struct SLAndroidConfigurationItf_;
|
||||
typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf;
|
||||
|
||||
struct SLAndroidConfigurationItf_ {
|
||||
|
||||
SLresult (*SetConfiguration) (SLAndroidConfigurationItf self,
|
||||
const SLchar *configKey,
|
||||
const void *pConfigValue,
|
||||
SLuint32 valueSize);
|
||||
|
||||
SLresult (*GetConfiguration) (SLAndroidConfigurationItf self,
|
||||
const SLchar *configKey,
|
||||
SLuint32 *pValueSize,
|
||||
void *pConfigValue
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android Simple Buffer Queue Interface */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
|
||||
|
||||
struct SLAndroidSimpleBufferQueueItf_;
|
||||
typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf;
|
||||
|
||||
typedef void (/*SLAPIENTRY*/ *slAndroidSimpleBufferQueueCallback)(
|
||||
SLAndroidSimpleBufferQueueItf caller,
|
||||
void *pContext
|
||||
);
|
||||
|
||||
/** Android simple buffer queue state **/
|
||||
|
||||
typedef struct SLAndroidSimpleBufferQueueState_ {
|
||||
SLuint32 count;
|
||||
SLuint32 index;
|
||||
} SLAndroidSimpleBufferQueueState;
|
||||
|
||||
|
||||
struct SLAndroidSimpleBufferQueueItf_ {
|
||||
SLresult (*Enqueue) (
|
||||
SLAndroidSimpleBufferQueueItf self,
|
||||
const void *pBuffer,
|
||||
SLuint32 size
|
||||
);
|
||||
SLresult (*Clear) (
|
||||
SLAndroidSimpleBufferQueueItf self
|
||||
);
|
||||
SLresult (*GetState) (
|
||||
SLAndroidSimpleBufferQueueItf self,
|
||||
SLAndroidSimpleBufferQueueState *pState
|
||||
);
|
||||
SLresult (*RegisterCallback) (
|
||||
SLAndroidSimpleBufferQueueItf self,
|
||||
slAndroidSimpleBufferQueueCallback callback,
|
||||
void* pContext
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android File Descriptor Data Locator */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Addendum to Data locator macros */
|
||||
#define SL_DATALOCATOR_ANDROIDFD ((SLuint32) 0x800007BC)
|
||||
|
||||
#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll)
|
||||
|
||||
/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */
|
||||
typedef struct SLDataLocator_AndroidFD_ {
|
||||
SLuint32 locatorType;
|
||||
SLint32 fd;
|
||||
SLAint64 offset;
|
||||
SLAint64 length;
|
||||
} SLDataLocator_AndroidFD;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android Android Simple Buffer Queue Data Locator */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Addendum to Data locator macros */
|
||||
#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD)
|
||||
|
||||
/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/
|
||||
typedef struct SLDataLocator_AndroidSimpleBufferQueue {
|
||||
SLuint32 locatorType;
|
||||
SLuint32 numBuffers;
|
||||
} SLDataLocator_AndroidSimpleBufferQueue;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* OPENSL_ES_ANDROID_H_ */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OPENSL_ES_ANDROIDCONFIGURATION_H_
|
||||
#define OPENSL_ES_ANDROIDCONFIGURATION_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android AudioRecorder configuration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Audio recording preset */
|
||||
/** Audio recording preset key */
|
||||
#define SL_ANDROID_KEY_RECORDING_PRESET ((const SLchar*) "androidRecordingPreset")
|
||||
/** Audio recording preset values */
|
||||
/** preset "none" cannot be set, it is used to indicate the current settings
|
||||
* do not match any of the presets. */
|
||||
#define SL_ANDROID_RECORDING_PRESET_NONE ((SLuint32) 0x00000000)
|
||||
/** generic recording configuration on the platform */
|
||||
#define SL_ANDROID_RECORDING_PRESET_GENERIC ((SLuint32) 0x00000001)
|
||||
/** uses the microphone audio source with the same orientation as the camera
|
||||
* if available, the main device microphone otherwise */
|
||||
#define SL_ANDROID_RECORDING_PRESET_CAMCORDER ((SLuint32) 0x00000002)
|
||||
/** uses the main microphone tuned for voice recognition */
|
||||
#define SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION ((SLuint32) 0x00000003)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Android AudioPlayer configuration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** Audio playback stream type */
|
||||
/** Audio playback stream type key */
|
||||
#define SL_ANDROID_KEY_STREAM_TYPE ((const SLchar*) "androidPlaybackStreamType")
|
||||
|
||||
/** Audio playback stream type values */
|
||||
/* same as android.media.AudioManager.STREAM_VOICE_CALL */
|
||||
#define SL_ANDROID_STREAM_VOICE ((SLint32) 0x00000000)
|
||||
/* same as android.media.AudioManager.STREAM_SYSTEM */
|
||||
#define SL_ANDROID_STREAM_SYSTEM ((SLint32) 0x00000001)
|
||||
/* same as android.media.AudioManager.STREAM_RING */
|
||||
#define SL_ANDROID_STREAM_RING ((SLint32) 0x00000002)
|
||||
/* same as android.media.AudioManager.STREAM_MUSIC */
|
||||
#define SL_ANDROID_STREAM_MEDIA ((SLint32) 0x00000003)
|
||||
/* same as android.media.AudioManager.STREAM_ALARM */
|
||||
#define SL_ANDROID_STREAM_ALARM ((SLint32) 0x00000004)
|
||||
/* same as android.media.AudioManager.STREAM_NOTIFICATION */
|
||||
#define SL_ANDROID_STREAM_NOTIFICATION ((SLint32) 0x00000005)
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* OPENSL_ES_ANDROIDCONFIGURATION_H_ */
|
||||
52
ndk/platforms/android-9/include/SLES/OpenSLES_Platform.h
Normal file
52
ndk/platforms/android-9/include/SLES/OpenSLES_Platform.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2009 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and /or associated documentation files (the "Materials "), to
|
||||
* deal in the Materials without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Materials, and to permit persons to whom the Materials are
|
||||
* furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
|
||||
* MATERIALS.
|
||||
*
|
||||
* OpenSLES_Platform.h - OpenSL ES version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
/* NOTE: This file contains definitions for the base types and the */
|
||||
/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */
|
||||
/* the correct definitions specific to the platform being used. */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _OPENSLES_PLATFORM_H_
|
||||
#define _OPENSLES_PLATFORM_H_
|
||||
|
||||
typedef unsigned char sl_uint8_t;
|
||||
typedef signed char sl_int8_t;
|
||||
typedef unsigned short sl_uint16_t;
|
||||
typedef signed short sl_int16_t;
|
||||
typedef unsigned long sl_uint32_t;
|
||||
typedef signed long sl_int32_t;
|
||||
typedef long long sl_int64_t;
|
||||
|
||||
#ifndef SLAPIENTRY
|
||||
#ifdef __GNUC__
|
||||
#define SLAPIENTRY /* override per-platform */
|
||||
#else
|
||||
#define SLAPIENTRY __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _OPENSLES_PLATFORM_H_ */
|
||||
Reference in New Issue
Block a user