diff options
| -rw-r--r-- | api/current.xml | 4 | ||||
| -rw-r--r-- | core/java/android/app/NativeActivity.java | 23 | ||||
| -rw-r--r-- | core/java/android/content/Context.java | 114 | ||||
| -rw-r--r-- | core/java/android/nfc/NdefTag.java | 1 | ||||
| -rw-r--r-- | core/java/android/nfc/RawTagConnection.java | 1 | ||||
| -rw-r--r-- | core/java/android/nfc/Tag.java | 14 | ||||
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 4 | ||||
| -rw-r--r-- | core/jni/android_app_NativeActivity.cpp | 10 | ||||
| -rw-r--r-- | native/include/android/native_activity.h | 32 | ||||
| -rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 14 | ||||
| -rw-r--r-- | services/camera/libcameraservice/CameraService.h | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/Transform.cpp | 60 | ||||
| -rw-r--r-- | services/surfaceflinger/Transform.h | 9 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/transform/Android.mk | 19 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/transform/TransformTest.cpp | 45 | 
15 files changed, 226 insertions, 126 deletions
| diff --git a/api/current.xml b/api/current.xml index c91c2b5e469b..d3d3e3d696d0 100644 --- a/api/current.xml +++ b/api/current.xml @@ -23853,11 +23853,11 @@  <parameter name="holder" type="android.view.SurfaceHolder">  </parameter>  </method> -<field name="KEY_NATIVE_SAVED_STATE" +<field name="META_DATA_FUNC_NAME"   type="java.lang.String"   transient="false"   volatile="false" - value=""android:native_state"" + value=""android.app.func_name""   static="true"   final="true"   deprecated="not deprecated" diff --git a/core/java/android/app/NativeActivity.java b/core/java/android/app/NativeActivity.java index c98128cbb255..de36f273d62c 100644 --- a/core/java/android/app/NativeActivity.java +++ b/core/java/android/app/NativeActivity.java @@ -5,7 +5,6 @@ import com.android.internal.view.IInputMethodSession;  import android.content.Context;  import android.content.pm.ActivityInfo; -import android.content.pm.ApplicationInfo;  import android.content.pm.PackageManager;  import android.content.res.AssetManager;  import android.content.res.Configuration; @@ -48,9 +47,22 @@ import java.lang.ref.WeakReference;   */  public class NativeActivity extends Activity implements SurfaceHolder.Callback2,          InputQueue.Callback, OnGlobalLayoutListener { +    /** +     * Optional meta-that can be in the manifest for this component, specifying +     * the name of the native shared library to load.  If not specified, +     * "main" is used. +     */      public static final String META_DATA_LIB_NAME = "android.app.lib_name"; -    public static final String KEY_NATIVE_SAVED_STATE = "android:native_state"; +    /** +     * Optional meta-that can be in the manifest for this component, specifying +     * the name of the main entry point for this native activity in the +     * {@link #META_DATA_LIB_NAME} native code.  If not specified, +     * "ANativeActivity_onCreate" is used. +     */ +    public static final String META_DATA_FUNC_NAME = "android.app.func_name"; +     +    private static final String KEY_NATIVE_SAVED_STATE = "android:native_state";      private NativeContentView mNativeContentView;      private InputMethodManager mIMM; @@ -71,7 +83,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,      private boolean mDestroyed; -    private native int loadNativeCode(String path, MessageQueue queue, +    private native int loadNativeCode(String path, String funcname, MessageQueue queue,              String internalDataPath, String externalDataPath, int sdkVersion,              AssetManager assetMgr, byte[] savedState);      private native void unloadNativeCode(int handle); @@ -131,6 +143,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,      @Override      protected void onCreate(Bundle savedInstanceState) {          String libname = "main"; +        String funcname = "ANativeActivity_onCreate";          ActivityInfo ai;          mIMM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); @@ -155,6 +168,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,              if (ai.metaData != null) {                  String ln = ai.metaData.getString(META_DATA_LIB_NAME);                  if (ln != null) libname = ln; +                ln = ai.metaData.getString(META_DATA_FUNC_NAME); +                if (ln != null) funcname = ln;              }          } catch (PackageManager.NameNotFoundException e) {              throw new RuntimeException("Error getting activity info", e); @@ -175,7 +190,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,          byte[] nativeSavedState = savedInstanceState != null                  ? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null; -        mNativeHandle = loadNativeCode(path, Looper.myQueue(), +        mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),                   getFilesDir().toString(),                   Environment.getExternalStorageAppFilesDirectory(ai.packageName).toString(),                   Build.VERSION.SDK_INT, getAssets(), nativeSavedState); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 0dd2e4a74878..75638312bdee 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -80,7 +80,8 @@ public abstract class Context {      /**       * Flag for {@link #bindService}: automatically create the service as long       * as the binding exists.  Note that while this will create the service, -     * its {@link android.app.Service#onStart} method will still only be called due to an +     * its {@link android.app.Service#onStartCommand} +     * method will still only be called due to an       * explicit call to {@link #startService}.  Even without that, though,       * this still provides you with access to the service object while the       * service is created. @@ -134,13 +135,13 @@ public abstract class Context {       * services, etc).       */      public abstract Looper getMainLooper(); -     +      /**       * Return the context of the single, global Application object of the       * current process.  This generally should only be used if you need a       * Context whose lifecycle is separate from the current context, that is       * tied to the lifetime of the process rather than the current component. -     *  +     *       * <p>Consider for example how this interacts with       * {@ #registerReceiver(BroadcastReceiver, IntentFilter)}:       * <ul> @@ -269,7 +270,7 @@ public abstract class Context {      /** Return the full application info for this context's package. */      public abstract ApplicationInfo getApplicationInfo(); -     +      /**       * Return the full path to this context's primary Android package.       * The Android package is a ZIP file which contains the application's @@ -412,18 +413,18 @@ public abstract class Context {       * @see #getDir       */      public abstract File getFilesDir(); -     +      /**       * Returns the absolute path to the directory on the external filesystem       * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory()       * Environment.getExternalStorageDirectory()}) where the application can       * place persistent files it owns.  These files are private to the       * applications, and not typically visible to the user as media. -     *  +     *       * <p>This is like {@link #getFilesDir()} in that these       * files will be deleted when the application is uninstalled, however there       * are some important differences: -     *  +     *       * <ul>       * <li>External files are not always available: they will disappear if the       * user mounts the external storage on a computer or removes it.  See the @@ -431,10 +432,10 @@ public abstract class Context {       * <li>There is no security enforced with these files.  All applications       * can read and write files placed here.       * </ul> -     *  +     *       * <p>Here is an example of typical code to manipulate a file in       * an application's private storage:</p> -     *  +     *       * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java       * private_file}       * @@ -454,13 +455,13 @@ public abstract class Context {       * {@link android.os.Environment#getExternalStoragePublicDirectory       * Environment.getExternalStoragePublicDirectory()}, the directory       * returned here will be automatically created for you. -     *  +     *       * <p>Here is an example of typical code to manipulate a picture in       * an application's private storage and add it to the media database:</p> -     *  +     *       * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java       * private_picture} -     *  +     *       * @param type The type of files directory to return.  May be null for       * the root of the files directory or one of       * the following Environment constants for a subdirectory: @@ -471,7 +472,7 @@ public abstract class Context {       * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS},       * {@link android.os.Environment#DIRECTORY_PICTURES}, or       * {@link android.os.Environment#DIRECTORY_MOVIES}. -     *  +     *       * @return Returns the path of the directory holding application files       * on external storage.  Returns null if external storage is not currently       * mounted so it could not ensure the path exists; you will need to call @@ -481,18 +482,18 @@ public abstract class Context {       * @see android.os.Environment#getExternalStoragePublicDirectory       */      public abstract File getExternalFilesDir(String type); -     +      /** -     * Returns the absolute path to the application specific cache directory  +     * Returns the absolute path to the application specific cache directory       * on the filesystem. These files will be ones that get deleted first when the       * device runs low on storage.       * There is no guarantee when these files will be deleted. -     *  +     *       * <strong>Note: you should not <em>rely</em> on the system deleting these       * files for you; you should always have a reasonable maximum, such as 1 MB,       * for the amount of space you consume with cache files, and prune those       * files when exceeding that space.</strong> -     *  +     *       * @return Returns the path of the directory holding application cache files.       *       * @see #openFileOutput @@ -506,11 +507,11 @@ public abstract class Context {       * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory()       * Environment.getExternalStorageDirectory()} where the application can       * place cache files it owns. -     *  +     *       * <p>This is like {@link #getCacheDir()} in that these       * files will be deleted when the application is uninstalled, however there       * are some important differences: -     *  +     *       * <ul>       * <li>The platform does not monitor the space available in external storage,       * and thus will not automatically delete these files.  Note that you should @@ -531,7 +532,7 @@ public abstract class Context {       * @see #getCacheDir       */      public abstract File getExternalCacheDir(); -     +      /**       * Returns an array of strings naming the private files associated with       * this Context's application package. @@ -702,7 +703,7 @@ public abstract class Context {       * here; otherwise, its associated action will be executed (such as       * sending a broadcast) as if you had called       * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. -     *  +     *       * @param intent The IntentSender to launch.       * @param fillInIntent If non-null, this will be provided as the       * intent parameter to {@link IntentSender#sendIntent}. @@ -855,7 +856,7 @@ public abstract class Context {       * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)       */      public abstract void sendStickyBroadcast(Intent intent); -     +      /**       * Version of {@link #sendStickyBroadcast} that allows you to       * receive data back from the broadcast.  This is accomplished by @@ -1011,7 +1012,7 @@ public abstract class Context {       * process for it if needed); if it is running then it remains running.       *       * <p>Every call to this method will result in a corresponding call to -     * the target service's {@link android.app.Service#onStart} method, +     * the target service's {@link android.app.Service#onStartCommand} method,       * with the <var>intent</var> given here.  This provides a convenient way       * to submit jobs to a service without having to bind and call on to its       * interface. @@ -1108,8 +1109,9 @@ public abstract class Context {       *      description (action, category, etc) to match an       *      {@link IntentFilter} published by a service.       * @param conn Receives information as the service is started and stopped. -     * @param flags Operation options for the binding.  May be 0 or -     *          {@link #BIND_AUTO_CREATE}. +     * @param flags Operation options for the binding.  May be 0, +     *          {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, or +     *          {@link #BIND_NOT_FOREGROUND}.       * @return If you have successfully bound to the service, true is returned;       *         false is returned if the connection is not made so you will not       *         receive the service object. @@ -1119,6 +1121,8 @@ public abstract class Context {       * @see #unbindService       * @see #startService       * @see #BIND_AUTO_CREATE +     * @see #BIND_DEBUG_UNBIND +     * @see #BIND_NOT_FOREGROUND       */      public abstract boolean bindService(Intent service, ServiceConnection conn,              int flags); @@ -1165,7 +1169,7 @@ public abstract class Context {       * Return the handle to a system-level service by name. The class of the       * returned object varies by the requested name. Currently available names       * are: -     *  +     *       * <dl>       *  <dt> {@link #WINDOW_SERVICE} ("window")       *  <dd> The top-level window manager in which you can place custom @@ -1209,16 +1213,16 @@ public abstract class Context {       * <dt> {@link #DOWNLOAD_SERVICE} ("download")       * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads       * </dl> -     *  +     *       * <p>Note:  System services obtained via this API may be closely associated with       * the Context in which they are obtained from.  In general, do not share the       * service objects between various different contexts (Activities, Applications,       * Services, Providers, etc.)       *       * @param name The name of the desired service. -     *  +     *       * @return The service or null if the name does not exist. -     *  +     *       * @see #WINDOW_SERVICE       * @see android.view.WindowManager       * @see #LAYOUT_INFLATER_SERVICE @@ -1267,7 +1271,7 @@ public abstract class Context {       * you're running long tasks.       */      public static final String POWER_SERVICE = "power"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.view.WindowManager} for accessing the system's window @@ -1277,7 +1281,7 @@ public abstract class Context {       * @see android.view.WindowManager       */      public static final String WINDOW_SERVICE = "window"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.view.LayoutInflater} for inflating layout resources in this @@ -1287,7 +1291,7 @@ public abstract class Context {       * @see android.view.LayoutInflater       */      public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.accounts.AccountManager} for receiving intents at a @@ -1297,7 +1301,7 @@ public abstract class Context {       * @see android.accounts.AccountManager       */      public static final String ACCOUNT_SERVICE = "account"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.app.ActivityManager} for interacting with the global @@ -1307,7 +1311,7 @@ public abstract class Context {       * @see android.app.ActivityManager       */      public static final String ACTIVITY_SERVICE = "activity"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.app.AlarmManager} for receiving intents at a @@ -1317,7 +1321,7 @@ public abstract class Context {       * @see android.app.AlarmManager       */      public static final String ALARM_SERVICE = "alarm"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.app.NotificationManager} for informing the user of @@ -1327,7 +1331,7 @@ public abstract class Context {       * @see android.app.NotificationManager       */      public static final String NOTIFICATION_SERVICE = "notification"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.view.accessibility.AccessibilityManager} for giving the user @@ -1337,7 +1341,7 @@ public abstract class Context {       * @see android.view.accessibility.AccessibilityManager       */      public static final String ACCESSIBILITY_SERVICE = "accessibility"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.app.NotificationManager} for controlling keyguard. @@ -1346,7 +1350,7 @@ public abstract class Context {       * @see android.app.KeyguardManager       */      public static final String KEYGUARD_SERVICE = "keyguard"; -     +      /**       * Use with {@link #getSystemService} to retrieve a {@link       * android.location.LocationManager} for controlling location @@ -1356,7 +1360,7 @@ public abstract class Context {       * @see android.location.LocationManager       */      public static final String LOCATION_SERVICE = "location"; -     +      /**       * Use with {@link #getSystemService} to retrieve a {@link       * android.app.SearchManager} for handling searches. @@ -1365,7 +1369,7 @@ public abstract class Context {       * @see android.app.SearchManager       */      public static final String SEARCH_SERVICE = "search"; -     +      /**       * Use with {@link #getSystemService} to retrieve a {@link       * android.hardware.SensorManager} for accessing sensors. @@ -1374,7 +1378,7 @@ public abstract class Context {       * @see android.hardware.SensorManager       */      public static final String SENSOR_SERVICE = "sensor"; -     +      /**       * Use with {@link #getSystemService} to retrieve a {@link       * android.os.storage.StorageManager} for accessing system storage @@ -1392,7 +1396,7 @@ public abstract class Context {       * @see #getSystemService       */      public static final String WALLPAPER_SERVICE = "wallpaper"; -     +      /**       * Use with {@link #getSystemService} to retrieve a {@link       * android.os.Vibrator} for interacting with the vibration hardware. @@ -1453,22 +1457,22 @@ public abstract class Context {       * @see android.net.wifi.WifiManager       */      public static final String WIFI_SERVICE = "wifi"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.media.AudioManager} for handling management of volume,       * ringer modes and audio routing. -     *  +     *       * @see #getSystemService       * @see android.media.AudioManager       */      public static final String AUDIO_SERVICE = "audio"; -     +      /**       * Use with {@link #getSystemService} to retrieve a       * {@link android.telephony.TelephonyManager} for handling management the       * telephony features of the device. -     *  +     *       * @see #getSystemService       * @see android.telephony.TelephonyManager       */ @@ -1478,14 +1482,14 @@ public abstract class Context {       * Use with {@link #getSystemService} to retrieve a       * {@link android.text.ClipboardManager} for accessing and modifying       * the contents of the global clipboard. -     *  +     *       * @see #getSystemService       * @see android.text.ClipboardManager       */      public static final String CLIPBOARD_SERVICE = "clipboard";      /** -     * Use with {@link #getSystemService} to retrieve a  +     * Use with {@link #getSystemService} to retrieve a       * {@link android.view.inputmethod.InputMethodManager} for accessing input       * methods.       * @@ -1507,7 +1511,7 @@ public abstract class Context {       * {@link android.app.backup.IBackupManager IBackupManager} for communicating       * with the backup mechanism.       * @hide -     *  +     *       * @see #getSystemService       */      public static final String BACKUP_SERVICE = "backup"; @@ -1521,7 +1525,7 @@ public abstract class Context {      public static final String DROPBOX_SERVICE = "dropbox";      /** -     * Use with {@link #getSystemService} to retrieve a  +     * Use with {@link #getSystemService} to retrieve a       * {@link android.app.admin.DevicePolicyManager} for working with global       * device policy management.       * @@ -1861,7 +1865,7 @@ public abstract class Context {       * #enforceCallingUriPermission}, except it grants your own       * permissions if you are not currently processing an IPC.  Use       * with care! -     *  +     *       * @param uri The uri that is being checked.       * @param modeFlags The type of access to grant.  May be one or both of       * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or @@ -1877,7 +1881,7 @@ public abstract class Context {       * Enforce both a Uri and normal permission.  This allows you to perform       * both {@link #enforcePermission} and {@link #enforceUriPermission} in one       * call. -     *  +     *       * @param uri The Uri whose permission is to be checked, or null to not       * do this check.       * @param readPermission The permission that provides overall read access, @@ -1920,7 +1924,7 @@ public abstract class Context {       * with extreme care!       */      public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; -     +      /**       * Flag for use with {@link #createPackageContext}: a restricted context may       * disable specific features. For instance, a View associated with a restricted @@ -1958,9 +1962,9 @@ public abstract class Context {      /**       * Indicates whether this Context is restricted. -     *  +     *       * @return True if this Context is restricted, false otherwise. -     *  +     *       * @see #CONTEXT_RESTRICTED       */      public boolean isRestricted() { diff --git a/core/java/android/nfc/NdefTag.java b/core/java/android/nfc/NdefTag.java index d8681dc21798..0626edb1c5ca 100644 --- a/core/java/android/nfc/NdefTag.java +++ b/core/java/android/nfc/NdefTag.java @@ -205,6 +205,7 @@ public class NdefTag extends Tag implements Parcelable {          dest.writeStringArray(mNdefTargets);          dest.writeInt(mMessages.length);          for (NdefMessage[] ms : mMessages) { +            dest.writeInt(ms.length);              dest.writeTypedArray(ms, flags);          }      } diff --git a/core/java/android/nfc/RawTagConnection.java b/core/java/android/nfc/RawTagConnection.java index cf8283b762be..844289360b2e 100644 --- a/core/java/android/nfc/RawTagConnection.java +++ b/core/java/android/nfc/RawTagConnection.java @@ -60,7 +60,6 @@ public class RawTagConnection {          mService = service;          mTagService = service.getNfcTagInterface(); -        mService.openTagConnection(tag);  // TODO(nxp): don't connect until connect()          mTag = tag;          mSelectedTarget = target;      } diff --git a/core/java/android/nfc/Tag.java b/core/java/android/nfc/Tag.java index 7741ad2ae462..dc6e798e189e 100644 --- a/core/java/android/nfc/Tag.java +++ b/core/java/android/nfc/Tag.java @@ -149,6 +149,12 @@ public class Tag implements Parcelable {       * Get the low-level bytes returned by this Tag at poll-time.       * <p>These can be used to help with advanced identification of a Tag.       * <p>The meaning of these bytes depends on the Tag technology. +     * <p>ISO14443-3A: ATQA/SENS_RES +     * <p>ISO14443-3B: Application data (4 bytes) and Protocol Info (3 bytes) from ATQB/SENSB_RES +     * <p>JIS_X_6319_4: PAD0 (2 byte), PAD1 (2 byte), MRTI(2 byte), PAD2 (1 byte), RC (2 byte) +     * <p>ISO15693: response flags (1 byte), DSFID (1 byte) +     * from SENSF_RES +     *       * @return poll bytes, or null if they do not exist for this Tag technology       */      public byte[] getPollBytes() { @@ -159,6 +165,12 @@ public class Tag implements Parcelable {       * Get the low-level bytes returned by this Tag at activation-time.       * <p>These can be used to help with advanced identification of a Tag.       * <p>The meaning of these bytes depends on the Tag technology. +     * <p>ISO14443-3A: SAK/SEL_RES +     * <p>ISO14443-3B: null +     * <p>ISO14443-3A & ISO14443-4: SAK/SEL_RES, historical bytes from ATS  <TODO: confirm> +     * <p>ISO14443-3B & ISO14443-4: ATTRIB response +     * <p>JIS_X_6319_4: null +     * <p>ISO15693: response flags (1 byte), DSFID (1 byte): null       * @return activation bytes, or null if they do not exist for this Tag technology       */      public byte[] getActivationBytes() { @@ -185,7 +197,7 @@ public class Tag implements Parcelable {      /*package*/ static byte[] readBytesWithNull(Parcel in) {          int len = in.readInt();          byte[] result = null; -        if (len > 0) { +        if (len >= 0) {              result = new byte[len];              in.readByteArray(result);          } diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 6260cdbdf5ed..9a38acc51d70 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2890,7 +2890,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te                          overScrollBy(0, overshoot, 0, mScrollY, 0, 0,                                  0, mOverflingDistance, false);                      } -                    edgeReached(delta); +                    if (more) { +                        edgeReached(delta); +                    }                      break;                  } diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp index 63d3578691b3..45fd5a094142 100644 --- a/core/jni/android_app_NativeActivity.cpp +++ b/core/jni/android_app_NativeActivity.cpp @@ -626,7 +626,8 @@ static int mainWorkCallback(int fd, int events, void* data) {  // ------------------------------------------------------------------------  static jint -loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQueue, +loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName, +        jobject messageQueue,          jstring internalDataDir, jstring externalDataDir, int sdkVersion,          jobject jAssetMgr, jbyteArray savedState)  { @@ -640,8 +641,11 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQ      env->ReleaseStringUTFChars(path, pathStr);      if (handle != NULL) { +        const char* funcStr = env->GetStringUTFChars(funcName, NULL);          code = new NativeCode(handle, (ANativeActivity_createFunc*) -                dlsym(handle, "ANativeActivity_onCreate")); +                dlsym(handle, funcStr)); +        env->ReleaseStringUTFChars(funcName, funcStr); +                  if (code->createActivityFunc == NULL) {              LOGW("ANativeActivity_onCreate not found");              delete code; @@ -999,7 +1003,7 @@ finishPreDispatchKeyEvent_native(JNIEnv* env, jobject clazz, jint handle,  }  static const JNINativeMethod g_methods[] = { -    { "loadNativeCode", "(Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;[B)I", +    { "loadNativeCode", "(Ljava/lang/String;Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;ILandroid/content/res/AssetManager;[B)I",              (void*)loadNativeCode_native },      { "unloadNativeCode", "(I)V", (void*)unloadNativeCode_native },      { "onStartNative", "(I)V", (void*)onStart_native }, diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h index a8f11c97ec82..d89bc8b9b6d3 100644 --- a/native/include/android/native_activity.h +++ b/native/include/android/native_activity.h @@ -223,18 +223,34 @@ typedef void ANativeActivity_createFunc(ANativeActivity* activity,  /**   * The name of the function that NativeInstance looks for when launching its - * native code. + * native code.  This is the default function that is used, you can specify + * "android.app.func_name" string meta-data in your manifest to use a different + * function.   */  extern ANativeActivity_createFunc ANativeActivity_onCreate;  /**   * Finish the given activity.  Its finish() method will be called, causing it - * to be stopped and destroyed. + * to be stopped and destroyed.  Note that this method can be called from + * *any* thread; it will send a message to the main thread of the process + * where the Java finish call will take place.   */  void ANativeActivity_finish(ANativeActivity* activity); +/** + * Change the window format of the given activity.  Calls getWindow().setFormat() + * of the given activity.  Note that this method can be called from + * *any* thread; it will send a message to the main thread of the process + * where the Java finish call will take place. + */  void ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format); +/** + * Change the window flags of the given activity.  Calls getWindow().setFlags() + * of the given activity.  Note that this method can be called from + * *any* thread; it will send a message to the main thread of the process + * where the Java finish call will take place.  See window.h for flag constants. + */  void ANativeActivity_setWindowFlags(ANativeActivity* activity,          uint32_t addFlags, uint32_t removeFlags); @@ -247,6 +263,12 @@ enum {      ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002,  }; +/** + * Show the IME while in the given activity.  Calls InputMethodManager.showSoftInput() + * for the given activity.  Note that this method can be called from + * *any* thread; it will send a message to the main thread of the process + * where the Java finish call will take place. + */  void ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags);  /** @@ -258,6 +280,12 @@ enum {      ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002,  }; +/** + * Hide the IME while in the given activity.  Calls InputMethodManager.hideSoftInput() + * for the given activity.  Note that this method can be called from + * *any* thread; it will send a message to the main thread of the process + * where the Java finish call will take place. + */  void ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags);  #ifdef __cplusplus diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 121819ae1b62..a64ddcfc118a 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -153,7 +153,7 @@ sp<ICamera> CameraService::connect(      CameraInfo info;      HAL_getCameraInfo(cameraId, &info);      client = new Client(this, cameraClient, hardware, cameraId, info.facing, -                        info.orientation, callingPid); +                        callingPid);      mClient[cameraId] = client;      LOG1("CameraService::connect X");      return client; @@ -295,7 +295,7 @@ void CameraService::playSound(sound_kind kind) {  CameraService::Client::Client(const sp<CameraService>& cameraService,          const sp<ICameraClient>& cameraClient,          const sp<CameraHardwareInterface>& hardware, -        int cameraId, int cameraFacing, int cameraOrientation, int clientPid) { +        int cameraId, int cameraFacing, int clientPid) {      int callingPid = getCallingPid();      LOG1("Client::Client E (pid %d)", callingPid); @@ -304,7 +304,6 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,      mHardware = hardware;      mCameraId = cameraId;      mCameraFacing = cameraFacing; -    mCameraOrientation = cameraOrientation;      mClientPid = clientPid;      mUseOverlay = mHardware->useOverlay();      mMsgEnabled = 0; @@ -1203,18 +1202,15 @@ int CameraService::Client::getOrientation(int degrees, bool mirror) {          else if (degrees == 90) return HAL_TRANSFORM_ROT_90;          else if (degrees == 180) return HAL_TRANSFORM_ROT_180;          else if (degrees == 270) return HAL_TRANSFORM_ROT_270; -    } else {  // mirror (horizontal flip) -        // Now overlay does ROT_90 before FLIP_V or FLIP_H. It should be FLIP_V -        // or FLIP_H first. -        // TODO: change this after overlay is fixed. +    } else {  // Do mirror (horizontal flip)          if (degrees == 0) {           // FLIP_H and ROT_0              return HAL_TRANSFORM_FLIP_H;          } else if (degrees == 90) {   // FLIP_H and ROT_90 -            return HAL_TRANSFORM_ROT_90 | HAL_TRANSFORM_FLIP_V; +            return HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90;          } else if (degrees == 180) {  // FLIP_H and ROT_180              return HAL_TRANSFORM_FLIP_V;          } else if (degrees == 270) {  // FLIP_H and ROT_270 -            return HAL_TRANSFORM_ROT_90 | HAL_TRANSFORM_FLIP_H; +            return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;          }      }      LOGE("Invalid setDisplayOrientation degrees=%d", degrees); diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 0dec2ab916ed..f09773d11a6c 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -109,7 +109,6 @@ private:                                         const sp<CameraHardwareInterface>& hardware,                                         int cameraId,                                         int cameraFacing, -                                       int mCameraOrientation,                                         int clientPid);                                  ~Client(); @@ -162,7 +161,6 @@ private:          sp<ICameraClient>               mCameraClient;          int                             mCameraId;       // immutable after constructor          int                             mCameraFacing;   // immutable after constructor -        int                             mCameraOrientation;  // immutable after constructor          pid_t                           mClientPid;          sp<CameraHardwareInterface>     mHardware;       // cleared after disconnect()          bool                            mUseOverlay;     // immutable after constructor diff --git a/services/surfaceflinger/Transform.cpp b/services/surfaceflinger/Transform.cpp index 5e27cc9bd9bf..f1284295bf04 100644 --- a/services/surfaceflinger/Transform.cpp +++ b/services/surfaceflinger/Transform.cpp @@ -159,56 +159,32 @@ status_t Transform::set(uint32_t flags, float w, float h)          return BAD_VALUE;      } -    mType = flags << 8; -    float sx = (flags & FLIP_H) ? -1 : 1; -    float sy = (flags & FLIP_V) ? -1 : 1; -    float a=0, b=0, c=0, d=0, x=0, y=0; -    int xmask = 0; - -    // computation of x,y -    // x y -    // 0 0  0 -    // w 0  ROT90 -    // w h  FLIPH|FLIPV -    // 0 h  FLIPH|FLIPV|ROT90 - -    if (flags & ROT_90) { -        mType |= ROTATE; -        b = -sy; -        c = sx; -        xmask = 1; -    } else { -        a = sx; -        d = sy; -    } - +    Transform H, V, R;      if (flags & FLIP_H) { -        mType ^= SCALE; -        xmask ^= 1; +        H.mType = (FLIP_H << 8) | SCALE; +        H.mType |= isZero(w) ? IDENTITY : TRANSLATE; +        mat33& M(H.mMatrix); +        M[0][0] = -1; +        M[2][0] = w;      }      if (flags & FLIP_V) { -        mType ^= SCALE; -        y = h; -    } - -    if ((flags & ROT_180) == ROT_180) { -        mType |= ROTATE; +        V.mType = (FLIP_V << 8) | SCALE; +        V.mType |= isZero(h) ? IDENTITY : TRANSLATE; +        mat33& M(V.mMatrix); +        M[1][1] = -1; +        M[2][1] = h;      } -    if (xmask) { -        x = w; -    } - -    if (!isZero(x) || !isZero(y)) { -        mType |= TRANSLATE; +    if (flags & ROT_90) { +        R.mType = (ROT_90 << 8) | ROTATE; +        R.mType |= isZero(w) ? IDENTITY : TRANSLATE; +        mat33& M(R.mMatrix); +        M[0][0] = 0;    M[1][0] =-1;    M[2][0] = w; +        M[0][1] = 1;    M[1][1] = 0;      } -    mat33& M(mMatrix); -    M[0][0] = a;    M[1][0] = b;    M[2][0] = x; -    M[0][1] = c;    M[1][1] = d;    M[2][1] = y; -    M[0][2] = 0;    M[1][2] = 0;    M[2][2] = 1; - +    *this = ((H*V)*R);      return NO_ERROR;  } diff --git a/services/surfaceflinger/Transform.h b/services/surfaceflinger/Transform.h index 20fa11a46ace..8fa5b86ffa43 100644 --- a/services/surfaceflinger/Transform.h +++ b/services/surfaceflinger/Transform.h @@ -23,6 +23,8 @@  #include <ui/Point.h>  #include <ui/Rect.h> +#include <hardware/hardware.h> +  namespace android {  class Region; @@ -37,12 +39,11 @@ public:             explicit Transform(uint32_t orientation);                      ~Transform(); -            // FIXME: must match OVERLAY_TRANSFORM_*, pull from hardware.h              enum orientation_flags {                  ROT_0   = 0x00000000, -                FLIP_H  = 0x00000001, -                FLIP_V  = 0x00000002, -                ROT_90  = 0x00000004, +                FLIP_H  = HAL_TRANSFORM_FLIP_H, +                FLIP_V  = HAL_TRANSFORM_FLIP_V, +                ROT_90  = HAL_TRANSFORM_ROT_90,                  ROT_180 = FLIP_H|FLIP_V,                  ROT_270 = ROT_180|ROT_90,                  ROT_INVALID = 0x80 diff --git a/services/surfaceflinger/tests/transform/Android.mk b/services/surfaceflinger/tests/transform/Android.mk new file mode 100644 index 000000000000..6219dae8bebd --- /dev/null +++ b/services/surfaceflinger/tests/transform/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ +	TransformTest.cpp \ +	../../Transform.cpp + +LOCAL_SHARED_LIBRARIES := \ +	libcutils \ +	libutils \ +	libui \ + +LOCAL_MODULE:= test-transform + +LOCAL_MODULE_TAGS := tests + +LOCAL_C_INCLUDES += ../.. + +include $(BUILD_EXECUTABLE) diff --git a/services/surfaceflinger/tests/transform/TransformTest.cpp b/services/surfaceflinger/tests/transform/TransformTest.cpp new file mode 100644 index 000000000000..e112c4ee00f6 --- /dev/null +++ b/services/surfaceflinger/tests/transform/TransformTest.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2007 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. + */ + +#include <utils/Errors.h> +#include "../../Transform.h" + +using namespace android; + +int main(int argc, char **argv) +{ +    Transform tr90(Transform::ROT_90); +    Transform trFH(Transform::FLIP_H); +    Transform trFV(Transform::FLIP_V); + +    Transform tr90FH(Transform::ROT_90 | Transform::FLIP_H); +    Transform tr90FV(Transform::ROT_90 | Transform::FLIP_V); + +    tr90.dump("tr90"); +    trFH.dump("trFH"); +    trFV.dump("trFV"); + +    tr90FH.dump("tr90FH"); +    tr90FV.dump("tr90FV"); + +    (trFH*tr90).dump("trFH*tr90"); +    (trFV*tr90).dump("trFV*tr90"); + +    (tr90*trFH).dump("tr90*trFH"); +    (tr90*trFV).dump("tr90*trFV"); + +    return 0; +} |