diff options
author | Vishal Mahaveer <vishalm@ti.com> | 2014-07-07 18:02:24 -0500 |
---|---|---|
committer | Vishal Mahaveer <vishalm@ti.com> | 2014-07-07 18:02:24 -0500 |
commit | d020834787b241ad558474ea95afd1a1a9d561c1 (patch) | |
tree | 063e93eb3b77b5e601e116a446ea8731680f31c3 | |
parent | 0083dd3bc678cd52b659593c5e33b60d89aebaf2 (diff) | |
download | common-open-d020834787b241ad558474ea95afd1a1a9d561c1.tar.gz |
cleanup: remove legacy sources
Remove unused source code
Change-Id: Ia5e53fb56b52c0dc0c9a00c7938cd909dbdb3b69
Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
76 files changed, 0 insertions, 5184 deletions
diff --git a/BoardConfig.mk b/BoardConfig.mk deleted file mode 100644 index 474c579..0000000 --- a/BoardConfig.mk +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments Inc. -# -# 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. -# - -# Common Makefile to be included at the bottom of each device's -# BoardConfig.mk file. Definitions here are supposed to be device independent. - - -# Function to check malformed boolean variable -define ti-check-boolean-var -$(if $(call filter,true,$($(1))),,$(if $($(1)),\ - $(error Boolean variable $(1) is set to "$($(1))". Expected: "true" or undefined),)) -endef - - -# Check boolean variables -$(call ti-check-boolean-var,ENHANCED_DOMX) -$(call ti-check-boolean-var,OMAP_ENHANCEMENT) -$(call ti-check-boolean-var,OMAP_ENHANCEMENT_S3D) -$(call ti-check-boolean-var,OMAP_ENHANCEMENT_CPCAM) -$(call ti-check-boolean-var,OMAP_ENHANCEMENT_VTC) -$(call ti-check-boolean-var,OMAP_ENHANCEMENT_BURST_CAPTURE) -$(call ti-check-boolean-var,USE_ITTIAM_AAC) -$(call ti-check-boolean-var,OMAP_ENHANCEMENT_MULTIGPU) - - -# Makefile variable and C/C++ macro to recognise DOMX version -ifdef ENHANCED_DOMX - COMMON_GLOBAL_CFLAGS += -DENHANCED_DOMX - DOMX_PATH := hardware/ti/domx -else - DOMX_PATH := hardware/ti/omap4xxx/domx -endif - -# C/C++ macros for OMAP_ENHANCEMENT -ifdef OMAP_ENHANCEMENT - COMMON_GLOBAL_CFLAGS += -DOMAP_ENHANCEMENT -DTARGET_OMAP4 -endif - -ifdef OMAP_ENHANCEMENT_BURST_CAPTURE - COMMON_GLOBAL_CFLAGS += -DOMAP_ENHANCEMENT_BURST_CAPTURE -endif - -ifdef OMAP_ENHANCEMENT_S3D - COMMON_GLOBAL_CFLAGS += -DOMAP_ENHANCEMENT_S3D -endif - -ifdef OMAP_ENHANCEMENT_CPCAM - COMMON_GLOBAL_CFLAGS += -DOMAP_ENHANCEMENT_CPCAM -endif - -ifdef OMAP_ENHANCEMENT_VTC - COMMON_GLOBAL_CFLAGS += -DOMAP_ENHANCEMENT_VTC -endif - -ifdef USE_ITTIAM_AAC - COMMON_GLOBAL_CFLAGS += -DUSE_ITTIAM_AAC -endif - -ifdef OMAP_ENHANCEMENT_MULTIGPU - COMMON_GLOBAL_CFLAGS += -DOMAP_ENHANCEMENT_MULTIGPU -endif - -# Undefine local functions -ti-check-boolean-var := diff --git a/board_identity/Android.mk b/board_identity/Android.mk deleted file mode 100644 index 5053e7d..0000000 --- a/board_identity/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(call all-subdir-makefiles) diff --git a/board_identity/include/omap4_board_identity.h b/board_identity/include/omap4_board_identity.h deleted file mode 100644 index bb37d49..0000000 --- a/board_identity/include/omap4_board_identity.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008 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 _OMAP4_BOARD_IDENTITY_H -#define _OMAP4_BOARD_IDENTITY_H - -#if __cplusplus -extern "C" { -#endif - -#define SOC_FAMILY 0 -#define SOC_REV 1 -#define SOC_TYPE 2 -#define SOC_MAX_FREQ 3 -#define APPS_BOARD_REV 4 -#define CPU_MAX_FREQ 5 -#define CPU_GOV 6 -#define LINUX_VERSION 7 -#define LINUX_PVR_VER 8 -#define LINUX_CMDLINE 9 -#define LINUX_CPU1_STAT 10 -#define LINUX_OFF_MODE 11 -#define WILINK_VERSION 12 -#define DPLL_TRIM 13 -#define RBB_TRIM 14 -#define PRODUCTION_ID 15 -#define DIE_ID 16 -#define MAX_FIELDS (DIE_ID + 1) - -#define PROP_DISPLAY_ID 0 -#define PROP_BUILD_TYPE 1 -#define PROP_SER_NO 2 -#define PROP_BOOTLOADER 3 -#define PROP_DEBUGGABLE 4 -#define PROP_CRYPTO_STATE 5 -#define MAX_PROP (PROP_CRYPTO_STATE + 1) - -#define GOV_STRING "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" -#define CPU1_ONLINE "/sys/devices/system/cpu/cpu1/online" -#define OFF_MODE "/sys/kernel/debug/pm_debug/enable_off_mode" -#define GOV_PERFORMANCE 0 -#define GOV_HOTPLUG 1 -#define GOV_ONDEMAND 2 -#define GOV_INTERACTIVE 3 -#define GOV_USERSPACE 4 -#define GOV_CONSERVATIVE 5 -#define GOV_POWERSAVE 6 -#define GOV_MAX 7 - -char* get_device_identity(int id_number); -char* get_device_property(int id_number); -int set_governor(int governor); -char* get_dpll_trim_val(void); -#if __cplusplus -} // extern "C" -#endif - -#endif // _OMAP4_BOARD_IDENTITY_H diff --git a/board_identity/src/Android.mk b/board_identity/src/Android.mk deleted file mode 100644 index 3629f10..0000000 --- a/board_identity/src/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright (C) 2011 The Android Open Source Project -# Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. -# -# 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. -# -ifeq ($(findstring omap, $(TARGET_BOARD_PLATFORM)),omap) -LOCAL_PATH := $(call my-dir) -include $(call all-makefiles-under,$(LOCAL_PATH)) -endif - diff --git a/board_identity/src/app/Android.mk b/board_identity/src/app/Android.mk deleted file mode 100644 index 0fa5dc9..0000000 --- a/board_identity/src/app/Android.mk +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (C) 2011 The Android Open Source Project -# Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. -# -# 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. -# - - -ifeq ($(findstring omap, $(TARGET_BOARD_PLATFORM)),omap) -ifeq ($(origin TARGET_BUILD_PDK),undefined) - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := optional -LOCAL_SHARED_LIBRARIES := libandroid_runtime -LOCAL_JAVA_LIBRARIES := framework -LOCAL_SRC_FILES := src/board_id/com/ti/Board_id_Activity.java \ - src/board_id/com/ti/BoardIDService.java \ - src/board_id/com/ti/IBoardIDService.aidl -LOCAL_PACKAGE_NAME := Board_id -LOCAL_CERTIFICATE := platform -LOCAL_SDK_VERSION := current -include $(BUILD_PACKAGE) - -include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := src/board_id/com/ti/BoardIDAgent.java \ - src/board_id/com/ti/IBoardIDService.aidl -LOCAL_MODULE := board_id.com.ti -LOCAL_JNI_SHARED_LIBRARIES := libboard_idJNI -LOCAL_CERTIFICATE := platform -LOCAL_SDK_VERSION := current -include $(BUILD_STATIC_JAVA_LIBRARY) - -endif -endif diff --git a/board_identity/src/app/AndroidManifest.xml b/board_identity/src/app/AndroidManifest.xml deleted file mode 100644 index fa04d6f..0000000 --- a/board_identity/src/app/AndroidManifest.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="board_id.com.ti" - android:versionCode="1" - android:versionName="1.0"> - <uses-sdk android:minSdkVersion="7" /> - - <application android:icon="@drawable/icon" android:label="@string/app_name"> - <activity android:name=".Board_id_Activity" - android:label="@string/app_name"> - <service android:name="board_id.com.ti.BoardIDService" - android:process=":BoardIDService"> - </service> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category - android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - </application> -</manifest> diff --git a/board_identity/src/app/proguard.cfg b/board_identity/src/app/proguard.cfg deleted file mode 100644 index b1cdf17..0000000 --- a/board_identity/src/app/proguard.cfg +++ /dev/null @@ -1,40 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native <methods>; -} - --keepclasseswithmembers class * { - public <init>(android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembers class * { - public <init>(android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/board_identity/src/app/res/drawable-hdpi/about.png b/board_identity/src/app/res/drawable-hdpi/about.png Binary files differdeleted file mode 100644 index 7c55dfd..0000000 --- a/board_identity/src/app/res/drawable-hdpi/about.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-hdpi/exit.png b/board_identity/src/app/res/drawable-hdpi/exit.png Binary files differdeleted file mode 100644 index 619858c..0000000 --- a/board_identity/src/app/res/drawable-hdpi/exit.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-hdpi/icon.png b/board_identity/src/app/res/drawable-hdpi/icon.png Binary files differdeleted file mode 100644 index a551e62..0000000 --- a/board_identity/src/app/res/drawable-hdpi/icon.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-ldpi/about.png b/board_identity/src/app/res/drawable-ldpi/about.png Binary files differdeleted file mode 100644 index 7c55dfd..0000000 --- a/board_identity/src/app/res/drawable-ldpi/about.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-ldpi/exit.png b/board_identity/src/app/res/drawable-ldpi/exit.png Binary files differdeleted file mode 100644 index 619858c..0000000 --- a/board_identity/src/app/res/drawable-ldpi/exit.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-ldpi/icon.png b/board_identity/src/app/res/drawable-ldpi/icon.png Binary files differdeleted file mode 100644 index a551e62..0000000 --- a/board_identity/src/app/res/drawable-ldpi/icon.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-mdpi/about.png b/board_identity/src/app/res/drawable-mdpi/about.png Binary files differdeleted file mode 100644 index 7c55dfd..0000000 --- a/board_identity/src/app/res/drawable-mdpi/about.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-mdpi/exit.png b/board_identity/src/app/res/drawable-mdpi/exit.png Binary files differdeleted file mode 100644 index 619858c..0000000 --- a/board_identity/src/app/res/drawable-mdpi/exit.png +++ /dev/null diff --git a/board_identity/src/app/res/drawable-mdpi/icon.png b/board_identity/src/app/res/drawable-mdpi/icon.png Binary files differdeleted file mode 100644 index a551e62..0000000 --- a/board_identity/src/app/res/drawable-mdpi/icon.png +++ /dev/null diff --git a/board_identity/src/app/res/layout/main.xml b/board_identity/src/app/res/layout/main.xml deleted file mode 100644 index 79789c8..0000000 --- a/board_identity/src/app/res/layout/main.xml +++ /dev/null @@ -1,203 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/scrllvwNo1" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - > - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:scrollbars="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:weightSum="1" - > - <TextView android:layout_width="wrap_content" - android:id="@+id/textView1" - android:textAppearance="?android:attr/textAppearanceLarge" - android:text="@string/dev_info_title" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/family" - android:text="@string/proc_family" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/type" - android:text="@string/proc_type" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/version" - android:text="@string/proc_version" - /> - <TextView - android:layout_width="wrap_content" - android:id="@+id/prod_id" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/prod_id_string" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="wrap_content" - android:id="@+id/die_id" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/die_id_string" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="wrap_content" - android:id="@+id/serial_no" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/ser_no" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/max_freq" - android:text="@string/proc_max_freq" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/rated_freq" - android:text="@string/proc_rated_freq" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/dpll_trim" - android:text="@string/dpll_trim_string" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/rbb_trim" - android:text="@string/rbb_trim_string" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/apps_brd_rev" - android:text="@string/apps_brd_rev" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/wilink_version" - android:text="@string/wilink_version" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/kernel_ver" - android:text="@string/kernel_version" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/pvr_version" - android:text="@string/pvr_string" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/cmd_line" - android:text="@string/cmd_line" - /> - <TextView android:id="@+id/blank_line_5" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="wrap_content" - android:id="@+id/textView1" - android:textAppearance="?android:attr/textAppearanceLarge" - android:text="@string/build_info_title" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="wrap_content" - android:id="@+id/boot_ver" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/bootloader_version" - android:layout_height="wrap_content"></TextView> - <TextView - android:layout_width="wrap_content" - android:id="@+id/build_ver" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/build_version" - android:layout_height="wrap_content"></TextView> - <TextView - android:layout_width="wrap_content" - android:id="@+id/board_ver" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/brd_rev" - android:layout_height="wrap_content"></TextView> - <TextView - android:layout_width="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/build_type" - android:text="@string/build_type_string" - android:layout_height="wrap_content"></TextView> - <TextView - android:layout_width="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/crypto_state" - android:text="@string/crypto_string" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_6" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:id="@+id/textView2" - android:text="@string/runtime_info_title" - android:layout_height="wrap_content"> - </TextView> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/cpu1_status" - android:text="@string/cpu1_string" - /> - <TextView - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:id="@+id/governor" - android:text="@string/curr_gov" - /> - <!-- Remove the button since we cannot write to the governor - <Button android:text="@string/gov_change_string" - android:id="@+id/gov_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </Button>--> - <TextView android:id="@+id/blank_line_7" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - </LinearLayout> -</ScrollView> diff --git a/board_identity/src/app/res/values/strings.xml b/board_identity/src/app/res/values/strings.xml deleted file mode 100644 index 6d376ac..0000000 --- a/board_identity/src/app/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="board_id_header">TI Board ID Application</string> - <string name="app_name">TI Board ID App</string> - <string name="build_info_title">Build Informaion </string> - <string name="dev_info_title">Device Information </string> - <string name="runtime_info_title">Runtime Information</string> - <string name="proc_family">Processor Family = </string> - <string name="proc_type">Processor Type = </string> - <string name="proc_version">Processor Version = </string> - <string name="proc_max_freq">Maximum Freq = </string> - <string name="proc_rated_freq">Rated Frequency = </string> - <string name="apps_brd_rev">Apps Board Rev = </string> - <string name="cmd_line">Command Line = </string> - <string name="kernel_version">Kernel Version = </string> - <string name="curr_gov">Current Governor = </string> - <string name="bootloader_version">Bootloader Version = </string> - <string name="build_version">Bu‎ild Version = </string> - <string name="brd_rev">Board Revision = </string> - <string name="ser_no">Serial Number = </string> - <string name="build_type_string">Build Type = </string> - <string name="crypto_string">Crypto State = </string> - <string name="pvr_string">PVR/SGX Version = </string> - <string name="gov_change_string">Change Governor</string> - <string name="cpu1_string">CPU1 Status = </string> - <string name="wilink_version">WiLink Version = </string> - <string name="dpll_trim_string">DPLL Trimmed = </string> - <string name="rbb_trim_string">RBB Trimmed = </string> - <string name="prod_id_string">Production ID = </string> - <string name="die_id_string">Die ID = </string> -</resources> diff --git a/board_identity/src/app/src/board_id/com/ti/BoardIDAgent.java b/board_identity/src/app/src/board_id/com/ti/BoardIDAgent.java deleted file mode 100644 index e761c5a..0000000 --- a/board_identity/src/app/src/board_id/com/ti/BoardIDAgent.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. - * - * 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 board_id.com.ti; - -import android.app.Activity; -import android.util.Log; - -import android.content.Context; -import android.os.IBinder; -import android.os.Message; -import android.os.RemoteException; -import android.content.ComponentName; -import android.content.Intent; -import android.content.ServiceConnection; - -/** -* @brief -* BoardIDAgent is the main entry point to the BoardIDDaemon -* -*/ -public class BoardIDAgent implements ServiceConnection { - - private static final String TAG = "BoardIDAgent"; - private IBinder mServiceToken; - private IBoardIDService mService; - private static Context mContext; - private boolean mConnected; - private static BoardIDAgentConnection mClient; - - /** - * Constructor[s] - */ - public BoardIDAgent(Context context, BoardIDAgentConnection client) { - mContext = context; - mClient = client; - mService = null; - mServiceToken = null; - mConnected = false; - } - - /** - * - * Creates a connection to the BoardIDService. - * (System call by Android! no direct invocation) - * - */ - public void onServiceConnected(ComponentName className, IBinder service) { - synchronized( this ) { - mService = IBoardIDService.Stub.asInterface((IBinder)service); - mServiceToken = (IBinder)service; - mConnected = true; - if (mClient != null) - mClient.onAgentConnected(); - } - } - - /** - * - * Releases the connection to the BoardIDDaemon. - * (System call by Android! no direct invocation) - * - */ - public void onServiceDisconnected(ComponentName className) { - synchronized( this ) { - mClient.onAgentDisconnected(); - mService = null; - mServiceToken = null; - mConnected = false; - } - } - - /** Creates a connection to the BoardIDDaemon. */ - public void Connect() { - synchronized( this ) { - if (!mConnected) { - Intent intent = new Intent("board_id.com.ti.IBoardIDService"); - if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) { - Log.e(TAG, " Failed to launch intent connecting to IBoardIDService"); - } else { - mConnected = true; - Log.e(TAG, " Connect():: TRUELY connected!"); - } - } - else - { - Log.d(TAG, "Already connected!"); - } - } - } - - /** - * - * Releases the connection to the BoardIDDaemon. - * - */ - public void Disconnect() { - synchronized (this) { - if (mConnected) { - try { - mContext.unbindService(this); - } catch (IllegalArgumentException ex) { - Log.v(TAG, " Could not disconnect from service: "+ex.toString()); - } - mConnected = false; - } else { - Log.d(TAG, "Already disconnected!"); - } - } - } - - /** - * - * Returns whether we are connected to the BoardIDDaemon service - * @return true if we are connected, false otherwise - */ - public synchronized boolean isConnected() { - return (mConnected); - } - - /** - * Defines a power state for the USP's current profile. - * - * @param state - power state to configure USP with - */ - public int GetBoardProp(int value) - { - int ret = 0; - - if (mService != null) { - try { - mService.GetBoardProp(value); - } catch (RemoteException e) { - Log.e(TAG, " Remote call exception: " + e.toString()); - } catch (NullPointerException e2) { - Log.e(TAG, " Null pointer exception: "+ e2.toString()); - } - } - return ret; - } - - public int GetProperty(int value) - { - int ret = 0; - - if (mService != null) { - try { - mService.GetProperty(value); - } catch (RemoteException e) { - Log.e(TAG, " Remote call exception: " + e.toString()); - } catch (NullPointerException e2) { - Log.e(TAG, " Null pointer exception: "+ e2.toString()); - } - } - return ret; - } - - public int SetGovernor(int value) - { - int ret = 0; - - if (mService != null) { - try { - ret = mService.SetGovernor(value); - } catch (RemoteException e) { - Log.e(TAG, " Remote call exception: " + e.toString()); - } catch (NullPointerException e2) { - Log.e(TAG, " Null pointer exception: "+ e2.toString()); - } - } - return ret; - } - - //************************************************************************** - // INTERFACES - //************************************************************************** - - /** - * - * A callback interface that allows the applications (clients - * of the BoardIDAgent) to operate on the BoardID Service, i.e. - * connect to / disconnect from it. - * - */ - public interface BoardIDAgentConnection { - - /** Called when the BoardIDAgent connects to the BoardIDService */ - public void onAgentConnected(); - - /** Called when the BoardIDDaemon changes the Power State */ - public void onPowerStateChange(int newState); - - /** Called when the BoardIDAgent disconnects from the BoardIDService */ - public void onAgentDisconnected(); - } -} - diff --git a/board_identity/src/app/src/board_id/com/ti/BoardIDService.java b/board_identity/src/app/src/board_id/com/ti/BoardIDService.java deleted file mode 100644 index 6c82f65..0000000 --- a/board_identity/src/app/src/board_id/com/ti/BoardIDService.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. - * - * 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 board_id.com.ti; - -import android.app.PendingIntent; -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.content.res.Configuration; -import android.os.Bundle; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.os.PowerManager; -import android.os.RemoteException; -import android.util.Log; - -public class BoardIDService extends Service { - - private static final String TAG = "BoardIDService"; - public static final int SOC_FAMILY = 0; - public static final int SOC_REV = 1; - public static final int SOC_TYPE = 2; - public static final int SOC_MAX_FREQ = 3; - public static final int APPS_BOARD_REV = 4; - public static final int CPU_MAX_FREQ = 5; - public static final int CPU_GOV = 6; - public static final int LINUX_VERSION = 7; - public static final int LINUX_PVR_VER = 8; - public static final int LINUX_CMDLINE = 9; - public static final int LINUX_CPU1_STAT = 10; - public static final int LINUX_OFF_MODE = 11; - public static final int WILINK_VERSION = 12; - public static final int DPLL_TRIM = 13; - public static final int RBB_TRIM = 14; - public static final int PRODUCTION_ID = 15; - public static final int DIE_ID = 16; - - public static final int PROP_DISPLAY_ID = 0; - public static final int PROP_BUILD_TYPE = 1; - public static final int PROP_SER_NO = 2; - public static final int PROP_BOOTLOADER = 3; - public static final int PROP_DEBUGGABLE = 4; - public static final int PROP_CRYPTO_STATE = 5; - - // Reference to the system power manager - protected PowerManager pm; - - // Used to control the service's wakelock - protected PowerManager.WakeLock serviceWakeLock; - - // Constructor method which sets up any needed initializations. - public BoardIDService() { - super(); - } - - // Overrides the Service class's standard method. It loads the ThermalObserver - @Override - public void onCreate() { - - //Log.d(TAG,"+BoardIDService.onCreate loading JNI"); - System.load("/system/lib/libboard_idJNI.so"); - // Let's {responsibly} control the power state - pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - // get a wake lock when we start - serviceWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); - } - - @Override - public IBinder onBind(Intent intent) { - Log.d(TAG,"+BoardIDService.onBind()"); - if (IBoardIDService.class.getName().equals(intent.getAction())) { - return mBinder; - } else { - return null; - } - } - - @Override - public boolean onUnbind(Intent intent) { - //Log.d(TAG,"+BoardIDService.onUnbind()"); - if (IBoardIDService.class.getName().equals(intent.getAction())) { - return super.onUnbind(intent); - } else { - return false; - } - } - - @Override - public void onRebind(Intent intent) { - //Log.d(TAG,"+BoardIDService.onRebind()"); - if (IBoardIDService.class.getName().equals(intent.getAction())) { - super.onRebind(intent); - } - } - - @Override - public void onDestroy() { - return; - } - - public String GetBoardProp(int value) { - //Log.d(TAG,"+BoardIDService.onCreate loading JNI"); - System.load("/system/lib/libboard_idJNI.so"); - return getBoardIDsysfsNative(value); - } - - public String GetProperty(int value) { - //Log.d(TAG,"+BoardIDService.onCreate loading JNI"); - System.load("/system/lib/libboard_idJNI.so"); - return getBoardIDpropNative(value); - } - - public int SetGovernor(int value) { - //Log.d(TAG,"+BoardIDService.onCreate loading JNI"); - System.load("/system/lib/libboard_idJNI.so"); - return setGovernorNative(value); - } - - private native String getBoardIDsysfsNative(int value); - private native String getBoardIDpropNative(int value); - private native int setGovernorNative(int value); - - //************************************************************************** - // PRIVATE - //************************************************************************** - - /** Defines our local RPC instance object which clients use to communicate with us. */ - private final IBoardIDService.Stub mBinder = new IBoardIDService.Stub() { - public String GetBoardProp(int value) { - return "Not Avaialble"; - } - public String GetProperty(int value) { - return "Not Avaialble"; - } - public int SetGovernor(int value) { - return -1; - } - }; - -} - diff --git a/board_identity/src/app/src/board_id/com/ti/Board_id_Activity.java b/board_identity/src/app/src/board_id/com/ti/Board_id_Activity.java deleted file mode 100644 index deadab9..0000000 --- a/board_identity/src/app/src/board_id/com/ti/Board_id_Activity.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Android Board Identification Application - * - * Copyright 2011 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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 board_id.com.ti; - -import board_id.com.ti.BoardIDService; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.*; -import android.provider.Settings; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.TextView; - -public class Board_id_Activity extends Activity { - /** Called when the activity is first created. */ - private static final String TAG = "BoardIDActivity"; - private static final String VER_NUM = "1.0"; - public BoardIDService IDService = null; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - //registerForContextMenu(findViewById(R.id.gov_button)); - - IDService = new BoardIDService(); - - this.get_sysfs_props(); - this.set_build_props(); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - int groupId = 0; - int menuItemOrder = Menu.NONE; - - MenuItem quitmenuItem = menu.add(groupId, 0, menuItemOrder, "Quit"); - quitmenuItem.setIcon(R.drawable.exit); - MenuItem aboutmenuItem = menu.add(groupId, 1, menuItemOrder, "About This Application"); - aboutmenuItem.setIcon(R.drawable.about); - - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle item selection - switch (item.getItemId()) { - //Quit - case 0: - this.onStop(); - finish(); - break; - //Help - case 1: - AlertDialog.Builder helpbox = new AlertDialog.Builder(this); - helpbox.setMessage("Texas Instruments Board Identification Application Version: " + VER_NUM); - helpbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface arg0, int arg1) { - // Do nothing as there is nothing to do - } - }); - helpbox.show(); - return true; - default: - return super.onOptionsItemSelected(item); - } - return true; - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - TextView gov_val, cpu1_stat_val; - boolean err = false; - String test = new String(); - String cpu = new String(); - - if (IDService == null) - IDService = new BoardIDService(); - - Log.d(TAG, "Got id " + item.getItemId()); - IDService.SetGovernor(item.getItemId()); - - test = IDService.GetBoardProp(BoardIDService.CPU_GOV); - gov_val = (TextView) findViewById(R.id.governor); - gov_val.setText(R.string.curr_gov); - gov_val.setText(gov_val.getText() + " " + test); - - cpu = IDService.GetBoardProp(BoardIDService.LINUX_CPU1_STAT); - cpu1_stat_val = (TextView) findViewById(R.id.cpu1_status); - cpu1_stat_val.setText(R.string.cpu1_string); - cpu1_stat_val.setText(cpu1_stat_val.getText() + " " + cpu); - - return true; - } - - @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { - - super.onCreateContextMenu(menu, v, menuInfo); - menu.add(0, 0, 0, "Performance"); - menu.add(0, 1, 0, "Hotplug"); - menu.add(0, 2, 0, "Ondemand"); - menu.add(0, 3, 0, "Interactive"); - menu.add(0, 4, 0, "Userspace"); - menu.add(0, 5, 0, "Conservative"); - menu.add(0, 6, 0, "Powersave"); - } - - private void get_sysfs_props() { - TextView max_freq_val, rated_freq_val, cmd_line_val, kernel_ver_val; - TextView family_val, type_val, ver_val, gov_val, apps_val, pvr_val; - TextView cpu1_stat_val, wl_ver_val, dpll_trim_val, rbb_trim_val; - TextView prod_id_val, die_id_val; - String test = new String(); - - if (this.IDService == null) - IDService = new BoardIDService(); - - test = IDService.GetBoardProp(BoardIDService.SOC_FAMILY); - - family_val = (TextView) findViewById(R.id.family); - family_val.setText(family_val.getText() + " " +test); - - test = IDService.GetBoardProp(BoardIDService.SOC_REV); - type_val = (TextView) findViewById(R.id.type); - type_val.setText(type_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.SOC_TYPE); - ver_val = (TextView) findViewById(R.id.version); - ver_val.setText(ver_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.SOC_MAX_FREQ); - max_freq_val = (TextView) findViewById(R.id.max_freq); - max_freq_val.setText(max_freq_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.APPS_BOARD_REV); - apps_val = (TextView) findViewById(R.id.apps_brd_rev); - apps_val.setText(apps_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.CPU_MAX_FREQ); - rated_freq_val = (TextView) findViewById(R.id.rated_freq); - rated_freq_val.setText(rated_freq_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.CPU_GOV); - gov_val = (TextView) findViewById(R.id.governor); - gov_val.setText(gov_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.LINUX_VERSION); - kernel_ver_val = (TextView) findViewById(R.id.kernel_ver); - kernel_ver_val.setText(kernel_ver_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.LINUX_PVR_VER); - pvr_val = (TextView) findViewById(R.id.pvr_version); - pvr_val.setText(pvr_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.LINUX_CMDLINE); - cmd_line_val = (TextView) findViewById(R.id.cmd_line); - cmd_line_val.setText(cmd_line_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.LINUX_CPU1_STAT ); - cpu1_stat_val = (TextView) findViewById(R.id.cpu1_status); - cpu1_stat_val.setText(cpu1_stat_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.WILINK_VERSION ); - wl_ver_val = (TextView) findViewById(R.id.wilink_version); - wl_ver_val.setText(wl_ver_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.DPLL_TRIM ); - dpll_trim_val = (TextView) findViewById(R.id.dpll_trim); - dpll_trim_val.setText(dpll_trim_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.RBB_TRIM ); - rbb_trim_val = (TextView) findViewById(R.id.rbb_trim); - rbb_trim_val.setText(rbb_trim_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.PRODUCTION_ID ); - prod_id_val = (TextView) findViewById(R.id.prod_id); - prod_id_val.setText(prod_id_val.getText() + " " + test); - - test = IDService.GetBoardProp(BoardIDService.DIE_ID ); - die_id_val = (TextView) findViewById(R.id.die_id); - die_id_val.setText(die_id_val.getText() + " " + test); - - } - private void set_build_props() { - final TextView bootloader_ver, db_number, serial_no, board_info; - final TextView debug_prop, build_val, crypto_val; - String serial = Build.SERIAL; - String boot_ver = Build.BOOTLOADER; - String build_id = Build.DISPLAY; - String board_id = Build.BOARD; - String test = new String(); - - if (IDService == null) - IDService = new BoardIDService(); - - test = IDService.GetProperty(1); - build_val = (TextView) findViewById(R.id.build_type); - build_val.setText(build_val.getText() + " " + test); - - IDService = new BoardIDService(); - test = IDService.GetProperty(5); - crypto_val = (TextView) findViewById(R.id.crypto_state); - crypto_val.setText(crypto_val.getText() + " " + test); - - serial_no = (TextView) findViewById(R.id.serial_no); - if (serial != null && !serial.equals("")) { - serial_no.setText(serial_no.getText() + " " + serial); - } else { - serial_no.setText(serial_no.getText() + "Not Avaiable"); - } - - bootloader_ver = (TextView) findViewById(R.id.boot_ver); - if (boot_ver != null && !boot_ver.equals("")) { - bootloader_ver.setText(bootloader_ver.getText() + " " + boot_ver); - } else { - bootloader_ver.setText(bootloader_ver.getText() + "Not Avaiable"); - } - - db_number = (TextView) findViewById(R.id.build_ver); - if (build_id != null && !build_id.equals("")) { - db_number.setText(db_number.getText() + " " + build_id); - } else { - db_number.setText(db_number.getText() + "Not Avaiable"); - } - - board_info = (TextView) findViewById(R.id.board_ver); - if (board_id != null && !board_id.equals("")) { - board_info.setText(board_info.getText() + " " + board_id); - } else { - board_info.setText(board_info.getText() + "Not Avaiable"); - } - } -} diff --git a/board_identity/src/app/src/board_id/com/ti/IBoardIDService.aidl b/board_identity/src/app/src/board_id/com/ti/IBoardIDService.aidl deleted file mode 100644 index 2c51402..0000000 --- a/board_identity/src/app/src/board_id/com/ti/IBoardIDService.aidl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. - * - * 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 board_id.com.ti; - -interface IBoardIDService { - String GetBoardProp(int value); - String GetProperty(int value); - int SetGovernor(int value); -} diff --git a/board_identity/src/daemon/Android.mk b/board_identity/src/daemon/Android.mk deleted file mode 100644 index a4c6e5d..0000000 --- a/board_identity/src/daemon/Android.mk +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (C) 2011 The Android Open Source Project -# Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. -# -# 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. -# - -#Binary form -ifeq ($(findstring omap, $(TARGET_BOARD_PLATFORM)),omap) -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_ARM_MODE := arm -LOCAL_SRC_FILES := \ - Identity_daemon.c -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../inc \ - $(LOCAL_PATH) -LOCAL_SHARED_LIBRARIES := libcutils \ - liblog - -LOCAL_CFLAGS := -DPRINT_ONLY - -LOCAL_MODULE := boardidentity -LOCAL_MODULE_TAGS := optional - -include $(BUILD_EXECUTABLE) - - -# Library form -include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := libboardidentity -LOCAL_PRELINK_MODULE := false -LOCAL_SHARED_LIBRARIES := libcutils \ - liblog - -LOCAL_SRC_FILES := \ - Identity_daemon.c - -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) -endif diff --git a/board_identity/src/daemon/Identity_daemon.c b/board_identity/src/daemon/Identity_daemon.c deleted file mode 100644 index 03c39f6..0000000 --- a/board_identity/src/daemon/Identity_daemon.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Identity Daemon - * - * Copyright (C) 2011 Texas Instruments, Inc. - * - * Dan Murphy (dmurphy@ti.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the dual BSD / GNU General Public License version 2 as - * published by the Free Software Foundation. When using or - * redistributing this file, you may do so under either license. - */ - -/* OS-specific headers */ -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <errno.h> -#include <pthread.h> -#include <dirent.h> -#include <ctype.h> - -#include <utils/Log.h> -#include <cutils/properties.h> - -#include "../../include/omap4_board_identity.h" - -#if defined (__cplusplus) -extern "C" { -#endif /* defined (__cplusplus) */ - -#define ID_DEBUG 1 - -struct id_data_sysfs { - int info_id; - const char *name; - const char *sysfs_node; -} id_sysfs[] = { - { SOC_FAMILY, "OMAP Family ", "/sys/board_properties/soc/family"}, - { SOC_REV, "OMAP Type ", "/sys/board_properties/soc/type"}, - { SOC_TYPE, "OMAP Rev ", "/sys/board_properties/soc/revision"}, - { SOC_MAX_FREQ, "Rated Freq ", "/sys/board_properties/soc/max_freq"}, - { APPS_BOARD_REV, "Apps Board Rev ", "/sys/board_properties/board/board_rev"}, - { CPU_MAX_FREQ, "Max Freq ", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"}, - { CPU_GOV, "Scaling Gov ", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"}, - { LINUX_VERSION, "Linux version ", "/proc/version"}, - { LINUX_CMDLINE, "cmdline ", "/proc/pvr/version"}, - { LINUX_CMDLINE, "cmdline ", "/proc/cmdline"}, - { LINUX_CPU1_STAT, "CPU1 Status ", CPU1_ONLINE}, - { LINUX_OFF_MODE, "Off Mode ", OFF_MODE}, - { WILINK_VERSION, "WiLink version ", "/sys/kernel/debug/ti-st/version"}, - { DPLL_TRIM, "DPLL Trimmed ", "/sys/board_properties/soc/dpll_trimmed"}, - { RBB_TRIM, "DPLL Trimmed ", "/sys/board_properties/soc/rbb_trimmed"}, - { PRODUCTION_ID, "Production ID ", "/sys/board_properties/soc/production_id"}, - { DIE_ID, "Die ID ", "/sys/board_properties/soc/die_id"}, -}; - -struct id_data_prop { - int info_id; - const char *name; - const char *prop_node; -} id_prop[] = { - { PROP_DISPLAY_ID, "Build ID ", "ro.build.display.id"}, - { PROP_BUILD_TYPE, "Build Type ", "ro.build.type"}, - { PROP_SER_NO, "Serial Number ", "ro.serialno"}, - { PROP_BOOTLOADER, "Bootloader ", "ro.bootloader"}, - { PROP_DEBUGGABLE, "Debug ", "ro.debuggable"}, - { PROP_CRYPTO_STATE, "Crypto State ", "ro.crypto.state"}, -}; - -struct gov_data { - int gov_id; - const char *name; -} gov_info[] = { - { GOV_PERFORMANCE, "performance"}, - { GOV_HOTPLUG, "hotplug"}, - { GOV_ONDEMAND, "ondemand "}, - { GOV_INTERACTIVE, "interactive"}, - { GOV_USERSPACE, "userspace"}, - { GOV_CONSERVATIVE, "conservative"}, - { GOV_POWERSAVE, "powersave"}, -}; - -char* get_device_identity(int id_number) -{ - char buffer[1024] = {0}; - char* buf; - int bytes_read = 13; - int sys_fd = -1; - - if (id_number > MAX_FIELDS) { - buf = (char *)calloc(1, bytes_read); - strcpy(buffer, "Not Avaiable"); - goto out; - } - - ALOGD("Reading %i %s\n", id_number, id_sysfs[id_number].sysfs_node); - sys_fd = open(id_sysfs[id_number].sysfs_node, O_RDONLY); - if (sys_fd >= 0) { - bytes_read = read(sys_fd, buffer, 1024); - buf = (char *)calloc(1, bytes_read); - ALOGD("%s = %s", id_sysfs[id_number].name, buffer); - close(sys_fd); - sys_fd = -1; - } else { - ALOGD("%s = %s", id_sysfs[id_number].name, "Not Avaialble"); - buf = (char *)calloc(1, bytes_read); - strcpy(buffer, "Not Avaiable"); - } - -out: - memcpy(buf, buffer, bytes_read - 1); - return buf; -} - -char* get_device_property(int id_number) -{ - char prop_return[1024] = {0}; - int bytes_read = 0; - - if (id_number > MAX_PROP) - goto out; - - bytes_read = property_get(id_prop[id_number].prop_node, prop_return, "unknown"); - ALOGD("%s = %s", id_prop[id_number].name, prop_return); - -out: - return prop_return; -} - -int set_governor(int governor) -{ - int ret = 0; - int sys_fd = -1; - int value = 1; - - if (governor > GOV_MAX) - goto out; - - sys_fd = open(GOV_STRING, O_RDWR); - if (sys_fd >= 0) { - ALOGD("Setting %s\n", gov_info[governor].name); - ret = write(sys_fd, gov_info[governor].name, 12); - if (ret < 0) - ALOGD("ERRNO %i\n", errno); - ALOGD("Returning %i\n", ret); - close(sys_fd); - if (governor != GOV_HOTPLUG) { - char buffer[20]; - sys_fd = open(CPU1_ONLINE, O_RDWR); - ALOGD("Setting CPU1 Online\n"); - int bytes = sprintf(buffer, "%d\n", value); - ret = write(sys_fd, buffer, bytes); - if (ret < 0) - ALOGD("ERRNO %i\n", errno); - ALOGD("Returning %i\n", ret); - close(sys_fd); - } - return ret; - } else { - ALOGD("Cannot open %s\n", GOV_STRING); - } - -out: - return -1; -} - -int set_off_mode(int off_mode) -{ - int ret = 0; - int sys_fd = -1; - - if (off_mode > 1) - off_mode = 1; - - sys_fd = open(OFF_MODE, O_RDWR); - if (sys_fd >= 0) { - char buffer[20]; - ALOGD("Setting %i\n", off_mode); - int bytes = sprintf(buffer, "%d\n", off_mode); - ret = write(sys_fd, buffer, bytes); - if (ret < 0) - ALOGD("ERRNO %i\n", errno); - ALOGD("Returning %i\n", ret); - close(sys_fd); - return ret; - } else { - ALOGD("Cannot open %s\n", OFF_MODE); - } - -out: - return -1; -} - -ssize_t print_prop_identity(int id_number) -{ - char prop_return[1024] = {0}; - - if (id_number > MAX_PROP) - goto out; - - property_get(id_prop[id_number].prop_node, prop_return, "unknown"); - - ALOGD("%s = %s", id_prop[id_number].name, prop_return); -out: - return 0; -} - -ssize_t print_sysfs_identity(int id_number) -{ - char buffer[1024] = {0}; - int bytes_read = 0; - int sys_fd = -1; - - if (id_number > MAX_FIELDS) - goto out; - - sys_fd = open(id_sysfs[id_number].sysfs_node, O_RDONLY); - if (sys_fd >= 0) { - bytes_read = read(sys_fd, buffer, 1024); - ALOGD("%s = %s", id_sysfs[id_number].name, buffer); - close(sys_fd); - sys_fd = -1; - } else { - ALOGD("%s = %s", id_sysfs[id_number].name, "Not Avaialble"); - strcpy(buffer, "Not Avaiable"); - } - -out: - return 0; -} - -int main(int argc, char * argv []) -{ - int bytes_read = 0; - int sys_fd = -1; - int i = 0; - int sysfs_count = MAX_FIELDS; - -#if PRINT_ONLY - for (i = 0; i < MAX_FIELDS; i++) { - print_sysfs_identity(i); - } - - for (i = 0; i < MAX_PROP; i++) { - print_prop_identity(i); - } - -#else - ALOGD(" I got nothing"); -#endif - return 0; -} - - -#if defined (__cplusplus) -} -#endif /* defined (__cplusplus) */ diff --git a/board_identity/src/jni/Android.mk b/board_identity/src/jni/Android.mk deleted file mode 100644 index a553dbd..0000000 --- a/board_identity/src/jni/Android.mk +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright (C) 2011 The Android Open Source Project -# Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. -# -# 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. -# - -LOCAL_PATH := $(call my-dir) - -ifeq ($(origin TARGET_BUILD_PDK),undefined) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - com_ti_boardid_BoardID_JNI.cpp - -LOCAL_C_INCLUDES := $(TOP)/include -LOCAL_C_INCLUDES += \ - $(JNI_H_INCLUDE) -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE_TAGS := optional -LOCAL_SHARED_LIBRARIES := \ - libandroid_runtime \ - libcutils \ - libnativehelper \ - libsystem_server \ - libutils \ - libui \ - libboardidentity - -ifeq ($(TARGET_SIMULATOR),true) -ifeq ($(TARGET_OS),linux) -ifeq ($(TARGET_ARCH),x86) -LOCAL_LDLIBS += -lpthread -ldl -lrt -endif -endif -endif - -ifeq ($(WITH_MALLOC_LEAK_CHECK),true) - LOCAL_CFLAGS += -DMALLOC_LEAK_CHECK -endif - -LOCAL_MODULE := libboard_idJNI - -include $(BUILD_SHARED_LIBRARY) -endif diff --git a/board_identity/src/jni/com_ti_boardid_BoardID_JNI.cpp b/board_identity/src/jni/com_ti_boardid_BoardID_JNI.cpp deleted file mode 100644 index c5c6b80..0000000 --- a/board_identity/src/jni/com_ti_boardid_BoardID_JNI.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * Copyright (C) 2010-2012 Texas Instruments, Inc. All rights reserved. - * - * 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. - */ - -#define LOG_TAG "Board_ID" - -#include "jni.h" -#include "JNIHelp.h" -#include "android_runtime/AndroidRuntime.h" - -#include <utils/misc.h> -#include <utils/Log.h> -#include "../../include/omap4_board_identity.h" - -#include <stdio.h> - -namespace android -{ - static jstring getBoardID_sysfs(JNIEnv *env __attribute__ ((unused)), - jobject clazz __attribute__ ((unused)), - jint id_to_get) - { - int data_size = 0; - char* data_ret; - - ALOGI("Getting the ID %i\n", id_to_get); - data_ret = get_device_identity(id_to_get); - jstring jdata_ret = env->NewStringUTF(data_ret); - return jdata_ret; - } - static jstring getBoardID_prop(JNIEnv *env __attribute__ ((unused)), - jobject clazz __attribute__ ((unused)), - jint id_to_get) - { - int data_size = 0; - char* data_ret; - - ALOGI("Getting the ID %i\n", id_to_get); - data_ret = get_device_property(id_to_get); - jstring jdata_ret = env->NewStringUTF(data_ret); - return jdata_ret; - } - - static jint setGov(JNIEnv *env __attribute__ ((unused)), - jobject clazz __attribute__ ((unused)), - jint gov_to_set) - { - int data_ret; - - ALOGI("Getting the ID %i\n", gov_to_set); - data_ret = set_governor(gov_to_set); - return data_ret; - } - - static JNINativeMethod method_table[] = { - { "getBoardIDsysfsNative", "(I)Ljava/lang/String;", (void*)getBoardID_sysfs }, - { "getBoardIDpropNative", "(I)Ljava/lang/String;", (void*)getBoardID_prop }, - { "setGovernorNative", "(I)I", (void*)setGov }, - }; - - int register_Board_ID_Service(JNIEnv *env) - { - return jniRegisterNativeMethods(env, "board_id/com/ti/BoardIDService", - method_table, NELEM(method_table)); - } - -}; - -using namespace android; -extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) -{ - JNIEnv* env = NULL; - jint result = -1; - - if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { - ALOGE("GetEnv failed!"); - return result; - } - ALOG_ASSERT(env, "Could not retrieve the env!"); - - register_Board_ID_Service(env); - - return JNI_VERSION_1_4; -} diff --git a/cpcam/Android.mk b/cpcam/Android.mk deleted file mode 100644 index 1ce211a..0000000 --- a/cpcam/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# -ifeq ($(OMAP_ENHANCEMENT_CPCAM), true) - include_cpcam_makefiles = yes -endif - -ifdef include_cpcam_makefiles -include $(call all-subdir-makefiles) -endif diff --git a/cpcam/cpcam-products.mk b/cpcam/cpcam-products.mk deleted file mode 100644 index ef03dba..0000000 --- a/cpcam/cpcam-products.mk +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# - -PRODUCT_PACKAGES += \ - com.ti.omap.android.cpcam \ - libcpcam_jni - -PRODUCT_COPY_FILES := \ - hardware/ti/omap4xxx/cpcam/com.ti.omap.android.cpcam.xml:system/etc/permissions/com.ti.omap.android.cpcam.xml diff --git a/cpcam/products/AndroidProducts.mk b/cpcam/products/AndroidProducts.mk deleted file mode 100644 index c6a3970..0000000 --- a/cpcam/products/AndroidProducts.mk +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# -# This file should set PRODUCT_MAKEFILES to a list of product makefiles -# to expose to the build system. LOCAL_DIR will already be set to -# the directory containing this file. -# -# This file may not rely on the value of any variable other than -# LOCAL_DIR; do not use any conditionals, and do not look up the -# value of any variable that isn't set in this file or in a file that -# it includes. -# - -PRODUCT_MAKEFILES := \ - $(LOCAL_DIR)/cpcam_sdk_addon.mk diff --git a/cpcam/products/cpcam_sdk_addon.mk b/cpcam/products/cpcam_sdk_addon.mk deleted file mode 100644 index fc6132c..0000000 --- a/cpcam/products/cpcam_sdk_addon.mk +++ /dev/null @@ -1,50 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# - -# List of apps and optional libraries (Java and native) to put in the add-on system image. -PRODUCT_PACKAGES := \ - com.ti.omap.android.cpcam \ - libcpcam_jni - -# Manually copy the optional library XML files in the system image. -PRODUCT_COPY_FILES := \ - hardware/ti/omap4xxx/cpcam/com.ti.omap.android.cpcam.xml:system/etc/permissions/com.ti.omap.android.cpcam.xml - -# name of the add-on -PRODUCT_SDK_ADDON_NAME := cpcam - -# Copy the manifest and hardware files for the SDK add-on. -# The content of those files is manually created for now. -PRODUCT_SDK_ADDON_COPY_FILES := \ - device/ti/common-open/cpcam/sdk_addon/manifest.ini:manifest.ini \ - device/ti/common-open/cpcam/sdk_addon/hardware.ini:hardware.ini \ - $(call find-copy-subdir-files,*,device/sample/skins/WVGAMedDpi,skins/WVGAMedDpi) - -# Copy the jar files for the optional libraries that are exposed as APIs. -PRODUCT_SDK_ADDON_COPY_MODULES := \ - com.ti.omap.android.cpcam:libs/cpcam.jar - -PRODUCT_SDK_ADDON_STUB_DEFS += \ - device/ti/common-open/cpcam/products/stub_defs.txt - -PRODUCT_SDK_ADDON_DOC_MODULES := cpcam - -# This add-on extends the default sdk product. -$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk) - -# Real name of the add-on. This is the name used to build the add-on. -# Use 'make PRODUCT-cpcam-sdk_addon' to build the add-on. -PRODUCT_NAME := cpcam diff --git a/cpcam/products/stub_defs.txt b/cpcam/products/stub_defs.txt deleted file mode 100644 index 7e13249..0000000 --- a/cpcam/products/stub_defs.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# - - -+com.ti.omap.android.cpcam.* diff --git a/cpcam/sdk_addon/hardware.ini b/cpcam/sdk_addon/hardware.ini deleted file mode 100644 index 36e18bb..0000000 --- a/cpcam/sdk_addon/hardware.ini +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# - -# Custom hardware options for the add-on. -# Properties defined here impact all AVD targetting this add-on. -# Each skin can also override those values with its own hardware.ini file. diff --git a/cpcam/sdk_addon/manifest.ini b/cpcam/sdk_addon/manifest.ini deleted file mode 100644 index 9222efc..0000000 --- a/cpcam/sdk_addon/manifest.ini +++ /dev/null @@ -1,61 +0,0 @@ -# -# Copyright (C) 2012 Texas Instruments -# -# 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. -# - - -# SDK Add-on Manifest -# File encoding is UTF-8 - -# Name and vendor of the add-on. -# Add-ons are uniquely identified by a string composed of name, vendor and api. -# 2 add-ons with the same identifier cannot be installed in the same SDK -# and only the add-on with the highest rev number will be installed. -# Name and vendor are used to create folder names, so they shouldn't contain -# any special characters. Also, the character ':' is forbidden. -# Mandatory character set: a-z A-Z 0-9 _.- -name=TI OMAP Add-On -vendor=Texas Instruments Inc -description=Android extensions for TI OMAP platform - -# version of the Android platform on which this add-on is built. -api=15 - -# revision of the add-on. This must be a strict integer. -revision=1 - -# list of libraries, separated by a semi-colon. -# This must be the name of the libraries, as required by the -# <uses-library> node in the AndroidManifest.xml file. -libraries=com.ti.omap.android.cpcam - -# details for each library. format is: -# <library.name>=<name>.jar;<desc> -# where -# <library.name>: the name of the library defined in the property "libraries" above. -# <name>.jar: the jar file containing the library API. This is to be located in -# the add-on folder in libs/ -com.ti.omap.android.cpcam=cpcam.jar;TI OMAP plaform library - -# default skin name. Optional. Only useful if the add-on has its own skin, or -# if it wishes to override the default skin of the base platform. -# This should be the name of the skin in the skins/ folder of the add-on. -skin=WVGAMedDpi - -# USB Vendor ID -# This 16-bit integer allows adb to detect new devices, by extending the list -# of USB Vendor IDs it knows. After installing an add-on the command -# 'android update' adb' must be run to update a file that adb reads during -# start-up. -#usb-vendor=0x0000 diff --git a/mtpfuse/Android.mk b/mtpfuse/Android.mk deleted file mode 100644 index f889e53..0000000 --- a/mtpfuse/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -ifdef OMAP_ENHANCEMENT -ifeq ($(TARGET_BOARD_PLATFORM), $(filter $(TARGET_BOARD_PLATFORM), jacinto6)) - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_CFLAGS:= -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 -D__MULTI_THREAD - -LOCAL_SRC_FILES:= mtpfuse.cpp \ - -LOCAL_MODULE:= mtpfuse -LOCAL_CFLAGS := -Wall -Wno-unused-parameter - -LOCAL_C_INCLUDES := \ - $(TOP)/external/libfuse/include \ - $(LOCAL_PATH)/. \ - $(TOP)/system/core/include \ - $(TOP)/frameworks/av/media/mtp \ - $(TOP)/frameworks/native/include - -LOCAL_SHARED_LIBRARIES := libc libusbhost libmtp libutils - -LOCAL_STATIC_LIBRARIES := libfuse - -include $(BUILD_EXECUTABLE) -endif # jacinto6 -endif # OMAP_ENHANCEMENT diff --git a/mtpfuse/mtpfuse.cpp b/mtpfuse/mtpfuse.cpp deleted file mode 100644 index 1bf49bc..0000000 --- a/mtpfuse/mtpfuse.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments - * - * 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. - */ - -#include <usbhost/usbhost.h> -#include <fuse.h> -#include <MtpStorageInfo.h> -#include <MtpObjectInfo.h> -#include <utils/String8.h> -#include <utils/Vector.h> -#include <utils/KeyedVector.h> -#include <stdio.h> -#include <string.h> -#include <MtpDevice.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/statfs.h> -#include <sys/mman.h> - - -#undef FUSE_USE_VERSION -#define FUSE_USE_VERSION 25 - -#ifdef DEBUG -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) -#define DBG(a...) {printf(a);} -#else -#define DBG(a...) -#endif - -using namespace android; - -MtpDevice* mtp_device = NULL; -usb_device* device = NULL; -int mtp_device_found = 0; -MtpStorageIDList* storageAreaList = NULL; -KeyedVector<uint32_t, char*> storageEntries; - -static struct fuse_operations mtpfuse_oper; -typedef Vector <String8*> PathTokenList; -typedef Vector <MtpObjectInfo*> childList; -KeyedVector<uint32_t, childList*> mtpEntries; -KeyedVector<uint32_t, String8> fileDescriptorTable; - -static int usb_device_listed(const char *devname, void* client_data) { - int fd; - device = usb_device_open(devname); - if (device == NULL) { - DBG("Error opening device\n"); - return 0; - } - fd = usb_device_get_fd(device); - if (fd < 0) { - DBG("Error getting fd\n"); - return 0; - } - - MtpDevice *mtp = MtpDevice::open(devname, fd); - if (mtp!= NULL) { - DBG("MTP device found\n"); - mtp_device_found = 1; - mtp_device = mtp; - } - return 0; -} - -static int list_devices () { - struct usb_host_context* context = usb_host_init(); - usb_host_load(context, usb_device_listed, NULL, NULL, NULL); - return 0; -} - -static int get_storage_id(PathTokenList* tokens) { - String8* storage = tokens->itemAt(0); - DBG("Storage %s\n", storage->string()); - if (storage == NULL) { - return -1; - } - for (size_t i = 0;i < storageEntries.size();i++) { - char* desc = storageEntries.valueAt(i); - if (strcmp(desc, storage->string()) == 0) { - return storageEntries.keyAt(i); - } - } - return -1; -} - -static int mtpfuse_release (const char *path, - struct fuse_file_info *fi) { - return 0; -} - -static PathTokenList* tokenize_path(String8* path) { - String8* remain = path; - PathTokenList* tokens = new PathTokenList(); - do { - String8* token = new String8(remain->walkPath(remain)); - tokens->add(token); - } while (*remain != ""); - return tokens; -} - -static MtpObjectInfo* get_mtp_obj_for_path(const char *path) { - PathTokenList* tokens; - MtpObjectInfo* ret = NULL; - String8* path_str = new String8(); - path_str->setPathName(path); - tokens = tokenize_path(path_str); - //Go through mtp entries to get the entries - int storageId = get_storage_id(tokens); - if (storageId == -1) { - DBG("Could not get Storage Id\n"); - tokens->removeItemsAt(0, tokens->size()); - delete tokens; - delete path_str; - return NULL; - } - int found = 0; - int index = mtpEntries.indexOfKey(storageId); - childList *list = mtpEntries.valueAt(index); - if (list != NULL) { - found = 1; - } - MtpObjectInfo *target = NULL; - if (tokens->size() > 1) { - found = 0; - for (size_t i = 1;i < tokens->size();i++) { - for (size_t j = 0;j < list->size();j++) { - if (strcmp(list->itemAt(j)->mName, tokens->itemAt(i)->string()) == 0) { - uint32_t handle = list->itemAt(j)->mHandle; - target = list->itemAt(j); - int indx = mtpEntries.indexOfKey(handle); - list = NULL; - list = mtpEntries.valueAt(indx); - if (i == tokens->size() - 1) { - found = 1; - } - break; - } - } - } - } - - if (found) { - ret = target; - } - tokens->removeItemsAt(0, tokens->size()); - delete tokens; - delete path_str; - return target; -} - - -static int mtpfuse_open (const char * path, struct fuse_file_info *fi) { - MtpObjectInfo *obj = get_mtp_obj_for_path(path); - if (obj == NULL) { - return -ENOENT; - } - fi->fh = (uint64_t)obj->mHandle; - DBG("Handle is %llu %s\n", fi->fh, obj->mName); - return 0; -} - -static int mtpfuse_readdir (const char * path, - void *buf, fuse_fill_dir_t filler, - off_t offset, struct fuse_file_info *fi) { - PathTokenList* tokens; - filler (buf, ".", NULL, 0); - filler (buf, "..", NULL, 0); - - if (strcmp(path, "/") == 0) { - //First get the storages - for (size_t i = 0;i < storageEntries.size();i++) { - struct stat st; - memset (&st, 0, sizeof (st)); - st.st_nlink = 2; - st.st_ino = storageEntries.keyAt(i); - st.st_mode = S_IFDIR | 0777; - char *desc = storageEntries.valueAt(i); - filler (buf, desc, &st, 0); - } - return 0; - } else { - String8* path_str = new String8(); - path_str->setPathName(path); - tokens = tokenize_path(path_str); - //Go through mtp entries to get the entries - int storageId = get_storage_id(tokens); - if (storageId == -1) { - tokens->removeItemsAt(0, tokens->size()); - delete tokens; - delete path_str; - return -ENOENT; - } - int found = 0; - int index = mtpEntries.indexOfKey(storageId); - childList *list = mtpEntries.valueAt(index); - if (list != NULL) { - found = 1; - } - - if (tokens->size() > 1) { - found = 0; - for (size_t i = 1;i < tokens->size();i++) { - for (size_t j = 0;j < list->size();j++) { - if (strcmp(list->itemAt(j)->mName, tokens->itemAt(i)->string()) == 0) { - uint32_t handle = list->itemAt(j)->mHandle; - int indx = mtpEntries.indexOfKey(handle); - list = NULL; - list = mtpEntries.valueAt(indx); - if (i == tokens->size() - 1) { - found = 1; - } - break; - } - } - } - } - - if (found) { - if (list != NULL) { - childList *leaves = NULL; - for (size_t i = 0;i < list->size();i++) { - uint32_t handle = list->itemAt(i)->mHandle; - int indx = mtpEntries.indexOfKey(handle); - leaves = mtpEntries.valueAt(indx); - if (leaves) { - if (leaves->size() == 0) { - struct stat st; - memset (&st, 0, sizeof (st)); - st.st_ino = list->itemAt(i)->mHandle; - st.st_mode = S_IFREG | 0777; - filler (buf, list->itemAt(i)->mName, &st, 0); - }else { - struct stat st; - memset (&st, 0, sizeof (st)); - st.st_ino = list->itemAt(i)->mHandle; - st.st_mode = S_IFDIR | 0777; - filler (buf, list->itemAt(i)->mName, &st, 0); - } - } - } - } - } - tokens->removeItemsAt(0, tokens->size()); - delete tokens; - delete path_str; - } - return 0; -} - - -static int mtpfuse_get_mtp_objects(const char * path) { - //First get the storages - for (size_t i = 0;i < storageAreaList->size();i++) { - uint32_t storageId = storageAreaList->itemAt(i); - //Each storage has handle - childList *forRoot = new childList; - mtpEntries.add(storageId, forRoot); - MtpObjectHandleList* mo_list = - mtp_device->getObjectHandles(storageId, 0, 0); - if (mo_list != NULL) { - //Each mtp object handle is associated with a Vector of child nodes. - //The object is stored as a KeyedVector which has an associated child Vector - for (size_t i = 0;i < mo_list->size();i++) { - MtpObjectInfo* info = mtp_device->getObjectInfo - (mo_list->itemAt(i)); - childList *c = new childList; - mtpEntries.add(info->mHandle, c); - //Handle to childList - childList* parent_child_list = NULL; - int index = -1; - if (info->mParent != 0) { - index = mtpEntries.indexOfKey(info->mParent); - }else { - index = mtpEntries.indexOfKey(storageId); - } - if (index == -1) { - continue; - } - parent_child_list = mtpEntries.valueAt(index); - if (parent_child_list != NULL) { - parent_child_list->add(info); - }else { - DBG("No handle to parent's list\n"); - } - } - } - } - return 0; -} - -static int mtpfuse_getattr (const char * path, struct stat *stbuf) { - PathTokenList* tokens; - - memset (stbuf, 0, sizeof (struct stat)); - - struct fuse_context *fc; - fc = fuse_get_context(); - stbuf->st_uid = fc->uid; - stbuf->st_gid = fc->gid; - - if (strcmp(path, "/") == 0) { - stbuf->st_mode = S_IFDIR | 0777; - stbuf->st_nlink = 2; - return 0; - - } else { - String8* path_str = new String8(); - path_str->setPathName(path); - tokens = tokenize_path(path_str); - //Go through mtp entries to get the entries - int storageId = get_storage_id(tokens); - if (storageId == -1) { - tokens->removeItemsAt(0, tokens->size()); - delete tokens; - delete path_str; - return -ENOENT; - } - int found = 0; - int index = mtpEntries.indexOfKey(storageId); - childList *list = mtpEntries.valueAt(index); - if (list != NULL) { - found = 1; - } - MtpObjectInfo *target = NULL; - if (tokens->size() > 1) { - found = 0; - for (size_t i = 1;i < tokens->size();i++) { - for (size_t j = 0;j < list->size();j++) { - if (strcmp(list->itemAt(j)->mName, tokens->itemAt(i)->string()) == 0) { - uint32_t handle = list->itemAt(j)->mHandle; - target = list->itemAt(j); - int indx = mtpEntries.indexOfKey(handle); - list = NULL; - list = mtpEntries.valueAt(indx); - if (i == tokens->size() - 1) { - found = 1; - } - break; - } - } - } - } - if (found) { - if (list != NULL) { - //If an object has no child nodes, assume it to be a directory - if (list->size() == 0) { - DBG("File\n"); - stbuf->st_ino = target->mHandle; - stbuf->st_size = target->mCompressedSize; - stbuf->st_blocks = (target->mCompressedSize / 512) + - (target->mCompressedSize % 512 > 0 ? 1 : 0); - stbuf->st_nlink = 1; - stbuf->st_mode = S_IFREG | 0777; - stbuf->st_uid = 1000; - stbuf->st_gid = 1015; - stbuf->st_mtime = target->mDateModified; - stbuf->st_ctime = target->mDateModified; - stbuf->st_atime = target->mDateModified; - }else { - DBG("Directory\n"); - if (target != NULL) - stbuf->st_ino = target->mHandle; - stbuf->st_mode = S_IFDIR | 0777; - stbuf->st_nlink = 2; - stbuf->st_uid = 1000; - stbuf->st_gid = 1015; - } - } - } - tokens->removeItemsAt(0, tokens->size()); - delete tokens; - delete path_str; - } - return 0; -} - -bool read_callback (void* data, int offset, int length, void* clientData) { - //DBG("Received read callback %d %d\n", offset, length); - memcpy((char *)clientData + offset, data, length); - return true; -} - -static int mtpfuse_read (const char * path, char * buf, - size_t size, off_t offset, - struct fuse_file_info *fi) { - int ret; - MtpObjectHandle h = (MtpObjectHandle)fi->fh; - bool status = mtp_device->readObject(h, read_callback, size, offset, buf); - if (status == false) { - ret = 0; - }else { - ret = size; - } - return ret; -} - -static void start_media_scanner() { - const char* cmd = - "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/shell/emulated/0"; - system(cmd); -} - -void mtpfuse_destroy (void *) { - //Release mtp entries - for (size_t i = 0;i < mtpEntries.size();i++) { - childList* list = mtpEntries.valueAt(i); - list->clear(); - } - mtpEntries.clear(); - mtp_device->close(); - storageEntries.clear(); - usb_device_close(device); - start_media_scanner(); -} - -void * mtpfuse_init (struct fuse_conn_info *conn) { - return 0; -} - -int main(int argc, char* argv[]) { - int fuse_stat; - - /*Create the mount directory, if it doesn't exist*/ - struct stat st; - if (stat(argv[1], &st) != 0) { - if (mkdir(argv[1], S_IRWXU) != 0 && errno != EEXIST) { - printf("Could not create mount point %d\n", errno); - exit(0); - } - } - - list_devices(); - if (mtp_device_found && mtp_device != NULL) { - storageAreaList = mtp_device->getStorageIDs(); - if (storageAreaList == NULL) { - return 0; - } - - if (storageAreaList->size() == 0) { - printf("No storages found\n"); - return 0; - } - printf("Found %d storage(s)\n", storageAreaList->size()); - for (size_t i = 0;i < storageAreaList->size();i++) { - MtpStorageInfo* storageInfo = mtp_device->getStorageInfo(storageAreaList->itemAt(i)); - printf("Desc: %s\n", storageInfo->mStorageDescription); - storageEntries.add(storageAreaList->itemAt(i), storageInfo->mStorageDescription); - } - mtpfuse_get_mtp_objects("/"); - mtpfuse_oper.readdir = mtpfuse_readdir; - mtpfuse_oper.release = mtpfuse_release; - mtpfuse_oper.getattr = mtpfuse_getattr; - mtpfuse_oper.open = mtpfuse_open; - mtpfuse_oper.read = mtpfuse_read; - mtpfuse_oper.destroy = mtpfuse_destroy; - //Mount fuse - DBG("Setting up FUSE\n"); - fuse_stat = fuse_main(argc, argv, &mtpfuse_oper); - return fuse_stat; - } - return 0; -} diff --git a/s3d/Android.mk b/s3d/Android.mk deleted file mode 100644 index fbdcaaf..0000000 --- a/s3d/Android.mk +++ /dev/null @@ -1,13 +0,0 @@ -ifeq ($(MAKECMDGOALS), sdk_addon) -ifeq ($(TARGET_PRODUCT), s3d) -include_s3d_makefiles = yes -endif -endif - -ifeq ($(OMAP_ENHANCEMENT_S3D), true) -include_s3d_makefiles = yes -endif - -ifdef include_s3d_makefiles -include $(call all-subdir-makefiles) -endif diff --git a/s3d/apps/Android.mk b/s3d/apps/Android.mk deleted file mode 100644 index 5053e7d..0000000 --- a/s3d/apps/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(call all-subdir-makefiles) diff --git a/s3d/apps/Cowboids/Android.mk b/s3d/apps/Cowboids/Android.mk deleted file mode 100644 index 008fcdb..0000000 --- a/s3d/apps/Cowboids/Android.mk +++ /dev/null @@ -1,16 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := S3DCowboids -LOCAL_SDK_VERSION := current - -LOCAL_JAVA_LIBRARIES := com.ti.s3d - -include $(BUILD_PACKAGE) - -# Use the following include to make our test apk. -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/s3d/apps/Cowboids/AndroidManifest.xml b/s3d/apps/Cowboids/AndroidManifest.xml deleted file mode 100644 index 9d9f8fd..0000000 --- a/s3d/apps/Cowboids/AndroidManifest.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.ti.s3d.cube"> - - <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> - <uses-library android:name="com.ti.s3d" /> - <activity android:name=".CowboidsActivity" - android:label="@string/app_name"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - -</manifest> diff --git a/s3d/apps/Cowboids/res/drawable/cowboid.png b/s3d/apps/Cowboids/res/drawable/cowboid.png Binary files differdeleted file mode 100644 index 6f9558f..0000000 --- a/s3d/apps/Cowboids/res/drawable/cowboid.png +++ /dev/null diff --git a/s3d/apps/Cowboids/res/drawable/icon.png b/s3d/apps/Cowboids/res/drawable/icon.png Binary files differdeleted file mode 100644 index cd556a4..0000000 --- a/s3d/apps/Cowboids/res/drawable/icon.png +++ /dev/null diff --git a/s3d/apps/Cowboids/res/layout/main.xml b/s3d/apps/Cowboids/res/layout/main.xml deleted file mode 100644 index 4361cfe..0000000 --- a/s3d/apps/Cowboids/res/layout/main.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - > -</LinearLayout> diff --git a/s3d/apps/Cowboids/res/values/strings.xml b/s3d/apps/Cowboids/res/values/strings.xml deleted file mode 100644 index 724114c..0000000 --- a/s3d/apps/Cowboids/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="app_name">S3D Cowboids</string> -</resources> diff --git a/s3d/apps/Cowboids/src/com/ti/s3d/cube/CowboidsActivity.java b/s3d/apps/Cowboids/src/com/ti/s3d/cube/CowboidsActivity.java deleted file mode 100644 index 25e7ccf..0000000 --- a/s3d/apps/Cowboids/src/com/ti/s3d/cube/CowboidsActivity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments Inc. - * - * 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.ti.s3d.cube; - -import android.app.Activity; -import android.os.Bundle; - -import com.ti.s3d.render.StereoGLView; - -public class CowboidsActivity extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - CubeScene scene = new CubeScene(this, R.drawable.cowboid); - mGLView = new StereoGLView(this, scene); - setContentView(mGLView); - } - - @Override - protected void onResume() { - super.onResume(); - mGLView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mGLView.onPause(); - } - - private StereoGLView mGLView; -} diff --git a/s3d/apps/Cowboids/src/com/ti/s3d/cube/CubeScene.java b/s3d/apps/Cowboids/src/com/ti/s3d/cube/CubeScene.java deleted file mode 100644 index 579d46a..0000000 --- a/s3d/apps/Cowboids/src/com/ti/s3d/cube/CubeScene.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments Inc. - * - * 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.ti.s3d.cube; - -import java.util.ArrayList; -import javax.microedition.khronos.opengles.GL10; - -import android.content.Context; - -import com.ti.s3d.render.Scene; - -public class CubeScene implements Scene { - - private TexturedCube mCube; - private ArrayList<Transform> transforms; - private float mAngle; - private float mAngleDelta; - private int h; - - //Draws a cube formation of textured cubes - public CubeScene(Context context, int resourceId) { - mCube = new TexturedCube(context, resourceId); - transforms = new ArrayList<Transform>(9); - float location = 2.0f; - transforms.add(new Transform(0.0f, 0.0f, 0.0f)); - for (int i=0;i<8;i++) { - float x = ( (i & 0x4) == 0) ? -location : location; - float y = ( (i & 0x2) == 0) ? -location : location; - float z = ( (i & 0x1) == 0) ? -location : location; - transforms.add(new Transform(x, y, z)); - } - mAngleDelta = 1.5f; - } - - public void draw(GL10 gl) { - mCube.drawBatchStart(gl); - for(Transform t : transforms) { - gl.glPushMatrix(); - t.apply(gl,mAngle); - mCube.draw(gl); - gl.glPopMatrix(); - } - mCube.drawBatchStop(gl); - } - - public void drawEnd(GL10 gl) { - mAngle += mAngleDelta; - } - - public void setup(GL10 gl, int w, int h) { - mCube.setup(gl); - this.h = h; - } - - public void onTouch(float deltaX, float deltaY) { - deltaY /= -h; - deltaY *= 20.0f; - mAngleDelta += deltaY; - if(mAngleDelta < 0.0f) - mAngleDelta = 0.0f; - else if(mAngleDelta > 20.0f) - mAngleDelta = 20.0f; - } - - private static class Transform { - //Translation - private float x, y, z; - //Angle ratios - private float ax, ay, az; - - private Transform(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - ax = (float)Math.random(); - ay = (float)Math.random(); - az = (float)Math.random(); - } - - private void apply(GL10 gl, float angle) { - gl.glTranslatef(x, y, z); - gl.glRotatef(ax*angle, 1, 0, 0); - gl.glRotatef(ay*angle, 0, 1, 0); - gl.glRotatef(az*angle, 0, 0, 1); - } - } -} diff --git a/s3d/apps/Cowboids/src/com/ti/s3d/cube/TexturedCube.java b/s3d/apps/Cowboids/src/com/ti/s3d/cube/TexturedCube.java deleted file mode 100644 index 5c65147..0000000 --- a/s3d/apps/Cowboids/src/com/ti/s3d/cube/TexturedCube.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments Inc. - * - * 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.ti.s3d.cube; - -import java.nio.FloatBuffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.lang.Float; - -import java.io.IOException; -import java.io.InputStream; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.opengl.GLUtils; - -import javax.microedition.khronos.opengles.GL10; -import javax.microedition.khronos.opengles.GL11; - -public class TexturedCube { - - private FloatBuffer vertices; - private FloatBuffer texCoords; - private ByteBuffer indices; - - private int mTextureID; - private int mVtxVboID; - private int mTexVboID; - private int mIndVboID; - - private int mResourceId; - private Context context; - - public TexturedCube(Context context, int resourceId) { - this.context = context; - this.mResourceId = resourceId; - - float cubeVertices[] = { - //front face - -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, - - //right face - 1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, -1.0f, - 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, -1.0f, - - //back face - 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, -1.0f, - 1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, -1.0f, - - //left face - -1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - -1.0f, 1.0f, 1.0f, - - //bottom face - -1.0f, -1.0f, -1.0f, - 1.0f, -1.0f, -1.0f, - -1.0f, -1.0f, 1.0f, - 1.0f, -1.0f, 1.0f, - - //top face - -1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, -1.0f, - 1.0f, 1.0f, -1.0f, - }; - - float texFaceCoords[] = { - 0.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - }; - - byte elIndices[] = { - 0,1,3, 0,3,2, - 4,5,7, 4,7,6, - 8,9,11, 8,11,10, - 12,13,15, 12,15,14, - 16,17,19, 16,19,18, - 20,21,23, 20,23,22, - }; - - ByteBuffer byteBuf = ByteBuffer.allocateDirect(cubeVertices.length * Float.SIZE); - byteBuf.order(ByteOrder.nativeOrder()); - vertices = byteBuf.asFloatBuffer(); - vertices.put(cubeVertices); - vertices.position(0); - - byteBuf = ByteBuffer.allocateDirect(texFaceCoords.length * 6 * Float.SIZE); - byteBuf.order(ByteOrder.nativeOrder()); - texCoords = byteBuf.asFloatBuffer(); - for(int i=0;i<6;i++) - texCoords.put(texFaceCoords); - texCoords.position(0); - - indices = ByteBuffer.allocateDirect(elIndices.length); - indices.put(elIndices); - indices.position(0); - } - - public void drawBatchStart(GL10 gl) { - gl.glActiveTexture(GL10.GL_TEXTURE0); - gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); - gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); - gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); - gl.glFrontFace(GL10.GL_CCW); - if(gl instanceof GL11) { - GL11 gl11 = (GL11)gl; - gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVtxVboID); - gl11.glVertexPointer(3, GL10.GL_FLOAT, 0, 0); - - gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mTexVboID); - gl11.glTexCoordPointer(2, GL10.GL_FLOAT, 0, 0); - gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndVboID); - } - } - - public void draw(GL10 gl) { - if(gl instanceof GL11) { - GL11 gl11 = (GL11)gl; - gl11.glDrawElements(GL10.GL_TRIANGLES, indices.limit(), GL10.GL_UNSIGNED_BYTE, 0); - } - } - - public void drawBatchStop(GL10 gl) { - gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); - gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); - if(gl instanceof GL11) { - GL11 gl11 = (GL11)gl; - gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0); - gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0); - } - } - - public void setup(GL10 gl10) { - if(gl10 instanceof GL11) { - GL11 gl = (GL11)gl10; - int[] ids = new int[3]; - gl.glGenBuffers(3, ids, 0); - mVtxVboID = ids[0]; - mTexVboID = ids[1]; - mIndVboID= ids[2]; - - gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVtxVboID); - gl.glBufferData(GL11.GL_ARRAY_BUFFER, vertices.capacity(), vertices, GL11.GL_STATIC_DRAW); - gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0); - - gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mTexVboID); - gl.glBufferData(GL11.GL_ARRAY_BUFFER, texCoords.capacity(), texCoords, GL11.GL_STATIC_DRAW); - gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0); - - gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndVboID); - gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.capacity(), indices, GL11.GL_STATIC_DRAW); - gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0); - } - textureLoadFromResource(gl10); - } - - public void textureLoadFromResource(GL10 gl) { - InputStream is = context.getResources().openRawResource(mResourceId); - Bitmap bitmap = null; - try { - bitmap = BitmapFactory.decodeStream(is); - } finally { - try { - is.close(); - is = null; - } catch (IOException e) { - } - } - - int[] ids = new int[1]; - gl.glGenTextures(1, ids, 0); - mTextureID = ids[0]; - - gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID); - - gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); - gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST); - gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT); - gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT); - GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); - - bitmap.recycle(); - } -} diff --git a/s3d/apps/Cowboids/src/com/ti/s3d/render/Scene.java b/s3d/apps/Cowboids/src/com/ti/s3d/render/Scene.java deleted file mode 100644 index 3c6ae15..0000000 --- a/s3d/apps/Cowboids/src/com/ti/s3d/render/Scene.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments Inc. - * - * 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.ti.s3d.render; - -import javax.microedition.khronos.opengles.GL10; - -public interface Scene { - public void draw(GL10 gl); - public void drawEnd(GL10 gl); - public void setup(GL10 gl, int w, int h); - public void onTouch(float deltaX, float deltaY); -} diff --git a/s3d/apps/Cowboids/src/com/ti/s3d/render/StereoGLView.java b/s3d/apps/Cowboids/src/com/ti/s3d/render/StereoGLView.java deleted file mode 100644 index 594e38c..0000000 --- a/s3d/apps/Cowboids/src/com/ti/s3d/render/StereoGLView.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments Inc. - * - * 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.ti.s3d.render; - -import android.view.MotionEvent; -import android.opengl.GLSurfaceView; -import android.content.Context; - -import com.ti.s3d.S3DView; - - -public class StereoGLView extends GLSurfaceView { - - public StereoGLView(Context context, Scene scene) { - super(context); - this.mScene = scene; - //Create an S3D view to signal we are rendering stereo content - s3dView = new S3DView(getHolder()); - mRenderer = new StereoRenderer(scene); - setRenderer(mRenderer); - mPrevX = 0; - mPrevY = 0; - } - - @Override - public boolean onTouchEvent(MotionEvent e) { - if (e.getActionMasked() == MotionEvent.ACTION_DOWN) { - mPrevX = e.getX(); - mPrevY = e.getY(); - } - if (e.getActionMasked() == MotionEvent.ACTION_MOVE) { - float deltaX = e.getX() - mPrevX; - float deltaY = e.getY() - mPrevY; - mRenderer.moveCam(deltaX); - mScene.onTouch(deltaX, deltaY); - mPrevX = e.getX(); - mPrevY = e.getY(); - } - return true; - } - - private float mPrevX; - private float mPrevY; - private S3DView s3dView; - private StereoRenderer mRenderer; - private Scene mScene; -} diff --git a/s3d/apps/Cowboids/src/com/ti/s3d/render/StereoRenderer.java b/s3d/apps/Cowboids/src/com/ti/s3d/render/StereoRenderer.java deleted file mode 100644 index 2e91808..0000000 --- a/s3d/apps/Cowboids/src/com/ti/s3d/render/StereoRenderer.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2011 Texas Instruments Inc. - * - * 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.ti.s3d.render; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; -import android.opengl.GLSurfaceView; - -import java.lang.Math; - -/** - * Render a stereo scene. - */ - -public class StereoRenderer implements GLSurfaceView.Renderer { - - private static final float DEGREES_TO_RADIANS = 0.0174532925f; - - private float mDepthZ = -10.0f; - private static final float nearZ = 3.0f; - private static final float farZ = 30.0f; - private static final float maxDepthZ = -(nearZ+2.0f); - private static final float minDepthZ = -(farZ-7.0f); - private static final float screenPlaneZ = 10.0f; - private static final float fovy = 45.0f; - //private static final float IOD = 0.2f; - private float IOD = 0.2f; - - private int width; - private int height; - private S3DRenderMode renderMode; - private Camera leftCam = new Camera(S3DView.LEFT); - private Camera rightCam = new Camera(S3DView.RIGHT); - - private Scene scene; - - public StereoRenderer(Scene scene) { - renderMode = S3DRenderMode.SIDE_BY_SIDE; - this.scene = scene; - } - - private void setViewPort(GL10 gl, S3DView view) { - gl.glViewport(renderMode.viewportX(view,width), - renderMode.viewportY(view,height), - renderMode.viewportWidth(width), - renderMode.viewportHeight(height)); - } - - private void drawScene(GL10 gl, S3DView view) { - setViewPort(gl, view); - - gl.glMatrixMode(GL10.GL_MODELVIEW); - gl.glLoadIdentity(); - gl.glPushMatrix(); - gl.glTranslatef(0.0f, 0.0f, mDepthZ); - scene.draw(gl); - gl.glPopMatrix(); - } - - public void onDrawFrame(GL10 gl) { - gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); - - leftCam.apply(gl); - drawScene(gl, S3DView.LEFT); - - rightCam.apply(gl); - drawScene(gl, S3DView.RIGHT); - - scene.drawEnd(gl); - } - - private void setupGL(GL10 gl) { - gl.glClearColor(0,0,0,0); - gl.glEnable(GL10.GL_CULL_FACE); - gl.glEnable(GL10.GL_DEPTH_TEST); - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - width = w; - height = h; - setupGL(gl); - scene.setup(gl, w, h); - - float aspect = (float)w/(float)h; - leftCam.setup(IOD, aspect); - rightCam.setup(IOD, aspect); - } - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - gl.glDisable(GL10.GL_DITHER); - gl.glEnable(GL10.GL_CULL_FACE); - gl.glEnable(GL10.GL_DEPTH_TEST); - gl.glEnable(GL10.GL_TEXTURE_2D); - gl.glShadeModel(GL10.GL_SMOOTH); - gl.glClearColor(0,0,0,0); - gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); - } - - public void moveCam(float deltaX) { - deltaX /= (float)width; - deltaX *= 20.0f; - mDepthZ += deltaX; - if(mDepthZ >= maxDepthZ) - mDepthZ = maxDepthZ; - else if(mDepthZ <= minDepthZ) - mDepthZ = minDepthZ; - } - - public void changeIOD(float deltaY) { - deltaY /= (float)height; - IOD += deltaY; - if(IOD > 0.75f) - IOD=0.75f; - else if(IOD < 0.0f) - IOD=0.0f; - float aspect = (float)width/(float)height; - leftCam.setup(IOD, aspect); - rightCam.setup(IOD, aspect); - } - - private static enum S3DView { LEFT, RIGHT }; - protected static enum S3DRenderMode { - SIDE_BY_SIDE { - S3DRenderMode next() { return OVER_UNDER; } - int viewportWidth(int width) { return width/2; } - int viewportHeight(int height) { return height; } - int viewportX(S3DView view, int w) { return view == S3DView.LEFT ? 0 : w/2; } - int viewportY(S3DView view, int h) { return 0; } - }, - OVER_UNDER { - S3DRenderMode next() { return SIDE_BY_SIDE; } - int viewportWidth(int width) { return width; } - int viewportHeight(int height) { return height/2; } - int viewportX(S3DView view, int w) { return 0; } - int viewportY(S3DView view, int h) { return (view == S3DView.RIGHT) ? 0 : h/2; } - }; - - abstract S3DRenderMode next(); - abstract int viewportWidth(int width); - abstract int viewportHeight(int height); - abstract int viewportX(S3DView view, int w); - abstract int viewportY(S3DView view, int h); - } - - private static class Camera { - - private Camera(S3DView view) { - this.view = view; - }; - - private void setup(float IOD, float aspect) { - float top = nearZ*(float)Math.tan(DEGREES_TO_RADIANS*fovy/2.0f); - float r = aspect*top; - float frustumshift = (IOD/2.0f)*nearZ/screenPlaneZ; - this.top = top; - this.bottom = -top; - this.left = view == S3DView.LEFT ? -r + frustumshift : -r-frustumshift; - this.right = view == S3DView.LEFT ? r + frustumshift : r-frustumshift; - this.x = view == S3DView.LEFT ? IOD/2.0f : -IOD/2.0f; - } - - private void apply(GL10 gl) { - gl.glMatrixMode(GL10.GL_PROJECTION); - gl.glLoadIdentity(); - gl.glFrustumf(left, right, bottom, top,nearZ, farZ); - gl.glTranslatef(x, 0.0f, 0.0f); - } - - private float left; - private float right; - private float bottom; - private float top; - private float x; - private S3DView view; - } -} diff --git a/s3d/frameworks/Android.mk b/s3d/frameworks/Android.mk deleted file mode 100644 index 972cf40..0000000 --- a/s3d/frameworks/Android.mk +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2011 Texas Instruments Inc. -# -# 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. -# - -# This makefile shows how to build your own shared library that can be -# shipped on the system of a phone, and included additional examples of -# including JNI code with the library and writing client applications against it. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_MODULE:= com.ti.s3d -LOCAL_MODULE_TAGS := optional - -include $(BUILD_JAVA_LIBRARY) - -# ============================================================ -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - $(call all-subdir-java-files) \ - $(call all-subdir-html-files) - -LOCAL_MODULE:= s3d_api -LOCAL_DROIDDOC_OPTIONS := com.ti.s3d -LOCAL_MODULE_CLASS := JAVA_LIBRARIES -LOCAL_DROIDDOC_USE_STANDARD_DOCLET := true - -include $(BUILD_DROIDDOC) - -# ============================================================ -include $(CLEAR_VARS) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/s3d/frameworks/com.ti.s3d.xml b/s3d/frameworks/com.ti.s3d.xml deleted file mode 100644 index ee3fa79..0000000 --- a/s3d/frameworks/com.ti.s3d.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<permissions> - <library name="com.ti.s3d" - file="/system/framework/com.ti.s3d.jar"/> -</permissions> diff --git a/s3d/frameworks/java/com/ti/s3d/S3DView.java b/s3d/frameworks/java/com/ti/s3d/S3DView.java deleted file mode 100644 index ddfd869..0000000 --- a/s3d/frameworks/java/com/ti/s3d/S3DView.java +++ /dev/null @@ -1,332 +0,0 @@ -/* -* Copyright (C) 2011 Texas Instruments Inc. -* -* 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.ti.s3d; - -import java.lang.IllegalArgumentException; - -import android.app.Activity; -import android.view.Surface; -import android.view.SurfaceHolder; - -/** - S3DView provides a mechanism to inform the surface composer (SurfaceFlinger) - that stereoscopic content is being rendered unto a surface or an Activity window. - <br /><br /> - - The typical use of this class when using SurfaceView or one of its descendants is:<br /> - <p><blockquote><pre> - SurfaceView view = new SurfaceView(context);<br /> - SurfaceHolder holder = view.getHolder();<br /> - S3DView s3dView = S3DView(holder, Layout.SIDE_BY_SIDE_LR, RenderMode.STEREO);<br /> - or <br /> - S3DView s3dView = S3DView(holder, Layout.TOPBOTTOM_L, RenderMode.STEREO); - </pre></blockquote> - - For a standard Activity window, the application has to invoke the methods provided by this class - after the underlying surface has been created. The easiest way to ensure this is by overriding - the method onWindowFocusChanged of the required target Activity; when onWindowFocusChanged is called - the activity window will already have a surface attached to it. If the S3DView method is invoked before - onWindowFocusChanged has happened, the configuration will be ignored. - <p><blockquote><pre> - public void onWindowFocusChanged(boolean hasFocus) {<br /> - super.onWindowFocusChanged(hasFocus);<br /> - if (hasFocus) {<br /> - S3DView.configureWindow(this, Layout.SIDE_BY_SIDE_LR, RenderMode.STEREO);<br /> - }<br /> - }<br /> - </pre></blockquote> - - To use this class in an application, the following is required in AndroidManifest.xml - as a child of the <application> element: - <p><blockquote><pre> - {@code <uses-library android:name="com.ti.s3d" android:required="false" />} - </pre></blockquote> - - Additionally, for a native build, the following line should be added in Android.mk: - <p><blockquote><pre> - LOCAL_JAVA_LIBRARIES := com.ti.s3d - </pre></blockquote> - - @author Alberto Aguirre - @author Jagadeesh Pakaravoor - @version 1.1, Jan 2012 - */ - -public class S3DView implements SurfaceHolder.Callback { - - /** - Equivalent to S3DView(Layout.SIDE_BY_SIDE_LR, RenderMode.STEREO) - @see #S3DView(SurfaceHolder, Layout, RenderMode) - */ - public S3DView(SurfaceHolder sh) { - this(sh, Layout.SIDE_BY_SIDE_LR, RenderMode.STEREO); - } - - /** - This constructor is used to inform the compositor about stereo content in SurfaceView. - If the surface holder already contains a valid surface, then the configuration - is done during the constructor. Otherwise, a callback is registered with - the given surface holder instance and performs the configuration during surfaceChanged. - @param sh The holder associated with the SurfaceView where stereo content will be rendered to. - @param layout Describes in which position the stereo views are rendered as. - @param mode Describes if the stereo view should be rendered in stereo or just one of the views - */ - public S3DView(SurfaceHolder sh, Layout layout, RenderMode mode) { - nativeClassInit(); - sh.addCallback(this); - this.layout = layout; - this.mode = mode; - if(sh.getSurface().isValid()) { - this.holder = sh; - config(); - } - } - - /** - This constructor is used to inform the compositor about stereo content in a regular window - associated with an Activity. - @param a The activity that owns the window where stereo content is rendered to. - @param layout Describes in which position the stereo views are rendered as. - @param mode Describes if the stereo view should be rendered in stereo or just one of the views - */ - public S3DView(Activity a, Layout layout, RenderMode mode) { - nativeClassInit(); - this.layout = layout; - this.mode = mode; - this.activity = a; - config(); - } - - /** - Equivalent to S3DView(Layout.SIDE_BY_SIDE_LR, RenderMode.STEREO) - @see #S3DView(Layout, RenderMode) - */ - public S3DView() { - this(Layout.SIDE_BY_SIDE_LR, RenderMode.STEREO); - } - - /** - This constructor is used to inform the compositor about stereo content in SurfaceView layer. - If the surface holder already contains a valid surface, then the configuration - is done during the constructor. Otherwise, a callback is registered with - the given surface holder instance and performs the configuration during surfaceChanged. - @param layout Describes in which position the stereo views are rendered as. - @param mode Describes if the stereo view should be rendered in stereo or just one of the views - */ - public S3DView(Layout layout, RenderMode mode) { - nativeClassInit(); - this.layout = layout; - this.mode = mode; - config(); - } - - /** - Changes the current layout and render mode. Typically this is used when - you reuse the same Surfaceview to render mono content, or potentially after - a system orientation change, where the preferred layout has changed. - @param layout Describes in which position the stereo views are rendered as. - @param mode Describes if the stereo view should be rendered in stereo or just one of the views - @see #getPrefLayout - */ - public void setConfig(S3DView.Layout layout, S3DView.RenderMode mode) { - this.layout = layout; - this.mode = mode; - config(); - } - - /** - Only the layout is changed. The RenderMode remains set to its current value. - @param layout Describes in which position the stereo views are rendered as. - @see S3DView.Layout - */ - public void setLayout(S3DView.Layout layout) { - this.layout = layout; - config(); - } - - /** - Only the render mode is changed. The layout remains set to its current value. - @param mode Describes in which position the stereo views are rendered as. - @see S3DView.Layout - */ - public void setMode(S3DView.RenderMode mode) { - this.mode = mode; - config(); - } - - /** - Swaps the left and right view. Useful mainly in cases where the rendering is not done - by the owner of this view, for example Camera or Video. - */ - public void swapLR() { - layout = layout.swapLR(); - config(); - } - - /** - Informs what is the preferred layout for the default display. - To minimize aliasing artifacts when dealing with interleaved S3D displays, - the user should render in the layout described here. - @return The layout preferred by the default display - */ - public S3DView.Layout getPrefLayout() { - return native_getPrefLayout(); - } - - /** - Convenience method to configure a window. It's the equivalent of:<br /> - S3DView v = new S3DView(a, layout, mode); - @param a The activity that owns the window where stereo content is rendered to. - @param layout Describes in which position the stereo views are rendered as. - @param mode Describes if the stereo view should be rendered in stereo or just one of the views - */ - public static void configureWindow(Activity a, Layout layout, RenderMode mode) { - S3DView v = new S3DView(a, layout, mode); - } - - /** - Convenience method to configure a surface. It's the equivalent of:<br /> - S3DView v = new S3DView(sh, layout, mode); - Throws IllegalArgumentException if the given surface holder doesn't contain - a valid surface. - @param sh The holder associated with the SurfaceView where stereo content will be rendered to. - @param layout Describes in which position the stereo views are rendered as. - @param mode Describes if the stereo view should be rendered in stereo or just one of the views - - */ - public static void configureSurface(SurfaceHolder sh, Layout layout, RenderMode mode) { - if(!sh.getSurface().isValid()) { - throw new IllegalArgumentException("Surface is not valid"); - } - S3DView v = new S3DView(sh, layout, mode); - } - - /** - SurfaceHolder.Callback implementation. - */ - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - this.holder = holder; - config(); - } - - /** - SurfaceHolder.Callback implementation. - */ - public void surfaceCreated(SurfaceHolder holder) {}; - - /** - SurfaceHolder.Callback implementation. - */ - public void surfaceDestroyed(SurfaceHolder holder) { - this.holder = null; - }; - - private void config() { - if (holder != null) { - native_setConfig(holder.getSurface(), layout.getType(), - layout.getLayoutOrder(), mode.getMode()); - } else if (activity != null) { - native_setWindowConfig(activity.getComponentName().flattenToString(), - layout.getType(), - layout.getLayoutOrder(), - mode.getMode()); - } else { - native_setSurfaceViewCfg(layout.getType(), - layout.getLayoutOrder(), mode.getMode()); - } - } - - /** - The supported stereo layouts - */ - public static enum Layout { - /** - Signals no stereo content is rendered - */ - MONO (0, 0) { Layout swapLR() { return MONO; }}, - /** - App renders left view on the surface's left half, - and the right view on the surface's right half. - */ - SIDE_BY_SIDE_LR (1, 0) { Layout swapLR() { return SIDE_BY_SIDE_RL; } }, - /** - App renders left view on the surface's right half, - and the right view on the surface's left half. - */ - SIDE_BY_SIDE_RL (1, 1) { Layout swapLR() { return SIDE_BY_SIDE_LR; } }, - /** - App renders left view on the surface's top half, - and the right view on the surface's bottom half. - */ - TOPBOTTOM_L (2, 0) { Layout swapLR() { return TOPBOTTOM_R; } }, - /** - App renders left view on the surface's bottom half, - and the right view on the surface's top half. - */ - TOPBOTTOM_R (2, 1) { Layout swapLR() { return TOPBOTTOM_L; } }; - - private final int type; - private final int layoutOrder; - - private Layout(int typ, int layoutOrder) { - this.type = typ; - this.layoutOrder = layoutOrder; - } - - abstract Layout swapLR(); - private int getType() { return type; } - private int getLayoutOrder() { return layoutOrder; } - } - - /** - The supported rendering modes - */ - public static enum RenderMode { - /** - The surface composer will only render the left view of the surface. - */ - MONO_LEFT(0), - /** - The surface composer will only render the right view of the surface. - */ - MONO_RIGHT(1), - /** - The surface composer will render both views as appropiate for the default display. - */ - STEREO(2); - - private final int mode; - private RenderMode(int mode) { this.mode = mode; } - private int getMode() { return mode; } - } - - static { - System.loadLibrary("s3dview_jni"); - } - - private Layout layout; - private RenderMode mode; - private SurfaceHolder holder; - private Activity activity; - - private native void native_setConfig(Surface s, int type, int order, int mode); - private native void native_setWindowConfig(String windowName, int type, int order, int mode); - private native void native_setSurfaceViewCfg(int type, int order, int mode); - private native S3DView.Layout native_getPrefLayout(); - private native void nativeClassInit(); - -}; diff --git a/s3d/frameworks/jni/Android.mk b/s3d/frameworks/jni/Android.mk deleted file mode 100644 index e7d3e39..0000000 --- a/s3d/frameworks/jni/Android.mk +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2011 Texas Instruments Inc. -# -# 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. -# - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE:= libs3dview_jni - -LOCAL_SRC_FILES:= \ - S3DView.cpp - -LOCAL_SHARED_LIBRARIES := \ - libnativehelper \ - libutils \ - libbinder \ - libgui - -LOCAL_C_INCLUDES := \ - $(JNI_H_INCLUDE) - -include $(BUILD_SHARED_LIBRARY) diff --git a/s3d/frameworks/jni/S3DView.cpp b/s3d/frameworks/jni/S3DView.cpp deleted file mode 100644 index a4d1391..0000000 --- a/s3d/frameworks/jni/S3DView.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* -* Copyright (C) 2011 Texas Instruments Inc. -* -* 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. -*/ - -#define LOG_TAG "S3DView" -#include "utils/Log.h" - -#include "jni.h" -#include "JNIHelp.h" - -#include <binder/Parcel.h> -#include <binder/IServiceManager.h> -#include <gui/Surface.h> -#include <ui/S3DFormat.h> - -using namespace android; - -struct so_t { - jfieldID surface; -}; -static so_t so; - -struct lo_t { - jfieldID mono; - jfieldID sbs_LR; - jfieldID sbs_RL; - jfieldID tb_L; - jfieldID tb_R; -}; -static lo_t lo; - -enum { //keep in sync with S3DSurfaceFlinger.h - SET_SURF_CONFIG = 4000, - GET_PREF_LAYOUT = 4001, - SET_WINDOW_CONFIG = 4003, - SET_SURFACE_VIEW_CONFIG = 4004, -}; - -// --------------------------------------------------------------------------- -static sp<Surface> getSurface(JNIEnv* env, jobject surfobj) { - sp<Surface> surf(reinterpret_cast<Surface*>(env->GetIntField(surfobj, so.surface))); - if (surf == 0) { - jniThrowException(env, "java/lang/NullPointerException", "Failed obtaining native surface"); - } - if (!Surface::isValid(surf)) { - jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid surface"); - } - return surf; -} - -static status_t sendCommand(uint32_t cmd, - const sp<Surface> surface, - const String8& name, - Parcel *reply, - const int32_t *data, - const int32_t nElements) { - sp<IServiceManager> sm = defaultServiceManager(); - sp<IBinder> service = sm->checkService(String16("SurfaceFlinger")); - if (service == NULL) { - ALOGE("failed to find SurfaceFlinger service"); - return BAD_VALUE; - } - - Parcel parcel, dummy, rep; - status_t status; - //Could not obtain the interface name - status = service->transact(IBinder::INTERFACE_TRANSACTION, dummy, &rep); - if (status != NO_ERROR) { - ALOGE("failed to get SurfaceFlinger service interface name"); - return status; - } - - String16 ifName = rep.readString16(); - if (ifName.size() <= 0) { - ALOGE("interface name is empty"); - return BAD_VALUE; - } - - parcel.writeInterfaceToken(ifName); - - if (surface != NULL) { - parcel.writeStrongBinder(surface->asBinder()); - } - - if (!name.isEmpty()) { - parcel.writeString8(name); - } - - for (int32_t i = 0; i < nElements; i++) - parcel.writeInt32(data[i]); - - status = service->transact(cmd, parcel, reply); - if (status) - ALOGE("failed transacting with surfaceflinger (%x)", status); - - return status; -} - -static status_t sendCommand(uint32_t cmd, - Parcel *reply, - const int32_t *data, - const int32_t nElements) { - sp<IServiceManager> sm = defaultServiceManager(); - sp<IBinder> service = sm->checkService(String16("SurfaceFlinger")); - if (service == NULL) { - ALOGE("failed to find SurfaceFlinger service"); - return BAD_VALUE; - } - - Parcel parcel, dummy, rep; - status_t status; - //Could not obtain the interface name - status = service->transact(IBinder::INTERFACE_TRANSACTION, dummy, &rep); - if (status != NO_ERROR) { - ALOGE("failed to get SurfaceFlinger service interface name"); - return status; - } - - String16 ifName = rep.readString16(); - if (ifName.size() <= 0) { - ALOGE("interface name is empty"); - return BAD_VALUE; - } - - parcel.writeInterfaceToken(ifName); - - for (int32_t i = 0; i < nElements; i++) - parcel.writeInt32(data[i]); - - status = service->transact(cmd, parcel, reply); - if (status) - ALOGE("failed transacting with surfaceflinger (%x)", status); - - return status; -} - -static void S3DView_setConfig(JNIEnv* env, jclass clazz, jobject surf, - jint type, jint order, jint mode) { - const sp<Surface>& sur(getSurface(env, surf)); - Parcel reply; - int32_t data[]={type, order, mode}; - sendCommand(SET_SURF_CONFIG, sur, String8(), &reply, data, 3); -} - -static void S3DView_setWindowConfig(JNIEnv* env, jclass clazz, - jstring jname, - jint type, - jint order, - jint mode) { - Parcel reply; - int32_t data[]={type, order, mode}; - - const jchar* str = env->GetStringCritical(jname, 0); - const String8 name(str, env->GetStringLength(jname)); - env->ReleaseStringCritical(jname, str); - - sendCommand(SET_WINDOW_CONFIG, NULL, name, &reply, data, 3); -} - -static void S3DView_setSurfaceView(JNIEnv* env, jclass clazz, - jint type, jint order, jint mode) { - Parcel reply; - int32_t data[] = {type, order, mode}; - sendCommand(SET_SURFACE_VIEW_CONFIG, &reply, data, 3); -} - -static jobject S3DView_getPrefLayout(JNIEnv* env, jclass clazz) { - jfieldID layoutID = lo.sbs_LR; - Parcel reply; - if(sendCommand(GET_PREF_LAYOUT, NULL, String8(), &reply, NULL, 0) == NO_ERROR) { - int32_t layoutType = reply.readInt32(); - int32_t layoutOrder = reply.readInt32(); - if(layoutType == eTopBottom && layoutOrder == eLeftViewFirst) - layoutID = lo.tb_L; - else if(layoutType == eTopBottom && layoutOrder == eRightViewFirst) - layoutID = lo.tb_R; - else if(layoutType == eSideBySide && layoutOrder == eLeftViewFirst) - layoutID = lo.sbs_LR; - else if(layoutType == eSideBySide && layoutOrder == eRightViewFirst) - layoutID = lo.sbs_RL; - } - jclass layout = env->FindClass("com/ti/s3d/S3DView$Layout"); - return env->GetStaticObjectField(layout, layoutID); -} - -// ---------------------------------------------------------------------------- -static void nativeClassInit(JNIEnv* env, jclass clazz); - -static const JNINativeMethod gMethods[] = { - { "nativeClassInit", "()V", (void*)nativeClassInit }, - { "native_setConfig", "(Landroid/view/Surface;III)V", (void*)S3DView_setConfig }, - { "native_setSurfaceViewCfg", "(III)V", (void*)S3DView_setSurfaceView }, - { "native_getPrefLayout", "()Lcom/ti/s3d/S3DView$Layout;", (void*)S3DView_getPrefLayout }, - { "native_setWindowConfig", "(Ljava/lang/String;III)V", (void*)S3DView_setWindowConfig } -}; - -static void nativeClassInit(JNIEnv* env, jclass clazz) { - const char* const kLayoutClassSignature = "Lcom/ti/s3d/S3DView$Layout;"; - - //Obtain native surface offset field - jclass surface = env->FindClass("android/view/Surface"); - so.surface = env->GetFieldID(surface, ANDROID_VIEW_SURFACE_JNI_ID, "I"); - - jclass layout = env->FindClass("com/ti/s3d/S3DView$Layout"); - lo.mono = env->GetStaticFieldID(layout, "MONO", kLayoutClassSignature); - lo.sbs_LR = env->GetStaticFieldID(layout, "SIDE_BY_SIDE_LR", kLayoutClassSignature); - lo.sbs_RL = env->GetStaticFieldID(layout, "SIDE_BY_SIDE_RL", kLayoutClassSignature); - lo.tb_L = env->GetStaticFieldID(layout, "TOPBOTTOM_L", kLayoutClassSignature); - lo.tb_R = env->GetStaticFieldID(layout, "TOPBOTTOM_R", kLayoutClassSignature); -} - -static int registerMethods(JNIEnv* env) { - static const char* const kClassName = "com/ti/s3d/S3DView"; - - jclass clazz; - - /* look up the class */ - clazz = env->FindClass(kClassName); - if (clazz == NULL) { - ALOGE("Can't find class %s\n", kClassName); - return -1; - } - - /* register all the methods */ - if (env->RegisterNatives(clazz, gMethods, - sizeof(gMethods) / sizeof(gMethods[0])) != JNI_OK) - { - ALOGE("Failed registering methods for %s\n", kClassName); - return -1; - } - - return 0; -} - -jint JNI_OnLoad(JavaVM* vm, void* reserved) { - JNIEnv* env = NULL; - jint result = -1; - - if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { - ALOGE("ERROR: GetEnv failed\n"); - goto bail; - } - assert(env != NULL); - - if (registerMethods(env) != 0) { - ALOGE("ERROR: S3DView native registration failed\n"); - goto bail; - } - - /* success -- return valid version number */ - result = JNI_VERSION_1_4; - -bail: - return result; -} diff --git a/s3d/products/AndroidProducts.mk b/s3d/products/AndroidProducts.mk deleted file mode 100644 index e31c1ee..0000000 --- a/s3d/products/AndroidProducts.mk +++ /dev/null @@ -1,13 +0,0 @@ -# -# This file should set PRODUCT_MAKEFILES to a list of product makefiles -# to expose to the build system. LOCAL_DIR will already be set to -# the directory containing this file. -# -# This file may not rely on the value of any variable other than -# LOCAL_DIR; do not use any conditionals, and do not look up the -# value of any variable that isn't set in this file or in a file that -# it includes. -# - -PRODUCT_MAKEFILES := \ - $(LOCAL_DIR)/s3d_sdk_addon.mk diff --git a/s3d/products/s3d_sdk_addon.mk b/s3d/products/s3d_sdk_addon.mk deleted file mode 100644 index 861728c..0000000 --- a/s3d/products/s3d_sdk_addon.mk +++ /dev/null @@ -1,39 +0,0 @@ -# List of apps and optional libraries (Java and native) to put in the add-on system image. -PRODUCT_PACKAGES := \ - com.ti.s3d \ - libs3dview_jni \ - S3DCowboids - -# name of the add-on -PRODUCT_SDK_ADDON_NAME := s3d - -# Manually copy the optional library XML files in the system image. -PRODUCT_COPY_FILES := \ - device/ti/common-open/s3d/frameworks/com.ti.s3d.xml:system/etc/permissions/com.ti.s3d.xml - -# Copy the manifest and hardware files for the SDK add-on. -# The content of those files is manually created for now. -PRODUCT_SDK_ADDON_COPY_FILES := \ - device/ti/common-open/s3d/sdk_addon/manifest.ini:manifest.ini \ - device/ti/common-open/s3d/sdk_addon/hardware.ini:hardware.ini \ - $(call find-copy-subdir-files,*,device/ti/common-open/s3d/apps/Cowboids,samples/S3DCowboids) - -# Copy the jar files for the optional libraries that are exposed as APIs. -PRODUCT_SDK_ADDON_COPY_MODULES := \ - com.ti.s3d:libs/s3d.jar - -# Build system considers this a global variable, not a part of this product def -PRODUCT_SDK_ADDON_STUB_DEFS += $(LOCAL_PATH)/stub_defs.txt - -# Name of the doc to generate and put in the add-on. This must match the name defined -# in the optional library with the tag -# LOCAL_MODULE:= platform_library -# in the documentation section. -PRODUCT_SDK_ADDON_DOC_MODULES := s3d_api - -# This add-on extends the default sdk product. -$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk) - -# Real name of the add-on. This is the name used to build the add-on. -# Use 'make PRODUCT-s3d-sdk_addon' to build the add-on. -PRODUCT_NAME := s3d diff --git a/s3d/products/stub_defs.txt b/s3d/products/stub_defs.txt deleted file mode 100644 index c01eda6..0000000 --- a/s3d/products/stub_defs.txt +++ /dev/null @@ -1 +0,0 @@ -+com.ti.s3d.* diff --git a/s3d/s3d-products.mk b/s3d/s3d-products.mk deleted file mode 100644 index 76fa5f0..0000000 --- a/s3d/s3d-products.mk +++ /dev/null @@ -1,13 +0,0 @@ -#Artifacts associated with S3D support - -# S3D platform library -PRODUCT_PACKAGES += \ - com.ti.s3d \ - libs3dview_jni - -PRODUCT_COPY_FILES += \ - device/ti/common-open/s3d/frameworks/com.ti.s3d.xml:system/etc/permissions/com.ti.s3d.xml - -# S3D Apps -PRODUCT_PACKAGES += \ - S3DCowboids
\ No newline at end of file diff --git a/s3d/sdk_addon/hardware.ini b/s3d/sdk_addon/hardware.ini deleted file mode 100644 index e7bc18d..0000000 --- a/s3d/sdk_addon/hardware.ini +++ /dev/null @@ -1,3 +0,0 @@ -# Custom hardware options for the add-on. -# Properties defined here impact all AVD targetting this add-on. -# Each skin can also override those values with its own hardware.ini file.
\ No newline at end of file diff --git a/s3d/sdk_addon/manifest.ini b/s3d/sdk_addon/manifest.ini deleted file mode 100644 index eca8dd3..0000000 --- a/s3d/sdk_addon/manifest.ini +++ /dev/null @@ -1,11 +0,0 @@ -# TI S3D SDK Add-on Manifest - -name=S3D Add-on -vendor=Texas Instruments -description=S3D add-on - -api=15 -revision=1 -libraries=com.ti.s3d -com.ti.s3d=s3d.jar;TI S3D SDK -usb-vendor=0x0451 diff --git a/sensor_test_app/Android.mk b/sensor_test_app/Android.mk deleted file mode 100644 index a50e286..0000000 --- a/sensor_test_app/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2008 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. - -ifeq ($(findstring omap, $(TARGET_BOARD_PLATFORM)),omap) -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := eng - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_PACKAGE_NAME := sensor.test - -LOCAL_PROGUARD_ENABLED := full - -include $(BUILD_PACKAGE) -endif diff --git a/sensor_test_app/AndroidManifest.xml b/sensor_test_app/AndroidManifest.xml deleted file mode 100644 index c62a252..0000000 --- a/sensor_test_app/AndroidManifest.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * Android Sensor Test Application - * - * Copyright 2010 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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.--> - -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="sensor.test" - android:minSdkVersion="7"> - <application android:icon="@drawable/icon" android:label="@string/app_name"> - <activity android:name=".com.android.sensor.Main" - android:label="@string/app_name"> - <action android:name="android.intent.action.MAIN" /> - <category - android:name="android.intent.category.LAUNCHER" /> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category - android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - <uses-sdk android:minSdkVersion="7" /> -</manifest> diff --git a/sensor_test_app/res/drawable-hdpi/about.png b/sensor_test_app/res/drawable-hdpi/about.png Binary files differdeleted file mode 100644 index 7c55dfd..0000000 --- a/sensor_test_app/res/drawable-hdpi/about.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-hdpi/exit.png b/sensor_test_app/res/drawable-hdpi/exit.png Binary files differdeleted file mode 100644 index 619858c..0000000 --- a/sensor_test_app/res/drawable-hdpi/exit.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-hdpi/icon.png b/sensor_test_app/res/drawable-hdpi/icon.png Binary files differdeleted file mode 100644 index f2db020..0000000 --- a/sensor_test_app/res/drawable-hdpi/icon.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-ldpi/about.png b/sensor_test_app/res/drawable-ldpi/about.png Binary files differdeleted file mode 100644 index 7c55dfd..0000000 --- a/sensor_test_app/res/drawable-ldpi/about.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-ldpi/exit.png b/sensor_test_app/res/drawable-ldpi/exit.png Binary files differdeleted file mode 100644 index 619858c..0000000 --- a/sensor_test_app/res/drawable-ldpi/exit.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-ldpi/icon.png b/sensor_test_app/res/drawable-ldpi/icon.png Binary files differdeleted file mode 100644 index f2db020..0000000 --- a/sensor_test_app/res/drawable-ldpi/icon.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-mdpi/about.png b/sensor_test_app/res/drawable-mdpi/about.png Binary files differdeleted file mode 100644 index 7c55dfd..0000000 --- a/sensor_test_app/res/drawable-mdpi/about.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-mdpi/exit.png b/sensor_test_app/res/drawable-mdpi/exit.png Binary files differdeleted file mode 100644 index 619858c..0000000 --- a/sensor_test_app/res/drawable-mdpi/exit.png +++ /dev/null diff --git a/sensor_test_app/res/drawable-mdpi/icon.png b/sensor_test_app/res/drawable-mdpi/icon.png Binary files differdeleted file mode 100644 index f2db020..0000000 --- a/sensor_test_app/res/drawable-mdpi/icon.png +++ /dev/null diff --git a/sensor_test_app/res/layout/main.xml b/sensor_test_app/res/layout/main.xml deleted file mode 100644 index b1271cf..0000000 --- a/sensor_test_app/res/layout/main.xml +++ /dev/null @@ -1,259 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * Android Sensor Test Application - * - * Copyright 2010 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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.--> - -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/scrllvwNo1" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - > - <LinearLayout - android:orientation="vertical" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:scrollbars="horizontal" - android:background="#FF000000"> - - <!-- Proximity Sensor Layout --> - <TextView android:text="@string/prox_header_string" - android:id="@+id/prox_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="#FFFF0000" - android:textSize="24dip"> - </TextView> - - <CheckBox android:text="@string/prox_enable_string" - android:id="@+id/prox_check_box" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </CheckBox> - <TextView android:text="@string/prox_state_string" - android:id="@+id/proximity" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_1" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <!-- Ambient Light Sensor Layout --> - <TextView android:text="@string/als_header_string" - android:id="@+id/als_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="#FFFF0000" - android:textSize="24dip"> - </TextView> - <TextView android:text="@string/als_state_string" - android:id="@+id/light" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_1_1" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <!-- Pressure Sensor Layout --> - <TextView android:text="@string/press_header_string" - android:id="@+id/pressure_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="#FFFF0000" - android:textSize="24dip"> - </TextView> - <CheckBox android:text="@string/press_enable_string" - android:id="@+id/pressure_check_box" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </CheckBox> - <TextView android:text="@string/press_state_string" - android:id="@+id/pressure" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_2" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <Button android:text="@string/press_units_string" - android:id="@+id/press_unit" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </Button> - <TextView android:id="@+id/blank_line_2_1" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <!-- Temperature Sensor Layout --> - <TextView android:text="@string/temp_header_string" - android:id="@+id/temp_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="#FFFF0000" - android:textSize="24dip"> - </TextView> - <CheckBox android:text="@string/temp_enable_string" - android:id="@+id/temp_check_box" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </CheckBox> - <TextView android:text="@string/temp_state_string" - android:id="@+id/temperature" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_2" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <Button android:text="@string/temp_units_string" - android:id="@+id/temp_unit" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </Button> - <TextView android:id="@+id/blank_line_2_1" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <!-- Accelerometer Sensor Layout --> - <TextView android:text="@string/acc_header_string" - android:textColor="#FFFF0000" - android:id="@+id/accel_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="24dip"> - </TextView> - <CheckBox android:text="@string/acc_enable_string" - android:id="@+id/accel_check_box" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </CheckBox> - <TextView android:text="@string/x_data_string" - android:id="@+id/accel_x" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:text="@string/y_data_string" - android:id="@+id/accel_y" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:text="@string/z_data_string" - android:id="@+id/accel_z" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <TextView android:id="@+id/blank_line_3" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <Button android:text="@string/acc_delay_string" - android:id="@+id/acc_delay" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </Button> - <TextView android:id="@+id/blank_line_4" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - - <!-- Magnetometer Sensor Layout --> - <TextView android:text="@string/mag_header_string" - android:textColor="#FFFF0000" - android:id="@+id/mag_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="24dip"> - </TextView> - <CheckBox android:text="@string/mag_enable_string" - android:id="@+id/mag_check_box" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </CheckBox> - <TextView android:text="@string/x_data_string" - android:id="@+id/mag_x" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:text="@string/y_data_string" - android:id="@+id/mag_y" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:text="@string/z_data_string" - android:id="@+id/mag_z" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_5" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <Button android:text="@string/mag_delay_string" - android:id="@+id/mag_delay" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </Button> - - <!-- Gyroscope Sensor Layout --> - <TextView android:text="@string/gyro_header_string" - android:textColor="#FFFF0000" - android:id="@+id/gyro_lbl_id" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textSize="24dip"> - </TextView> - <CheckBox android:text="@string/gyro_enable_string" - android:id="@+id/gyro_check_box" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </CheckBox> - <TextView android:text="@string/x_data_string" - android:id="@+id/gyro_x" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:text="@string/y_data_string" - android:id="@+id/gyro_y" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:text="@string/z_data_string" - android:id="@+id/gyro_z" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <TextView android:id="@+id/blank_line_5" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </TextView> - <Button android:text="@string/gyro_delay_string" - android:id="@+id/gyro_delay" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - </Button> - </LinearLayout> -</ScrollView> diff --git a/sensor_test_app/res/values/strings.xml b/sensor_test_app/res/values/strings.xml deleted file mode 100644 index edb43c1..0000000 --- a/sensor_test_app/res/values/strings.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * Android Sensor Test Application - * - * Copyright 2010 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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.--> - -<resources> - <string name="app_name">TI Sensor Test App</string> - <string name="app_title">TI Sensor Test Application</string> - - <string name="prox_header_string">Proximity Sensor</string> - <string name="prox_enable_string">Proximity Enable</string> - <string name="prox_state_string">Prox State: Waiting for data</string> - - <string name="als_header_string">Ambient Light Sensor</string> - <string name="als_state_string">ALS Reading: Waiting for data</string> - - <string name="press_header_string">Pressure Sensor</string> - <string name="press_enable_string">Pressure Enable</string> - <string name="press_state_string">Pressure Reading: Waiting for data</string> - <string name="press_units_string">Pressure Units</string> - - <string name="temp_header_string">Temperature Sensor</string> - <string name="temp_enable_string">Temperature Enable</string> - <string name="temp_state_string">Temperature Reading: Waiting for data</string> - <string name="temp_units_string">Temperature Units</string> - - <string name="acc_header_string">Accelerometer Sensor</string> - <string name="acc_enable_string">Accelerometer Enable</string> - <string name="acc_delay_string">Accelerometer Delay</string> - - <string name="mag_header_string">Magnetometer Sensor</string> - <string name="mag_enable_string">Magnetometer Enable</string> - <string name="mag_delay_string">Magnetometer Delay</string> - - <string name="gyro_header_string">Gyroscope Sensor</string> - <string name="gyro_enable_string">Gyroscope Enable</string> - <string name="gyro_delay_string">Gyroscope Delay</string> - - <string name="x_data_string">X Data: Waiting for Data</string> - <string name="y_data_string">Y Data: Waiting for Data</string> - <string name="z_data_string">Z Data: Waiting for Data</string> -</resources> diff --git a/sensor_test_app/src/sensor/test/com/android/sensor/Main.java b/sensor_test_app/src/sensor/test/com/android/sensor/Main.java deleted file mode 100644 index 0dca112..0000000 --- a/sensor_test_app/src/sensor/test/com/android/sensor/Main.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Android Sensor Test Application - * - * Copyright 2010 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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 sensor.test.com.android.sensor; - -import java.text.DecimalFormat; -import java.util.List; - -import sensor.test.R; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.hardware.Sensor; -import android.hardware.SensorManager; -import android.os.Bundle; -import android.util.Log; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.TextView; -import android.widget.Toast; - - -public class Main extends Activity { - private static final String TESTING_TAG = "SensorTestOutput"; - private static final String FAIL_TAG = "FAILIED: "; - private static final String WARN_TAG = "WARNING: "; - private static final String INFO_TAG = "Information: "; - private static final String VER_NUM = "1.0"; - static Sensor_data data = new Sensor_data(new DecimalFormat("0.000000")); - static Sensor_management manage = new Sensor_management(); - public List<Sensor> all; - - - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - this.setTitle(R.string.app_title); - Log.d(TESTING_TAG, "Texas Instruments Sensor Test Application: " + VER_NUM); - //Acquire SensorManager - data.sensmang = (SensorManager) getSystemService(SENSOR_SERVICE); - all = data.sensmang.getSensorList(Sensor.TYPE_ALL); - for (int i = 0; i < all.size(); i++) { - Sensor s = all.get(i); - Log.d(TESTING_TAG, "Found Sensor: " + s.getName()); - Log.d(TESTING_TAG, " Vendor: " + s.getVendor()); - Log.d(TESTING_TAG, " Max: " + s.getMaximumRange()); - Log.d(TESTING_TAG, " Resolution: " + s.getResolution()); - Log.d(TESTING_TAG, " Version: " + s.getVersion()); - }; - - //Proximity initialisation - data.proximity = data.sensmang.getDefaultSensor(Sensor.TYPE_PROXIMITY); - data.prox_lbl = (TextView) findViewById(R.id.prox_lbl_id); - data.prox = (TextView) findViewById(R.id.proximity); - data.prox_check = (CheckBox) findViewById(R.id.prox_check_box); - data.prox_state = false; - - if (data.proximity == null) { - Log.d(TESTING_TAG, WARN_TAG + "No proximity sensor avaliable."); - data.prox_lbl.setText("No Proximity Sensor available"); - data.prox.setText("Proximity State: N/A"); - data.prox_check.setClickable(false); - } else { - data.prox_lbl.setText(data.proximity.getName()); - data.prox_check.setChecked(data.prox_state); - data.prox_check.setClickable(true); - manage.set_sensor_state(Sensor.TYPE_PROXIMITY, data.prox_state, SensorManager.SENSOR_DELAY_FASTEST); - - data.prox_check.setOnClickListener(new OnClickListener() { - public void onClick(View arg0) { - if (data.prox_check.isChecked()) - data.prox_state = true; - else - data.prox_state = false; - - manage.set_sensor_state(Sensor.TYPE_PROXIMITY, data.prox_state, data.sensor_delay); - } - }); - } - - //Ambient Light sensor initialisation - data.alsensor = data.sensmang.getDefaultSensor(Sensor.TYPE_LIGHT); - data.als_lbl = (TextView) findViewById(R.id.als_lbl_id); - data.als = (TextView) findViewById(R.id.light); - data.accel_lbl = (TextView) findViewById(R.id.accel_lbl_id); - - if (data.alsensor == null) { - Log.d(TESTING_TAG, WARN_TAG + "No ALS sensor avaliable."); - data.als_lbl.setText("No ALS Sensor available"); - } else { - data.als_lbl.setText(data.alsensor.getName()); - manage.set_sensor_state(Sensor.TYPE_LIGHT, true, data.sensor_delay); - } - - //Pressure Sensor initialisation - data.pressure = data.sensmang.getDefaultSensor(Sensor.TYPE_PRESSURE); - data.press_lbl = (TextView) findViewById(R.id.pressure_lbl_id); - data.press = (TextView) findViewById(R.id.pressure); - data.pressure_check = (CheckBox) findViewById(R.id.pressure_check_box); - data.press_unit_butt = (Button) findViewById(R.id.press_unit); - data.pressure_state = false; - - if (data.pressure == null) { - Log.d(TESTING_TAG, WARN_TAG + "No pressure sensor avaliable."); - data.press_lbl.setText("No Pressure Sensor available"); - data.press.setText("Pressure Reading: N/A"); - data.press_unit_butt.setText("N/A"); - data.pressure_check.setClickable(false); - data.press_unit_butt.setEnabled(false); - } else { - data.press_lbl.setText(data.pressure.getName()); - data.pressure_check.setChecked(data.pressure_state); - data.pressure_check.setClickable(true); - manage.set_sensor_state(Sensor.TYPE_PRESSURE, data.pressure_state, data.sensor_delay); - registerForContextMenu(findViewById(R.id.press_unit)); - data.pressure_check.setOnClickListener(new OnClickListener() { - public void onClick(View arg0) { - if (data.pressure_check.isChecked()) - data.pressure_state = true; - else - data.pressure_state = false; - manage.set_sensor_state(Sensor.TYPE_PRESSURE, data.pressure_state, data.sensor_delay); - } - }); - } - //Temperature Sensor initialisation - data.temperature = data.sensmang.getDefaultSensor(Sensor.TYPE_TEMPERATURE); - data.temp_lbl = (TextView) findViewById(R.id.temp_lbl_id); - data.temp = (TextView) findViewById(R.id.temperature); - data.temperature_check = (CheckBox) findViewById(R.id.temp_check_box); - data.temp_unit_butt = (Button) findViewById(R.id.temp_unit); - data.temperature_state = false; - - if ( data.temperature == null) { - Log.d(TESTING_TAG, WARN_TAG + "No temperature sensor avaliable."); - data.temp_lbl.setText("No temperature Sensor available"); - data.temp.setText("Temperature Reading: N/A"); - data.temp_unit_butt.setText("N/A"); - data.temperature_check.setClickable(false); - data.temp_unit_butt.setEnabled(false); - } else { - data.temp_lbl.setText(data.temperature.getName()); - data.temperature_check.setChecked(data.temperature_state); - data.temperature_check.setClickable(true); - manage.set_sensor_state(Sensor.TYPE_TEMPERATURE, data.temperature_state, data.sensor_delay); - registerForContextMenu(findViewById(R.id.temp_unit)); - data.temperature_check.setOnClickListener(new OnClickListener() { - public void onClick(View arg0) { - if (data.temperature_check.isChecked()) - data.temperature_state = true; - else - data.temperature_state = false; - manage.set_sensor_state(Sensor.TYPE_TEMPERATURE, data.temperature_state, data.sensor_delay); - } - }); - } - //Accelerometer sensor initialisation - data.accelerometer = data.sensmang.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - data.accel_lbl = (TextView) findViewById(R.id.accel_lbl_id); - data.accel_x = (TextView) findViewById(R.id.accel_x); - data.accel_y = (TextView) findViewById(R.id.accel_y); - data.accel_z = (TextView) findViewById(R.id.accel_z); - data.accel_delay_butt = (Button) findViewById(R.id.acc_delay); - data.accel_check = (CheckBox) findViewById(R.id.accel_check_box); - - if (data.accelerometer == null) { - Log.d(TESTING_TAG, WARN_TAG + "No Accelerometer sensor avaliable."); - data.accel_lbl.setText("No Accelerometer Sensor available"); - data.accel_check.setClickable(false); - data.accel_delay_butt.setEnabled(false); - data.accel_delay_butt.setText("N/A"); - data.accel_x.setText("X Data: N/A"); - data.accel_y.setText("Y Data: N/A"); - data.accel_z.setText("Z Data: N/A"); - - } else { - data.accel_lbl.setText(data.accelerometer.getName()); - registerForContextMenu(findViewById(R.id.acc_delay)); - data.accel_state = false; - data.accel_check.setChecked(data.accel_state); - manage.set_sensor_state(Sensor.TYPE_ACCELEROMETER, data.accel_state, data.sensor_delay); - data.accel_check.setOnClickListener(new OnClickListener() { - public void onClick(View arg0) { - if (data.accel_check.isChecked()) - data.accel_state = true; - else - data.accel_state = false; - manage.set_sensor_state(Sensor.TYPE_ACCELEROMETER, data.accel_state, data.sensor_delay); - } - }); - } - - //Magnetometer sensor initialisation - data.magnetometer = data.sensmang.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); - data.mag_lbl = (TextView) findViewById(R.id.mag_lbl_id); - data.mag_x = (TextView) findViewById(R.id.mag_x); - data.mag_y = (TextView) findViewById(R.id.mag_y); - data.mag_z = (TextView) findViewById(R.id.mag_z); - data.mag_delay_butt = (Button) findViewById(R.id.mag_delay); - data.mag_check = (CheckBox) findViewById(R.id.mag_check_box); - - if (data.magnetometer == null) { - Log.d(TESTING_TAG, WARN_TAG + "No Magnetometer sensor avaliable."); - data.mag_lbl.setText("No Magnetometer Sensor available"); - data.mag_check.setClickable(false); - data.mag_delay_butt.setEnabled(false); - data.mag_delay_butt.setText("N/A"); - data.mag_x.setText("X Data: N/A"); - data.mag_y.setText("Y Data: N/A"); - data.mag_z.setText("Z Data: N/A"); - - } else { - data.mag_lbl.setText(data.magnetometer.getName()); - registerForContextMenu(findViewById(R.id.mag_delay)); - data.mag_state = false; - data.mag_check.setChecked(data.accel_state); - manage.set_sensor_state(Sensor.TYPE_MAGNETIC_FIELD, data.mag_state, data.sensor_delay); - data.mag_check.setOnClickListener(new OnClickListener() { - public void onClick(View arg0) { - if (data.mag_check.isChecked()) - data.mag_state = true; - else - data.mag_state = false; - manage.set_sensor_state(Sensor.TYPE_MAGNETIC_FIELD, data.mag_state, data.sensor_delay); - } - }); - } - //Gyroscope sensor initialisation - data.gyroscope = data.sensmang.getDefaultSensor(Sensor.TYPE_GYROSCOPE); - data.gyro_lbl = (TextView) findViewById(R.id.gyro_lbl_id); - data.gyro_x = (TextView) findViewById(R.id.gyro_x); - data.gyro_y = (TextView) findViewById(R.id.gyro_y); - data.gyro_z = (TextView) findViewById(R.id.gyro_z); - data.gyro_delay_butt = (Button) findViewById(R.id.gyro_delay); - data.gyro_check = (CheckBox) findViewById(R.id.gyro_check_box); - - if (data.gyroscope == null) { - Log.d(TESTING_TAG, WARN_TAG + "No Gyroscope sensor avaliable."); - data.gyro_lbl.setText("No Gyroscope Sensor available"); - data.gyro_check.setClickable(false); - data.gyro_delay_butt.setEnabled(false); - data.gyro_delay_butt.setText("N/A"); - data.gyro_x.setText("X Data: N/A"); - data.gyro_y.setText("Y Data: N/A"); - data.gyro_z.setText("Z Data: N/A"); - - } else { - data.gyro_lbl.setText(data.gyroscope.getName()); - registerForContextMenu(findViewById(R.id.gyro_delay)); - data.gyro_state = false; - data.gyro_check.setChecked(data.gyro_state); - manage.set_sensor_state(Sensor.TYPE_GYROSCOPE, data.gyro_state, data.sensor_delay); - data.gyro_check.setOnClickListener(new OnClickListener() { - public void onClick(View arg0) { - if (data.gyro_check.isChecked()) - data.gyro_state = true; - else - data.gyro_state = false; - manage.set_sensor_state(Sensor.TYPE_GYROSCOPE, data.gyro_state, data.sensor_delay); - } - }); - } - } - - @Override - protected void onResume() { - data.accel_state = data.accel_check.isChecked(); - data.prox_state = data.prox_check.isChecked(); - data.mag_state = data.mag_check.isChecked(); - data.pressure_state = data.pressure_check.isChecked(); - data.temperature_state = data.temperature_check.isChecked(); - data.gyro_state = data.gyro_check.isChecked(); - - manage.set_sensor_state(Sensor.TYPE_PROXIMITY, data.prox_state, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_LIGHT, true, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_ACCELEROMETER, data.accel_state, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_MAGNETIC_FIELD, data.mag_state, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_PRESSURE, data.pressure_state, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_TEMPERATURE, data.temperature_state, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_GYROSCOPE, data.gyro_state, data.sensor_delay); - manage.ok_to_toast = false; - super.onResume(); - } - - @Override - protected void onStop() { - manage.set_sensor_state(Sensor.TYPE_PROXIMITY, false, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_LIGHT, false, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_ACCELEROMETER, false, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_MAGNETIC_FIELD, false, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_PRESSURE, false, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_TEMPERATURE, false, data.sensor_delay); - manage.set_sensor_state(Sensor.TYPE_GYROSCOPE, false, data.sensor_delay); - manage.ok_to_toast = false; - super.onStop(); - } - @Override - public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { - - super.onCreateContextMenu(menu, v, menuInfo); - if (v.getId() == R.id.acc_delay) { - if (data.accel_state == true) { - menu.setHeaderTitle("Accelerometer Delay Menu"); - Main.manage.sensor_to_manage = Sensor.TYPE_ACCELEROMETER; - menu.add(0, 0, 0, "Fastest"); - menu.add(0, 1, 0, "Gamer"); - menu.add(0, 2, 0, "UI"); - menu.add(0, 3, 0, "Normal"); - } else { - Log.e(TESTING_TAG, WARN_TAG + "Accelerometer not enabled"); - return; - } - } else if (v.getId() == R.id.mag_delay) { - if (data.mag_state == true) { - menu.setHeaderTitle("Magnetometer Delay Menu"); - Main.manage.sensor_to_manage = Sensor.TYPE_MAGNETIC_FIELD; - menu.add(0, 0, 0, "Fastest"); - menu.add(0, 1, 0, "Gamer"); - menu.add(0, 2, 0, "UI"); - menu.add(0, 3, 0, "Normal"); - } else { - Log.e(TESTING_TAG, WARN_TAG + "Magnetometer not enabled"); - return; - } - } else if (v.getId() == R.id.gyro_delay) { - if (data.gyro_state == true) { - menu.setHeaderTitle("Gyroscope Delay Menu"); - Main.manage.sensor_to_manage = Sensor.TYPE_GYROSCOPE; - menu.add(0, 0, 0, "Fastest"); - menu.add(0, 1, 0, "Gamer"); - menu.add(0, 2, 0, "UI"); - menu.add(0, 3, 0, "Normal"); - } else { - Log.e(TESTING_TAG, WARN_TAG + "Gyroscope not enabled"); - return; - } - } else if (v.getId() == R.id.press_unit) { - if (data.pressure_state == true) { - Main.manage.sensor_to_manage = Sensor.TYPE_PRESSURE; - menu.setHeaderTitle("Pressure Unit Menu"); - menu.add(0, 0, 0, "Pascals"); - menu.add(0, 1, 0, "mmHg"); - menu.add(0, 2, 0, "inHg"); - } else { - Log.e(TESTING_TAG, WARN_TAG + "Pressure Sensor not enabled"); - return; - } - } else if (v.getId() == R.id.temp_unit) { - if (data.temperature_state == true) { - Main.manage.sensor_to_manage = Sensor.TYPE_TEMPERATURE; - menu.setHeaderTitle("Temperature Unit Menu"); - menu.add(0, 0, 0, "Celcius"); - menu.add(0, 1, 0, "Farenheit"); - } else { - Log.e(TESTING_TAG, WARN_TAG + "Temperature Sensor not enabled"); - return; - } - }else { - return; - } - } - - @Override - public boolean onContextItemSelected(MenuItem item) { - boolean err = false; - int delay = SensorManager.SENSOR_DELAY_NORMAL; - - if (Main.manage.sensor_to_manage == Sensor.TYPE_PRESSURE) { - if(item.getItemId() == 0) { - data.pressure_measurement = 0; - Log.d(TESTING_TAG, INFO_TAG + "Setting Pressure data to Pascals"); - } else if(item.getItemId() == 1){ - data.pressure_measurement = 1; - Log.d(TESTING_TAG, INFO_TAG + "Setting Pressure data to mmHg"); - } else if(item.getItemId() == 2){ - data.pressure_measurement = 2; - Log.d(TESTING_TAG, INFO_TAG + "Setting Pressure data to inHg"); - } else { - Log.e(TESTING_TAG, FAIL_TAG + "Unknown Pressure scale requested"); - return false; - } - } else if (Main.manage.sensor_to_manage == Sensor.TYPE_TEMPERATURE) { - if(item.getItemId() == 0) { - if (data.temperature_units == 1) - data.temp.setText("Temperature Reading: " + data.temperature_measurement + " C"); - - data.temperature_units = 0; - Log.d(TESTING_TAG, INFO_TAG + "Setting Temperature data to Celcius"); - } else if(item.getItemId() == 1){ - if (data.temperature_units == 0) - data.temp.setText("Temperature Reading: " + (data.temperature_measurement * 1.8f + 32) + " F"); - - data.temperature_units = 1; - Log.d(TESTING_TAG, INFO_TAG + "Setting Temperature to Farenheit"); - } else { - Log.e(TESTING_TAG, FAIL_TAG + "Unknown Pressure scale requested"); - return false; - } - } else { - if(item.getItemId() == 0) { - Toast.makeText(getBaseContext(), "Setting to Fastest Speed", - Toast.LENGTH_SHORT).show(); - delay = SensorManager.SENSOR_DELAY_FASTEST; - Log.d(TESTING_TAG, INFO_TAG + "Fastest data rate requested"); - } else if(item.getItemId() == 1){ - Toast.makeText(getBaseContext(), "Setting to Gaming Speed", - Toast.LENGTH_SHORT).show(); - delay = SensorManager.SENSOR_DELAY_GAME; - Log.d(TESTING_TAG, INFO_TAG + "Gaming data rate requested"); - } else if(item.getItemId() == 2){ - Toast.makeText(getBaseContext(), "Setting to UI Speed", - Toast.LENGTH_SHORT).show(); - delay = SensorManager.SENSOR_DELAY_UI; - Log.d(TESTING_TAG, INFO_TAG + "UI data rate requested"); - } else if(item.getItemId() == 3){ - Toast.makeText(getBaseContext(), "Setting to Normal Speed", - Toast.LENGTH_SHORT).show(); - delay = SensorManager.SENSOR_DELAY_NORMAL; - Log.d(TESTING_TAG, INFO_TAG + "Normal data rate requested"); - } else { - Log.e(TESTING_TAG, FAIL_TAG + "Unknown data rate requested"); - return false; - } - - data.sensor_delay = delay; - - err = manage.set_sensor_delay(Main.manage.sensor_to_manage, delay); - if (err != true) { - Toast.makeText(getBaseContext(), "Delay was not set", - Toast.LENGTH_SHORT).show(); - Log.e(TESTING_TAG, FAIL_TAG + "Sensor delay was not set"); - return err; - } - } - - return true; - } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - int groupId = 0; - int menuItemOrder = Menu.NONE; - MenuItem quitmenuItem = menu.add(groupId, 0, menuItemOrder, "Quit"); - quitmenuItem.setIcon(R.drawable.exit); - MenuItem aboutmenuItem = menu.add(groupId, 1, menuItemOrder, "About This Application"); - aboutmenuItem.setIcon(R.drawable.about); - - return true; - } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle item selection - switch (item.getItemId()) { - //Quit - case 0: - this.onStop(); - finish(); - break; - //Help - case 1: - AlertDialog.Builder helpbox = new AlertDialog.Builder(this); - helpbox.setMessage("Texas Instruments Sensor Test Application Version: " + VER_NUM); - helpbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface arg0, int arg1) { - // Do nothing as there is nothing to do - } - }); - helpbox.show(); - return true; - default: - return super.onOptionsItemSelected(item); - } - return true; - } -} diff --git a/sensor_test_app/src/sensor/test/com/android/sensor/Sensor_data.java b/sensor_test_app/src/sensor/test/com/android/sensor/Sensor_data.java deleted file mode 100644 index 67df907..0000000 --- a/sensor_test_app/src/sensor/test/com/android/sensor/Sensor_data.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Android Sensor Test Application - * - * Copyright 2010 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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 sensor.test.com.android.sensor; - -import java.text.DecimalFormat; - -import android.util.Log; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.TextView; - -public class Sensor_data { - private static final String ACCEL_DATA = "Accel_Out"; - private static final String MAG_DATA = "Mag_Out"; - private static final String ALS_DATA = "ALS_Out"; - private static final String PROX_DATA = "Proximity_Out"; - private static final String PRESS_DATA = "Pressure_Out"; - private static final String GYRO_DATA = "Gyroscope_Out"; - private static final String TEMP_DATA = "Temperature_Out"; - private static final String INFO_TAG = "Information: "; - public SensorManager sensmang; - public Sensor proximity; - public Sensor alsensor; - public Sensor accelerometer; - public Sensor magnetometer; - public Sensor pressure; - public Sensor temperature; - public Sensor gyroscope; - public TextView prox, prox_lbl, press, press_lbl, temp_lbl, temp; - public TextView als, als_lbl, accel_lbl, mag_lbl; - public TextView gyro, gyro_lbl; - public TextView accel_x, accel_y, accel_z; - public TextView mag_x, mag_y, mag_z; - public TextView gyro_x, gyro_y, gyro_z; - public CheckBox accel_check, mag_check, gyro_check; - public boolean accel_state, mag_state, gyro_state; - public Button accel_delay_butt, mag_delay_butt, press_unit_butt, temp_unit_butt; - public Button gyro_delay_butt; - public CheckBox prox_check, pressure_check, temperature_check; - public boolean prox_state, pressure_state, temperature_state; - public DecimalFormat round; - public int pressure_measurement = 0; - public float temperature_measurement = 0; - public int temperature_units = 0; - private double mmHG_Conv = 0.7500616827042; - private double inHG_Conv = 0.029529983071; - - public int sensor_delay = sensmang.SENSOR_DELAY_FASTEST; - - public SensorEventListener proxEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - public void onSensorChanged(SensorEvent event) { - - if (event.values[0] <= 3) { - Log.d(PROX_DATA, "Proximity State: NEAR"); - prox.setText("Proximity State: NEAR"); - } else { - Log.d(PROX_DATA, "Proximity State: FAR"); - prox.setText("Proximity State: FAR"); - } - } - }; - - public SensorEventListener alsEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - public void onSensorChanged(SensorEvent event) { - als.setText("ALS Reading: " + - new DecimalFormat("0.00").format(event.values[0]) + - " lux"); - Log.d(ALS_DATA, "ALS Reading: " + event.values[0] + " Lux"); - } - }; - - public SensorEventListener accelEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - public void onSensorChanged(SensorEvent event) { - if (Main.data.accel_state == true) { - accel_x.setText("X Data: " + round.format(event.values[0]) + " m/s^2"); - accel_y.setText("Y Data: " + round.format(event.values[1]) + " m/s^2"); - accel_z.setText("Z Data: " + round.format(event.values[2]) + " m/s^2"); - - Log.d(ACCEL_DATA, "Accl X Data: " + round.format(event.values[0]) + " m/s^2"); - Log.d(ACCEL_DATA, "Accl Y Data: " + round.format(event.values[1]) + " m/s^2"); - Log.d(ACCEL_DATA, "Accl Z Data: " + round.format(event.values[2]) + " m/s^2"); - } else { - Log.d(ACCEL_DATA, INFO_TAG + "Received one more data set while disabling"); - Log.d(ACCEL_DATA, "Accl X Data: " + round.format(event.values[0]) + " m/s^2"); - Log.d(ACCEL_DATA, "Accl Y Data: " + round.format(event.values[1]) + " m/s^2"); - Log.d(ACCEL_DATA, "Accl Z Data: " + round.format(event.values[2]) + " m/s^2"); - - } - } - }; - - public SensorEventListener magEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - public void onSensorChanged(SensorEvent event) { - if (Main.data.mag_state == true) { - mag_x.setText("X Data: " + round.format(event.values[0]) + " micro Tesla"); - mag_y.setText("Y Data: " + round.format(event.values[1]) + " micro Tesla"); - mag_z.setText("Z Data: " + round.format(event.values[2]) + " micro Tesla"); - - Log.d(MAG_DATA, "Mag X Data: " + round.format(event.values[0]) + " micro Tesla"); - Log.d(MAG_DATA, "Mag Y Data: " + round.format(event.values[1]) + " micro Tesla"); - Log.d(MAG_DATA, "Mag Z Data: " + round.format(event.values[2]) + " micro Tesla"); - } else { - Log.d(MAG_DATA, INFO_TAG + "Received one more data set while disabling"); - Log.d(MAG_DATA, "Mag X Data: " + round.format(event.values[0]) + " micro Tesla"); - Log.d(MAG_DATA, "Mag Y Data: " + round.format(event.values[1]) + " micro Tesla"); - Log.d(MAG_DATA, "Mag Z Data: " + round.format(event.values[2]) + " micro Tesla"); - } - } - }; - - public SensorEventListener gyroEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - public void onSensorChanged(SensorEvent event) { - if (Main.data.gyro_state == true) { - gyro_x.setText("X Data: " + round.format(event.values[0]) + " rad/s"); - gyro_y.setText("Y Data: " + round.format(event.values[1]) + " rad/s"); - gyro_z.setText("Z Data: " + round.format(event.values[2]) + " rad/s"); - - Log.d(GYRO_DATA, "Gyro X Data: " + round.format(event.values[0]) + " rad/s"); - Log.d(GYRO_DATA, "Gyro Y Data: " + round.format(event.values[1]) + " rad/s"); - Log.d(GYRO_DATA, "Gyro Z Data: " + round.format(event.values[2]) + " rad/s"); - } else { - Log.d(GYRO_DATA, INFO_TAG + "Received one more data set while disabling"); - Log.d(GYRO_DATA, "Gyro X Data: " + round.format(event.values[0]) + " rad/s"); - Log.d(GYRO_DATA, "Gyro Y Data: " + round.format(event.values[1]) + " rad/s"); - Log.d(GYRO_DATA, "Gyro Z Data: " + round.format(event.values[2]) + " rad/s"); - } - } - }; - - public SensorEventListener pressureEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - public void onSensorChanged(SensorEvent event) { - if (event.sensor.getType() == Sensor.TYPE_PRESSURE) { - if (pressure_measurement == 0) { - press.setText("Pressure Reading: " + event.values[0] + " N/m^2"); - Log.d(PRESS_DATA, "Pressure Reading: " + event.values[0] + " N/m^2"); - } else if (pressure_measurement == 1) { - press.setText("Pressure Reading: " + (event.values[0] * mmHG_Conv) + " mmHg"); - Log.d(PRESS_DATA, "Pressure Reading: " + (event.values[0] * mmHG_Conv) + " mmHg"); - } else if (pressure_measurement == 2) { - press.setText("Pressure Reading: " + (event.values[0] * inHG_Conv) + " inHg"); - Log.d(PRESS_DATA, "Pressure Reading: " + (event.values[0] * inHG_Conv) + " inHg"); - } - } - } - }; - - public SensorEventListener temperatureEventListener = new SensorEventListener() { - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO Auto-generated method stub - } - - public void onSensorChanged(SensorEvent event) { - if (event.sensor.getType() == Sensor.TYPE_TEMPERATURE) { - temperature_measurement = event.values[0]; - if (temperature_units == 0) { - temp.setText("Temperature Reading: " + temperature_measurement + " C"); - Log.d(TEMP_DATA, "Temperature Reading: " + temperature_measurement + " C"); - } else if (temperature_units == 1) { - temp.setText("Temperature Reading: " + (temperature_measurement * 1.8f + 32) + " F"); - Log.d(TEMP_DATA, "Temperature Reading: " + (temperature_measurement * 1.8f + 32) + " F"); - } - } - } - }; - - public Sensor_data(DecimalFormat round) { - this.round = round; - } -} diff --git a/sensor_test_app/src/sensor/test/com/android/sensor/Sensor_management.java b/sensor_test_app/src/sensor/test/com/android/sensor/Sensor_management.java deleted file mode 100644 index 72be39a..0000000 --- a/sensor_test_app/src/sensor/test/com/android/sensor/Sensor_management.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Android Sensor Test Application - * - * Copyright 2010 Texas Instruments, Inc. - http://www.ti.com/ - * - * Written by Dan Murphy <dmurphy@ti.com> - * - * 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 sensor.test.com.android.sensor; - -import android.app.Activity; -import android.hardware.Sensor; -import android.hardware.SensorManager; -import android.util.Log; -import android.widget.Toast; - -public class Sensor_management extends Activity { - private static final String TAG = "SensorApp"; - private static final String TESTING_TAG = "SensorTestOutput"; - private static final String FAIL_TAG = "FAILIED: "; - private static final String WARN_TAG = "WARNING: "; - private static final String INFO_TAG = "Information: "; - public SensorManager sensmang; - public int sensor_to_manage; - public boolean ok_to_toast = false; - - /** - * @param sensor_type - Sensor type from Sensor Manager - * @param state - true for turning on the sensor false for turning off the sensor - * @return - void - */ - public void set_sensor_state(int sensor_type, boolean state, int delay) { - boolean sensor_return = true; - - if (sensor_type == Sensor.TYPE_ACCELEROMETER) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.accelEventListener, - Main.data.accelerometer, - delay); - if (sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Accelerometer failed to register!"); - Main.data.accel_state = false; - Main.data.accel_check.setChecked(false); - Main.data.accel_delay_butt.setEnabled(false); - Main.data.accel_x.setText("X Data: N/A"); - Main.data.accel_y.setText("Y Data: N/A"); - Main.data.accel_z.setText("Z Data: N/A"); - } else { - make_a_toast("Accelerometer Sensor Enabled"); - Main.data.accel_x.setText("X Data: Enabled"); - Main.data.accel_y.setText("Y Data: Enabled"); - Main.data.accel_z.setText("Z Data: Enabled"); - Log.d(TESTING_TAG, INFO_TAG + "Accelerometer Sensor Enabled."); - } - } else { - Main.data.sensmang.unregisterListener(Main.data.accelEventListener); - make_a_toast("Accelerometer Sensor Disabled"); - Main.data.accel_x.setText("X Data: Disabled"); - Main.data.accel_y.setText("Y Data: Disabled"); - Main.data.accel_z.setText("Z Data: Disabled"); - Log.d(TESTING_TAG, INFO_TAG + "Accelerometer Sensor Disabled."); - } - - } else if (sensor_type == Sensor.TYPE_MAGNETIC_FIELD) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.magEventListener, - Main.data.magnetometer, - delay); - if(sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Magnetometer failed to register!"); - Main.data.mag_state = false; - Main.data.mag_check.setChecked(false); - Main.data.mag_delay_butt.setEnabled(false); - Main.data.mag_x.setText("X Data: N/A"); - Main.data.mag_y.setText("Y Data: N/A"); - Main.data.mag_z.setText("Z Data: N/A"); - - } else { - make_a_toast("Magnetometer Sensor Enabled"); - Main.data.mag_x.setText("X Data: Enabled"); - Main.data.mag_y.setText("Y Data: Enabled"); - Main.data.mag_z.setText("Z Data: Enabled"); - Log.d(TESTING_TAG, INFO_TAG + "Magnetometer Sensor Enabled."); - } - } else { - Main.data.sensmang.unregisterListener(Main.data.magEventListener); - make_a_toast("Magnetometer Sensor Disabled"); - Main.data.mag_x.setText("X Data: Disabled"); - Main.data.mag_y.setText("Y Data: Disabled"); - Main.data.mag_z.setText("Z Data: Disabled"); - Log.d(TESTING_TAG, INFO_TAG + "Magnetometer Sensor Disabled."); - } - - } else if (sensor_type == Sensor.TYPE_PROXIMITY) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.proxEventListener, - Main.data.proximity, - delay); - if (sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Proximity failed to register!"); - Main.data.prox_state = false; - Main.data.prox_check.setChecked(false); - Main.data.prox.setText("Proximity State: N/A"); - } else { - make_a_toast("Proximity Sensor Enabled"); - Main.data.prox.setText("Proximity State: Enabled"); - Log.d(TESTING_TAG, INFO_TAG + "Proximity State: Enable"); - } - } else { - Main.data.sensmang.unregisterListener(Main.data.proxEventListener); - make_a_toast("Proximity Sensor Disabled"); - Main.data.prox.setText("Proximity State: Disabled"); - Log.d(TESTING_TAG, INFO_TAG + "Proximity State: Disabled"); - } - - } else if (sensor_type == Sensor.TYPE_LIGHT) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.alsEventListener, - Main.data.alsensor, - delay); - if (sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Ambient Light Sensor failed to register!"); - Main.data.als.setText("ALS Reading: N/A"); - } - } else - Main.data.sensmang.unregisterListener(Main.data.alsEventListener); - - } else if (sensor_type == Sensor.TYPE_PRESSURE) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.pressureEventListener, - Main.data.pressure, - delay); - if(sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Pressure Sensor failed to register!"); - Main.data.pressure_state = false; - Main.data.pressure_check.setChecked(false); - Main.data.press.setText("Pressure Reading: N/A"); - } else { - make_a_toast("Pressure Sensor Enabled"); - Main.data.press.setText("Pressure Reading: Enabled"); - Log.d(TAG, INFO_TAG + "Pressure Reading: Enable"); - } - } else { - Main.data.sensmang.unregisterListener(Main.data.pressureEventListener); - make_a_toast("Pressure Sensor Disabled"); - Main.data.press.setText("Pressure Reading: Disabled"); - Log.d(TAG, INFO_TAG + "Pressure Reading: Disabled"); - } - - } else if (sensor_type == Sensor.TYPE_TEMPERATURE) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.temperatureEventListener, - Main.data.temperature, - delay); - if(sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Temperature Sensor failed to register!"); - Main.data.temperature_state = false; - Main.data.temperature_check.setChecked(false); - Main.data.temp.setText("Temperature Reading: N/A"); - } else { - make_a_toast("Temperature Sensor Enabled"); - Main.data.temp.setText("Temperature Reading: Enabled"); - Log.d(TAG, INFO_TAG + "Temperature Reading: Enable"); - } - } else { - Main.data.sensmang.unregisterListener(Main.data.temperatureEventListener); - make_a_toast("Temperature Sensor Disabled"); - Main.data.temp.setText("Temperature Reading: Disabled"); - Log.d(TAG, INFO_TAG + "Temperature Reading: Disabled"); - } - - } else if (sensor_type == Sensor.TYPE_GYROSCOPE) { - if (state) { - sensor_return = Main.data.sensmang.registerListener(Main.data.gyroEventListener, - Main.data.gyroscope, - delay); - if(sensor_return != true) { - Log.e(TESTING_TAG, FAIL_TAG + "Gyroscope Sensor failed to register!"); - Main.data.gyro_state = false; - Main.data.gyro_check.setChecked(false); - Main.data.gyro_x.setText("X Data: N/A"); - Main.data.gyro_y.setText("Y Data: N/A"); - Main.data.gyro_z.setText("Z Data: N/A"); - - } else { - make_a_toast("Gyroscope Sensor Enabled"); - Main.data.gyro_x.setText("X Data: Enabled"); - Main.data.gyro_y.setText("Y Data: Enabled"); - Main.data.gyro_z.setText("Z Data: Enabled"); - Log.d(TAG, INFO_TAG + "Gyroscope Reading: Enable"); - } - } else { - Main.data.sensmang.unregisterListener(Main.data.gyroEventListener); - make_a_toast("Gyroscope Sensor Disabled"); - Main.data.gyro_x.setText("X Data: Disabled"); - Main.data.gyro_y.setText("Y Data: Disabled"); - Main.data.gyro_z.setText("Z Data: Disabled"); - Log.d(TAG, INFO_TAG + "Gyroscope Reading: Disabled"); - } - - } else { - Log.e(TAG, WARN_TAG + "Invalid parameter passed to set_sensor_state."); - sensor_return = false; - } - - } - - /** - * @param sensor_type - Sensor type from Sensor Manager - * @param delay - Sensor delay from the Sensor Manager - * @return 0 for pass and <0 for a failure - */ - public boolean set_sensor_delay(int sensor_type, int delay) { - boolean sensor_return = true; - - if (Main.data.accel_state) { - Main.data.sensmang.unregisterListener(Main.data.accelEventListener); - set_sensor_state(Sensor.TYPE_ACCELEROMETER, Main.data.accel_state, delay); - } - if (Main.data.mag_state) { - Main.data.sensmang.unregisterListener(Main.data.magEventListener); - set_sensor_state(Sensor.TYPE_MAGNETIC_FIELD, Main.data.mag_state, delay); - } - if (Main.data.prox_state) { - Main.data.sensmang.unregisterListener(Main.data.proxEventListener); - set_sensor_state(Sensor.TYPE_PROXIMITY, true, delay); - } - if (Main.data.temperature_state) { - Main.data.sensmang.unregisterListener(Main.data.temperatureEventListener); - set_sensor_state(Sensor.TYPE_TEMPERATURE, true, delay); - } - if (Main.data.pressure_state) { - Main.data.sensmang.unregisterListener(Main.data.pressureEventListener); - set_sensor_state(Sensor.TYPE_PRESSURE, true, delay); - } - if (Main.data.gyro_state) { - Main.data.sensmang.unregisterListener(Main.data.gyroEventListener); - set_sensor_state(Sensor.TYPE_GYROSCOPE, true, delay); - } - - Main.data.sensmang.unregisterListener(Main.data.alsEventListener); - set_sensor_state(Sensor.TYPE_LIGHT, true, delay); - return sensor_return; - } - - /** - * @param toast_string - String to present in the toast - */ - public void make_a_toast(CharSequence toast_string) { - - if (this.ok_to_toast) { - Toast.makeText(getBaseContext(), toast_string, - Toast.LENGTH_SHORT).show(); - } - } - public Sensor_management() { - super(); - } -} |