Merge "Fix document stack."
diff --git a/api/current.txt b/api/current.txt
index 6c639f3..e2b1556 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5762,6 +5762,7 @@
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
method public long getMaximumTimeToLock(android.content.ComponentName);
method public boolean getPackageSuspended(android.content.ComponentName, java.lang.String);
+ method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
method public long getPasswordExpiration(android.content.ComponentName);
method public long getPasswordExpirationTimeout(android.content.ComponentName);
method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -9446,8 +9447,10 @@
method public abstract java.lang.String getNameForUid(int);
method public android.content.pm.PackageInfo getPackageArchiveInfo(java.lang.String, int);
method public abstract int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+ method public abstract int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.PackageInstaller getPackageInstaller();
+ method public abstract int getPackageUid(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.lang.String[] getPackagesForUid(int);
method public abstract java.util.List<android.content.pm.PackageInfo> getPackagesHoldingPermissions(java.lang.String[], int);
method public abstract android.content.pm.PermissionGroupInfo getPermissionGroupInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -22379,6 +22382,24 @@
ctor public MtpConstants();
method public static boolean isAbstractObject(int);
field public static final int ASSOCIATION_TYPE_GENERIC_FOLDER = 1; // 0x1
+ field public static final int EVENT_CANCEL_TRANSACTION = 16385; // 0x4001
+ field public static final int EVENT_CAPTURE_COMPLETE = 16397; // 0x400d
+ field public static final int EVENT_DEVICE_INFO_CHANGED = 16392; // 0x4008
+ field public static final int EVENT_DEVICE_PROP_CHANGED = 16390; // 0x4006
+ field public static final int EVENT_DEVICE_RESET = 16395; // 0x400b
+ field public static final int EVENT_OBJECT_ADDED = 16386; // 0x4002
+ field public static final int EVENT_OBJECT_INFO_CHANGED = 16391; // 0x4007
+ field public static final int EVENT_OBJECT_PROP_CHANGED = 51201; // 0xc801
+ field public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 51202; // 0xc802
+ field public static final int EVENT_OBJECT_REFERENCES_CHANGED = 51203; // 0xc803
+ field public static final int EVENT_OBJECT_REMOVED = 16387; // 0x4003
+ field public static final int EVENT_REQUEST_OBJECT_TRANSFER = 16393; // 0x4009
+ field public static final int EVENT_STORAGE_INFO_CHANGED = 16396; // 0x400c
+ field public static final int EVENT_STORE_ADDED = 16388; // 0x4004
+ field public static final int EVENT_STORE_FULL = 16394; // 0x400a
+ field public static final int EVENT_STORE_REMOVED = 16389; // 0x4005
+ field public static final int EVENT_UNDEFINED = 16384; // 0x4000
+ field public static final int EVENT_UNREPORTED_STATUS = 16398; // 0x400e
field public static final int FORMAT_3GP_CONTAINER = 47492; // 0xb984
field public static final int FORMAT_AAC = 47363; // 0xb903
field public static final int FORMAT_ABSTRACT_AUDIO_ALBUM = 47619; // 0xba03
@@ -22475,24 +22496,6 @@
public class MtpEvent {
ctor public MtpEvent();
method public int getEventCode();
- field public static final int EVENT_CANCEL_TRANSACTION = 16385; // 0x4001
- field public static final int EVENT_CAPTURE_COMPLETE = 16397; // 0x400d
- field public static final int EVENT_DEVICE_INFO_CHANGED = 16392; // 0x4008
- field public static final int EVENT_DEVICE_PROP_CHANGED = 16390; // 0x4006
- field public static final int EVENT_DEVICE_RESET = 16395; // 0x400b
- field public static final int EVENT_OBJECT_ADDED = 16386; // 0x4002
- field public static final int EVENT_OBJECT_INFO_CHANGED = 16391; // 0x4007
- field public static final int EVENT_OBJECT_PROP_CHANGED = 51201; // 0xc801
- field public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 51202; // 0xc802
- field public static final int EVENT_OBJECT_REFERENCES_CHANGED = 51203; // 0xc803
- field public static final int EVENT_OBJECT_REMOVED = 16387; // 0x4003
- field public static final int EVENT_REQUEST_OBJECT_TRANSFER = 16393; // 0x4009
- field public static final int EVENT_STORAGE_INFO_CHANGED = 16396; // 0x400c
- field public static final int EVENT_STORE_ADDED = 16388; // 0x4004
- field public static final int EVENT_STORE_FULL = 16394; // 0x400a
- field public static final int EVENT_STORE_REMOVED = 16389; // 0x4005
- field public static final int EVENT_UNDEFINED = 16384; // 0x4000
- field public static final int EVENT_UNREPORTED_STATUS = 16398; // 0x400e
}
public final class MtpObjectInfo {
@@ -31233,6 +31236,7 @@
field public static final java.lang.String ACTION_SEARCH_SETTINGS = "android.search.action.SEARCH_SETTINGS";
field public static final java.lang.String ACTION_SECURITY_SETTINGS = "android.settings.SECURITY_SETTINGS";
field public static final java.lang.String ACTION_SETTINGS = "android.settings.SETTINGS";
+ field public static final java.lang.String ACTION_SHOW_ADMIN_SUPPORT_DETAILS = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";
field public static final java.lang.String ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
field public static final java.lang.String ACTION_SOUND_SETTINGS = "android.settings.SOUND_SETTINGS";
field public static final java.lang.String ACTION_SYNC_SETTINGS = "android.settings.SYNC_SETTINGS";
@@ -36046,6 +36050,7 @@
method public java.lang.String getSubscriberId();
method public java.lang.String getVoiceMailAlphaTag();
method public java.lang.String getVoiceMailNumber();
+ method public android.net.Uri getVoicemailRingtoneUri(android.telecom.PhoneAccountHandle);
method public boolean hasCarrierPrivileges();
method public boolean hasIccCard();
method public boolean iccCloseLogicalChannel(int);
@@ -36058,6 +36063,7 @@
method public boolean isSmsCapable();
method public boolean isTtyModeSupported();
method public boolean isVoiceCapable();
+ method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
method public boolean isWorldPhone();
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
@@ -36751,8 +36757,10 @@
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
method public java.lang.String getNameForUid(int);
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+ method public int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInstaller getPackageInstaller();
+ method public int getPackageUid(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] getPackagesForUid(int);
method public java.util.List<android.content.pm.PackageInfo> getPackagesHoldingPermissions(java.lang.String[], int);
method public android.content.pm.PermissionGroupInfo getPermissionGroupInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -40559,7 +40567,6 @@
field public static final int AXIS_RX = 12; // 0xc
field public static final int AXIS_RY = 13; // 0xd
field public static final int AXIS_RZ = 14; // 0xe
- field public static final int AXIS_SCROLL = 26; // 0x1a
field public static final int AXIS_SIZE = 3; // 0x3
field public static final int AXIS_THROTTLE = 19; // 0x13
field public static final int AXIS_TILT = 25; // 0x19
@@ -44046,7 +44053,7 @@
method public abstract deprecated void setEnableSmoothTransition(boolean);
method public abstract void setFantasyFontFamily(java.lang.String);
method public abstract void setFixedFontFamily(java.lang.String);
- method public abstract void setGeolocationDatabasePath(java.lang.String);
+ method public abstract deprecated void setGeolocationDatabasePath(java.lang.String);
method public abstract void setGeolocationEnabled(boolean);
method public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean);
method public abstract void setJavaScriptEnabled(boolean);
diff --git a/api/system-current.txt b/api/system-current.txt
index 6359f84..d50a6c9 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5890,6 +5890,7 @@
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
method public long getMaximumTimeToLock(android.content.ComponentName);
method public boolean getPackageSuspended(android.content.ComponentName, java.lang.String);
+ method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
method public long getPasswordExpiration(android.content.ComponentName);
method public long getPasswordExpirationTimeout(android.content.ComponentName);
method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -9747,8 +9748,10 @@
method public abstract java.lang.String getNameForUid(int);
method public android.content.pm.PackageInfo getPackageArchiveInfo(java.lang.String, int);
method public abstract int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+ method public abstract int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.PackageInstaller getPackageInstaller();
+ method public abstract int getPackageUid(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.lang.String[] getPackagesForUid(int);
method public abstract java.util.List<android.content.pm.PackageInfo> getPackagesHoldingPermissions(java.lang.String[], int);
method public abstract int getPermissionFlags(java.lang.String, java.lang.String, android.os.UserHandle);
@@ -23925,6 +23928,24 @@
ctor public MtpConstants();
method public static boolean isAbstractObject(int);
field public static final int ASSOCIATION_TYPE_GENERIC_FOLDER = 1; // 0x1
+ field public static final int EVENT_CANCEL_TRANSACTION = 16385; // 0x4001
+ field public static final int EVENT_CAPTURE_COMPLETE = 16397; // 0x400d
+ field public static final int EVENT_DEVICE_INFO_CHANGED = 16392; // 0x4008
+ field public static final int EVENT_DEVICE_PROP_CHANGED = 16390; // 0x4006
+ field public static final int EVENT_DEVICE_RESET = 16395; // 0x400b
+ field public static final int EVENT_OBJECT_ADDED = 16386; // 0x4002
+ field public static final int EVENT_OBJECT_INFO_CHANGED = 16391; // 0x4007
+ field public static final int EVENT_OBJECT_PROP_CHANGED = 51201; // 0xc801
+ field public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 51202; // 0xc802
+ field public static final int EVENT_OBJECT_REFERENCES_CHANGED = 51203; // 0xc803
+ field public static final int EVENT_OBJECT_REMOVED = 16387; // 0x4003
+ field public static final int EVENT_REQUEST_OBJECT_TRANSFER = 16393; // 0x4009
+ field public static final int EVENT_STORAGE_INFO_CHANGED = 16396; // 0x400c
+ field public static final int EVENT_STORE_ADDED = 16388; // 0x4004
+ field public static final int EVENT_STORE_FULL = 16394; // 0x400a
+ field public static final int EVENT_STORE_REMOVED = 16389; // 0x4005
+ field public static final int EVENT_UNDEFINED = 16384; // 0x4000
+ field public static final int EVENT_UNREPORTED_STATUS = 16398; // 0x400e
field public static final int FORMAT_3GP_CONTAINER = 47492; // 0xb984
field public static final int FORMAT_AAC = 47363; // 0xb903
field public static final int FORMAT_ABSTRACT_AUDIO_ALBUM = 47619; // 0xba03
@@ -24021,24 +24042,6 @@
public class MtpEvent {
ctor public MtpEvent();
method public int getEventCode();
- field public static final int EVENT_CANCEL_TRANSACTION = 16385; // 0x4001
- field public static final int EVENT_CAPTURE_COMPLETE = 16397; // 0x400d
- field public static final int EVENT_DEVICE_INFO_CHANGED = 16392; // 0x4008
- field public static final int EVENT_DEVICE_PROP_CHANGED = 16390; // 0x4006
- field public static final int EVENT_DEVICE_RESET = 16395; // 0x400b
- field public static final int EVENT_OBJECT_ADDED = 16386; // 0x4002
- field public static final int EVENT_OBJECT_INFO_CHANGED = 16391; // 0x4007
- field public static final int EVENT_OBJECT_PROP_CHANGED = 51201; // 0xc801
- field public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 51202; // 0xc802
- field public static final int EVENT_OBJECT_REFERENCES_CHANGED = 51203; // 0xc803
- field public static final int EVENT_OBJECT_REMOVED = 16387; // 0x4003
- field public static final int EVENT_REQUEST_OBJECT_TRANSFER = 16393; // 0x4009
- field public static final int EVENT_STORAGE_INFO_CHANGED = 16396; // 0x400c
- field public static final int EVENT_STORE_ADDED = 16388; // 0x4004
- field public static final int EVENT_STORE_FULL = 16394; // 0x400a
- field public static final int EVENT_STORE_REMOVED = 16389; // 0x4005
- field public static final int EVENT_UNDEFINED = 16384; // 0x4000
- field public static final int EVENT_UNREPORTED_STATUS = 16398; // 0x400e
}
public final class MtpObjectInfo {
@@ -33368,6 +33371,7 @@
field public static final java.lang.String ACTION_SEARCH_SETTINGS = "android.search.action.SEARCH_SETTINGS";
field public static final java.lang.String ACTION_SECURITY_SETTINGS = "android.settings.SECURITY_SETTINGS";
field public static final java.lang.String ACTION_SETTINGS = "android.settings.SETTINGS";
+ field public static final java.lang.String ACTION_SHOW_ADMIN_SUPPORT_DETAILS = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";
field public static final java.lang.String ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
field public static final java.lang.String ACTION_SOUND_SETTINGS = "android.settings.SOUND_SETTINGS";
field public static final java.lang.String ACTION_SYNC_SETTINGS = "android.settings.SYNC_SETTINGS";
@@ -38347,6 +38351,7 @@
method public java.lang.String getSubscriberId();
method public java.lang.String getVoiceMailAlphaTag();
method public java.lang.String getVoiceMailNumber();
+ method public android.net.Uri getVoicemailRingtoneUri(android.telecom.PhoneAccountHandle);
method public boolean handlePinMmi(java.lang.String);
method public boolean handlePinMmiForSubscriber(int, java.lang.String);
method public boolean hasCarrierPrivileges();
@@ -38368,6 +38373,7 @@
method public boolean isTtyModeSupported();
method public boolean isVideoCallingEnabled();
method public boolean isVoiceCapable();
+ method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
method public boolean isWorldPhone();
method public void listen(android.telephony.PhoneStateListener, int);
method public boolean needsOtaServiceProvisioning();
@@ -39092,8 +39098,10 @@
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
method public java.lang.String getNameForUid(int);
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+ method public int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInstaller getPackageInstaller();
+ method public int getPackageUid(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] getPackagesForUid(int);
method public java.util.List<android.content.pm.PackageInfo> getPackagesHoldingPermissions(java.lang.String[], int);
method public int getPermissionFlags(java.lang.String, java.lang.String, android.os.UserHandle);
@@ -42906,7 +42914,6 @@
field public static final int AXIS_RX = 12; // 0xc
field public static final int AXIS_RY = 13; // 0xd
field public static final int AXIS_RZ = 14; // 0xe
- field public static final int AXIS_SCROLL = 26; // 0x1a
field public static final int AXIS_SIZE = 3; // 0x3
field public static final int AXIS_THROTTLE = 19; // 0x13
field public static final int AXIS_TILT = 25; // 0x19
@@ -46464,7 +46471,7 @@
method public abstract deprecated void setEnableSmoothTransition(boolean);
method public abstract void setFantasyFontFamily(java.lang.String);
method public abstract void setFixedFontFamily(java.lang.String);
- method public abstract void setGeolocationDatabasePath(java.lang.String);
+ method public abstract deprecated void setGeolocationDatabasePath(java.lang.String);
method public abstract void setGeolocationEnabled(boolean);
method public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean);
method public abstract void setJavaScriptEnabled(boolean);
diff --git a/api/test-current.txt b/api/test-current.txt
index 9ed5a47..80f250a 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5764,6 +5764,7 @@
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
method public long getMaximumTimeToLock(android.content.ComponentName);
method public boolean getPackageSuspended(android.content.ComponentName, java.lang.String);
+ method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
method public long getPasswordExpiration(android.content.ComponentName);
method public long getPasswordExpirationTimeout(android.content.ComponentName);
method public int getPasswordHistoryLength(android.content.ComponentName);
@@ -9454,8 +9455,10 @@
method public abstract java.lang.String getNameForUid(int);
method public android.content.pm.PackageInfo getPackageArchiveInfo(java.lang.String, int);
method public abstract int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+ method public abstract int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract android.content.pm.PackageInstaller getPackageInstaller();
+ method public abstract int getPackageUid(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public abstract java.lang.String[] getPackagesForUid(int);
method public abstract java.util.List<android.content.pm.PackageInfo> getPackagesHoldingPermissions(java.lang.String[], int);
method public abstract android.content.pm.PermissionGroupInfo getPermissionGroupInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -22387,6 +22390,24 @@
ctor public MtpConstants();
method public static boolean isAbstractObject(int);
field public static final int ASSOCIATION_TYPE_GENERIC_FOLDER = 1; // 0x1
+ field public static final int EVENT_CANCEL_TRANSACTION = 16385; // 0x4001
+ field public static final int EVENT_CAPTURE_COMPLETE = 16397; // 0x400d
+ field public static final int EVENT_DEVICE_INFO_CHANGED = 16392; // 0x4008
+ field public static final int EVENT_DEVICE_PROP_CHANGED = 16390; // 0x4006
+ field public static final int EVENT_DEVICE_RESET = 16395; // 0x400b
+ field public static final int EVENT_OBJECT_ADDED = 16386; // 0x4002
+ field public static final int EVENT_OBJECT_INFO_CHANGED = 16391; // 0x4007
+ field public static final int EVENT_OBJECT_PROP_CHANGED = 51201; // 0xc801
+ field public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 51202; // 0xc802
+ field public static final int EVENT_OBJECT_REFERENCES_CHANGED = 51203; // 0xc803
+ field public static final int EVENT_OBJECT_REMOVED = 16387; // 0x4003
+ field public static final int EVENT_REQUEST_OBJECT_TRANSFER = 16393; // 0x4009
+ field public static final int EVENT_STORAGE_INFO_CHANGED = 16396; // 0x400c
+ field public static final int EVENT_STORE_ADDED = 16388; // 0x4004
+ field public static final int EVENT_STORE_FULL = 16394; // 0x400a
+ field public static final int EVENT_STORE_REMOVED = 16389; // 0x4005
+ field public static final int EVENT_UNDEFINED = 16384; // 0x4000
+ field public static final int EVENT_UNREPORTED_STATUS = 16398; // 0x400e
field public static final int FORMAT_3GP_CONTAINER = 47492; // 0xb984
field public static final int FORMAT_AAC = 47363; // 0xb903
field public static final int FORMAT_ABSTRACT_AUDIO_ALBUM = 47619; // 0xba03
@@ -22483,24 +22504,6 @@
public class MtpEvent {
ctor public MtpEvent();
method public int getEventCode();
- field public static final int EVENT_CANCEL_TRANSACTION = 16385; // 0x4001
- field public static final int EVENT_CAPTURE_COMPLETE = 16397; // 0x400d
- field public static final int EVENT_DEVICE_INFO_CHANGED = 16392; // 0x4008
- field public static final int EVENT_DEVICE_PROP_CHANGED = 16390; // 0x4006
- field public static final int EVENT_DEVICE_RESET = 16395; // 0x400b
- field public static final int EVENT_OBJECT_ADDED = 16386; // 0x4002
- field public static final int EVENT_OBJECT_INFO_CHANGED = 16391; // 0x4007
- field public static final int EVENT_OBJECT_PROP_CHANGED = 51201; // 0xc801
- field public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 51202; // 0xc802
- field public static final int EVENT_OBJECT_REFERENCES_CHANGED = 51203; // 0xc803
- field public static final int EVENT_OBJECT_REMOVED = 16387; // 0x4003
- field public static final int EVENT_REQUEST_OBJECT_TRANSFER = 16393; // 0x4009
- field public static final int EVENT_STORAGE_INFO_CHANGED = 16396; // 0x400c
- field public static final int EVENT_STORE_ADDED = 16388; // 0x4004
- field public static final int EVENT_STORE_FULL = 16394; // 0x400a
- field public static final int EVENT_STORE_REMOVED = 16389; // 0x4005
- field public static final int EVENT_UNDEFINED = 16384; // 0x4000
- field public static final int EVENT_UNREPORTED_STATUS = 16398; // 0x400e
}
public final class MtpObjectInfo {
@@ -31245,6 +31248,7 @@
field public static final java.lang.String ACTION_SEARCH_SETTINGS = "android.search.action.SEARCH_SETTINGS";
field public static final java.lang.String ACTION_SECURITY_SETTINGS = "android.settings.SECURITY_SETTINGS";
field public static final java.lang.String ACTION_SETTINGS = "android.settings.SETTINGS";
+ field public static final java.lang.String ACTION_SHOW_ADMIN_SUPPORT_DETAILS = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";
field public static final java.lang.String ACTION_SHOW_REGULATORY_INFO = "android.settings.SHOW_REGULATORY_INFO";
field public static final java.lang.String ACTION_SOUND_SETTINGS = "android.settings.SOUND_SETTINGS";
field public static final java.lang.String ACTION_SYNC_SETTINGS = "android.settings.SYNC_SETTINGS";
@@ -36060,6 +36064,7 @@
method public java.lang.String getSubscriberId();
method public java.lang.String getVoiceMailAlphaTag();
method public java.lang.String getVoiceMailNumber();
+ method public android.net.Uri getVoicemailRingtoneUri(android.telecom.PhoneAccountHandle);
method public boolean hasCarrierPrivileges();
method public boolean hasIccCard();
method public boolean iccCloseLogicalChannel(int);
@@ -36072,6 +36077,7 @@
method public boolean isSmsCapable();
method public boolean isTtyModeSupported();
method public boolean isVoiceCapable();
+ method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
method public boolean isWorldPhone();
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
@@ -36767,8 +36773,10 @@
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
method public java.lang.String getNameForUid(int);
method public int[] getPackageGids(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
+ method public int[] getPackageGids(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInfo getPackageInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public android.content.pm.PackageInstaller getPackageInstaller();
+ method public int getPackageUid(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
method public java.lang.String[] getPackagesForUid(int);
method public java.util.List<android.content.pm.PackageInfo> getPackagesHoldingPermissions(java.lang.String[], int);
method public android.content.pm.PermissionGroupInfo getPermissionGroupInfo(java.lang.String, int) throws android.content.pm.PackageManager.NameNotFoundException;
@@ -40575,7 +40583,6 @@
field public static final int AXIS_RX = 12; // 0xc
field public static final int AXIS_RY = 13; // 0xd
field public static final int AXIS_RZ = 14; // 0xe
- field public static final int AXIS_SCROLL = 26; // 0x1a
field public static final int AXIS_SIZE = 3; // 0x3
field public static final int AXIS_THROTTLE = 19; // 0x13
field public static final int AXIS_TILT = 25; // 0x19
@@ -44062,7 +44069,7 @@
method public abstract deprecated void setEnableSmoothTransition(boolean);
method public abstract void setFantasyFontFamily(java.lang.String);
method public abstract void setFixedFontFamily(java.lang.String);
- method public abstract void setGeolocationDatabasePath(java.lang.String);
+ method public abstract deprecated void setGeolocationDatabasePath(java.lang.String);
method public abstract void setGeolocationEnabled(boolean);
method public abstract void setJavaScriptCanOpenWindowsAutomatically(boolean);
method public abstract void setJavaScriptEnabled(boolean);
diff --git a/core/java/android/annotation/AppIdInt.java b/core/java/android/annotation/AppIdInt.java
new file mode 100644
index 0000000..29838dd
--- /dev/null
+++ b/core/java/android/annotation/AppIdInt.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes that the annotated element is a multi-user application ID. This is
+ * <em>not</em> the same as a UID.
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD, PARAMETER, FIELD})
+public @interface AppIdInt {
+}
diff --git a/core/java/android/annotation/UserIdInt.java b/core/java/android/annotation/UserIdInt.java
new file mode 100644
index 0000000..7b9ce25
--- /dev/null
+++ b/core/java/android/annotation/UserIdInt.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes that the annotated element is a multi-user user ID. This is
+ * <em>not</em> the same as a UID.
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target({METHOD, PARAMETER, FIELD})
+public @interface UserIdInt {
+}
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 8346161..64642ac 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -62,7 +62,6 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.graphics.Rect;
import android.media.AudioManager;
import android.media.session.MediaController;
import android.net.Uri;
@@ -2807,17 +2806,15 @@
/**
- * Called to move the window and its activity/task to a different stack container.
- * For example, a window can move between
- * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack and
- * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} stack.
+ * Moves the activity from
+ * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
+ * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
*
- * @param stackId stack Id to change to.
* @hide
*/
@Override
- public void changeWindowStack(int stackId) throws RemoteException {
- ActivityManagerNative.getDefault().moveActivityToStack(mToken, stackId);
+ public void exitFreeformMode() throws RemoteException {
+ ActivityManagerNative.getDefault().exitFreeformMode(mToken);
}
/** Returns the current stack Id for the window.
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index da21099..4bea112 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -2752,11 +2752,10 @@
reply.writeInt(stackId);
return true;
}
- case MOVE_ACTIVITY_TO_STACK_TRANSACTION: {
+ case EXIT_FREEFORM_MODE_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
IBinder token = data.readStrongBinder();
- int stackId = data.readInt();
- moveActivityToStack(token, stackId);
+ exitFreeformMode(token);
reply.writeNoException();
return true;
}
@@ -6457,13 +6456,12 @@
}
@Override
- public void moveActivityToStack(IBinder token, int stackId) throws RemoteException {
+ public void exitFreeformMode(IBinder token) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(token);
- data.writeInt(stackId);
- mRemote.transact(MOVE_ACTIVITY_TO_STACK_TRANSACTION, data, reply, 0);
+ mRemote.transact(EXIT_FREEFORM_MODE_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
reply.recycle();
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 177fabe..4531a74 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -101,6 +101,9 @@
import android.view.WindowManagerGlobal;
import android.renderscript.RenderScriptCacheDir;
import android.security.keystore.AndroidKeyStoreProvider;
+import android.system.Os;
+import android.system.OsConstants;
+import android.system.ErrnoException;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IVoiceInteractor;
@@ -820,48 +823,6 @@
setCoreSettings(coreSettings);
- /*
- * Two possible indications that this package could be
- * sharing its runtime with other packages:
- *
- * 1.) the sharedUserId attribute is set in the manifest,
- * indicating a request to share a VM with other
- * packages with the same sharedUserId.
- *
- * 2.) the application element of the manifest has an
- * attribute specifying a non-default process name,
- * indicating the desire to run in another packages VM.
- *
- * If sharing is enabled we do not have a unique application
- * in a process and therefore cannot rely on the package
- * name inside the runtime.
- */
- IPackageManager pm = getPackageManager();
- android.content.pm.PackageInfo pi = null;
- try {
- pi = pm.getPackageInfo(appInfo.packageName, 0, UserHandle.myUserId());
- } catch (RemoteException e) {
- }
- if (pi != null) {
- boolean sharedUserIdSet = (pi.sharedUserId != null);
- boolean processNameNotDefault =
- (pi.applicationInfo != null &&
- !appInfo.packageName.equals(pi.applicationInfo.processName));
- boolean sharable = (sharedUserIdSet || processNameNotDefault);
-
- // Tell the VMRuntime about the application, unless it is shared
- // inside a process.
- if (!sharable) {
- final List<String> codePaths = new ArrayList<>();
- codePaths.add(appInfo.sourceDir);
- if (appInfo.splitSourceDirs != null) {
- Collections.addAll(codePaths, appInfo.splitSourceDirs);
- }
- VMRuntime.registerAppInfo(appInfo.packageName, appInfo.dataDir,
- codePaths.toArray(new String[codePaths.size()]));
- }
- }
-
AppBindData data = new AppBindData();
data.processName = processName;
data.appInfo = appInfo;
@@ -4697,6 +4658,87 @@
}
}
+ private static void setupJitProfileSupport(LoadedApk loadedApk, File cacheDir) {
+ final ApplicationInfo appInfo = loadedApk.getApplicationInfo();
+ if (isSharingRuntime(appInfo)) {
+ // If sharing is enabled we do not have a unique application
+ // in a process and therefore cannot rely on the package
+ // name inside the runtime.
+ return;
+ }
+ final List<String> codePaths = new ArrayList<>();
+ if ((appInfo.flags & ApplicationInfo.FLAG_HAS_CODE) != 0) {
+ codePaths.add(appInfo.sourceDir);
+ }
+ if (appInfo.splitSourceDirs != null) {
+ Collections.addAll(codePaths, appInfo.splitSourceDirs);
+ }
+
+ if (codePaths.isEmpty()) {
+ // If there are no code paths there's no need to setup a profile file and register with
+ // the runtime,
+ return;
+ }
+
+ // Add an extension to the file name to better reveal its intended use.
+ // Keep in sync with BackgroundDexOptService.
+ final String profileExtension = ".prof";
+ final File profileFile = new File(cacheDir, loadedApk.mPackageName + profileExtension);
+ if (!profileFile.exists()) {
+ FileDescriptor fd = null;
+ try {
+ final int permissions = 0600; // read-write for user.
+ fd = Os.open(profileFile.getAbsolutePath(), OsConstants.O_CREAT, permissions);
+ Os.fchmod(fd, permissions);
+ Os.fchown(fd, appInfo.uid, appInfo.uid);
+ } catch (ErrnoException e) {
+ Log.w(TAG, "Unable to create jit profile file " + profileFile, e);
+ try {
+ Os.unlink(profileFile.getAbsolutePath());
+ } catch (ErrnoException unlinkErr) {
+ Log.v(TAG, "Unable to unlink jit profile file " + profileFile, unlinkErr);
+ }
+ return;
+ } finally {
+ IoUtils.closeQuietly(fd);
+ }
+ }
+
+ VMRuntime.registerAppInfo(profileFile.getAbsolutePath(), appInfo.dataDir,
+ codePaths.toArray(new String[codePaths.size()]));
+ }
+
+ /*
+ * Two possible indications that this package could be
+ * sharing its runtime with other packages:
+ *
+ * 1) the sharedUserId attribute is set in the manifest,
+ * indicating a request to share a VM with other
+ * packages with the same sharedUserId.
+ *
+ * 2) the application element of the manifest has an
+ * attribute specifying a non-default process name,
+ * indicating the desire to run in another packages VM.
+ */
+ private static boolean isSharingRuntime(ApplicationInfo appInfo) {
+ IPackageManager pm = getPackageManager();
+ android.content.pm.PackageInfo pi = null;
+ try {
+ pi = pm.getPackageInfo(appInfo.packageName, 0, UserHandle.myUserId());
+ } catch (RemoteException e) {
+ }
+ if (pi != null) {
+ boolean sharedUserIdSet = (pi.sharedUserId != null);
+ boolean processNameNotDefault = (pi.applicationInfo != null) &&
+ !appInfo.packageName.equals(pi.applicationInfo.processName);
+ boolean sharable = sharedUserIdSet || processNameNotDefault;
+ return sharable;
+ }
+ // We couldn't get information for the package. Be pessimistic and assume
+ // it's sharing the runtime.
+ return true;
+ }
+
private void updateDefaultDensity() {
if (mCurDefaultDisplayDpi != Configuration.DENSITY_DPI_UNDEFINED
&& mCurDefaultDisplayDpi != DisplayMetrics.DENSITY_DEVICE
@@ -4900,12 +4942,14 @@
+ "due to missing cache directory");
}
- // Use codeCacheDir to store generated/compiled graphics code
+ // Use codeCacheDir to store generated/compiled graphics code and jit profiling data.
final File codeCacheDir = appContext.getCodeCacheDir();
if (codeCacheDir != null) {
setupGraphicsSupport(data.info, codeCacheDir);
+ setupJitProfileSupport(data.info, codeCacheDir);
} else {
- Log.e(TAG, "Unable to setupGraphicsSupport due to missing code-cache directory");
+ Log.e(TAG, "Unable to setupGraphicsSupport and setupJitProfileSupport " +
+ "due to missing code-cache directory");
}
}
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index e34b1ac..42b18384 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -213,10 +213,15 @@
}
@Override
- public int[] getPackageGids(String packageName)
+ public int[] getPackageGids(String packageName) throws NameNotFoundException {
+ return getPackageGids(packageName, 0);
+ }
+
+ @Override
+ public int[] getPackageGids(String packageName, int flags)
throws NameNotFoundException {
try {
- int[] gids = mPM.getPackageGids(packageName, mContext.getUserId());
+ int[] gids = mPM.getPackageGidsEtc(packageName, flags, mContext.getUserId());
if (gids != null) {
return gids;
}
@@ -228,10 +233,20 @@
}
@Override
- public int getPackageUidAsUser(String packageName, int userHandle)
+ public int getPackageUid(String packageName, int flags) throws NameNotFoundException {
+ return getPackageUidAsUser(packageName, flags, mContext.getUserId());
+ }
+
+ @Override
+ public int getPackageUidAsUser(String packageName, int userId) throws NameNotFoundException {
+ return getPackageUidAsUser(packageName, 0, userId);
+ }
+
+ @Override
+ public int getPackageUidAsUser(String packageName, int flags, int userId)
throws NameNotFoundException {
try {
- int uid = mPM.getPackageUid(packageName, userHandle);
+ int uid = mPM.getPackageUidEtc(packageName, flags, userId);
if (uid >= 0) {
return uid;
}
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index a9516d0..ed4bb28 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -920,9 +920,9 @@
private final ContentResolver mResolver;
private final String mPackageName;
- private final int mTargetSdkVersion;
private Uri mBaseUri = Downloads.Impl.CONTENT_URI;
+ private boolean mAccessFilename;
/**
* @hide
@@ -930,7 +930,10 @@
public DownloadManager(Context context) {
mResolver = context.getContentResolver();
mPackageName = context.getPackageName();
- mTargetSdkVersion = context.getApplicationInfo().targetSdkVersion;
+
+ // Callers can access filename columns when targeting old platform
+ // versions; otherwise we throw telling them it's deprecated.
+ mAccessFilename = context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.N;
}
/**
@@ -946,6 +949,11 @@
}
}
+ /** {@hide} */
+ public void setAccessFilename(boolean accessFilename) {
+ mAccessFilename = accessFilename;
+ }
+
/**
* Enqueue a new download. The download will start automatically once the download manager is
* ready to execute it and connectivity is available.
@@ -1010,7 +1018,7 @@
if (underlyingCursor == null) {
return null;
}
- return new CursorTranslator(underlyingCursor, mBaseUri, mTargetSdkVersion);
+ return new CursorTranslator(underlyingCursor, mBaseUri, mAccessFilename);
}
/**
@@ -1279,12 +1287,12 @@
*/
private static class CursorTranslator extends CursorWrapper {
private final Uri mBaseUri;
- private final int mTargetSdkVersion;
+ private final boolean mAccessFilename;
- public CursorTranslator(Cursor cursor, Uri baseUri, int targetSdkVersion) {
+ public CursorTranslator(Cursor cursor, Uri baseUri, boolean accessFilename) {
super(cursor);
mBaseUri = baseUri;
- mTargetSdkVersion = targetSdkVersion;
+ mAccessFilename = accessFilename;
}
@Override
@@ -1310,7 +1318,7 @@
case COLUMN_LOCAL_URI:
return getLocalUri();
case COLUMN_LOCAL_FILENAME:
- if (mTargetSdkVersion >= Build.VERSION_CODES.N) {
+ if (!mAccessFilename) {
throw new IllegalArgumentException(
"COLUMN_LOCAL_FILENAME is deprecated;"
+ " use ContentResolver.openFileDescriptor() instead");
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index ceb14ad..8804c8b 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -564,7 +564,7 @@
public boolean stopBinderTrackingAndDump(ParcelFileDescriptor fd) throws RemoteException;
public int getActivityStackId(IBinder token) throws RemoteException;
- public void moveActivityToStack(IBinder token, int stackId) throws RemoteException;
+ public void exitFreeformMode(IBinder token) throws RemoteException;
public void suppressResizeConfigChanges(boolean suppress) throws RemoteException;
@@ -933,7 +933,7 @@
int STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 341;
int POSITION_TASK_IN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 342;
int GET_ACTIVITY_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 343;
- int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
+ int EXIT_FREEFORM_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
int MOVE_TASK_TO_DOCKED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
int SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index f940bd6..08e9b1e 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -88,13 +88,15 @@
private final Context mContext;
private final IDevicePolicyManager mService;
+ private boolean mParentInstance;
private static final String REMOTE_EXCEPTION_MESSAGE =
"Failed to talk with device policy manager service";
- private DevicePolicyManager(Context context) {
+ private DevicePolicyManager(Context context, boolean parentInstance) {
this(context, IDevicePolicyManager.Stub.asInterface(
ServiceManager.getService(Context.DEVICE_POLICY_SERVICE)));
+ mParentInstance = parentInstance;
}
/** @hide */
@@ -106,7 +108,7 @@
/** @hide */
public static DevicePolicyManager create(Context context) {
- DevicePolicyManager me = new DevicePolicyManager(context);
+ DevicePolicyManager me = new DevicePolicyManager(context, false);
return me.mService != null ? me : null;
}
@@ -1031,7 +1033,7 @@
public void setPasswordQuality(@NonNull ComponentName admin, int quality) {
if (mService != null) {
try {
- mService.setPasswordQuality(admin, quality);
+ mService.setPasswordQuality(admin, quality, mParentInstance);
} catch (RemoteException e) {
Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
}
@@ -1052,7 +1054,7 @@
public int getPasswordQuality(@Nullable ComponentName admin, int userHandle) {
if (mService != null) {
try {
- return mService.getPasswordQuality(admin, userHandle);
+ return mService.getPasswordQuality(admin, userHandle, mParentInstance);
} catch (RemoteException e) {
Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
}
@@ -1622,7 +1624,7 @@
public boolean isActivePasswordSufficient() {
if (mService != null) {
try {
- return mService.isActivePasswordSufficient(myUserId());
+ return mService.isActivePasswordSufficient(myUserId(), mParentInstance);
} catch (RemoteException e) {
Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
}
@@ -1791,6 +1793,9 @@
* not acceptable for the current constraints or if the user has not been decrypted yet.
*/
public boolean resetPassword(String password, int flags) {
+ if (mParentInstance) {
+ throw new SecurityException("Reset password does not work across profiles.");
+ }
if (mService != null) {
try {
return mService.resetPassword(password, flags);
@@ -3060,6 +3065,8 @@
*
* <p>If the device owner information is {@code null} or empty then the device owner info is
* cleared and the user owner info is shown on the lock screen if it is set.
+ * <p>If the device owner information contains only whitespaces then the message on the lock
+ * screen will be blank and the user will not be allowed to change it.
*
* @param admin The name of the admin component to check.
* @param info Device owner information which will be displayed instead of the user
@@ -4927,4 +4934,23 @@
}
return null;
}
+
+ /**
+ * Obtains a {@link DevicePolicyManager} whose calls act on the parent profile.
+ *
+ * <p> Note only some methods will work on the parent Manager.
+ *
+ * @return a new instance of {@link DevicePolicyManager} that acts on the parent profile.
+ */
+ public DevicePolicyManager getParentProfileInstance(@NonNull ComponentName admin) {
+ try {
+ if (!mService.isManagedProfile(admin)) {
+ throw new SecurityException("The current user does not have a parent profile.");
+ }
+ return new DevicePolicyManager(mContext, true);
+ } catch (RemoteException re) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, re);
+ return null;
+ }
+ }
}
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index f480a02..754cb43 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -35,8 +35,8 @@
* {@hide}
*/
interface IDevicePolicyManager {
- void setPasswordQuality(in ComponentName who, int quality);
- int getPasswordQuality(in ComponentName who, int userHandle);
+ void setPasswordQuality(in ComponentName who, int quality, boolean parent);
+ int getPasswordQuality(in ComponentName who, int userHandle, boolean parent);
void setPasswordMinimumLength(in ComponentName who, int length);
int getPasswordMinimumLength(in ComponentName who, int userHandle);
@@ -67,7 +67,7 @@
long getPasswordExpiration(in ComponentName who, int userHandle);
- boolean isActivePasswordSufficient(int userHandle);
+ boolean isActivePasswordSufficient(int userHandle, boolean parent);
int getCurrentFailedPasswordAttempts(int userHandle);
int getProfileWithMinimumFailedPasswordsForWipe(int userHandle);
diff --git a/core/java/android/app/job/JobScheduler.java b/core/java/android/app/job/JobScheduler.java
index a1c11f3..6e96da5 100644
--- a/core/java/android/app/job/JobScheduler.java
+++ b/core/java/android/app/job/JobScheduler.java
@@ -50,18 +50,15 @@
*/
public static final int RESULT_FAILURE = 0;
/**
- * Returned from {@link #schedule(JobInfo)} if this application has made too many requests for
- * work over too short a time.
+ * Returned from {@link #schedule(JobInfo)} if this job has been successfully scheduled.
*/
- // TODO: Determine if this is necessary.
public static final int RESULT_SUCCESS = 1;
/**
* @param job The job you wish scheduled. See
* {@link android.app.job.JobInfo.Builder JobInfo.Builder} for more detail on the sorts of jobs
* you can schedule.
- * @return If >0, this int returns the jobId of the successfully scheduled job.
- * Otherwise you have to compare the return value to the error codes defined in this class.
+ * @return An int representing ({@link #RESULT_SUCCESS} or {@link #RESULT_FAILURE}).
*/
public abstract int schedule(JobInfo job);
diff --git a/core/java/android/content/ContentProviderClient.java b/core/java/android/content/ContentProviderClient.java
index dec0d91..9221fbb 100644
--- a/core/java/android/content/ContentProviderClient.java
+++ b/core/java/android/content/ContentProviderClient.java
@@ -144,7 +144,16 @@
}
final Cursor cursor = mContentProvider.query(mPackageName, url, projection, selection,
selectionArgs, sortOrder, remoteCancellationSignal);
- return new CursorWrapperInner(cursor);
+ if (cursor == null) {
+ return null;
+ }
+
+ if ("com.google.android.gms".equals(mPackageName)) {
+ // They're casting to a concrete subclass, sigh
+ return cursor;
+ } else {
+ return new CursorWrapperInner(cursor);
+ }
} catch (DeadObjectException e) {
if (!mStable) {
mContentResolver.unstableProviderDied(mContentProvider);
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index 5105ad6..684a85e 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -21,6 +21,7 @@
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.TestApi;
+import android.annotation.UserIdInt;
import android.app.ActivityManagerNative;
import android.app.ActivityThread;
import android.app.AppGlobals;
@@ -1611,7 +1612,7 @@
/** @hide - designated user version */
public final void registerContentObserver(Uri uri, boolean notifyForDescendents,
- ContentObserver observer, int userHandle) {
+ ContentObserver observer, @UserIdInt int userHandle) {
try {
getContentService().registerContentObserver(uri, notifyForDescendents,
observer.getContentObserver(), userHandle);
@@ -1685,7 +1686,7 @@
* @hide
*/
public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork,
- int userHandle) {
+ @UserIdInt int userHandle) {
try {
getContentService().notifyChange(
uri, observer == null ? null : observer.getContentObserver(),
@@ -1826,7 +1827,7 @@
* @see #requestSync(Account, String, Bundle)
* @hide
*/
- public static void requestSyncAsUser(Account account, String authority, int userId,
+ public static void requestSyncAsUser(Account account, String authority, @UserIdInt int userId,
Bundle extras) {
if (extras == null) {
throw new IllegalArgumentException("Must specify extras.");
@@ -1923,7 +1924,7 @@
* @see #cancelSync(Account, String)
* @hide
*/
- public static void cancelSyncAsUser(Account account, String authority, int userId) {
+ public static void cancelSyncAsUser(Account account, String authority, @UserIdInt int userId) {
try {
getContentService().cancelSyncAsUser(account, authority, null, userId);
} catch (RemoteException e) {
@@ -1946,7 +1947,7 @@
* @see #getSyncAdapterTypes()
* @hide
*/
- public static SyncAdapterType[] getSyncAdapterTypesAsUser(int userId) {
+ public static SyncAdapterType[] getSyncAdapterTypesAsUser(@UserIdInt int userId) {
try {
return getContentService().getSyncAdapterTypesAsUser(userId);
} catch (RemoteException e) {
@@ -1960,7 +1961,7 @@
*/
@TestApi
public static String[] getSyncAdapterPackagesForAuthorityAsUser(String authority,
- int userId) {
+ @UserIdInt int userId) {
try {
return getContentService().getSyncAdapterPackagesForAuthorityAsUser(authority, userId);
} catch (RemoteException e) {
@@ -1990,7 +1991,7 @@
* @hide
*/
public static boolean getSyncAutomaticallyAsUser(Account account, String authority,
- int userId) {
+ @UserIdInt int userId) {
try {
return getContentService().getSyncAutomaticallyAsUser(account, authority, userId);
} catch (RemoteException e) {
@@ -2016,7 +2017,7 @@
* @hide
*/
public static void setSyncAutomaticallyAsUser(Account account, String authority, boolean sync,
- int userId) {
+ @UserIdInt int userId) {
try {
getContentService().setSyncAutomaticallyAsUser(account, authority, sync, userId);
} catch (RemoteException e) {
@@ -2175,7 +2176,8 @@
* @see #getIsSyncable(Account, String)
* @hide
*/
- public static int getIsSyncableAsUser(Account account, String authority, int userId) {
+ public static int getIsSyncableAsUser(Account account, String authority,
+ @UserIdInt int userId) {
try {
return getContentService().getIsSyncableAsUser(account, authority, userId);
} catch (RemoteException e) {
@@ -2218,7 +2220,7 @@
* @see #getMasterSyncAutomatically()
* @hide
*/
- public static boolean getMasterSyncAutomaticallyAsUser(int userId) {
+ public static boolean getMasterSyncAutomaticallyAsUser(@UserIdInt int userId) {
try {
return getContentService().getMasterSyncAutomaticallyAsUser(userId);
} catch (RemoteException e) {
@@ -2242,7 +2244,7 @@
* @see #setMasterSyncAutomatically(boolean)
* @hide
*/
- public static void setMasterSyncAutomaticallyAsUser(boolean sync, int userId) {
+ public static void setMasterSyncAutomaticallyAsUser(boolean sync, @UserIdInt int userId) {
try {
getContentService().setMasterSyncAutomaticallyAsUser(sync, userId);
} catch (RemoteException e) {
@@ -2322,7 +2324,7 @@
* @see #getCurrentSyncs()
* @hide
*/
- public static List<SyncInfo> getCurrentSyncsAsUser(int userId) {
+ public static List<SyncInfo> getCurrentSyncsAsUser(@UserIdInt int userId) {
try {
return getContentService().getCurrentSyncsAsUser(userId);
} catch (RemoteException e) {
@@ -2350,7 +2352,7 @@
* @hide
*/
public static SyncStatusInfo getSyncStatusAsUser(Account account, String authority,
- int userId) {
+ @UserIdInt int userId) {
try {
return getContentService().getSyncStatusAsUser(account, authority, null, userId);
} catch (RemoteException e) {
@@ -2374,7 +2376,8 @@
* @see #requestSync(Account, String, Bundle)
* @hide
*/
- public static boolean isSyncPendingAsUser(Account account, String authority, int userId) {
+ public static boolean isSyncPendingAsUser(Account account, String authority,
+ @UserIdInt int userId) {
try {
return getContentService().isSyncPendingAsUser(account, authority, null, userId);
} catch (RemoteException e) {
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 9894b92..a6036bb 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -31,6 +31,7 @@
import android.annotation.StyleableRes;
import android.annotation.SystemApi;
import android.annotation.TestApi;
+import android.annotation.UserIdInt;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
@@ -3969,7 +3970,7 @@
* @hide
*/
@TestApi
- public abstract int getUserId();
+ public abstract @UserIdInt int getUserId();
/**
* Return a new Context object for the current Context but whose resources
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 411dfa2..0168908 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -804,7 +804,12 @@
public boolean hasRtlSupport() {
return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
}
-
+
+ /** {@hide} */
+ public boolean hasCode() {
+ return (flags & FLAG_HAS_CODE) != 0;
+ }
+
public static class DisplayNameComparator
implements Comparator<ApplicationInfo> {
public DisplayNameComparator(PackageManager pm) {
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 8750282..9d94b74 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -27,6 +27,7 @@
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.StringRes;
import android.annotation.SystemApi;
+import android.annotation.UserIdInt;
import android.annotation.TestApi;
import android.annotation.XmlRes;
import android.app.PackageDeleteObserver;
@@ -2228,9 +2229,6 @@
/**
* Retrieve overall information about an application package that is
* installed on the system.
- * <p>
- * Throws {@link NameNotFoundException} if a package with the given name can
- * not be found on the system.
*
* @param packageName The full name (i.e. com.google.apps.contacts) of the
* desired package.
@@ -2248,6 +2246,8 @@
* applications (which includes installed applications as well as
* applications with data directory i.e. applications which had been
* deleted with {@code DONT_DELETE_DATA} flag set).
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
* @see #GET_ACTIVITIES
* @see #GET_GIDS
* @see #GET_CONFIGURATIONS
@@ -2266,9 +2266,6 @@
* @hide
* Retrieve overall information about an application package that is
* installed on the system.
- * <p>
- * Throws {@link NameNotFoundException} if a package with the given name can
- * not be found on the system.
*
* @param packageName The full name (i.e. com.google.apps.contacts) of the
* desired package.
@@ -2287,6 +2284,8 @@
* applications (which includes installed applications as well as
* applications with data directory i.e. applications which had been
* deleted with {@code DONT_DELETE_DATA} flag set).
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
* @see #GET_ACTIVITIES
* @see #GET_GIDS
* @see #GET_CONFIGURATIONS
@@ -2300,7 +2299,7 @@
*/
@RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
public abstract PackageInfo getPackageInfoAsUser(String packageName,
- @PackageInfoFlags int flags, int userId) throws NameNotFoundException;
+ @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException;
/**
* Map from the current package names in use on the device to whatever
@@ -2342,9 +2341,6 @@
* through packages. The current implementation will look for a main
* activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
* return null if no main leanback activities are found.
- * <p>
- * Throws {@link NameNotFoundException} if a package with the given name
- * cannot be found on the system.
*
* @param packageName The name of the package to inspect.
* @return Returns either a fully-qualified Intent that can be used to launch
@@ -2356,39 +2352,73 @@
/**
* Return an array of all of the secondary group-ids that have been assigned
* to a package.
- * <p>
- * Throws {@link NameNotFoundException} if a package with the given name
- * cannot be found on the system.
*
* @param packageName The full name (i.e. com.google.apps.contacts) of the
* desired package.
* @return Returns an int array of the assigned gids, or null if there are
* none.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*/
public abstract int[] getPackageGids(String packageName)
throws NameNotFoundException;
/**
- * @hide Return the uid associated with the given package name for the
- * given user.
- *
- * <p>Throws {@link NameNotFoundException} if a package with the given
- * name can not be found on the system.
+ * Return an array of all of the secondary group-ids that have been assigned
+ * to a package.
*
* @param packageName The full name (i.e. com.google.apps.contacts) of the
- * desired package.
- * @param userHandle The user handle identifier to look up the package under.
- *
- * @return Returns an integer uid who owns the given package name.
+ * desired package.
+ * @return Returns an int array of the assigned gids, or null if there are
+ * none.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*/
- public abstract int getPackageUidAsUser(String packageName, int userId)
+ public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags)
throws NameNotFoundException;
/**
- * Retrieve all of the information we know about a particular permission.
+ * Return the UID associated with the given package name.
*
- * <p>Throws {@link NameNotFoundException} if a permission with the given
- * name cannot be found on the system.
+ * @param packageName The full name (i.e. com.google.apps.contacts) of the
+ * desired package.
+ * @return Returns an integer UID who owns the given package name.
+ * @throws NameNotFoundException if a package with the given name can not be
+ * found on the system.
+ */
+ public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags)
+ throws NameNotFoundException;
+
+ /**
+ * Return the UID associated with the given package name.
+ *
+ * @param packageName The full name (i.e. com.google.apps.contacts) of the
+ * desired package.
+ * @param userId The user handle identifier to look up the package under.
+ * @return Returns an integer UID who owns the given package name.
+ * @throws NameNotFoundException if a package with the given name can not be
+ * found on the system.
+ * @hide
+ */
+ public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId)
+ throws NameNotFoundException;
+
+ /**
+ * Return the UID associated with the given package name.
+ *
+ * @param packageName The full name (i.e. com.google.apps.contacts) of the
+ * desired package.
+ * @param userId The user handle identifier to look up the package under.
+ * @return Returns an integer UID who owns the given package name.
+ * @throws NameNotFoundException if a package with the given name can not be
+ * found on the system.
+ * @hide
+ */
+ public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags,
+ @UserIdInt int userId) throws NameNotFoundException;
+
+ /**
+ * Retrieve all of the information we know about a particular permission.
*
* @param name The fully qualified name (i.e. com.google.permission.LOGIN)
* of the permission you are interested in.
@@ -2397,6 +2427,8 @@
*
* @return Returns a {@link PermissionInfo} containing information about the
* permission.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*/
public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags)
throws NameNotFoundException;
@@ -2404,9 +2436,6 @@
/**
* Query for all of the permissions associated with a particular group.
*
- * <p>Throws {@link NameNotFoundException} if the given group does not
- * exist.
- *
* @param group The fully qualified name (i.e. com.google.permission.LOGIN)
* of the permission group you are interested in. Use null to
* find all of the permissions not associated with a group.
@@ -2415,6 +2444,8 @@
*
* @return Returns a list of {@link PermissionInfo} containing information
* about all of the permissions in the given group.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*/
public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
@PermissionInfoFlags int flags) throws NameNotFoundException;
@@ -2423,9 +2454,6 @@
* Retrieve all of the information we know about a particular group of
* permissions.
*
- * <p>Throws {@link NameNotFoundException} if a permission group with the given
- * name cannot be found on the system.
- *
* @param name The fully qualified name (i.e. com.google.permission_group.APPS)
* of the permission you are interested in.
* @param flags Additional option flags. Use {@link #GET_META_DATA} to
@@ -2433,6 +2461,8 @@
*
* @return Returns a {@link PermissionGroupInfo} containing information
* about the permission.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*/
public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
@PermissionGroupInfoFlags int flags) throws NameNotFoundException;
@@ -2453,9 +2483,6 @@
* Retrieve all of the information we know about a particular
* package/application.
*
- * <p>Throws {@link NameNotFoundException} if an application with the given
- * package name cannot be found on the system.
- *
* @param packageName The full name (i.e. com.google.apps.contacts) of an
* application.
* @param flags Additional option flags. Use any combination of
@@ -2471,6 +2498,8 @@
* installed applications as well as applications
* with data directory ie applications which had been
* deleted with {@code DONT_DELETE_DATA} flag set).
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*
* @see #GET_META_DATA
* @see #GET_SHARED_LIBRARY_FILES
@@ -2483,9 +2512,6 @@
* Retrieve all of the information we know about a particular activity
* class.
*
- * <p>Throws {@link NameNotFoundException} if an activity with the given
- * class name cannot be found on the system.
- *
* @param component The full component name (i.e.
* com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
* class.
@@ -2494,6 +2520,8 @@
* to modify the data (in ApplicationInfo) returned.
*
* @return {@link ActivityInfo} containing information about the activity.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*
* @see #GET_INTENT_FILTERS
* @see #GET_META_DATA
@@ -2506,9 +2534,6 @@
* Retrieve all of the information we know about a particular receiver
* class.
*
- * <p>Throws {@link NameNotFoundException} if a receiver with the given
- * class name cannot be found on the system.
- *
* @param component The full component name (i.e.
* com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
* class.
@@ -2517,6 +2542,8 @@
* to modify the data returned.
*
* @return {@link ActivityInfo} containing information about the receiver.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*
* @see #GET_INTENT_FILTERS
* @see #GET_META_DATA
@@ -2529,9 +2556,6 @@
* Retrieve all of the information we know about a particular service
* class.
*
- * <p>Throws {@link NameNotFoundException} if a service with the given
- * class name cannot be found on the system.
- *
* @param component The full component name (i.e.
* com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
* class.
@@ -2540,6 +2564,8 @@
* to modify the data returned.
*
* @return ServiceInfo containing information about the service.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*
* @see #GET_META_DATA
* @see #GET_SHARED_LIBRARY_FILES
@@ -2551,9 +2577,6 @@
* Retrieve all of the information we know about a particular content
* provider class.
*
- * <p>Throws {@link NameNotFoundException} if a provider with the given
- * class name cannot be found on the system.
- *
* @param component The full component name (i.e.
* com.google.providers.media/com.google.providers.media.MediaProvider) of a
* ContentProvider class.
@@ -2562,6 +2585,8 @@
* to modify the data returned.
*
* @return ProviderInfo containing information about the service.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*
* @see #GET_META_DATA
* @see #GET_SHARED_LIBRARY_FILES
@@ -2676,7 +2701,7 @@
* @hide
*/
public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
- int userId);
+ @UserIdInt int userId);
/**
* Check whether a particular package has been granted a particular
@@ -2988,8 +3013,9 @@
* shared user.
*
* @param sharedUserName The shared user name whose uid is to be retrieved.
- * @return Returns the uid associated with the shared user, or NameNotFoundException
- * if the shared user name is not being used by any installed packages
+ * @return Returns the UID associated with the shared user.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
* @hide
*/
public abstract int getUidForSharedUser(String sharedUserName)
@@ -3185,7 +3211,7 @@
* @hide
*/
public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags,
- int userId);
+ @UserIdInt int userId);
/**
* Retrieve all activities that can be performed for the given intent.
@@ -3232,7 +3258,7 @@
* @hide
*/
public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
- @ResolveInfoFlags int flags, int userId);
+ @ResolveInfoFlags int flags, @UserIdInt int userId);
/**
* Retrieve a set of activities that should be presented to the user as
@@ -3301,7 +3327,7 @@
* @hide
*/
public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent,
- @ResolveInfoFlags int flags, int userId);
+ @ResolveInfoFlags int flags, @UserIdInt int userId);
/**
* Determine the best service to handle for a given Intent.
@@ -3356,11 +3382,11 @@
* @hide
*/
public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
- @ResolveInfoFlags int flags, int userId);
+ @ResolveInfoFlags int flags, @UserIdInt int userId);
/** {@hide} */
public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
- Intent intent, @ResolveInfoFlags int flags, int userId);
+ Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId);
/**
* Retrieve all providers that can match the given intent.
@@ -3401,7 +3427,7 @@
* @hide
*/
public abstract ProviderInfo resolveContentProviderAsUser(String name,
- @ComponentInfoFlags int flags, int userId);
+ @ComponentInfoFlags int flags, @UserIdInt int userId);
/**
* Retrieve content provider information.
@@ -3428,9 +3454,6 @@
* Retrieve all of the information we know about a particular
* instrumentation class.
*
- * <p>Throws {@link NameNotFoundException} if instrumentation with the
- * given class name cannot be found on the system.
- *
* @param className The full name (i.e.
* com.google.apps.contacts.InstrumentList) of an
* Instrumentation class.
@@ -3438,6 +3461,8 @@
*
* @return InstrumentationInfo containing information about the
* instrumentation.
+ * @throws NameNotFoundException if a package with the given name cannot be
+ * found on the system.
*/
public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className,
@InstrumentationInfoFlags int flags) throws NameNotFoundException;
@@ -3860,8 +3885,8 @@
throws NameNotFoundException;
/** @hide */
- public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
- throws NameNotFoundException;
+ public abstract Resources getResourcesForApplicationAsUser(String appPackageName,
+ @UserIdInt int userId) throws NameNotFoundException;
/**
* Retrieve overall information about an application package defined
@@ -4061,7 +4086,7 @@
Manifest.permission.INTERACT_ACROSS_USERS_FULL})
public abstract void installPackageAsUser(
Uri packageURI, PackageInstallObserver observer, int flags,
- String installerPackageName, int userId);
+ String installerPackageName, @UserIdInt int userId);
/**
* Similar to
@@ -4134,7 +4159,7 @@
@RequiresPermission(anyOf = {
Manifest.permission.INSTALL_PACKAGES,
Manifest.permission.INTERACT_ACROSS_USERS_FULL})
- public abstract int installExistingPackageAsUser(String packageName, int userId)
+ public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
throws NameNotFoundException;
/**
@@ -4232,7 +4257,7 @@
*
* @hide
*/
- public abstract int getIntentVerificationStatusAsUser(String packageName, int userId);
+ public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId);
/**
* Allow to change the status of a Intent Verification status for all IntentFilter of an App.
@@ -4255,7 +4280,7 @@
* @hide
*/
public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
- int userId);
+ @UserIdInt int userId);
/**
* Get the list of IntentFilterVerificationInfo for a specific package and User.
@@ -4296,7 +4321,7 @@
* @hide
*/
@TestApi
- public abstract String getDefaultBrowserPackageNameAsUser(int userId);
+ public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId);
/**
* Set the default Browser package name for a specific user.
@@ -4310,7 +4335,8 @@
*
* @hide
*/
- public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, int userId);
+ public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
+ @UserIdInt int userId);
/**
* Change the installer associated with a given package. There are limitations
@@ -4369,7 +4395,7 @@
Manifest.permission.DELETE_PACKAGES,
Manifest.permission.INTERACT_ACROSS_USERS_FULL})
public abstract void deletePackageAsUser(
- String packageName, IPackageDeleteObserver observer, int flags, int userId);
+ String packageName, IPackageDeleteObserver observer, int flags, @UserIdInt int userId);
/**
* Retrieve the package name of the application that installed a package. This identifies
@@ -4493,7 +4519,7 @@
*
* @hide
*/
- public abstract void getPackageSizeInfoAsUser(String packageName, int userId,
+ public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId,
IPackageStatsObserver observer);
/**
@@ -4583,7 +4609,7 @@
* @hide
*/
public void addPreferredActivityAsUser(IntentFilter filter, int match,
- ComponentName[] set, ComponentName activity, int userId) {
+ ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
}
@@ -4617,7 +4643,7 @@
*/
@Deprecated
public void replacePreferredActivityAsUser(IntentFilter filter, int match,
- ComponentName[] set, ComponentName activity, int userId) {
+ ComponentName[] set, ComponentName activity, @UserIdInt int userId) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
}
@@ -4845,7 +4871,7 @@
* @hide
*/
public abstract boolean setPackageSuspendedAsUser(
- String packageName, boolean suspended, int userId);
+ String packageName, boolean suspended, @UserIdInt int userId);
/** {@hide} */
public static boolean isMoveStatusFinished(int status) {
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 8ab8991..f642f08 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -19,16 +19,22 @@
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import android.annotation.CallSuper;
import android.annotation.DrawableRes;
+import android.annotation.IntDef;
+import android.annotation.MainThread;
import android.app.ActivityManager;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
+import android.database.ContentObserver;
import android.graphics.Rect;
import android.graphics.Region;
+import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
import android.os.IBinder;
import android.os.ResultReceiver;
import android.os.SystemClock;
@@ -68,6 +74,8 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
/**
* InputMethodService provides a standard implementation of an InputMethod,
@@ -634,6 +642,97 @@
}
/**
+ * A {@link ContentObserver} to monitor {@link Settings.Secure#SHOW_IME_WITH_HARD_KEYBOARD}.
+ *
+ * <p>Note that {@link Settings.Secure#SHOW_IME_WITH_HARD_KEYBOARD} is not a public API.
+ * Basically this functionality still needs to be considered as implementation details.</p>
+ */
+ @MainThread
+ private static final class SettingsObserver extends ContentObserver {
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ ShowImeWithHardKeyboardType.UNKNOWN,
+ ShowImeWithHardKeyboardType.FALSE,
+ ShowImeWithHardKeyboardType.TRUE,
+ })
+ private @interface ShowImeWithHardKeyboardType {
+ int UNKNOWN = 0;
+ int FALSE = 1;
+ int TRUE = 2;
+ }
+ @ShowImeWithHardKeyboardType
+ private int mShowImeWithHardKeyboard = ShowImeWithHardKeyboardType.UNKNOWN;
+
+ private final InputMethodService mService;
+
+ private SettingsObserver(InputMethodService service) {
+ super(new Handler(service.getMainLooper()));
+ mService = service;
+ }
+
+ /**
+ * A factory method that internally enforces two-phase initialization to make sure that the
+ * object reference will not be escaped until the object is properly constructed.
+ *
+ * <p>NOTE: Currently {@link SettingsObserver} is accessed only from main thread. Hence
+ * this enforcement of two-phase initialization may be unnecessary at the moment.</p>
+ *
+ * @param service {@link InputMethodService} that needs to receive the callback.
+ * @return {@link SettingsObserver} that is already registered to
+ * {@link android.content.ContentResolver}. The caller must call
+ * {@link SettingsObserver#unregister()}.
+ */
+ public static SettingsObserver createAndRegister(InputMethodService service) {
+ final SettingsObserver observer = new SettingsObserver(service);
+ // The observer is properly constructed. Let's start accepting the event.
+ service.getContentResolver().registerContentObserver(
+ Settings.Secure.getUriFor(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD),
+ false, observer);
+ return observer;
+ }
+
+ void unregister() {
+ mService.getContentResolver().unregisterContentObserver(this);
+ }
+
+ private boolean shouldShowImeWithHardKeyboard() {
+ // Lazily initialize as needed.
+ if (mShowImeWithHardKeyboard == ShowImeWithHardKeyboardType.UNKNOWN) {
+ mShowImeWithHardKeyboard = Settings.Secure.getInt(mService.getContentResolver(),
+ Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD, 0) != 0 ?
+ ShowImeWithHardKeyboardType.TRUE : ShowImeWithHardKeyboardType.FALSE;
+ }
+ switch (mShowImeWithHardKeyboard) {
+ case ShowImeWithHardKeyboardType.TRUE:
+ return true;
+ case ShowImeWithHardKeyboardType.FALSE:
+ return false;
+ default:
+ Log.e(TAG, "Unexpected mShowImeWithHardKeyboard=" + mShowImeWithHardKeyboard);
+ return false;
+ }
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ final Uri showImeWithHardKeyboardUri =
+ Settings.Secure.getUriFor(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD);
+ if (showImeWithHardKeyboardUri.equals(uri)) {
+ mShowImeWithHardKeyboard = Settings.Secure.getInt(mService.getContentResolver(),
+ Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD, 0) != 0 ?
+ ShowImeWithHardKeyboardType.TRUE : ShowImeWithHardKeyboardType.FALSE;
+ mService.updateInputViewShown();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "SettingsObserver{mShowImeWithHardKeyboard=" + mShowImeWithHardKeyboard + "}";
+ }
+ }
+ private SettingsObserver mSettingsObserver;
+
+ /**
* You can call this to customize the theme used by your IME's window.
* This theme should typically be one that derives from
* {@link android.R.style#Theme_InputMethod}, which is the default theme
@@ -682,6 +781,7 @@
super.setTheme(mTheme);
super.onCreate();
mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
+ mSettingsObserver = SettingsObserver.createAndRegister(this);
// If the previous IME has occupied non-empty inset in the screen, we need to decide whether
// we continue to use the same size of the inset or update it
mShouldClearInsetOfPreviousIme = (mImm.getInputMethodWindowVisibleHeight() > 0);
@@ -764,6 +864,10 @@
mWindow.getWindow().setWindowAnimations(0);
mWindow.dismiss();
}
+ if (mSettingsObserver != null) {
+ mSettingsObserver.unregister();
+ mSettingsObserver = null;
+ }
}
/**
@@ -1140,21 +1244,28 @@
public boolean isInputViewShown() {
return mIsInputViewShown && mWindowVisible;
}
-
+
/**
- * Override this to control when the soft input area should be shown to
- * the user. The default implementation only shows the input view when
- * there is no hard keyboard or the keyboard is hidden. If you change what
- * this returns, you will need to call {@link #updateInputViewShown()}
- * yourself whenever the returned value may have changed to have it
- * re-evaluated and applied.
+ * Override this to control when the soft input area should be shown to the user. The default
+ * implementation returns {@code false} when there is no hard keyboard or the keyboard is hidden
+ * unless the user shows an intention to use software keyboard. If you change what this
+ * returns, you will need to call {@link #updateInputViewShown()} yourself whenever the returned
+ * value may have changed to have it re-evaluated and applied.
+ *
+ * <p>When you override this method, it is recommended to call
+ * {@code super.onEvaluateInputViewShown()} and return {@code true} when {@code true} is
+ * returned.</p>
*/
+ @CallSuper
public boolean onEvaluateInputViewShown() {
+ if (mSettingsObserver.shouldShowImeWithHardKeyboard()) {
+ return true;
+ }
Configuration config = getResources().getConfiguration();
return config.keyboard == Configuration.KEYBOARD_NOKEYS
|| config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES;
}
-
+
/**
* Controls the visibility of the candidates display area. By default
* it is hidden.
@@ -2483,5 +2594,6 @@
+ " touchableInsets=" + mTmpInsets.touchableInsets
+ " touchableRegion=" + mTmpInsets.touchableRegion);
p.println(" mShouldClearInsetOfPreviousIme=" + mShouldClearInsetOfPreviousIme);
+ p.println(" mSettingsObserver=" + mSettingsObserver);
}
}
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 126824f..4159d89 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -980,6 +980,14 @@
= "android.os.action.POWER_SAVE_MODE_CHANGED";
/**
+ * Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes.
+ * @hide
+ */
+ @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_POWER_SAVE_MODE_CHANGED_INTERNAL
+ = "android.os.action.POWER_SAVE_MODE_CHANGED_INTERNAL";
+
+ /**
* Intent that is broadcast when the state of {@link #isDeviceIdleMode()} changes.
* This broadcast is only sent to registered receivers.
*/
diff --git a/core/java/android/os/ServiceManager.java b/core/java/android/os/ServiceManager.java
index 13b8b66..2ba4aa4 100644
--- a/core/java/android/os/ServiceManager.java
+++ b/core/java/android/os/ServiceManager.java
@@ -112,8 +112,10 @@
/**
* Return a list of all currently running services.
+ * @return an array of all currently running services, or <code>null</code> in
+ * case of an exception
*/
- public static String[] listServices() throws RemoteException {
+ public static String[] listServices() {
try {
return getIServiceManager().listServices();
} catch (RemoteException e) {
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index 2498bff..867d0b9 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -16,8 +16,10 @@
package android.os;
+import android.annotation.AppIdInt;
import android.annotation.SystemApi;
import android.annotation.TestApi;
+import android.annotation.UserIdInt;
import java.io.PrintWriter;
@@ -128,7 +130,7 @@
* Returns the user id for a given uid.
* @hide
*/
- public static int getUserId(int uid) {
+ public static @UserIdInt int getUserId(int uid) {
if (MU_ENABLED) {
return uid / PER_USER_RANGE;
} else {
@@ -137,12 +139,12 @@
}
/** @hide */
- public static int getCallingUserId() {
+ public static @UserIdInt int getCallingUserId() {
return getUserId(Binder.getCallingUid());
}
/** @hide */
- public static UserHandle of(int userId) {
+ public static UserHandle of(@UserIdInt int userId) {
return userId == USER_SYSTEM ? SYSTEM : new UserHandle(userId);
}
@@ -150,7 +152,7 @@
* Returns the uid that is composed from the userId and the appId.
* @hide
*/
- public static int getUid(int userId, int appId) {
+ public static int getUid(@UserIdInt int userId, @AppIdInt int appId) {
if (MU_ENABLED) {
return userId * PER_USER_RANGE + (appId % PER_USER_RANGE);
} else {
@@ -163,7 +165,7 @@
* @hide
*/
@TestApi
- public static int getAppId(int uid) {
+ public static @AppIdInt int getAppId(int uid) {
return uid % PER_USER_RANGE;
}
@@ -171,7 +173,7 @@
* Returns the gid shared between all apps with this userId.
* @hide
*/
- public static int getUserGid(int userId) {
+ public static int getUserGid(@UserIdInt int userId) {
return getUid(userId, Process.SHARED_USER_GID);
}
@@ -188,7 +190,7 @@
* Returns the app id for a given shared app gid. Returns -1 if the ID is invalid.
* @hide
*/
- public static int getAppIdFromSharedAppGid(int gid) {
+ public static @AppIdInt int getAppIdFromSharedAppGid(int gid) {
final int appId = getAppId(gid) + Process.FIRST_APPLICATION_UID
- Process.FIRST_SHARED_APPLICATION_GID;
if (appId < 0 || appId >= Process.FIRST_SHARED_APPLICATION_GID) {
@@ -259,7 +261,7 @@
}
/** @hide */
- public static int parseUserArg(String arg) {
+ public static @UserIdInt int parseUserArg(String arg) {
int userId;
if ("all".equals(arg)) {
userId = UserHandle.USER_ALL;
@@ -281,7 +283,7 @@
* @hide
*/
@SystemApi
- public static int myUserId() {
+ public static @UserIdInt int myUserId() {
return getUserId(Process.myUid());
}
@@ -317,7 +319,7 @@
* @hide
*/
@SystemApi
- public int getIdentifier() {
+ public @UserIdInt int getIdentifier() {
return mHandle;
}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 037916a..887dd17 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
@@ -601,7 +602,7 @@
* @return the user handle of this process.
* @hide
*/
- public int getUserHandle() {
+ public @UserIdInt int getUserHandle() {
return UserHandle.myUserId();
}
@@ -671,7 +672,7 @@
* Returns whether the provided user is an admin user. There can be more than one admin
* user.
*/
- public boolean isUserAdmin(int userId) {
+ public boolean isUserAdmin(@UserIdInt int userId) {
UserInfo user = getUserInfo(userId);
return user != null && user.isAdmin();
}
@@ -695,7 +696,7 @@
* Checks if specified user can have restricted profile.
* @hide
*/
- public boolean canHaveRestrictedProfile(int userId) {
+ public boolean canHaveRestrictedProfile(@UserIdInt int userId) {
try {
return mService.canHaveRestrictedProfile(userId);
} catch (RemoteException re) {
@@ -741,7 +742,7 @@
* Returns whether the specified user is ephemeral.
* @hide
*/
- public boolean isUserEphemeral(int userId) {
+ public boolean isUserEphemeral(@UserIdInt int userId) {
final UserInfo user = getUserInfo(userId);
return user != null && user.isEphemeral();
}
@@ -861,7 +862,7 @@
}
/** {@hide} */
- public boolean isUserUnlocked(int userId) {
+ public boolean isUserUnlocked(@UserIdInt int userId) {
// TODO: eventually pivot this back to look at ActivityManager state,
// but there is race where we can start a non-encryption-aware launcher
// before that lifecycle has entered the running unlocked state.
@@ -875,7 +876,7 @@
* @return the UserInfo object for a specific user.
* @hide
*/
- public UserInfo getUserInfo(int userHandle) {
+ public UserInfo getUserInfo(@UserIdInt int userHandle) {
try {
return mService.getUserInfo(userHandle);
} catch (RemoteException re) {
@@ -1093,7 +1094,7 @@
* @return the UserInfo object for the created user, or null if the user could not be created.
* @hide
*/
- public UserInfo createProfileForUser(String name, int flags, int userHandle) {
+ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle) {
try {
return mService.createProfileForUser(name, flags, userHandle);
} catch (RemoteException re) {
@@ -1133,7 +1134,7 @@
* @param userHandle
* @return
*/
- public boolean markGuestForDeletion(int userHandle) {
+ public boolean markGuestForDeletion(@UserIdInt int userHandle) {
try {
return mService.markGuestForDeletion(userHandle);
} catch (RemoteException re) {
@@ -1150,7 +1151,7 @@
* @param userHandle the id of the profile to enable
* @hide
*/
- public void setUserEnabled(int userHandle) {
+ public void setUserEnabled(@UserIdInt int userHandle) {
try {
mService.setUserEnabled(userHandle);
} catch (RemoteException e) {
@@ -1189,7 +1190,7 @@
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.MANAGE_USERS
})
- public @Nullable String getUserAccount(int userHandle) {
+ public @Nullable String getUserAccount(@UserIdInt int userHandle) {
try {
return mService.getUserAccount(userHandle);
} catch (RemoteException re) {
@@ -1206,7 +1207,7 @@
Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Manifest.permission.MANAGE_USERS
})
- public void setUserAccount(int userHandle, @Nullable String accountName) {
+ public void setUserAccount(@UserIdInt int userHandle, @Nullable String accountName) {
try {
mService.setUserAccount(userHandle, accountName);
} catch (RemoteException re) {
@@ -1259,7 +1260,7 @@
* @return true if more managed profiles can be added, false if limit has been reached.
* @hide
*/
- public boolean canAddMoreManagedProfiles(int userId, boolean allowedToRemoveOne) {
+ public boolean canAddMoreManagedProfiles(@UserIdInt int userId, boolean allowedToRemoveOne) {
try {
return mService.canAddMoreManagedProfiles(userId, allowedToRemoveOne);
} catch (RemoteException re) {
@@ -1279,7 +1280,7 @@
* @return the list of profiles.
* @hide
*/
- public List<UserInfo> getProfiles(int userHandle) {
+ public List<UserInfo> getProfiles(@UserIdInt int userHandle) {
try {
return mService.getProfiles(userHandle, false /* enabledOnly */);
} catch (RemoteException re) {
@@ -1295,7 +1296,7 @@
* @return true if the two user ids are in the same profile group.
* @hide
*/
- public boolean isSameProfileGroup(int userId, int otherUserId) {
+ public boolean isSameProfileGroup(@UserIdInt int userId, int otherUserId) {
try {
return mService.isSameProfileGroup(userId, otherUserId);
} catch (RemoteException re) {
@@ -1314,7 +1315,7 @@
* @return the list of profiles.
* @hide
*/
- public List<UserInfo> getEnabledProfiles(int userHandle) {
+ public List<UserInfo> getEnabledProfiles(@UserIdInt int userHandle) {
try {
return mService.getProfiles(userHandle, true /* enabledOnly */);
} catch (RemoteException re) {
@@ -1352,7 +1353,7 @@
*
* @hide
*/
- public int getCredentialOwnerProfile(int userHandle) {
+ public int getCredentialOwnerProfile(@UserIdInt int userHandle) {
try {
return mService.getCredentialOwnerProfile(userHandle);
} catch (RemoteException re) {
@@ -1367,7 +1368,7 @@
*
* @hide
*/
- public UserInfo getProfileParent(int userHandle) {
+ public UserInfo getProfileParent(@UserIdInt int userHandle) {
try {
return mService.getProfileParent(userHandle);
} catch (RemoteException re) {
@@ -1383,7 +1384,7 @@
* @param enableQuietMode Whether quiet mode should be enabled or disabled.
* @hide
*/
- public void setQuietModeEnabled(int userHandle, boolean enableQuietMode) {
+ public void setQuietModeEnabled(@UserIdInt int userHandle, boolean enableQuietMode) {
try {
mService.setQuietModeEnabled(userHandle, enableQuietMode);
} catch (RemoteException e) {
@@ -1499,7 +1500,7 @@
* @param userHandle the integer handle of the user, where 0 is the primary user.
* @hide
*/
- public boolean removeUser(int userHandle) {
+ public boolean removeUser(@UserIdInt int userHandle) {
try {
return mService.removeUser(userHandle);
} catch (RemoteException re) {
@@ -1516,7 +1517,7 @@
* @param name the new name for the user
* @hide
*/
- public void setUserName(int userHandle, String name) {
+ public void setUserName(@UserIdInt int userHandle, String name) {
try {
mService.setUserName(userHandle, name);
} catch (RemoteException re) {
@@ -1530,7 +1531,7 @@
* @param icon the bitmap to set as the photo.
* @hide
*/
- public void setUserIcon(int userHandle, Bitmap icon) {
+ public void setUserIcon(@UserIdInt int userHandle, Bitmap icon) {
try {
mService.setUserIcon(userHandle, icon);
} catch (RemoteException re) {
@@ -1545,7 +1546,7 @@
* @see com.android.internal.util.UserIcons#getDefaultUserIcon for a default.
* @hide
*/
- public Bitmap getUserIcon(int userHandle) {
+ public Bitmap getUserIcon(@UserIdInt int userHandle) {
try {
ParcelFileDescriptor fd = mService.getUserIcon(userHandle);
if (fd != null) {
@@ -1611,7 +1612,7 @@
* @return a serial number associated with that user, or -1 if the userHandle is not valid.
* @hide
*/
- public int getUserSerialNumber(int userHandle) {
+ public int getUserSerialNumber(@UserIdInt int userHandle) {
try {
return mService.getUserSerialNumber(userHandle);
} catch (RemoteException re) {
@@ -1629,7 +1630,7 @@
* is not valid.
* @hide
*/
- public int getUserHandle(int userSerialNumber) {
+ public @UserIdInt int getUserHandle(int userSerialNumber) {
try {
return mService.getUserHandle(userSerialNumber);
} catch (RemoteException re) {
diff --git a/core/java/android/print/IPrintSpooler.aidl b/core/java/android/print/IPrintSpooler.aidl
index c3625b8..469a4ea 100644
--- a/core/java/android/print/IPrintSpooler.aidl
+++ b/core/java/android/print/IPrintSpooler.aidl
@@ -98,5 +98,11 @@
void writePrintJobData(in ParcelFileDescriptor fd, in PrintJobId printJobId);
void setClient(IPrintSpoolerClient client);
void setPrintJobCancelling(in PrintJobId printJobId, boolean cancelling);
- void removeApprovedPrintService(in ComponentName serviceToRemove);
+
+ /**
+ * Remove all approved print services that are not in the given set.
+ *
+ * @param servicesToKeep The names of the services to keep
+ */
+ void pruneApprovedPrintServices(in List<ComponentName> servicesToKeep);
}
diff --git a/core/java/android/printservice/PrintServiceInfo.java b/core/java/android/printservice/PrintServiceInfo.java
index b33ef83..91e01f2 100644
--- a/core/java/android/printservice/PrintServiceInfo.java
+++ b/core/java/android/printservice/PrintServiceInfo.java
@@ -16,6 +16,7 @@
package android.printservice;
+import android.annotation.NonNull;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -94,6 +95,16 @@
}
/**
+ * Return the component name for this print service.
+ *
+ * @return The component name for this print service.
+ */
+ public @NonNull ComponentName getComponentName() {
+ return new ComponentName(mResolveInfo.serviceInfo.packageName,
+ mResolveInfo.serviceInfo.name);
+ }
+
+ /**
* Creates a new instance.
*
* @param resolveInfo The service resolve info.
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index d0f2159..e1391da 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1139,6 +1139,19 @@
/** @hide */ public static final String EXTRA_APP_UID = "app_uid";
/** @hide */ public static final String EXTRA_APP_PACKAGE = "app_package";
+ /**
+ * Activity Action: Show a dialog with disabled by policy message.
+ * <p> If an user action is disabled by policy, this dialog can be triggered to let
+ * the user know about this.
+ * <p>
+ * Input: Nothing.
+ * <p>
+ * Output: Nothing.
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_SHOW_ADMIN_SUPPORT_DETAILS
+ = "android.settings.SHOW_ADMIN_SUPPORT_DETAILS";
+
// End of Intent actions for Settings
/**
@@ -4974,19 +4987,22 @@
/**
* List of the enabled print services.
+ *
+ * N and beyond uses {@link #DISABLED_PRINT_SERVICES}. But this might be used in an upgrade
+ * from pre-N.
+ *
* @hide
*/
public static final String ENABLED_PRINT_SERVICES =
"enabled_print_services";
/**
- * List of the system print services we enabled on first boot. On
- * first boot we enable all system, i.e. bundled print services,
- * once, so they work out-of-the-box.
+ * List of the disabled print services.
+ *
* @hide
*/
- public static final String ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES =
- "enabled_on_first_boot_system_print_services";
+ public static final String DISABLED_PRINT_SERVICES =
+ "disabled_print_services";
/**
* Setting to always use the default text-to-speech settings regardless
diff --git a/core/java/android/text/Editable.java b/core/java/android/text/Editable.java
index a284a00..b3f2c2a 100644
--- a/core/java/android/text/Editable.java
+++ b/core/java/android/text/Editable.java
@@ -40,10 +40,14 @@
* is Spanned, the spans from it are preserved into the Editable.
* Existing spans within the Editable that entirely cover the replaced
* range are retained, but any that were strictly within the range
- * that was replaced are removed. As a special case, the cursor
- * position is preserved even when the entire range where it is
- * located is replaced.
+ * that was replaced are removed. If the <code>source</code> contains a span
+ * with {@link Spanned#SPAN_PARAGRAPH} flag, and it does not satisfy the
+ * paragraph boundary constraint, it is not retained. As a special case, the
+ * cursor position is preserved even when the entire range where it is located
+ * is replaced.
* @return a reference to this object.
+ *
+ * @see Spanned#SPAN_PARAGRAPH
*/
public Editable replace(int st, int en, CharSequence source, int start, int end);
diff --git a/core/java/android/text/SpannableStringBuilder.java b/core/java/android/text/SpannableStringBuilder.java
index 40315ad..4267238 100644
--- a/core/java/android/text/SpannableStringBuilder.java
+++ b/core/java/android/text/SpannableStringBuilder.java
@@ -421,8 +421,17 @@
// Add span only if this object is not yet used as a span in this string
if (getSpanStart(spans[i]) < 0) {
- setSpan(false, spans[i], st - csStart + start, en - csStart + start,
- sp.getSpanFlags(spans[i]) | SPAN_ADDED);
+ int copySpanStart = st - csStart + start;
+ int copySpanEnd = en - csStart + start;
+ int copySpanFlags = sp.getSpanFlags(spans[i]) | SPAN_ADDED;
+
+ int flagsStart = (copySpanFlags & START_MASK) >> START_SHIFT;
+ int flagsEnd = copySpanFlags & END_MASK;
+
+ if(!isInvalidParagraphStart(copySpanStart, flagsStart) &&
+ !isInvalidParagraphEnd(copySpanEnd, flagsEnd)) {
+ setSpan(false, spans[i], copySpanStart, copySpanEnd, copySpanFlags);
+ }
}
}
restoreInvariants();
@@ -666,23 +675,13 @@
checkRange("setSpan", start, end);
int flagsStart = (flags & START_MASK) >> START_SHIFT;
- if (flagsStart == PARAGRAPH) {
- if (start != 0 && start != length()) {
- char c = charAt(start - 1);
-
- if (c != '\n')
- throw new RuntimeException("PARAGRAPH span must start at paragraph boundary");
- }
+ if(isInvalidParagraphStart(start, flagsStart)) {
+ throw new RuntimeException("PARAGRAPH span must start at paragraph boundary");
}
int flagsEnd = flags & END_MASK;
- if (flagsEnd == PARAGRAPH) {
- if (end != 0 && end != length()) {
- char c = charAt(end - 1);
-
- if (c != '\n')
- throw new RuntimeException("PARAGRAPH span must end at paragraph boundary");
- }
+ if(isInvalidParagraphEnd(end, flagsEnd)) {
+ throw new RuntimeException("PARAGRAPH span must end at paragraph boundary");
}
// 0-length Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
@@ -761,6 +760,28 @@
}
}
+ private final boolean isInvalidParagraphStart(int start, int flagsStart) {
+ if (flagsStart == PARAGRAPH) {
+ if (start != 0 && start != length()) {
+ char c = charAt(start - 1);
+
+ if (c != '\n') return true;
+ }
+ }
+ return false;
+ }
+
+ private final boolean isInvalidParagraphEnd(int end, int flagsEnd) {
+ if (flagsEnd == PARAGRAPH) {
+ if (end != 0 && end != length()) {
+ char c = charAt(end - 1);
+
+ if (c != '\n') return true;
+ }
+ }
+ return false;
+ }
+
/**
* Remove the specified markup object from the buffer.
*/
diff --git a/core/java/android/text/Spanned.java b/core/java/android/text/Spanned.java
index a785d1b..a0d54c26c 100644
--- a/core/java/android/text/Spanned.java
+++ b/core/java/android/text/Spanned.java
@@ -81,7 +81,9 @@
* immediately after a \n character, and if the \n
* that anchors it is deleted, the endpoint is pulled to the
* next \n that follows in the buffer (or to the end of
- * the buffer).
+ * the buffer). If a span with SPAN_PARAGRAPH flag is pasted
+ * into another text and the paragraph boundary constraint
+ * is not satisfied, the span is discarded.
*/
public static final int SPAN_PARAGRAPH = 0x33;
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 7a544b8..a0f5142 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -973,6 +973,7 @@
* </p>
*
* @see #getAxisValue(int, int)
+ * {@hide}
*/
public static final int AXIS_SCROLL = 26;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 3a1e9ab..68f1ac3 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -3592,6 +3592,9 @@
private int[] mDrawableState = null;
+ /** Whether draw() is currently being called. */
+ private boolean mInDraw = false;
+
ViewOutlineProvider mOutlineProvider = ViewOutlineProvider.BACKGROUND;
/**
@@ -16470,6 +16473,8 @@
*/
@CallSuper
public void draw(Canvas canvas) {
+ mInDraw = true;
+
final int privateFlags = mPrivateFlags;
final boolean dirtyOpaque = (privateFlags & PFLAG_DIRTY_MASK) == PFLAG_DIRTY_OPAQUE &&
(mAttachInfo == null || !mAttachInfo.mIgnoreDirtyState);
@@ -16514,6 +16519,7 @@
onDrawForeground(canvas);
// we're done...
+ mInDraw = false;
return;
}
@@ -16661,6 +16667,8 @@
// Step 6, draw decorations (foreground, scrollbars)
onDrawForeground(canvas);
+
+ mInDraw = false;
}
/**
@@ -17105,7 +17113,8 @@
*/
@Override
public void invalidateDrawable(@NonNull Drawable drawable) {
- if (verifyDrawable(drawable)) {
+ // Don't invalidate if a drawable changes during drawing.
+ if (verifyDrawable(drawable) && !mInDraw) {
final Rect dirty = drawable.getDirtyBounds();
final int scrollX = mScrollX;
final int scrollY = mScrollY;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 1c9f3b4..0fb3951 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -384,6 +384,8 @@
int localChanges;
}
+ private String mTag = TAG;
+
public ViewRootImpl(Context context, Display display) {
mContext = context;
mWindowSession = WindowManagerGlobal.getWindowSession();
@@ -510,6 +512,7 @@
mWindowAttributes.packageName = mBasePackageName;
}
attrs = mWindowAttributes;
+ setTag();
// Keep track of the actual window flags supplied by the client.
mClientWindowLayoutFlags = attrs.flags;
@@ -546,7 +549,7 @@
attrs.backup();
mTranslator.translateWindowLayout(attrs);
}
- if (DEBUG_LAYOUT) Log.d(TAG, "WindowLayout in setView:" + attrs);
+ if (DEBUG_LAYOUT) Log.d(mTag, "WindowLayout in setView:" + attrs);
if (!compatibilityInfo.supportsScreen()) {
attrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
@@ -607,7 +610,7 @@
mPendingContentInsets.set(mAttachInfo.mContentInsets);
mPendingStableInsets.set(mAttachInfo.mStableInsets);
mPendingVisibleInsets.set(0, 0, 0, 0);
- if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
+ if (DEBUG_LAYOUT) Log.v(mTag, "Added window " + mWindow);
if (res < WindowManagerGlobal.ADD_OKAY) {
mAttachInfo.mRootView = null;
mAdded = false;
@@ -701,6 +704,13 @@
}
}
+ private void setTag() {
+ final String[] split = mWindowAttributes.getTitle().toString().split("\\.");
+ if (split.length > 0) {
+ mTag = TAG + "[" + split[split.length - 1] + "]";
+ }
+ }
+
/** Whether the window is in local focus mode or not */
private boolean isInLocalFocusMode() {
return (mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE) != 0;
@@ -990,7 +1000,7 @@
@Override
public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
checkThread();
- if (DEBUG_DRAW) Log.v(TAG, "Invalidate child: " + dirty);
+ if (DEBUG_DRAW) Log.v(mTag, "Invalidate child: " + dirty);
if (dirty == null) {
invalidate();
@@ -1174,7 +1184,7 @@
private boolean collectViewAttributes() {
if (mAttachInfo.mRecomputeGlobalAttributes) {
- //Log.i(TAG, "Computing view hierarchy attributes!");
+ //Log.i(mTag, "Computing view hierarchy attributes!");
mAttachInfo.mRecomputeGlobalAttributes = false;
boolean oldScreenOn = mAttachInfo.mKeepScreenOn;
mAttachInfo.mKeepScreenOn = false;
@@ -1215,7 +1225,7 @@
int childHeightMeasureSpec;
boolean windowSizeMayChange = false;
- if (DEBUG_ORIENTATION || DEBUG_LAYOUT) Log.v(TAG,
+ if (DEBUG_ORIENTATION || DEBUG_LAYOUT) Log.v(mTag,
"Measuring " + host + " in display " + desiredWindowWidth
+ "x" + desiredWindowHeight + "...");
@@ -1231,26 +1241,26 @@
if (mTmpValue.type == TypedValue.TYPE_DIMENSION) {
baseSize = (int)mTmpValue.getDimension(packageMetrics);
}
- if (DEBUG_DIALOG) Log.v(TAG, "Window " + mView + ": baseSize=" + baseSize);
+ if (DEBUG_DIALOG) Log.v(mTag, "Window " + mView + ": baseSize=" + baseSize);
if (baseSize != 0 && desiredWindowWidth > baseSize) {
childWidthMeasureSpec = getRootMeasureSpec(baseSize, lp.width);
childHeightMeasureSpec = getRootMeasureSpec(desiredWindowHeight, lp.height);
performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
- if (DEBUG_DIALOG) Log.v(TAG, "Window " + mView + ": measured ("
+ if (DEBUG_DIALOG) Log.v(mTag, "Window " + mView + ": measured ("
+ host.getMeasuredWidth() + "," + host.getMeasuredHeight() + ")");
if ((host.getMeasuredWidthAndState()&View.MEASURED_STATE_TOO_SMALL) == 0) {
goodMeasure = true;
} else {
// Didn't fit in that size... try expanding a bit.
baseSize = (baseSize+desiredWindowWidth)/2;
- if (DEBUG_DIALOG) Log.v(TAG, "Window " + mView + ": next baseSize="
+ if (DEBUG_DIALOG) Log.v(mTag, "Window " + mView + ": next baseSize="
+ baseSize);
childWidthMeasureSpec = getRootMeasureSpec(baseSize, lp.width);
performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
- if (DEBUG_DIALOG) Log.v(TAG, "Window " + mView + ": measured ("
+ if (DEBUG_DIALOG) Log.v(mTag, "Window " + mView + ": measured ("
+ host.getMeasuredWidth() + "," + host.getMeasuredHeight() + ")");
if ((host.getMeasuredWidthAndState()&View.MEASURED_STATE_TOO_SMALL) == 0) {
- if (DEBUG_DIALOG) Log.v(TAG, "Good!");
+ if (DEBUG_DIALOG) Log.v(mTag, "Good!");
goodMeasure = true;
}
}
@@ -1350,8 +1360,8 @@
int desiredWindowHeight;
final int viewVisibility = getHostVisibility();
- boolean viewVisibilityChanged = mViewVisibility != viewVisibility
- || mNewSurfaceNeeded;
+ final boolean viewVisibilityChanged = !mFirst
+ && (mViewVisibility != viewVisibility || mNewSurfaceNeeded);
WindowManager.LayoutParams params = null;
if (mWindowAttributesChanged) {
@@ -1401,7 +1411,6 @@
mAttachInfo.mHasWindowFocus = false;
mAttachInfo.mWindowVisibility = viewVisibility;
mAttachInfo.mRecomputeGlobalAttributes = false;
- viewVisibilityChanged = false;
mLastConfiguration.setTo(host.getResources().getConfiguration());
mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
// Set the layout direction if it has not been set before (inherit is the default)
@@ -1411,14 +1420,13 @@
host.dispatchAttachedToWindow(mAttachInfo, 0);
mAttachInfo.mTreeObserver.dispatchOnWindowAttachedChange(true);
dispatchApplyInsets(host);
- //Log.i(TAG, "Screen on initialized: " + attachInfo.mKeepScreenOn);
+ //Log.i(mTag, "Screen on initialized: " + attachInfo.mKeepScreenOn);
} else {
desiredWindowWidth = frame.width();
desiredWindowHeight = frame.height();
if (desiredWindowWidth != mWidth || desiredWindowHeight != mHeight) {
- if (DEBUG_ORIENTATION) Log.v(TAG,
- "View " + host + " resized to: " + frame);
+ if (DEBUG_ORIENTATION) Log.v(mTag, "View " + host + " resized to: " + frame);
mFullRedrawNeeded = true;
mLayoutRequested = true;
windowSizeMayChange = true;
@@ -1471,28 +1479,22 @@
}
if (!mPendingVisibleInsets.equals(mAttachInfo.mVisibleInsets)) {
mAttachInfo.mVisibleInsets.set(mPendingVisibleInsets);
- if (DEBUG_LAYOUT) Log.v(TAG, "Visible insets changing to: "
+ if (DEBUG_LAYOUT) Log.v(mTag, "Visible insets changing to: "
+ mAttachInfo.mVisibleInsets);
}
if (!mPendingOutsets.equals(mAttachInfo.mOutsets)) {
insetsChanged = true;
}
- if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT
- || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
+ if ((lp.width == ViewGroup.LayoutParams.WRAP_CONTENT
+ || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT)
+ && (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL
+ || lp.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD)) {
windowSizeMayChange = true;
-
- if (lp.type == WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL
- || lp.type == WindowManager.LayoutParams.TYPE_INPUT_METHOD) {
- // NOTE -- system code, won't try to do compat mode.
- Point size = new Point();
- mDisplay.getRealSize(size);
- desiredWindowWidth = size.x;
- desiredWindowHeight = size.y;
- } else {
- DisplayMetrics packageMetrics = res.getDisplayMetrics();
- desiredWindowWidth = packageMetrics.widthPixels;
- desiredWindowHeight = packageMetrics.heightPixels;
- }
+ // NOTE -- system code, won't try to do compat mode.
+ Point size = new Point();
+ mDisplay.getRealSize(size);
+ desiredWindowWidth = size.x;
+ desiredWindowHeight = size.y;
}
}
@@ -1616,7 +1618,7 @@
try {
if (DEBUG_LAYOUT) {
- Log.i(TAG, "host=w:" + host.getMeasuredWidth() + ", h:" +
+ Log.i(mTag, "host=w:" + host.getMeasuredWidth() + ", h:" +
host.getMeasuredHeight() + ", params=" + params);
}
@@ -1634,7 +1636,7 @@
final int surfaceGenerationId = mSurface.getGenerationId();
relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
- if (DEBUG_LAYOUT) Log.v(TAG, "relayout: frame=" + frame.toShortString()
+ if (DEBUG_LAYOUT) Log.v(mTag, "relayout: frame=" + frame.toShortString()
+ " overscan=" + mPendingOverscanInsets.toShortString()
+ " content=" + mPendingContentInsets.toShortString()
+ " visible=" + mPendingVisibleInsets.toShortString()
@@ -1643,7 +1645,7 @@
+ " surface=" + mSurface);
if (mPendingConfiguration.seq != 0) {
- if (DEBUG_CONFIGURATION) Log.v(TAG, "Visible with new config: "
+ if (DEBUG_CONFIGURATION) Log.v(mTag, "Visible with new config: "
+ mPendingConfiguration);
updateConfiguration(new Configuration(mPendingConfiguration), !mFirst);
mPendingConfiguration.seq = 0;
@@ -1662,19 +1664,19 @@
& WindowManagerGlobal.RELAYOUT_RES_SURFACE_RESIZED) != 0;
if (contentInsetsChanged) {
mAttachInfo.mContentInsets.set(mPendingContentInsets);
- if (DEBUG_LAYOUT) Log.v(TAG, "Content insets changing to: "
+ if (DEBUG_LAYOUT) Log.v(mTag, "Content insets changing to: "
+ mAttachInfo.mContentInsets);
}
if (overscanInsetsChanged) {
mAttachInfo.mOverscanInsets.set(mPendingOverscanInsets);
- if (DEBUG_LAYOUT) Log.v(TAG, "Overscan insets changing to: "
+ if (DEBUG_LAYOUT) Log.v(mTag, "Overscan insets changing to: "
+ mAttachInfo.mOverscanInsets);
// Need to relayout with content insets.
contentInsetsChanged = true;
}
if (stableInsetsChanged) {
mAttachInfo.mStableInsets.set(mPendingStableInsets);
- if (DEBUG_LAYOUT) Log.v(TAG, "Decor insets changing to: "
+ if (DEBUG_LAYOUT) Log.v(mTag, "Decor insets changing to: "
+ mAttachInfo.mStableInsets);
// Need to relayout with content insets.
contentInsetsChanged = true;
@@ -1691,7 +1693,7 @@
}
if (visibleInsetsChanged) {
mAttachInfo.mVisibleInsets.set(mPendingVisibleInsets);
- if (DEBUG_LAYOUT) Log.v(TAG, "Visible insets changing to: "
+ if (DEBUG_LAYOUT) Log.v(mTag, "Visible insets changing to: "
+ mAttachInfo.mVisibleInsets);
}
@@ -1872,7 +1874,7 @@
int childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width);
int childHeightMeasureSpec = getRootMeasureSpec(mHeight, lp.height);
- if (DEBUG_LAYOUT) Log.v(TAG, "Ooops, something changed! mWidth="
+ if (DEBUG_LAYOUT) Log.v(mTag, "Ooops, something changed! mWidth="
+ mWidth + " measuredWidth=" + host.getMeasuredWidth()
+ " mHeight=" + mHeight
+ " measuredHeight=" + host.getMeasuredHeight()
@@ -1902,7 +1904,7 @@
}
if (measureAgain) {
- if (DEBUG_LAYOUT) Log.v(TAG,
+ if (DEBUG_LAYOUT) Log.v(mTag,
"And hey let's measure once more: width=" + width
+ " height=" + height);
performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
@@ -2024,15 +2026,15 @@
if (mFirst) {
// handle first focus request
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "First: mView.hasFocus()="
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "First: mView.hasFocus()="
+ mView.hasFocus());
if (mView != null) {
if (!mView.hasFocus()) {
mView.requestFocus(View.FOCUS_FORWARD);
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "First: requested focused view="
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "First: requested focused view="
+ mView.findFocus());
} else {
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "First: existing focused view="
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "First: existing focused view="
+ mView.findFocus());
}
}
@@ -2104,11 +2106,11 @@
}
private void handleOutOfResourcesException(Surface.OutOfResourcesException e) {
- Log.e(TAG, "OutOfResourcesException initializing HW surface", e);
+ Log.e(mTag, "OutOfResourcesException initializing HW surface", e);
try {
if (!mWindowSession.outOfMemory(mWindow) &&
Process.myUid() != Process.SYSTEM_UID) {
- Slog.w(TAG, "No processes killed for memory; killing self");
+ Slog.w(mTag, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
} catch (RemoteException ex) {
@@ -2184,7 +2186,7 @@
final View host = mView;
if (DEBUG_ORIENTATION || DEBUG_LAYOUT) {
- Log.v(TAG, "Laying out " + host + " to (" +
+ Log.v(mTag, "Laying out " + host + " to (" +
host.getMeasuredWidth() + ", " + host.getMeasuredHeight() + ")");
}
@@ -2427,11 +2429,11 @@
String thisHash = Integer.toHexString(System.identityHashCode(this));
long frameTime = nowTime - mFpsPrevTime;
long totalTime = nowTime - mFpsStartTime;
- Log.v(TAG, "0x" + thisHash + "\tFrame time:\t" + frameTime);
+ Log.v(mTag, "0x" + thisHash + "\tFrame time:\t" + frameTime);
mFpsPrevTime = nowTime;
if (totalTime > 1000) {
float fps = (float) mFpsNumFrames * 1000 / totalTime;
- Log.v(TAG, "0x" + thisHash + "\tFPS:\t" + fps);
+ Log.v(mTag, "0x" + thisHash + "\tFPS:\t" + fps);
mFpsStartTime = nowTime;
mFpsNumFrames = 0;
}
@@ -2473,7 +2475,7 @@
try {
mWindowDrawCountDown.await();
} catch (InterruptedException e) {
- Log.e(TAG, "Window redraw count down interruped!");
+ Log.e(mTag, "Window redraw count down interruped!");
}
mWindowDrawCountDown = null;
}
@@ -2483,7 +2485,7 @@
}
if (LOCAL_LOGV) {
- Log.v(TAG, "FINISHED DRAWING: " + mWindowAttributes.getTitle());
+ Log.v(mTag, "FINISHED DRAWING: " + mWindowAttributes.getTitle());
}
if (mSurfaceHolder != null && mSurface.isValid()) {
mSurfaceHolderCallback.surfaceRedrawNeeded(mSurfaceHolder);
@@ -2566,7 +2568,7 @@
}
if (DEBUG_ORIENTATION || DEBUG_DRAW) {
- Log.v(TAG, "Draw " + mView + "/"
+ Log.v(mTag, "Draw " + mView + "/"
+ mWindowAttributes.getTitle()
+ ": dirty={" + dirty.left + "," + dirty.top
+ "," + dirty.right + "," + dirty.bottom + "} surface="
@@ -2700,7 +2702,7 @@
handleOutOfResourcesException(e);
return false;
} catch (IllegalArgumentException e) {
- Log.e(TAG, "Could not lock surface", e);
+ Log.e(mTag, "Could not lock surface", e);
// Don't assume this is due to out of memory, it could be
// something else, and if it is something else then we could
// kill stuff (or ourself) for no reason.
@@ -2710,7 +2712,7 @@
try {
if (DEBUG_ORIENTATION || DEBUG_DRAW) {
- Log.v(TAG, "Surface " + surface + " drawing to bitmap w="
+ Log.v(mTag, "Surface " + surface + " drawing to bitmap w="
+ canvas.getWidth() + ", h=" + canvas.getHeight());
//canvas.drawARGB(255, 255, 0, 0);
}
@@ -2733,7 +2735,7 @@
if (DEBUG_DRAW) {
Context cxt = mView.getContext();
- Log.i(TAG, "Drawing: package:" + cxt.getPackageName() +
+ Log.i(mTag, "Drawing: package:" + cxt.getPackageName() +
", metrics=" + cxt.getResources().getDisplayMetrics() +
", compatibilityInfo=" + cxt.getResources().getCompatibilityInfo());
}
@@ -2758,14 +2760,14 @@
try {
surface.unlockCanvasAndPost(canvas);
} catch (IllegalArgumentException e) {
- Log.e(TAG, "Could not unlock surface", e);
+ Log.e(mTag, "Could not unlock surface", e);
mLayoutRequested = true; // ask wm for a new surface next time.
//noinspection ReturnInsideFinallyBlock
return false;
}
if (LOCAL_LOGV) {
- Log.v(TAG, "Surface " + surface + " unlockCanvasAndPost");
+ Log.v(mTag, "Surface " + surface + " unlockCanvasAndPost");
}
}
return true;
@@ -2870,14 +2872,14 @@
// view is visible.
rectangle = null;
}
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Eval scroll: focus=" + focus
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "Eval scroll: focus=" + focus
+ " rectangle=" + rectangle + " ci=" + ci
+ " vi=" + vi);
if (focus == lastScrolledFocus && !mScrollMayChange && rectangle == null) {
// Optimization: if the focus hasn't changed since last
// time, and no layout has happened, then just leave things
// as they are.
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Keeping scroll y="
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "Keeping scroll y="
+ mScrollY + " vi=" + vi.toShortString());
} else {
// We need to determine if the currently focused view is
@@ -2885,51 +2887,51 @@
// a pan so it can be seen.
mLastScrolledFocus = new WeakReference<View>(focus);
mScrollMayChange = false;
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Need to scroll?");
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "Need to scroll?");
// Try to find the rectangle from the focus view.
if (focus.getGlobalVisibleRect(mVisRect, null)) {
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Root w="
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "Root w="
+ mView.getWidth() + " h=" + mView.getHeight()
+ " ci=" + ci.toShortString()
+ " vi=" + vi.toShortString());
if (rectangle == null) {
focus.getFocusedRect(mTempRect);
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Focus " + focus
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "Focus " + focus
+ ": focusRect=" + mTempRect.toShortString());
if (mView instanceof ViewGroup) {
((ViewGroup) mView).offsetDescendantRectToMyCoords(
focus, mTempRect);
}
- if (DEBUG_INPUT_RESIZE) Log.v(TAG,
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Focus in window: focusRect="
+ mTempRect.toShortString()
+ " visRect=" + mVisRect.toShortString());
} else {
mTempRect.set(rectangle);
- if (DEBUG_INPUT_RESIZE) Log.v(TAG,
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Request scroll to rect: "
+ mTempRect.toShortString()
+ " visRect=" + mVisRect.toShortString());
}
if (mTempRect.intersect(mVisRect)) {
- if (DEBUG_INPUT_RESIZE) Log.v(TAG,
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Focus window visible rect: "
+ mTempRect.toShortString());
if (mTempRect.height() >
(mView.getHeight()-vi.top-vi.bottom)) {
// If the focus simply is not going to fit, then
// best is probably just to leave things as-is.
- if (DEBUG_INPUT_RESIZE) Log.v(TAG,
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Too tall; leaving scrollY=" + scrollY);
} else if ((mTempRect.top-scrollY) < vi.top) {
scrollY -= vi.top - (mTempRect.top-scrollY);
- if (DEBUG_INPUT_RESIZE) Log.v(TAG,
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Top covered; scrollY=" + scrollY);
} else if ((mTempRect.bottom-scrollY)
> (mView.getHeight()-vi.bottom)) {
scrollY += (mTempRect.bottom-scrollY)
- (mView.getHeight()-vi.bottom);
- if (DEBUG_INPUT_RESIZE) Log.v(TAG,
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag,
"Bottom covered; scrollY=" + scrollY);
}
handled = true;
@@ -2939,7 +2941,7 @@
}
if (scrollY != mScrollY) {
- if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Pan scroll changed: old="
+ if (DEBUG_INPUT_RESIZE) Log.v(mTag, "Pan scroll changed: old="
+ mScrollY + " , new=" + scrollY);
if (!immediate) {
if (mScroller == null) {
@@ -3018,7 +3020,7 @@
void setPointerCapture(View view) {
if (!mAttachInfo.mHasWindowFocus) {
- Log.w(TAG, "Can't set capture if it's not focused.");
+ Log.w(mTag, "Can't set capture if it's not focused.");
return;
}
if (mCapturingView == view) {
@@ -3044,7 +3046,7 @@
@Override
public void requestChildFocus(View child, View focused) {
if (DEBUG_INPUT_RESIZE) {
- Log.v(TAG, "Request child focus: focus now " + focused);
+ Log.v(mTag, "Request child focus: focus now " + focused);
}
checkThread();
scheduleTraversals();
@@ -3053,7 +3055,7 @@
@Override
public void clearChildFocus(View child) {
if (DEBUG_INPUT_RESIZE) {
- Log.v(TAG, "Clearing child focus");
+ Log.v(mTag, "Clearing child focus");
}
checkThread();
scheduleTraversals();
@@ -3152,7 +3154,7 @@
}
void updateConfiguration(Configuration config, boolean force) {
- if (DEBUG_CONFIGURATION) Log.v(TAG,
+ if (DEBUG_CONFIGURATION) Log.v(mTag,
"Applying new config to window "
+ mWindowAttributes.getTitle()
+ ": " + config);
@@ -3388,10 +3390,10 @@
mAttachInfo.mHardwareRenderer.initializeIfNeeded(
mWidth, mHeight, mAttachInfo, mSurface, surfaceInsets);
} catch (OutOfResourcesException e) {
- Log.e(TAG, "OutOfResourcesException locking surface", e);
+ Log.e(mTag, "OutOfResourcesException locking surface", e);
try {
if (!mWindowSession.outOfMemory(mWindow)) {
- Slog.w(TAG, "No processes killed for memory; killing self");
+ Slog.w(mTag, "No processes killed for memory; killing self");
Process.killProcess(Process.myPid());
}
} catch (RemoteException ex) {
@@ -3714,7 +3716,7 @@
*/
protected void onDeliverToNext(QueuedInputEvent q) {
if (DEBUG_INPUT_STAGES) {
- Log.v(TAG, "Done with " + getClass().getSimpleName() + ". " + q);
+ Log.v(mTag, "Done with " + getClass().getSimpleName() + ". " + q);
}
if (mNext != null) {
mNext.deliver(q);
@@ -3725,7 +3727,7 @@
protected boolean shouldDropInputEvent(QueuedInputEvent q) {
if (mView == null || !mAdded) {
- Slog.w(TAG, "Dropping event due to root view being removed: " + q.mEvent);
+ Slog.w(mTag, "Dropping event due to root view being removed: " + q.mEvent);
return true;
} else if ((!mAttachInfo.mHasWindowFocus
&& !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) || mStopped
@@ -3736,12 +3738,12 @@
if (isTerminalInputEvent(q.mEvent)) {
// Don't drop terminal input events, however mark them as canceled.
q.mEvent.cancel();
- Slog.w(TAG, "Cancelling event due to no window focus: " + q.mEvent);
+ Slog.w(mTag, "Cancelling event due to no window focus: " + q.mEvent);
return false;
}
// Drop non-terminal input events.
- Slog.w(TAG, "Dropping event due to no window focus: " + q.mEvent);
+ Slog.w(mTag, "Dropping event due to no window focus: " + q.mEvent);
return true;
}
return false;
@@ -3981,7 +3983,7 @@
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
final InputEvent event = q.mEvent;
- if (DEBUG_IMF) Log.v(TAG, "Sending input event to IME: " + event);
+ if (DEBUG_IMF) Log.v(mTag, "Sending input event to IME: " + event);
int result = imm.dispatchInputEvent(event, q, this, mHandler);
if (result == InputMethodManager.DISPATCH_HANDLED) {
return FINISH_HANDLED;
@@ -4413,7 +4415,7 @@
break;
}
- if (DEBUG_TRACKBALL) Log.v(TAG, "TB X=" + mX.position + " step="
+ if (DEBUG_TRACKBALL) Log.v(mTag, "TB X=" + mX.position + " step="
+ mX.step + " dir=" + mX.dir + " acc=" + mX.acceleration
+ " move=" + event.getX()
+ " / Y=" + mY.position + " step="
@@ -4452,11 +4454,11 @@
if (keycode != 0) {
if (movement < 0) movement = -movement;
int accelMovement = (int)(movement * accel);
- if (DEBUG_TRACKBALL) Log.v(TAG, "Move: movement=" + movement
+ if (DEBUG_TRACKBALL) Log.v(mTag, "Move: movement=" + movement
+ " accelMovement=" + accelMovement
+ " accel=" + accel);
if (accelMovement > movement) {
- if (DEBUG_TRACKBALL) Log.v(TAG, "Delivering fake DPAD: "
+ if (DEBUG_TRACKBALL) Log.v(mTag, "Delivering fake DPAD: "
+ keycode);
movement--;
int repeatCount = accelMovement - movement;
@@ -4466,7 +4468,7 @@
InputDevice.SOURCE_KEYBOARD));
}
while (movement > 0) {
- if (DEBUG_TRACKBALL) Log.v(TAG, "Delivering fake DPAD: "
+ if (DEBUG_TRACKBALL) Log.v(mTag, "Delivering fake DPAD: "
+ keycode);
movement--;
curTime = SystemClock.uptimeMillis();
@@ -4708,7 +4710,7 @@
update(event, true);
break;
default:
- Log.w(TAG, "Unexpected action: " + event.getActionMasked());
+ Log.w(mTag, "Unexpected action: " + event.getActionMasked());
}
}
@@ -5347,7 +5349,7 @@
mWindowSession.dragRecipientEntered(mWindow);
}
} catch (RemoteException e) {
- Slog.e(TAG, "Unable to note drag target change");
+ Slog.e(mTag, "Unable to note drag target change");
}
}
@@ -5355,10 +5357,10 @@
if (what == DragEvent.ACTION_DROP) {
mDragDescription = null;
try {
- Log.i(TAG, "Reporting drop result: " + result);
+ Log.i(mTag, "Reporting drop result: " + result);
mWindowSession.reportDropResult(mWindow, result);
} catch (RemoteException e) {
- Log.e(TAG, "Unable to report drop result");
+ Log.e(mTag, "Unable to report drop result");
}
}
@@ -5444,14 +5446,14 @@
mTranslator.translateWindowLayout(params);
}
if (params != null) {
- if (DBG) Log.d(TAG, "WindowLayout in layoutWindow:" + params);
+ if (DBG) Log.d(mTag, "WindowLayout in layoutWindow:" + params);
}
mPendingConfiguration.seq = 0;
- //Log.d(TAG, ">>>>>> CALLING relayout");
+ //Log.d(mTag, ">>>>>> CALLING relayout");
if (params != null && mOrigWindowType != params.type) {
// For compatibility with old apps, don't crash here.
if (mTargetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- Slog.w(TAG, "Window type can not be changed after "
+ Slog.w(mTag, "Window type can not be changed after "
+ "the window is added; ignoring change of " + mView);
params.type = mOrigWindowType;
}
@@ -5463,7 +5465,7 @@
viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
mWinFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets,
mPendingStableInsets, mPendingOutsets, mPendingConfiguration, mSurface);
- //Log.d(TAG, "<<<<<< BACK FROM relayout");
+ //Log.d(mTag, "<<<<<< BACK FROM relayout");
if (restore) {
params.restore();
}
@@ -5510,7 +5512,7 @@
}
} catch (IllegalStateException e) {
// Exception thrown by getAudioManager() when mView is null
- Log.e(TAG, "FATAL EXCEPTION when attempting to play sound effect: " + e);
+ Log.e(mTag, "FATAL EXCEPTION when attempting to play sound effect: " + e);
e.printStackTrace();
}
}
@@ -5633,7 +5635,7 @@
if (!mIsDrawing) {
destroyHardwareRenderer();
} else {
- Log.e(TAG, "Attempting to destroy the window while drawing!\n" +
+ Log.e(mTag, "Attempting to destroy the window while drawing!\n" +
" window=" + this + ", title=" + mWindowAttributes.getTitle());
}
mHandler.sendEmptyMessage(MSG_DIE);
@@ -5642,7 +5644,7 @@
void doDie() {
checkThread();
- if (LOCAL_LOGV) Log.v(TAG, "DIE in " + this + " of " + mSurface);
+ if (LOCAL_LOGV) Log.v(mTag, "DIE in " + this + " of " + mSurface);
synchronized (this) {
if (mRemoved) {
return;
@@ -5735,7 +5737,7 @@
public void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
Configuration newConfig, Rect backDropFrame) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": frame=" + frame.toShortString()
+ if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString()
+ " contentInsets=" + contentInsets.toShortString()
+ " visibleInsets=" + visibleInsets.toShortString()
+ " reportDraw=" + reportDraw
@@ -5773,7 +5775,7 @@
}
public void dispatchMoved(int newX, int newY) {
- if (DEBUG_LAYOUT) Log.v(TAG, "Window moved " + this + ": newX=" + newX + " newY=" + newY);
+ if (DEBUG_LAYOUT) Log.v(mTag, "Window moved " + this + ": newX=" + newX + " newY=" + newY);
if (mTranslator != null) {
PointF point = new PointF(newX, newY);
mTranslator.translatePointInScreenToAppWindow(point);
@@ -6690,7 +6692,7 @@
}
void changeCanvasOpacity(boolean opaque) {
- Log.d(TAG, "changeCanvasOpacity: opaque=" + opaque);
+ Log.d(mTag, "changeCanvasOpacity: opaque=" + opaque);
if (mAttachInfo.mHardwareRenderer != null) {
mAttachInfo.mHardwareRenderer.setOpaque(opaque);
}
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index d7a98ab..0b06d15 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -571,14 +571,11 @@
/** @hide */
public interface WindowControllerCallback {
/**
- * Called to move the window and its activity/task to a different stack container.
- * For example, a window can move between
- * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack and
- * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} stack.
- *
- * @param stackId stack Id to change to.
+ * Moves the activity from
+ * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
+ * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
*/
- void changeWindowStack(int stackId) throws RemoteException;
+ void exitFreeformMode() throws RemoteException;
/** Returns the current stack Id for the window. */
int getWindowStackId() throws RemoteException;
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 01bfbb5..ecec258 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -623,14 +623,16 @@
* decorations that can never be removed. That is, system bar or
* button bar.
*/
- public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation);
+ public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return the display height available after excluding any screen
* decorations that can never be removed. That is, system bar or
* button bar.
*/
- public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation);
+ public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return the available screen width that we should report for the
@@ -638,7 +640,8 @@
* {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
- public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation);
+ public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return the available screen height that we should report for the
@@ -646,7 +649,8 @@
* {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
- public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation);
+ public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation,
+ int uiMode);
/**
* Return whether the given window is forcibly hiding all windows except windows with
@@ -861,11 +865,11 @@
* @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
- * @param displayRotation The current rotation being applied to the base
- * window.
+ * @param displayRotation The current rotation being applied to the base window.
+ * @param uiMode The current uiMode in configuration.
*/
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
- int displayRotation);
+ int displayRotation, int uiMode);
/**
* Returns the bottom-most layer of the system decor, above which no policy decor should
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 9442226..9595db2 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -987,9 +987,6 @@
* @deprecated Database paths are managed by the implementation and calling this method
* will have no effect.
*/
- // This will update WebCore when the Sync runs in the C++ side.
- // Note that the WebCore Database Tracker only allows the path to be set
- // once.
@Deprecated
public abstract void setDatabasePath(String databasePath);
@@ -1000,8 +997,10 @@
*
* @param databasePath a path to the directory where databases should be
* saved.
+ * @deprecated Geolocation database are managed by the implementation and calling this method
+ * will have no effect.
*/
- // This will update WebCore when the Sync runs in the C++ side.
+ @Deprecated
public abstract void setGeolocationDatabasePath(String databasePath);
/**
@@ -1102,8 +1101,6 @@
* via the JavaScript Geolocation API.
* </ul>
* <p>
- * As an option, it is possible to store previous locations and web origin
- * permissions in a database. See {@link #setGeolocationDatabasePath}.
*
* @param flag whether Geolocation should be enabled
*/
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 7443bce..0f58ba3 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -280,6 +280,23 @@
* instead.
* </p>
*
+ * <h3>Metrics</h3>
+ *
+ * <p>
+ * WebView may upload anonymous diagnostic data to Google when the user has consented. This data
+ * helps Google improve WebView. Data is collected on a per-app basis for each app which has
+ * instantiated a WebView. An individual app can opt out of this feature by putting the following
+ * tag in its manifest:
+ * </p>
+ * <pre>
+ * <meta-data android:name="android.webkit.WebView.MetricsOptOut"
+ * android:value="true" />
+ * </pre>
+ * <p>
+ * Data will only be uploaded for a given app if the user has consented AND the app has not opted
+ * out.
+ * </p>
+ *
*/
// Implementation notes.
// The WebView is a thin API class that delegates its public API to a backend WebViewProvider
diff --git a/core/java/android/widget/ActionMenuPresenter.java b/core/java/android/widget/ActionMenuPresenter.java
index 0032f17..48d1d2b 100644
--- a/core/java/android/widget/ActionMenuPresenter.java
+++ b/core/java/android/widget/ActionMenuPresenter.java
@@ -20,6 +20,8 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -134,7 +136,7 @@
}
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
super.initForMenu(context, menu);
final Resources res = context.getResources();
@@ -629,8 +631,16 @@
}
public boolean flagActionItems() {
- final ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems();
- final int itemsSize = visibleItems.size();
+ final ArrayList<MenuItemImpl> visibleItems;
+ final int itemsSize;
+ if (mMenu != null) {
+ visibleItems = mMenu.getVisibleItems();
+ itemsSize = visibleItems.size();
+ } else {
+ visibleItems = null;
+ itemsSize = 0;
+ }
+
int maxActions = mMaxItems;
int widthLimit = mActionItemWidthLimit;
final int querySpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
@@ -786,7 +796,7 @@
if (isVisible) {
// Not a submenu, but treat it like one.
super.onSubMenuSelected(null);
- } else {
+ } else if (mMenu != null) {
mMenu.close(false /* closeAllMenus */);
}
}
@@ -938,7 +948,9 @@
@Override
protected void onDismiss() {
- mMenu.close();
+ if (mMenu != null) {
+ mMenu.close();
+ }
mOverflowPopup = null;
super.onDismiss();
@@ -999,7 +1011,9 @@
}
public void run() {
- mMenu.changeMenuMode();
+ if (mMenu != null) {
+ mMenu.changeMenuMode();
+ }
final View menuView = (View) mMenuView;
if (menuView != null && menuView.getWindowToken() != null && mPopup.tryShow()) {
mOverflowPopup = mPopup;
diff --git a/core/java/android/widget/ActionMenuView.java b/core/java/android/widget/ActionMenuView.java
index 1f02c3b..4d0a1c8 100644
--- a/core/java/android/widget/ActionMenuView.java
+++ b/core/java/android/widget/ActionMenuView.java
@@ -622,7 +622,7 @@
}
/** @hide */
- public void initialize(MenuBuilder menu) {
+ public void initialize(@Nullable MenuBuilder menu) {
mMenu = menu;
}
diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java
index 258424a..ef6628a 100644
--- a/core/java/android/widget/GridLayout.java
+++ b/core/java/android/widget/GridLayout.java
@@ -1752,7 +1752,8 @@
boolean validSolution = true;
// do a binary search to find the max delta that won't conflict with constraints
while(deltaMin < deltaMax) {
- final int delta = (deltaMin + deltaMax) / 2;
+ // cast to long to prevent overflow.
+ final int delta = (int) (((long) deltaMin + deltaMax) / 2);
invalidateValues();
shareOutDelta(delta, totalWeight);
validSolution = solve(getArcs(), a, false);
diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java
index acbf5eb..8e711b0 100644
--- a/core/java/android/widget/Toolbar.java
+++ b/core/java/android/widget/Toolbar.java
@@ -2070,7 +2070,7 @@
MenuItemImpl mCurrentExpandedItem;
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
// Clear the expanded action view when menus change.
if (mMenu != null && mCurrentExpandedItem != null) {
mMenu.collapseItemActionView(mCurrentExpandedItem);
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 40eaaf7..cc2f714 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -23,7 +23,6 @@
import com.android.internal.view.StandaloneActionMode;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.MenuHelper;
-import com.android.internal.view.menu.MenuPresenter;
import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.BackgroundFallback;
import com.android.internal.widget.DecorCaptionView;
@@ -72,6 +71,7 @@
import static android.app.ActivityManager.StackId;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.getMode;
@@ -194,7 +194,12 @@
private Drawable mCaptionBackgroundDrawable;
private Drawable mUserCaptionBackgroundDrawable;
- DecorView(Context context, int featureId, PhoneWindow window) {
+ private float mAvailableWidth;
+
+ String mLogTag = TAG;
+
+ DecorView(Context context, int featureId, PhoneWindow window,
+ WindowManager.LayoutParams params) {
super(context);
mFeatureId = featureId;
@@ -210,7 +215,11 @@
mSemiTransparentStatusBarColor = context.getResources().getColor(
R.color.system_bar_background_semi_transparent, null /* theme */);
+ updateAvailableWidth();
+
setWindow(window);
+
+ updateLogTag(params);
}
void setBackgroundFallback(int resId) {
@@ -408,7 +417,7 @@
if (mFeatureId >= 0) {
if (action == MotionEvent.ACTION_DOWN) {
- Log.i(TAG, "Watchiing!");
+ Log.i(mLogTag, "Watchiing!");
mWatchingForMenu = true;
mDownY = (int) event.getY();
return false;
@@ -421,7 +430,7 @@
int y = (int)event.getY();
if (action == MotionEvent.ACTION_MOVE) {
if (y > (mDownY+30)) {
- Log.i(TAG, "Closing!");
+ Log.i(mLogTag, "Closing!");
mWindow.closePanel(mFeatureId);
mWatchingForMenu = false;
return true;
@@ -433,13 +442,13 @@
return false;
}
- //Log.i(TAG, "Intercept: action=" + action + " y=" + event.getY()
+ //Log.i(mLogTag, "Intercept: action=" + action + " y=" + event.getY()
// + " (in " + getHeight() + ")");
if (action == MotionEvent.ACTION_DOWN) {
int y = (int)event.getY();
if (y >= (getHeight()-5) && !mWindow.hasChildren()) {
- Log.i(TAG, "Watching!");
+ Log.i(mLogTag, "Watching!");
mWatchingForMenu = true;
}
return false;
@@ -452,7 +461,7 @@
int y = (int)event.getY();
if (action == MotionEvent.ACTION_MOVE) {
if (y < (getHeight()-30)) {
- Log.i(TAG, "Opening!");
+ Log.i(mLogTag, "Opening!");
mWindow.openPanel(Window.FEATURE_OPTIONS_PANEL, new KeyEvent(
KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU));
mWatchingForMenu = false;
@@ -543,15 +552,15 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
- final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
+ final boolean isPortrait =
+ getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT;
final int widthMode = getMode(widthMeasureSpec);
final int heightMode = getMode(heightMeasureSpec);
boolean fixedWidth = false;
if (widthMode == AT_MOST) {
- final TypedValue tvw = isPortrait ? mWindow.mFixedWidthMinor
- : mWindow.mFixedWidthMajor;
+ final TypedValue tvw = isPortrait ? mWindow.mFixedWidthMinor : mWindow.mFixedWidthMajor;
if (tvw != null && tvw.type != TypedValue.TYPE_NULL) {
final int w;
if (tvw.type == TypedValue.TYPE_DIMENSION) {
@@ -623,7 +632,7 @@
if (tv.type == TypedValue.TYPE_DIMENSION) {
min = (int)tv.getDimension(metrics);
} else if (tv.type == TypedValue.TYPE_FRACTION) {
- min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels);
+ min = (int)tv.getFraction(mAvailableWidth, mAvailableWidth);
} else {
min = 0;
}
@@ -1217,7 +1226,7 @@
int fop = fg.getOpacity();
int bop = bg.getOpacity();
if (false)
- Log.v(TAG, "Background opacity: " + bop + ", Frame opacity: " + fop);
+ Log.v(mLogTag, "Background opacity: " + bop + ", Frame opacity: " + fop);
if (fop == PixelFormat.OPAQUE || bop == PixelFormat.OPAQUE) {
opacity = PixelFormat.OPAQUE;
} else if (fop == PixelFormat.UNKNOWN) {
@@ -1232,16 +1241,16 @@
// frame with padding... there is no way to tell if the
// frame and background together will draw all pixels.
if (false)
- Log.v(TAG, "Padding: " + mFramePadding);
+ Log.v(mLogTag, "Padding: " + mFramePadding);
opacity = PixelFormat.TRANSLUCENT;
}
}
if (false)
- Log.v(TAG, "Background: " + bg + ", Frame: " + fg);
+ Log.v(mLogTag, "Background: " + bg + ", Frame: " + fg);
}
if (false)
- Log.v(TAG, "Selected default opacity: " + opacity);
+ Log.v(mLogTag, "Selected default opacity: " + opacity);
mDefaultOpacity = opacity;
if (mFeatureId < 0) {
@@ -1600,6 +1609,7 @@
enableCaption(StackId.hasWindowDecor(workspaceId));
}
}
+ updateAvailableWidth();
initializeElevation();
}
@@ -1744,7 +1754,7 @@
// We shouldn't really get here as the background fallback should be always available since
// it is defaulted by the system.
- Log.w(TAG, "Failed to find background drawable for PhoneWindow=" + mWindow);
+ Log.w(mLogTag, "Failed to find background drawable for PhoneWindow=" + mWindow);
return null;
}
@@ -1761,7 +1771,7 @@
try {
workspaceId = callback.getWindowStackId();
} catch (RemoteException ex) {
- Log.e(TAG, "Failed to get the workspace ID of a PhoneWindow.");
+ Log.e(mLogTag, "Failed to get the workspace ID of a PhoneWindow.");
}
}
if (workspaceId == INVALID_STACK_ID) {
@@ -1927,6 +1937,19 @@
}
}
+ void updateLogTag(WindowManager.LayoutParams params) {
+ final String[] split = params.getTitle().toString().split("\\.");
+ if (split.length > 0) {
+ mLogTag = TAG + "[" + split[split.length - 1] + "]";
+ }
+ }
+
+ private void updateAvailableWidth() {
+ Resources res = getResources();
+ mAvailableWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ res.getConfiguration().screenWidthDp, res.getDisplayMetrics());
+ }
+
private static class ColorViewState {
View view = null;
int targetVisibility = View.INVISIBLE;
@@ -1988,12 +2011,12 @@
isPrimary = mode == mPrimaryActionMode;
isFloating = mode == mFloatingActionMode;
if (!isPrimary && mode.getType() == ActionMode.TYPE_PRIMARY) {
- Log.e(TAG, "Destroying unexpected ActionMode instance of TYPE_PRIMARY; "
+ Log.e(mLogTag, "Destroying unexpected ActionMode instance of TYPE_PRIMARY; "
+ mode + " was not the current primary action mode! Expected "
+ mPrimaryActionMode);
}
if (!isFloating && mode.getType() == ActionMode.TYPE_FLOATING) {
- Log.e(TAG, "Destroying unexpected ActionMode instance of TYPE_FLOATING; "
+ Log.e(mLogTag, "Destroying unexpected ActionMode instance of TYPE_FLOATING; "
+ mode + " was not the current floating action mode! Expected "
+ mFloatingActionMode);
}
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 2f951cc..f159a4d 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -113,6 +113,8 @@
private final static String TAG = "PhoneWindow";
+ private static final boolean DEBUG = false;
+
private final static int DEFAULT_BACKGROUND_FADE_DURATION_MS = 300;
private static final int CUSTOM_TITLE_COMPATIBLE_FEATURES = DEFAULT_FEATURES |
@@ -2286,7 +2288,7 @@
} else {
context = getContext();
}
- return new DecorView(context, featureId, this);
+ return new DecorView(context, featureId, this, getAttributes());
}
protected ViewGroup generateLayout(DecorView decor) {
@@ -2365,6 +2367,8 @@
a.getValue(R.styleable.Window_windowMinWidthMajor, mMinWidthMajor);
a.getValue(R.styleable.Window_windowMinWidthMinor, mMinWidthMinor);
+ if (DEBUG) Log.d(TAG, "Min width minor: " + mMinWidthMinor.coerceToString()
+ + ", major: " + mMinWidthMajor.coerceToString());
if (a.hasValue(R.styleable.Window_windowFixedWidthMajor)) {
if (mFixedWidthMajor == null) mFixedWidthMajor = new TypedValue();
a.getValue(R.styleable.Window_windowFixedWidthMajor,
@@ -3781,4 +3785,12 @@
int getDecorCaptionShade() {
return mDecorCaptionShade;
}
+
+ @Override
+ public void setAttributes(WindowManager.LayoutParams params) {
+ super.setAttributes(params);
+ if (mDecor != null) {
+ mDecor.updateLogTag(params);
+ }
+ }
}
diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl
index 849d314..4dd71e7 100644
--- a/core/java/com/android/internal/statusbar/IStatusBar.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl
@@ -46,7 +46,7 @@
void cancelPreloadRecentApps();
void showScreenPinningRequest();
- void showKeyboardShortcutsMenu();
+ void toggleKeyboardShortcutsMenu();
/**
* Notifies the status bar that an app transition is pending to delay applying some flags with
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 0a4ad06..0125d37 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -68,7 +68,7 @@
void preloadRecentApps();
void cancelPreloadRecentApps();
- void showKeyboardShortcutsMenu();
+ void toggleKeyboardShortcutsMenu();
/**
* Notifies the status bar that an app transition is pending to delay applying some flags with
diff --git a/core/java/com/android/internal/util/StateMachine.java b/core/java/com/android/internal/util/StateMachine.java
index 406b487..dc66818 100644
--- a/core/java/com/android/internal/util/StateMachine.java
+++ b/core/java/com/android/internal/util/StateMachine.java
@@ -779,7 +779,7 @@
@Override
public final void handleMessage(Message msg) {
if (!mHasQuit) {
- if (mSm != null) {
+ if (mSm != null && msg.what != SM_INIT_CMD && msg.what != SM_QUIT_CMD) {
mSm.onPreHandleMessage(msg);
}
@@ -807,7 +807,7 @@
// We need to check if mSm == null here as we could be quitting.
if (mDbg && mSm != null) mSm.log("handleMessage: X");
- if (mSm != null) {
+ if (mSm != null && msg.what != SM_INIT_CMD && msg.what != SM_QUIT_CMD) {
mSm.onPostHandleMessage(msg);
}
}
diff --git a/core/java/com/android/internal/view/menu/BaseMenuPresenter.java b/core/java/com/android/internal/view/menu/BaseMenuPresenter.java
index 92e9ea6..7ac0ac3 100644
--- a/core/java/com/android/internal/view/menu/BaseMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/BaseMenuPresenter.java
@@ -16,6 +16,8 @@
package com.android.internal.view.menu;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -58,7 +60,7 @@
}
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
mContext = context;
mInflater = LayoutInflater.from(mContext);
mMenu = menu;
diff --git a/core/java/com/android/internal/view/menu/IconMenuPresenter.java b/core/java/com/android/internal/view/menu/IconMenuPresenter.java
index 2439b5d..5223a7b 100644
--- a/core/java/com/android/internal/view/menu/IconMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/IconMenuPresenter.java
@@ -17,6 +17,8 @@
import com.android.internal.view.menu.MenuView.ItemView;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
@@ -49,7 +51,7 @@
}
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
super.initForMenu(context, menu);
mMaxItems = -1;
}
diff --git a/core/java/com/android/internal/view/menu/ListMenuPresenter.java b/core/java/com/android/internal/view/menu/ListMenuPresenter.java
index c476354..2fff3ba 100644
--- a/core/java/com/android/internal/view/menu/ListMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/ListMenuPresenter.java
@@ -16,6 +16,8 @@
package com.android.internal.view.menu;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
@@ -76,7 +78,7 @@
}
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
if (mThemeRes != 0) {
mContext = new ContextThemeWrapper(context, mThemeRes);
mInflater = LayoutInflater.from(mContext);
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index 465d775..31b2f96 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -17,6 +17,7 @@
package com.android.internal.view.menu;
+import android.annotation.NonNull;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -1027,23 +1028,24 @@
mIsActionItemsStale = true;
onItemsChanged(true);
}
-
+
+ @NonNull
public ArrayList<MenuItemImpl> getVisibleItems() {
if (!mIsVisibleItemsStale) return mVisibleItems;
-
+
// Refresh the visible items
mVisibleItems.clear();
-
+
final int itemsSize = mItems.size();
MenuItemImpl item;
for (int i = 0; i < itemsSize; i++) {
item = mItems.get(i);
if (item.isVisible()) mVisibleItems.add(item);
}
-
+
mIsVisibleItemsStale = false;
mIsActionItemsStale = true;
-
+
return mVisibleItems;
}
diff --git a/core/java/com/android/internal/view/menu/MenuPopup.java b/core/java/com/android/internal/view/menu/MenuPopup.java
index 98f5d90..b151f34 100644
--- a/core/java/com/android/internal/view/menu/MenuPopup.java
+++ b/core/java/com/android/internal/view/menu/MenuPopup.java
@@ -16,6 +16,8 @@
package com.android.internal.view.menu;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.view.MenuItem;
import android.view.View;
@@ -73,7 +75,7 @@
public abstract void setOnDismissListener(PopupWindow.OnDismissListener listener);
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
// Don't need to do anything; we added as a presenter in the constructor.
}
diff --git a/core/java/com/android/internal/view/menu/MenuPresenter.java b/core/java/com/android/internal/view/menu/MenuPresenter.java
index c847c15..65bdc09 100644
--- a/core/java/com/android/internal/view/menu/MenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/MenuPresenter.java
@@ -16,6 +16,8 @@
package com.android.internal.view.menu;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.os.Parcelable;
import android.view.ViewGroup;
@@ -49,14 +51,16 @@
}
/**
- * Initialize this presenter for the given context and menu.
- * This method is called by MenuBuilder when a presenter is
- * added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)}
+ * Initializes this presenter for the given context and menu.
+ * <p>
+ * This method is called by MenuBuilder when a presenter is added. See
+ * {@link MenuBuilder#addMenuPresenter(MenuPresenter)}.
*
- * @param context Context for this presenter; used for view creation and resource management
- * @param menu Menu to host
+ * @param context the context for this presenter; used for view creation
+ * and resource management, must be non-{@code null}
+ * @param menu the menu to host, or {@code null} to clear the hosted menu
*/
- public void initForMenu(Context context, MenuBuilder menu);
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu);
/**
* Retrieve a MenuView to display the menu specified in
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 825e336..f90b59d 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -17,6 +17,8 @@
package com.android.internal.widget;
import android.animation.LayoutTransition;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.ActionBar;
import android.content.Context;
import android.content.res.Configuration;
@@ -1593,7 +1595,7 @@
MenuItemImpl mCurrentExpandedItem;
@Override
- public void initForMenu(Context context, MenuBuilder menu) {
+ public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
// Clear the expanded action view when menus change.
if (mMenu != null && mCurrentExpandedItem != null) {
mMenu.collapseItemActionView(mCurrentExpandedItem);
diff --git a/core/java/com/android/internal/widget/DecorCaptionView.java b/core/java/com/android/internal/widget/DecorCaptionView.java
index c3fe9e7..409a17f 100644
--- a/core/java/com/android/internal/widget/DecorCaptionView.java
+++ b/core/java/com/android/internal/widget/DecorCaptionView.java
@@ -16,8 +16,6 @@
package com.android.internal.widget;
-import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
-
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
@@ -351,7 +349,7 @@
Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
if (callback != null) {
try {
- callback.changeWindowStack(FULLSCREEN_WORKSPACE_STACK_ID);
+ callback.exitFreeformMode();
} catch (RemoteException ex) {
Log.e(TAG, "Cannot change task workspace.");
}
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index d8ec22a..92f7812 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -260,6 +260,15 @@
return nullObjectReturn("SkAndroidCodec::NewFromStream returned null");
}
+ // Do not allow ninepatch decodes to 565. In the past, decodes to 565
+ // would dither, and we do not want to pre-dither ninepatches, since we
+ // know that they will be stretched. We no longer dither 565 decodes,
+ // but we continue to prevent ninepatches from decoding to 565, in order
+ // to maintain the old behavior.
+ if (peeker.mPatch && kRGB_565_SkColorType == prefColorType) {
+ prefColorType = kN32_SkColorType;
+ }
+
// Determine the output size and return if the client only wants the size.
SkISize size = codec->getSampledDimensions(sampleSize);
if (options != NULL) {
@@ -369,15 +378,7 @@
case SkCodec::kIncompleteInput:
break;
default:
- return nullObjectReturn("codec->getAndoridPixels() failed.");
- }
-
- // Some images may initially report that they have alpha due to the format
- // of the encoded data, but then never use any colors which have alpha
- // less than 100%. Here we check if the image really had alpha, and
- // mark it as opaque if it is actually opaque.
- if (kOpaque_SkAlphaType != alphaType && !codec->reallyHasAlpha()) {
- decodingBitmap.setAlphaType(kOpaque_SkAlphaType);
+ return nullObjectReturn("codec->getAndroidPixels() failed.");
}
int scaledWidth = size.width();
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 7860b74..42f3fb0 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -1049,6 +1049,10 @@
pJniStorage->mDeviceCallback.clear();
}
+static jint android_media_AudioTrack_get_FCC_8(JNIEnv *env, jobject thiz) {
+ return FCC_8;
+}
+
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -1106,6 +1110,7 @@
{"native_getRoutedDeviceId", "()I", (void *)android_media_AudioTrack_getRoutedDeviceId},
{"native_enableDeviceCallback", "()V", (void *)android_media_AudioTrack_enableDeviceCallback},
{"native_disableDeviceCallback", "()V", (void *)android_media_AudioTrack_disableDeviceCallback},
+ {"native_get_FCC_8", "()I", (void *)android_media_AudioTrack_get_FCC_8},
};
@@ -1135,6 +1140,9 @@
// ----------------------------------------------------------------------------
int register_android_media_AudioTrack(JNIEnv *env)
{
+ // must be first
+ int res = RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
+
javaAudioTrackFields.nativeTrackInJavaObj = NULL;
javaAudioTrackFields.postNativeEventInJava = NULL;
@@ -1173,7 +1181,7 @@
// initialize PlaybackParams field info
gPlaybackParamsFields.init(env);
- return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
+ return res;
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index c154e91..7d9fd93 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -277,8 +277,10 @@
<protected-broadcast android:name="android.intent.action.AIRPLANE_MODE" />
<protected-broadcast android:name="android.intent.action.ADVANCED_SETTINGS" />
<protected-broadcast android:name="android.intent.action.APPLICATION_RESTRICTIONS_CHANGED" />
- <protected-broadcast android:name="android.intent.action.BUGREPORT_FINISHED" />
<protected-broadcast android:name="android.intent.action.BUGREPORT_STARTED" />
+ <protected-broadcast android:name="android.intent.action.BUGREPORT_FINISHED" />
+ <protected-broadcast android:name="android.intent.action.REMOTE_BUGREPORT_FINISHED" />
+ <protected-broadcast android:name="android.intent.action.REMOTE_BUGREPORT_DISPATCH" />
<protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_START" />
<protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_END" />
@@ -383,6 +385,12 @@
<protected-broadcast android:name="com.android.server.Wifi.action.TOGGLE_PNO" />
<protected-broadcast android:name="intent.action.ACTION_RF_BAND_INFO" />
+ <protected-broadcast android:name="android.app.action.INTERRUPTION_FILTER_CHANGED" />
+ <protected-broadcast android:name="android.app.action.INTERRUPTION_FILTER_CHANGED_INTERNAL" />
+ <protected-broadcast android:name="android.app.action.NOTIFICATION_POLICY_CHANGED" />
+ <protected-broadcast android:name="android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED" />
+ <protected-broadcast android:name="android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED" />
+
<!-- ====================================================================== -->
<!-- RUNTIME PERMISSIONS -->
<!-- ====================================================================== -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index d13a622..58c4046 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2417,4 +2417,8 @@
2 - 1 snap target: 1:1
-->
<integer name="config_dockedStackDividerSnapMode">0</integer>
+
+ <!-- List of comma separated package names for which we the system will not show crash, ANR,
+ etc. dialogs. -->
+ <string translatable="false" name="config_appsNotReportingCrashes"></string>
</resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 37b2c12..b2482cd 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -35,6 +35,13 @@
<dimen name="navigation_bar_height_landscape">48dp</dimen>
<!-- Width of the navigation bar when it is placed vertically on the screen -->
<dimen name="navigation_bar_width">48dp</dimen>
+ <!-- Height of the bottom navigation / system bar in car mode. -->
+ <dimen name="navigation_bar_height_car_mode">96dp</dimen>
+ <!-- Height of the bottom navigation bar in portrait; often the same as
+ @dimen/navigation_bar_height_car_mode -->
+ <dimen name="navigation_bar_height_landscape_car_mode">96dp</dimen>
+ <!-- Width of the navigation bar when it is placed vertically on the screen in car mode -->
+ <dimen name="navigation_bar_width_car_mode">96dp</dimen>
<!-- Height of notification icons in the status bar -->
<dimen name="status_bar_icon_size">24dip</dimen>
<!-- Size of the giant number (unread count) in the notifications -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 845c8c9..a4654e8 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -575,6 +575,7 @@
<java-symbol type="string" name="config_ntpServer" />
<java-symbol type="string" name="config_useragentprofile_url" />
<java-symbol type="string" name="config_wifi_p2p_device_type" />
+ <java-symbol type="string" name="config_appsNotReportingCrashes" />
<java-symbol type="string" name="contentServiceSync" />
<java-symbol type="string" name="contentServiceSyncNotificationTitle" />
<java-symbol type="string" name="contentServiceTooManyDeletesNotificationDesc" />
@@ -1497,6 +1498,9 @@
<java-symbol type="dimen" name="navigation_bar_height" />
<java-symbol type="dimen" name="navigation_bar_height_landscape" />
<java-symbol type="dimen" name="navigation_bar_width" />
+ <java-symbol type="dimen" name="navigation_bar_height_car_mode" />
+ <java-symbol type="dimen" name="navigation_bar_height_landscape_car_mode" />
+ <java-symbol type="dimen" name="navigation_bar_width_car_mode" />
<java-symbol type="dimen" name="status_bar_height" />
<java-symbol type="drawable" name="ic_jog_dial_sound_off" />
<java-symbol type="drawable" name="ic_jog_dial_sound_on" />
diff --git a/graphics/java/android/graphics/drawable/RippleBackground.java b/graphics/java/android/graphics/drawable/RippleBackground.java
index d313aa5..6bd2646 100644
--- a/graphics/java/android/graphics/drawable/RippleBackground.java
+++ b/graphics/java/android/graphics/drawable/RippleBackground.java
@@ -33,6 +33,7 @@
* Draws a ripple background.
*/
class RippleBackground extends RippleComponent {
+
private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
private static final int OPACITY_ENTER_DURATION = 600;
@@ -48,8 +49,14 @@
// Software rendering properties.
private float mOpacity = 0;
- public RippleBackground(RippleDrawable owner, Rect bounds, boolean forceSoftware) {
+ /** Whether this ripple is bounded. */
+ private boolean mIsBounded;
+
+ public RippleBackground(RippleDrawable owner, Rect bounds, boolean isBounded,
+ boolean forceSoftware) {
super(owner, bounds, forceSoftware);
+
+ mIsBounded = isBounded;
}
public boolean isVisible() {
@@ -105,7 +112,8 @@
final AnimatorSet.Builder builder = set.play(exit);
// Linear "fast" enter based on current opacity.
- final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST);
+ final int fastEnterDuration = mIsBounded ?
+ (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0;
if (fastEnterDuration > 0) {
final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1);
enter.setInterpolator(LINEAR_INTERPOLATOR);
@@ -131,15 +139,18 @@
mPropX = CanvasProperty.createFloat(0);
mPropY = CanvasProperty.createFloat(0);
- final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST);
+ final int fastEnterDuration = mIsBounded ?
+ (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0;
// Linear exit after enter is completed.
final RenderNodeAnimator exit = new RenderNodeAnimator(
mPropPaint, RenderNodeAnimator.PAINT_ALPHA, 0);
exit.setInterpolator(LINEAR_INTERPOLATOR);
exit.setDuration(OPACITY_EXIT_DURATION);
- exit.setStartDelay(fastEnterDuration);
- exit.setStartValue(targetAlpha);
+ if (fastEnterDuration > 0) {
+ exit.setStartDelay(fastEnterDuration);
+ exit.setStartValue(targetAlpha);
+ }
set.add(exit);
// Linear "fast" enter based on current opacity.
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index 5213e10..9c691e5 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -540,7 +540,8 @@
*/
private void tryBackgroundEnter(boolean focused) {
if (mBackground == null) {
- mBackground = new RippleBackground(this, mHotspotBounds, mForceSoftware);
+ final boolean isBounded = isBounded();
+ mBackground = new RippleBackground(this, mHotspotBounds, isBounded, mForceSoftware);
}
mBackground.setup(mState.mMaxRadius, mDensity);
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index bb4f7d9..a810ff1 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -97,9 +97,10 @@
/** Maximum value for sample rate */
private static final int SAMPLE_RATE_HZ_MAX = 192000;
- // FCC_8
- /** Maximum value for AudioTrack channel count */
- private static final int CHANNEL_COUNT_MAX = 8;
+ /** Maximum value for AudioTrack channel count
+ * @hide public for MediaCode only, do not un-hide or change to a numeric literal
+ */
+ public static final int CHANNEL_COUNT_MAX = native_get_FCC_8();
/** indicates AudioTrack state is stopped */
public static final int PLAYSTATE_STOPPED = 1; // matches SL_PLAYSTATE_STOPPED
@@ -2583,6 +2584,7 @@
private native final int native_getRoutedDeviceId();
private native final void native_enableDeviceCallback();
private native final void native_disableDeviceCallback();
+ static private native int native_get_FCC_8();
//---------------------------------------------------------
// Utility methods
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index e6bc8f1..9bcb5e3 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -907,7 +907,7 @@
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_RAW)) {
sampleRateRange = Range.create(1, 96000);
bitRates = Range.create(1, 10000000);
- maxChannels = 8;
+ maxChannels = AudioTrack.CHANNEL_COUNT_MAX;
} else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_AUDIO_FLAC)) {
sampleRateRange = Range.create(1, 655350);
// lossless codec, so bitrate is ignored
diff --git a/media/java/android/mtp/MtpConstants.java b/media/java/android/mtp/MtpConstants.java
index d245f588..1657796 100644
--- a/media/java/android/mtp/MtpConstants.java
+++ b/media/java/android/mtp/MtpConstants.java
@@ -573,4 +573,41 @@
* Association type for objects representing file system directories.
*/
public static final int ASSOCIATION_TYPE_GENERIC_FOLDER = 0x0001;
+
+ /** Event code for UNDEFINED event */
+ public static final int EVENT_UNDEFINED = 0x4000;
+ /** Event code for CANCEL_TRANSACTION event */
+ public static final int EVENT_CANCEL_TRANSACTION = 0x4001;
+ /** Event code for OBJECT_ADDED event */
+ public static final int EVENT_OBJECT_ADDED = 0x4002;
+ /** Event code for OBJECT_REMOVED event */
+ public static final int EVENT_OBJECT_REMOVED = 0x4003;
+ /** Event code for STORE_ADDED event */
+ public static final int EVENT_STORE_ADDED = 0x4004;
+ /** Event code for STORE_REMOVED event */
+ public static final int EVENT_STORE_REMOVED = 0x4005;
+ /** Event code for DEVICE_PROP_CHANGED event */
+ public static final int EVENT_DEVICE_PROP_CHANGED = 0x4006;
+ /** Event code for OBJECT_INFO_CHANGED event */
+ public static final int EVENT_OBJECT_INFO_CHANGED = 0x4007;
+ /** Event code for DEVICE_INFO_CHANGED event */
+ public static final int EVENT_DEVICE_INFO_CHANGED = 0x4008;
+ /** Event code for REQUEST_OBJECT_TRANSFER event */
+ public static final int EVENT_REQUEST_OBJECT_TRANSFER = 0x4009;
+ /** Event code for STORE_FULL event */
+ public static final int EVENT_STORE_FULL = 0x400A;
+ /** Event code for DEVICE_RESET event */
+ public static final int EVENT_DEVICE_RESET = 0x400B;
+ /** Event code for STORAGE_INFO_CHANGED event */
+ public static final int EVENT_STORAGE_INFO_CHANGED = 0x400C;
+ /** Event code for CAPTURE_COMPLETE event */
+ public static final int EVENT_CAPTURE_COMPLETE = 0x400D;
+ /** Event code for UNREPORTED_STATUS event */
+ public static final int EVENT_UNREPORTED_STATUS = 0x400E;
+ /** Event code for OBJECT_PROP_CHANGED event */
+ public static final int EVENT_OBJECT_PROP_CHANGED = 0xC801;
+ /** Event code for OBJECT_PROP_DESC_CHANGED event */
+ public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 0xC802;
+ /** Event code for OBJECT_REFERENCES_CHANGED event */
+ public static final int EVENT_OBJECT_REFERENCES_CHANGED = 0xC803;
}
diff --git a/media/java/android/mtp/MtpEvent.java b/media/java/android/mtp/MtpEvent.java
index 4c8a742..6ec16db 100644
--- a/media/java/android/mtp/MtpEvent.java
+++ b/media/java/android/mtp/MtpEvent.java
@@ -21,26 +21,7 @@
* Event constants are defined by the USB-IF MTP specification.
*/
public class MtpEvent {
- public static final int EVENT_UNDEFINED = 0x4000;
- public static final int EVENT_CANCEL_TRANSACTION = 0x4001;
- public static final int EVENT_OBJECT_ADDED = 0x4002;
- public static final int EVENT_OBJECT_REMOVED = 0x4003;
- public static final int EVENT_STORE_ADDED = 0x4004;
- public static final int EVENT_STORE_REMOVED = 0x4005;
- public static final int EVENT_DEVICE_PROP_CHANGED = 0x4006;
- public static final int EVENT_OBJECT_INFO_CHANGED = 0x4007;
- public static final int EVENT_DEVICE_INFO_CHANGED = 0x4008;
- public static final int EVENT_REQUEST_OBJECT_TRANSFER = 0x4009;
- public static final int EVENT_STORE_FULL = 0x400A;
- public static final int EVENT_DEVICE_RESET = 0x400B;
- public static final int EVENT_STORAGE_INFO_CHANGED = 0x400C;
- public static final int EVENT_CAPTURE_COMPLETE = 0x400D;
- public static final int EVENT_UNREPORTED_STATUS = 0x400E;
- public static final int EVENT_OBJECT_PROP_CHANGED = 0xC801;
- public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 0xC802;
- public static final int EVENT_OBJECT_REFERENCES_CHANGED = 0xC803;
-
- private int mEventCode = EVENT_UNDEFINED;
+ private int mEventCode = MtpConstants.EVENT_UNDEFINED;
/**
* Returns event code of MTP event.
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp
index 70d651f..b63df6f 100644
--- a/media/jni/soundpool/SoundPool.cpp
+++ b/media/jni/soundpool/SoundPool.cpp
@@ -655,7 +655,7 @@
goto error;
}
- if ((numChannels < 1) || (numChannels > 8)) {
+ if ((numChannels < 1) || (numChannels > FCC_8)) {
ALOGE("Sample channel count (%d) out of range", numChannels);
status = BAD_VALUE;
goto error;
diff --git a/packages/DocumentsUI/AndroidManifest.xml b/packages/DocumentsUI/AndroidManifest.xml
index 5e634a4..6beef44 100644
--- a/packages/DocumentsUI/AndroidManifest.xml
+++ b/packages/DocumentsUI/AndroidManifest.xml
@@ -92,7 +92,7 @@
</receiver>
<service
- android:name=".CopyService"
+ android:name=".services.FileOperationService"
android:exported="false">
</service>
</application>
diff --git a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java
deleted file mode 100644
index 34614b4..0000000
--- a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.documentsui;
-
-import static com.android.documentsui.Shared.DEBUG;
-import static com.android.documentsui.model.DocumentInfo.getCursorLong;
-import static com.android.documentsui.model.DocumentInfo.getCursorString;
-
-import android.app.Activity;
-import android.app.IntentService;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.ContentProviderClient;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.AssetFileDescriptor;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.CancellationSignal;
-import android.os.ParcelFileDescriptor;
-import android.os.Parcelable;
-import android.os.PowerManager;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.provider.DocumentsContract;
-import android.provider.DocumentsContract.Document;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-import android.support.design.widget.Snackbar;
-import android.text.format.DateUtils;
-import android.util.Log;
-import android.webkit.MimeTypeMap;
-
-import com.android.documentsui.model.DocumentInfo;
-import com.android.documentsui.model.DocumentStack;
-import com.android.documentsui.model.RootInfo;
-
-import libcore.io.IoUtils;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-public class CopyService extends IntentService {
- public static final String TAG = "CopyService";
-
- private static final String EXTRA_CANCEL = "com.android.documentsui.CANCEL";
- public static final String EXTRA_SRC_LIST = "com.android.documentsui.SRC_LIST";
- public static final String EXTRA_FAILURE = "com.android.documentsui.FAILURE";
- public static final String EXTRA_TRANSFER_MODE = "com.android.documentsui.TRANSFER_MODE";
-
- public static final int TRANSFER_MODE_COPY = 1;
- public static final int TRANSFER_MODE_MOVE = 2;
-
- // TODO: Move it to a shared file when more operations are implemented.
- public static final int FAILURE_COPY = 1;
-
- // Parameters of the copy job. Requests to an IntentService are serialized so this code only
- // needs to deal with one job at a time.
- // NOTE: This must be declared by concrete type as the concrete type
- // is required by putParcelableArrayListExtra.
- private final ArrayList<DocumentInfo> mFailedFiles = new ArrayList<>();
-
- private PowerManager mPowerManager;
-
- private NotificationManager mNotificationManager;
- private Notification.Builder mProgressBuilder;
-
- // Jobs are serialized but a job ID is used, to avoid mixing up cancellation requests.
- private String mJobId;
- private volatile boolean mIsCancelled;
- private long mBatchSize;
- private long mBytesCopied;
- private long mStartTime;
- private long mLastNotificationTime;
- // Speed estimation
- private long mBytesCopiedSample;
- private long mSampleTime;
- private long mSpeed;
- private long mRemainingTime;
- // Provider clients are acquired for the duration of each copy job. Note that there is an
- // implicit assumption that all srcs come from the same authority.
- private ContentProviderClient mSrcClient;
- private ContentProviderClient mDstClient;
-
- // For testing only.
- @Nullable private TestOnlyListener mJobFinishedListener;
-
- public CopyService() {
- super("CopyService");
- }
-
- /**
- * Starts the service for a copy operation.
- *
- * @param context Context for the intent.
- * @param srcDocs A list of src files to copy.
- * @param dstStack The copy destination stack.
- */
- public static void start(Activity activity, List<DocumentInfo> srcDocs, DocumentStack dstStack,
- int mode) {
- final Resources res = activity.getResources();
- final Intent copyIntent = new Intent(activity, CopyService.class);
- copyIntent.putParcelableArrayListExtra(
- EXTRA_SRC_LIST,
- // Don't create a copy unless absolutely necessary :)
- srcDocs instanceof ArrayList
- ? (ArrayList<DocumentInfo>) srcDocs
- : new ArrayList<DocumentInfo>(srcDocs));
- copyIntent.putExtra(Shared.EXTRA_STACK, (Parcelable) dstStack);
- copyIntent.putExtra(EXTRA_TRANSFER_MODE, mode);
-
- int toastMessage = (mode == TRANSFER_MODE_COPY) ? R.plurals.copy_begin
- : R.plurals.move_begin;
- Snackbars.makeSnackbar(activity,
- res.getQuantityString(toastMessage, srcDocs.size(), srcDocs.size()),
- Snackbar.LENGTH_SHORT).show();
- activity.startService(copyIntent);
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if (intent.hasExtra(EXTRA_CANCEL)) {
- handleCancel(intent);
- }
- return super.onStartCommand(intent, flags, startId);
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- if (intent.hasExtra(EXTRA_CANCEL)) {
- handleCancel(intent);
- return;
- }
-
- final PowerManager.WakeLock wakeLock = mPowerManager
- .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
- final ArrayList<DocumentInfo> srcs = intent.getParcelableArrayListExtra(EXTRA_SRC_LIST);
- final DocumentStack stack = intent.getParcelableExtra(Shared.EXTRA_STACK);
- // Copy by default.
- final int transferMode = intent.getIntExtra(EXTRA_TRANSFER_MODE, TRANSFER_MODE_COPY);
-
- try {
- wakeLock.acquire();
-
- // Acquire content providers.
- mSrcClient = DocumentsApplication.acquireUnstableProviderOrThrow(getContentResolver(),
- srcs.get(0).authority);
- mDstClient = DocumentsApplication.acquireUnstableProviderOrThrow(getContentResolver(),
- stack.peek().authority);
-
- setupCopyJob(srcs, stack, transferMode);
-
- final String opDesc = transferMode == TRANSFER_MODE_COPY ? "copy" : "move";
- DocumentInfo srcInfo;
- DocumentInfo dstInfo;
- for (int i = 0; i < srcs.size() && !mIsCancelled; ++i) {
- srcInfo = srcs.get(i);
- dstInfo = stack.peek();
-
- // Guard unsupported recursive operation.
- if (dstInfo.equals(srcInfo) || isDescendentOf(srcInfo, dstInfo)) {
- if (DEBUG) Log.d(TAG,
- "Skipping recursive " + opDesc + " of directory " + dstInfo.derivedUri);
- mFailedFiles.add(srcInfo);
- continue;
- }
-
- if (DEBUG) Log.d(TAG,
- "Performing " + opDesc + " of " + srcInfo.displayName
- + " (" + srcInfo.derivedUri + ")" + " to " + dstInfo.displayName
- + " (" + dstInfo.derivedUri + ")");
-
- copy(srcInfo, dstInfo, transferMode);
- }
- } catch (Exception e) {
- // Catch-all to prevent any copy errors from wedging the app.
- Log.e(TAG, "Exceptions occurred during copying", e);
- } finally {
- if (DEBUG) Log.d(TAG, "Cleaning up after copy");
- ContentProviderClient.releaseQuietly(mSrcClient);
- ContentProviderClient.releaseQuietly(mDstClient);
-
- wakeLock.release();
-
- // Dismiss the ongoing copy notification when the copy is done.
- mNotificationManager.cancel(mJobId, 0);
-
- if (mFailedFiles.size() > 0) {
- Log.e(TAG, mFailedFiles.size() + " files failed to copy");
- final Context context = getApplicationContext();
- final Intent navigateIntent = buildNavigateIntent(context, stack);
- navigateIntent.putExtra(EXTRA_FAILURE, FAILURE_COPY);
- navigateIntent.putExtra(EXTRA_TRANSFER_MODE, transferMode);
- navigateIntent.putParcelableArrayListExtra(EXTRA_SRC_LIST, mFailedFiles);
-
- final int titleResourceId = (transferMode == TRANSFER_MODE_COPY ?
- R.plurals.copy_error_notification_title :
- R.plurals.move_error_notification_title);
- final Notification.Builder errorBuilder = new Notification.Builder(this)
- .setContentTitle(context.getResources().getQuantityString(titleResourceId,
- mFailedFiles.size(), mFailedFiles.size()))
- .setContentText(getString(R.string.notification_touch_for_details))
- .setContentIntent(PendingIntent.getActivity(context, 0, navigateIntent,
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT))
- .setCategory(Notification.CATEGORY_ERROR)
- .setSmallIcon(R.drawable.ic_menu_copy)
- .setAutoCancel(true);
- mNotificationManager.notify(mJobId, 0, errorBuilder.build());
- }
-
- if (mJobFinishedListener != null) {
- mJobFinishedListener.onFinished(mFailedFiles);
- }
-
- if (DEBUG) Log.d(TAG, "Done cleaning up");
- }
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- mPowerManager = getSystemService(PowerManager.class);
- mNotificationManager = getSystemService(NotificationManager.class);
- }
-
- /**
- * Sets up the CopyService to start tracking and sending notifications for the given batch of
- * files.
- *
- * @param srcs A list of src files to copy.
- * @param stack The copy destination stack.
- * @param transferMode The mode (i.e. copy, or move)
- * @throws RemoteException
- */
- private void setupCopyJob(ArrayList<DocumentInfo> srcs, DocumentStack stack, int transferMode)
- throws RemoteException {
- final boolean copying = (transferMode == TRANSFER_MODE_COPY);
- // Create an ID for this copy job. Use the timestamp.
- mJobId = String.valueOf(SystemClock.elapsedRealtime());
- // Reset the cancellation flag.
- mIsCancelled = false;
-
- final Context context = getApplicationContext();
- final Intent navigateIntent = buildNavigateIntent(context, stack);
-
- final String contentTitle = getString(copying ? R.string.copy_notification_title
- : R.string.move_notification_title);
- mProgressBuilder = new Notification.Builder(this)
- .setContentTitle(contentTitle)
- .setContentIntent(PendingIntent.getActivity(context, 0, navigateIntent, 0))
- .setCategory(Notification.CATEGORY_PROGRESS)
- .setSmallIcon(R.drawable.ic_menu_copy)
- .setOngoing(true);
-
- final Intent cancelIntent = new Intent(this, CopyService.class);
- cancelIntent.putExtra(EXTRA_CANCEL, mJobId);
- mProgressBuilder.addAction(R.drawable.ic_cab_cancel,
- getString(android.R.string.cancel), PendingIntent.getService(this, 0,
- cancelIntent,
- PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT));
-
- // Send an initial progress notification.
- final String contentText = getString(copying ? R.string.copy_preparing
- : R.string.move_preparing);
- mProgressBuilder.setProgress(0, 0, true); // Indeterminate progress while setting up.
- mProgressBuilder.setContentText(contentText);
- mNotificationManager.notify(mJobId, 0, mProgressBuilder.build());
-
- // Reset batch parameters.
- mFailedFiles.clear();
- mBatchSize = calculateFileSizes(srcs);
- mBytesCopied = 0;
- mStartTime = SystemClock.elapsedRealtime();
- mLastNotificationTime = 0;
- mBytesCopiedSample = 0;
- mSampleTime = 0;
- mSpeed = 0;
- mRemainingTime = 0;
-
- // TODO: Check preconditions for copy.
- // - check that the destination has enough space and is writeable?
- // - check MIME types?
- }
-
- /**
- * Sets a callback to be run when the next run job is finished.
- * This is test ONLY instrumentation. The alternative is for us to add
- * broadcast intents SOLELY for the purpose of testing.
- * @param listener
- */
- @VisibleForTesting
- void addFinishedListener(TestOnlyListener listener) {
- this.mJobFinishedListener = listener;
-
- }
-
- /**
- * Only used for testing. Is that obvious enough?
- */
- @VisibleForTesting
- interface TestOnlyListener {
- void onFinished(List<DocumentInfo> failed);
- }
-
- /**
- * Calculates the cumulative size of all the documents in the list. Directories are recursed
- * into and totaled up.
- *
- * @param srcs
- * @return Size in bytes.
- * @throws RemoteException
- */
- private long calculateFileSizes(List<DocumentInfo> srcs) throws RemoteException {
- long result = 0;
- for (DocumentInfo src : srcs) {
- if (src.isDirectory()) {
- // Directories need to be recursed into.
- result += calculateFileSizesHelper(src.derivedUri);
- } else {
- result += src.size;
- }
- }
- return result;
- }
-
- /**
- * Calculates (recursively) the cumulative size of all the files under the given directory.
- *
- * @throws RemoteException
- */
- private long calculateFileSizesHelper(Uri uri) throws RemoteException {
- final String authority = uri.getAuthority();
- final Uri queryUri = DocumentsContract.buildChildDocumentsUri(authority,
- DocumentsContract.getDocumentId(uri));
- final String queryColumns[] = new String[] {
- Document.COLUMN_DOCUMENT_ID,
- Document.COLUMN_MIME_TYPE,
- Document.COLUMN_SIZE
- };
-
- long result = 0;
- Cursor cursor = null;
- try {
- cursor = mSrcClient.query(queryUri, queryColumns, null, null, null);
- while (cursor.moveToNext()) {
- if (Document.MIME_TYPE_DIR.equals(
- getCursorString(cursor, Document.COLUMN_MIME_TYPE))) {
- // Recurse into directories.
- final Uri subdirUri = DocumentsContract.buildDocumentUri(authority,
- getCursorString(cursor, Document.COLUMN_DOCUMENT_ID));
- result += calculateFileSizesHelper(subdirUri);
- } else {
- // This may return -1 if the size isn't defined. Ignore those cases.
- long size = getCursorLong(cursor, Document.COLUMN_SIZE);
- result += size > 0 ? size : 0;
- }
- }
- } finally {
- IoUtils.closeQuietly(cursor);
- }
-
- return result;
- }
-
- /**
- * Cancels the current copy job, if its ID matches the given ID.
- *
- * @param intent The cancellation intent.
- */
- private void handleCancel(Intent intent) {
- final String cancelledId = intent.getStringExtra(EXTRA_CANCEL);
- // Do nothing if the cancelled ID doesn't match the current job ID. This prevents racey
- // cancellation requests from affecting unrelated copy jobs. However, if the current job ID
- // is null, the service most likely crashed and was revived by the incoming cancel intent.
- // In that case, always allow the cancellation to proceed.
- if (Objects.equals(mJobId, cancelledId) || mJobId == null) {
- // Set the cancel flag. This causes the copy loops to exit.
- mIsCancelled = true;
- // Dismiss the progress notification here rather than in the copy loop. This preserves
- // interactivity for the user in case the copy loop is stalled.
- mNotificationManager.cancel(cancelledId, 0);
- }
- }
-
- /**
- * Logs progress on the current copy operation. Displays/Updates the progress notification.
- *
- * @param bytesCopied
- */
- private void makeProgress(long bytesCopied) {
- mBytesCopied += bytesCopied;
- double done = (double) mBytesCopied / mBatchSize;
- String percent = NumberFormat.getPercentInstance().format(done);
-
- // Update time estimate
- long currentTime = SystemClock.elapsedRealtime();
- long elapsedTime = currentTime - mStartTime;
-
- // Send out progress notifications once a second.
- if (currentTime - mLastNotificationTime > 1000) {
- updateRemainingTimeEstimate(elapsedTime);
- mProgressBuilder.setProgress(100, (int) (done * 100), false);
- mProgressBuilder.setContentInfo(percent);
- if (mRemainingTime > 0) {
- mProgressBuilder.setContentText(getString(R.string.copy_remaining,
- DateUtils.formatDuration(mRemainingTime)));
- } else {
- mProgressBuilder.setContentText(null);
- }
- mNotificationManager.notify(mJobId, 0, mProgressBuilder.build());
- mLastNotificationTime = currentTime;
- }
- }
-
- /**
- * Generates an estimate of the remaining time in the copy.
- *
- * @param elapsedTime The time elapsed so far.
- */
- private void updateRemainingTimeEstimate(long elapsedTime) {
- final long sampleDuration = elapsedTime - mSampleTime;
- final long sampleSpeed = ((mBytesCopied - mBytesCopiedSample) * 1000) / sampleDuration;
- if (mSpeed == 0) {
- mSpeed = sampleSpeed;
- } else {
- mSpeed = ((3 * mSpeed) + sampleSpeed) / 4;
- }
-
- if (mSampleTime > 0 && mSpeed > 0) {
- mRemainingTime = ((mBatchSize - mBytesCopied) * 1000) / mSpeed;
- } else {
- mRemainingTime = 0;
- }
-
- mSampleTime = elapsedTime;
- mBytesCopiedSample = mBytesCopied;
- }
-
- /**
- * Copies a the given documents to the given location.
- *
- * @param srcInfo DocumentInfos for the documents to copy.
- * @param dstDirInfo The destination directory.
- * @param mode The transfer mode (copy or move).
- * @return True on success, false on failure.
- * @throws RemoteException
- */
- private boolean copy(DocumentInfo srcInfo, DocumentInfo dstDirInfo, int mode)
- throws RemoteException {
- // When copying within the same provider, try to use optimized copying and moving.
- // If not supported, then fallback to byte-by-byte copy/move.
- if (srcInfo.authority.equals(dstDirInfo.authority)) {
- switch (mode) {
- case TRANSFER_MODE_COPY:
- if ((srcInfo.flags & Document.FLAG_SUPPORTS_COPY) != 0) {
- if (DocumentsContract.copyDocument(mSrcClient, srcInfo.derivedUri,
- dstDirInfo.derivedUri) == null) {
- mFailedFiles.add(srcInfo);
- }
- return false;
- }
- break;
- case TRANSFER_MODE_MOVE:
- if ((srcInfo.flags & Document.FLAG_SUPPORTS_MOVE) != 0) {
- if (DocumentsContract.moveDocument(mSrcClient, srcInfo.derivedUri,
- dstDirInfo.derivedUri) == null) {
- mFailedFiles.add(srcInfo);
- }
- return false;
- }
- break;
- default:
- throw new IllegalArgumentException("Unknown transfer mode.");
- }
- }
-
- final String dstMimeType;
- final String dstDisplayName;
-
- // If the file is virtual, but can be converted to another format, then try to copy it
- // as such format. Also, append an extension for the target mime type (if known).
- if (srcInfo.isVirtualDocument()) {
- final String[] streamTypes = getContentResolver().getStreamTypes(
- srcInfo.derivedUri, "*/*");
- if (streamTypes != null && streamTypes.length > 0) {
- dstMimeType = streamTypes[0];
- final String extension = MimeTypeMap.getSingleton().
- getExtensionFromMimeType(dstMimeType);
- dstDisplayName = srcInfo.displayName +
- (extension != null ? "." + extension : srcInfo.displayName);
- } else {
- // The virtual file is not available as any alternative streamable format.
- // TODO: Log failures. b/26192412
- mFailedFiles.add(srcInfo);
- return false;
- }
- } else {
- dstMimeType = srcInfo.mimeType;
- dstDisplayName = srcInfo.displayName;
- }
-
- // Create the target document (either a file or a directory), then copy recursively the
- // contents (bytes or children).
- final Uri dstUri = DocumentsContract.createDocument(mDstClient,
- dstDirInfo.derivedUri, dstMimeType, dstDisplayName);
- if (dstUri == null) {
- // If this is a directory, the entire subdir will not be copied over.
- mFailedFiles.add(srcInfo);
- return false;
- }
-
- DocumentInfo dstInfo = null;
- try {
- dstInfo = DocumentInfo.fromUri(getContentResolver(), dstUri);
- } catch (FileNotFoundException e) {
- mFailedFiles.add(srcInfo);
- return false;
- }
-
- final boolean success;
- if (Document.MIME_TYPE_DIR.equals(srcInfo.mimeType)) {
- success = copyDirectoryHelper(srcInfo, dstInfo, mode);
- } else {
- success = copyFileHelper(srcInfo, dstInfo, dstMimeType, mode);
- }
-
- if (mode == TRANSFER_MODE_MOVE && success) {
- // This is racey. We should make sure that we never delete a directory after
- // it changed, so we don't remove a file which had not been copied earlier
- // to the target location.
- try {
- DocumentsContract.deleteDocument(mSrcClient, srcInfo.derivedUri);
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to delete source after moving: " + srcInfo.derivedUri, e);
- throw e;
- }
- }
-
- return success;
- }
-
- /**
- * Returns true if {@code doc} is a descendant of {@code parentDoc}.
- * @throws RemoteException
- */
- boolean isDescendentOf(DocumentInfo doc, DocumentInfo parentDoc)
- throws RemoteException {
- if (parentDoc.isDirectory() && doc.authority.equals(parentDoc.authority)) {
- return DocumentsContract.isChildDocument(
- mDstClient, doc.derivedUri, parentDoc.derivedUri);
- }
- return false;
- }
-
- /**
- * Handles recursion into a directory and copying its contents. Note that in linux terms, this
- * does the equivalent of "cp src/* dst", not "cp -r src dst".
- *
- * @param srcDirInfo Info of the directory to copy from. The routine will copy the directory's
- * contents, not the directory itself.
- * @param dstDirInfo Info of the directory to copy to. Must be created beforehand.
- * @return True on success, false if some of the children failed to copy.
- * @throws RemoteException
- */
- private boolean copyDirectoryHelper(
- DocumentInfo srcDirInfo, DocumentInfo dstDirInfo, int mode)
- throws RemoteException {
- // Recurse into directories. Copy children into the new subdirectory.
- final String queryColumns[] = new String[] {
- Document.COLUMN_DISPLAY_NAME,
- Document.COLUMN_DOCUMENT_ID,
- Document.COLUMN_MIME_TYPE,
- Document.COLUMN_SIZE,
- Document.COLUMN_FLAGS
- };
- Cursor cursor = null;
- boolean success = true;
- try {
- // Iterate over srcs in the directory; copy to the destination directory.
- final Uri queryUri = DocumentsContract.buildChildDocumentsUri(srcDirInfo.authority,
- srcDirInfo.documentId);
- cursor = mSrcClient.query(queryUri, queryColumns, null, null, null);
- DocumentInfo srcInfo;
- while (cursor.moveToNext()) {
- srcInfo = DocumentInfo.fromCursor(cursor, srcDirInfo.authority);
- success &= copy(srcInfo, dstDirInfo, mode);
- }
- } finally {
- IoUtils.closeQuietly(cursor);
- }
-
- return success;
- }
-
- /**
- * Handles copying a single file.
- *
- * @param srcUriInfo Info of the file to copy from.
- * @param dstUriInfo Info of the *file* to copy to. Must be created beforehand.
- * @param mimeType Mime type for the target. Can be different than source for virtual files.
- * @return True on success, false on error.
- * @throws RemoteException
- */
- private boolean copyFileHelper(DocumentInfo srcInfo, DocumentInfo dstInfo, String mimeType,
- int mode) throws RemoteException {
- // Copy an individual file.
- CancellationSignal canceller = new CancellationSignal();
- ParcelFileDescriptor srcFile = null;
- ParcelFileDescriptor dstFile = null;
- InputStream src = null;
- OutputStream dst = null;
-
- boolean success = true;
- try {
- // If the file is virtual, then try to copy it as an alternative format.
- if (srcInfo.isVirtualDocument()) {
- final AssetFileDescriptor srcFileAsAsset =
- mSrcClient.openTypedAssetFileDescriptor(
- srcInfo.derivedUri, mimeType, null, canceller);
- srcFile = srcFileAsAsset.getParcelFileDescriptor();
- src = new AssetFileDescriptor.AutoCloseInputStream(srcFileAsAsset);
- } else {
- srcFile = mSrcClient.openFile(srcInfo.derivedUri, "r", canceller);
- src = new ParcelFileDescriptor.AutoCloseInputStream(srcFile);
- }
-
- dstFile = mDstClient.openFile(dstInfo.derivedUri, "w", canceller);
- dst = new ParcelFileDescriptor.AutoCloseOutputStream(dstFile);
-
- byte[] buffer = new byte[8192];
- int len;
- while ((len = src.read(buffer)) != -1) {
- if (mIsCancelled) {
- success = false;
- break;
- }
- dst.write(buffer, 0, len);
- makeProgress(len);
- }
-
- srcFile.checkError();
- } catch (IOException e) {
- success = false;
- mFailedFiles.add(srcInfo);
-
- if (dstFile != null) {
- try {
- dstFile.closeWithError(e.getMessage());
- } catch (IOException closeError) {
- Log.e(TAG, "Error closing destination", closeError);
- }
- }
- } finally {
- // This also ensures the file descriptors are closed.
- IoUtils.closeQuietly(src);
- IoUtils.closeQuietly(dst);
- }
-
- if (!success) {
- // Clean up half-copied files.
- canceller.cancel();
- try {
- DocumentsContract.deleteDocument(mDstClient, dstInfo.derivedUri);
- } catch (RemoteException e) {
- // RemoteExceptions usually signal that the connection is dead, so there's no
- // point attempting to continue. Propagate the exception up so the copy job is
- // cancelled.
- Log.w(TAG, "Failed to cleanup after copy error: " + srcInfo.derivedUri, e);
- throw e;
- }
- }
-
- return success;
- }
-
- /**
- * Creates an intent for navigating back to the destination directory.
- */
- private Intent buildNavigateIntent(Context context, DocumentStack stack) {
- Intent intent = new Intent(context, FilesActivity.class);
- intent.setAction(DocumentsContract.ACTION_BROWSE);
- intent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
- return intent;
- }
-}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
index 8ca2cfb..ca8ef2e 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
@@ -54,6 +54,7 @@
import com.android.documentsui.model.DocumentInfo;
import com.android.documentsui.model.DurableUtils;
import com.android.documentsui.model.RootInfo;
+import com.android.documentsui.services.FileOperationService;
import java.util.Arrays;
import java.util.List;
@@ -154,8 +155,8 @@
if (state.action == ACTION_PICK_COPY_DESTINATION) {
state.directoryCopy = intent.getBooleanExtra(
Shared.EXTRA_DIRECTORY_COPY, false);
- state.transferMode = intent.getIntExtra(CopyService.EXTRA_TRANSFER_MODE,
- CopyService.TRANSFER_MODE_COPY);
+ state.transferMode = intent.getIntExtra(FileOperationService.EXTRA_OPERATION,
+ FileOperationService.OPERATION_COPY);
}
return state;
@@ -481,7 +482,7 @@
// Picking a copy destination is only used internally by us, so we
// don't need to extend permissions to the caller.
intent.putExtra(Shared.EXTRA_STACK, (Parcelable) mState.stack);
- intent.putExtra(CopyService.EXTRA_TRANSFER_MODE, mState.transferMode);
+ intent.putExtra(FileOperationService.EXTRA_OPERATION, mState.transferMode);
} else {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
diff --git a/packages/DocumentsUI/src/com/android/documentsui/FailureDialogFragment.java b/packages/DocumentsUI/src/com/android/documentsui/FailureDialogFragment.java
index 23074f0..7f6f1c6 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/FailureDialogFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/FailureDialogFragment.java
@@ -16,6 +16,8 @@
package com.android.documentsui;
+import static com.android.internal.util.Preconditions.checkArgument;
+
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
@@ -27,6 +29,8 @@
import com.android.documentsui.model.DocumentInfo;
import com.android.documentsui.model.DocumentStack;
+import com.android.documentsui.services.FileOperationService;
+import com.android.documentsui.services.FileOperations;
import java.util.ArrayList;
@@ -37,20 +41,20 @@
implements DialogInterface.OnClickListener {
private static final String TAG = "FailureDialogFragment";
- private int mTransferMode;
+ private int mOperationType;
private ArrayList<DocumentInfo> mFailedSrcList;
public static void show(FragmentManager fm, int failure,
- ArrayList<DocumentInfo> failedSrcList, DocumentStack dstStack, int transferMode) {
+ ArrayList<DocumentInfo> failedSrcList, DocumentStack dstStack, int operationType) {
// TODO: Add support for other failures than copy.
- if (failure != CopyService.FAILURE_COPY) {
+ if (failure != FileOperationService.FAILURE_COPY) {
return;
}
final Bundle args = new Bundle();
- args.putInt(CopyService.EXTRA_FAILURE, failure);
- args.putInt(CopyService.EXTRA_TRANSFER_MODE, transferMode);
- args.putParcelableArrayList(CopyService.EXTRA_SRC_LIST, failedSrcList);
+ args.putInt(FileOperationService.EXTRA_FAILURE, failure);
+ args.putInt(FileOperationService.EXTRA_OPERATION, operationType);
+ args.putParcelableArrayList(FileOperationService.EXTRA_SRC_LIST, failedSrcList);
final FragmentTransaction ft = fm.beginTransaction();
final FailureDialogFragment fragment = new FailureDialogFragment();
@@ -63,10 +67,12 @@
@Override
public void onClick(DialogInterface dialog, int whichButton) {
if (whichButton == DialogInterface.BUTTON_POSITIVE) {
- CopyService.start(getActivity(), mFailedSrcList,
+ FileOperations.start(
+ getActivity(),
+ mFailedSrcList,
(DocumentStack) getActivity().getIntent().getParcelableExtra(
Shared.EXTRA_STACK),
- mTransferMode);
+ mOperationType);
}
}
@@ -74,16 +80,27 @@
public Dialog onCreateDialog(Bundle inState) {
super.onCreate(inState);
- mTransferMode = getArguments().getInt(CopyService.EXTRA_TRANSFER_MODE);
- mFailedSrcList = getArguments().getParcelableArrayList(CopyService.EXTRA_SRC_LIST);
+ mOperationType = getArguments().getInt(FileOperationService.EXTRA_OPERATION);
+ mFailedSrcList = getArguments().getParcelableArrayList(FileOperationService.EXTRA_SRC_LIST);
final StringBuilder list = new StringBuilder("<p>");
for (DocumentInfo documentInfo : mFailedSrcList) {
list.append(String.format("• %s<br>", documentInfo.displayName));
}
list.append("</p>");
- final String messageFormat = getString(mTransferMode == CopyService.TRANSFER_MODE_COPY ?
- R.string.copy_failure_alert_content : R.string.move_failure_alert_content);
+
+ // TODO: Add support for other file operations.
+ checkArgument(
+ mOperationType == FileOperationService.OPERATION_COPY
+ || mOperationType == FileOperationService.OPERATION_MOVE);
+
+ int messageId = mOperationType == FileOperationService.OPERATION_COPY
+ ? R.string.copy_failure_alert_content
+ : R.string.move_failure_alert_content;
+
+ final String messageFormat = getString(
+ messageId);
+
final String message = String.format(messageFormat, list.toString());
return new AlertDialog.Builder(getActivity())
diff --git a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
index e308f3f..0bd09f6 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
@@ -49,6 +49,7 @@
import com.android.documentsui.model.DocumentStack;
import com.android.documentsui.model.DurableUtils;
import com.android.documentsui.model.RootInfo;
+import com.android.documentsui.services.FileOperationService;
import java.util.ArrayList;
import java.util.Arrays;
@@ -120,20 +121,22 @@
ProviderExecutor.forAuthority(homeUri.getAuthority()));
}
- final int failure = intent.getIntExtra(CopyService.EXTRA_FAILURE, 0);
- final int transferMode = intent.getIntExtra(CopyService.EXTRA_TRANSFER_MODE,
- CopyService.TRANSFER_MODE_COPY);
+ final int failure = intent.getIntExtra(FileOperationService.EXTRA_FAILURE, 0);
+ final int opType = intent.getIntExtra(
+ FileOperationService.EXTRA_OPERATION,
+ FileOperationService.OPERATION_COPY);
+
// DialogFragment takes care of restoring the dialog on configuration change.
// Only show it manually for the first time (icicle is null).
if (icicle == null && failure != 0) {
final ArrayList<DocumentInfo> failedSrcList =
- intent.getParcelableArrayListExtra(CopyService.EXTRA_SRC_LIST);
+ intent.getParcelableArrayListExtra(FileOperationService.EXTRA_SRC_LIST);
FailureDialogFragment.show(
getFragmentManager(),
failure,
failedSrcList,
mState.stack,
- transferMode);
+ opType);
}
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/Shared.java b/packages/DocumentsUI/src/com/android/documentsui/Shared.java
index c3366c3..22cb25a2 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/Shared.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/Shared.java
@@ -20,6 +20,9 @@
import android.text.format.DateUtils;
import android.text.format.Time;
+import java.util.ArrayList;
+import java.util.List;
+
/** @hide */
public final class Shared {
/** Intent action name to pick a copy destination. */
@@ -64,4 +67,13 @@
return DateUtils.formatDateTime(context, when, flags);
}
+ /**
+ * A convenient way to transform any list into a (parcelable) ArrayList.
+ * Uses cast if possible, else creates a new list with entries from {@code list}.
+ */
+ public static <T> ArrayList<T> asArrayList(List<T> list) {
+ return list instanceof ArrayList
+ ? (ArrayList<T>) list
+ : new ArrayList<T>(list);
+ }
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
index 9d2fa17..84ab85e 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -78,7 +78,6 @@
import android.widget.TextView;
import com.android.documentsui.BaseActivity;
-import com.android.documentsui.CopyService;
import com.android.documentsui.DirectoryLoader;
import com.android.documentsui.DirectoryResult;
import com.android.documentsui.DocumentClipper;
@@ -100,6 +99,8 @@
import com.android.documentsui.model.DocumentInfo;
import com.android.documentsui.model.DocumentStack;
import com.android.documentsui.model.RootInfo;
+import com.android.documentsui.services.FileOperationService;
+import com.android.documentsui.services.FileOperations;
import com.google.common.collect.Lists;
@@ -455,9 +456,15 @@
return;
}
- CopyService.start(getActivity(), getDisplayState().selectedDocumentsForCopy,
+ int operationType = data.getIntExtra(
+ FileOperationService.EXTRA_OPERATION,
+ FileOperationService.OPERATION_COPY);
+
+ FileOperations.start(
+ getActivity(),
+ getDisplayState().selectedDocumentsForCopy,
(DocumentStack) data.getParcelableExtra(Shared.EXTRA_STACK),
- data.getIntExtra(CopyService.EXTRA_TRANSFER_MODE, CopyService.TRANSFER_MODE_COPY));
+ operationType);
}
private boolean onSingleTapUp(MotionEvent e) {
@@ -739,14 +746,14 @@
return true;
case R.id.menu_copy_to:
- transferDocuments(selection, CopyService.TRANSFER_MODE_COPY);
+ transferDocuments(selection, FileOperationService.OPERATION_COPY);
mode.finish();
return true;
case R.id.menu_move_to:
// Exit selection mode first, so we avoid deselecting deleted documents.
mode.finish();
- transferDocuments(selection, CopyService.TRANSFER_MODE_MOVE);
+ transferDocuments(selection, FileOperationService.OPERATION_MOVE);
return true;
case R.id.menu_copy_to_clipboard:
@@ -898,7 +905,7 @@
}
}
intent.putExtra(Shared.EXTRA_DIRECTORY_COPY, directoryCopy);
- intent.putExtra(CopyService.EXTRA_TRANSFER_MODE, mode);
+ intent.putExtra(FileOperationService.EXTRA_OPERATION, mode);
startActivityForResult(intent, REQUEST_COPY_DESTINATION);
}
}.execute(selected);
@@ -1035,7 +1042,7 @@
tmpStack = curStack;
}
- CopyService.start(getActivity(), docs, tmpStack, CopyService.TRANSFER_MODE_COPY);
+ FileOperations.copy(getActivity(), docs, tmpStack);
}
private ClipData getClipDataFromDocuments(List<DocumentInfo> docs) {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java b/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java
new file mode 100644
index 0000000..8f89b4e
--- /dev/null
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java
@@ -0,0 +1,505 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui.services;
+
+import static android.os.SystemClock.elapsedRealtime;
+import static com.android.documentsui.DocumentsApplication.acquireUnstableProviderOrThrow;
+import static com.android.documentsui.Shared.DEBUG;
+import static com.android.documentsui.model.DocumentInfo.getCursorLong;
+import static com.android.documentsui.model.DocumentInfo.getCursorString;
+import static com.android.documentsui.services.FileOperationService.OPERATION_COPY;
+import static com.google.common.base.Preconditions.checkArgument;
+
+import android.annotation.StringRes;
+import android.app.Notification;
+import android.app.Notification.Builder;
+import android.content.ContentProviderClient;
+import android.content.Context;
+import android.content.res.AssetFileDescriptor;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.CancellationSignal;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+import android.provider.DocumentsContract;
+import android.provider.DocumentsContract.Document;
+import android.text.format.DateUtils;
+import android.util.Log;
+import android.webkit.MimeTypeMap;
+
+import com.android.documentsui.R;
+import com.android.documentsui.model.DocumentInfo;
+import com.android.documentsui.model.DocumentStack;
+
+import libcore.io.IoUtils;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.NumberFormat;
+import java.util.List;
+
+class CopyJob extends Job {
+ private static final String TAG = "CopyJob";
+ private static final int PROGRESS_INTERVAL_MILLIS = 1000;
+ final List<DocumentInfo> mSrcFiles;
+
+ // Provider clients are acquired for the duration of each copy job. Note that there is an
+ // implicit assumption that all srcs come from the same authority.
+ ContentProviderClient srcClient;
+ ContentProviderClient dstClient;
+
+ private long mStartTime = -1;
+ private long mBatchSize;
+ private long mBytesCopied;
+ private long mLastNotificationTime;
+ // Speed estimation
+ private long mBytesCopiedSample;
+ private long mSampleTime;
+ private long mSpeed;
+ private long mRemainingTime;
+
+ /**
+ * Copies files to a destination identified by {@code destination}.
+ * @see @link {@link Job} constructor for most param descriptions.
+ *
+ * @param srcs List of files to be copied.
+ */
+ CopyJob(Context serviceContext, Context appContext, Listener listener,
+ String id, DocumentStack destination, List<DocumentInfo> srcs) {
+ super(OPERATION_COPY, serviceContext, appContext, listener, id, destination);
+
+ checkArgument(!srcs.isEmpty());
+ this.mSrcFiles = srcs;
+ }
+
+ @Override
+ Builder createProgressBuilder() {
+ return super.createProgressBuilder(
+ serviceContext.getString(R.string.copy_notification_title),
+ R.drawable.ic_menu_copy,
+ serviceContext.getString(android.R.string.cancel),
+ R.drawable.ic_cab_cancel);
+ }
+
+ @Override
+ public Notification getSetupNotification() {
+ return getSetupNotification(serviceContext.getString(R.string.copy_preparing));
+ }
+
+ public boolean shouldUpdateProgress() {
+ // Wait a while between updates :)
+ return elapsedRealtime() - mLastNotificationTime > PROGRESS_INTERVAL_MILLIS;
+ }
+
+ Notification getProgressNotification(@StringRes int msgId) {
+ double completed = (double) this.mBytesCopied / mBatchSize;
+ mProgressBuilder.setProgress(100, (int) (completed * 100), false);
+ mProgressBuilder.setContentInfo(
+ NumberFormat.getPercentInstance().format(completed));
+ if (mRemainingTime > 0) {
+ mProgressBuilder.setContentText(serviceContext.getString(msgId,
+ DateUtils.formatDuration(mRemainingTime)));
+ } else {
+ mProgressBuilder.setContentText(null);
+ }
+
+ // Remember when we last returned progress so we can provide an answer
+ // in shouldUpdateProgress.
+ mLastNotificationTime = elapsedRealtime();
+ return mProgressBuilder.build();
+ }
+
+ public Notification getProgressNotification() {
+ return getProgressNotification(R.string.copy_remaining);
+ }
+
+ void onBytesCopied(long numBytes) {
+ this.mBytesCopied += numBytes;
+ }
+
+ /**
+ * Generates an estimate of the remaining time in the copy.
+ */
+ void updateRemainingTimeEstimate() {
+ long elapsedTime = elapsedRealtime() - mStartTime;
+
+ final long sampleDuration = elapsedTime - mSampleTime;
+ final long sampleSpeed = ((mBytesCopied - mBytesCopiedSample) * 1000) / sampleDuration;
+ if (mSpeed == 0) {
+ mSpeed = sampleSpeed;
+ } else {
+ mSpeed = ((3 * mSpeed) + sampleSpeed) / 4;
+ }
+
+ if (mSampleTime > 0 && mSpeed > 0) {
+ mRemainingTime = ((mBatchSize - mBytesCopied) * 1000) / mSpeed;
+ } else {
+ mRemainingTime = 0;
+ }
+
+ mSampleTime = elapsedTime;
+ mBytesCopiedSample = mBytesCopied;
+ }
+
+ @Override
+ Notification getFailureNotification() {
+ return getFailureNotification(
+ R.plurals.copy_error_notification_title, R.drawable.ic_menu_copy);
+ }
+
+ @Override
+ void run(FileOperationService service) throws RemoteException {
+ mStartTime = elapsedRealtime();
+
+ // Acquire content providers.
+ srcClient = acquireUnstableProviderOrThrow(
+ getContentResolver(),
+ mSrcFiles.get(0).authority);
+ dstClient = acquireUnstableProviderOrThrow(
+ getContentResolver(),
+ stack.peek().authority);
+
+ // client
+ mBatchSize = calculateSize(srcClient, mSrcFiles);
+
+ DocumentInfo srcInfo;
+ DocumentInfo dstInfo;
+ for (int i = 0; i < mSrcFiles.size() && !isCanceled(); ++i) {
+ srcInfo = mSrcFiles.get(i);
+ dstInfo = stack.peek();
+
+ // Guard unsupported recursive operation.
+ if (dstInfo.equals(srcInfo) || isDescendentOf(srcInfo, dstInfo)) {
+ if (DEBUG) Log.d(TAG, "Skipping recursive operation on directory "
+ + dstInfo.derivedUri);
+ onFileFailed(srcInfo);
+ continue;
+ }
+
+ if (DEBUG) Log.d(TAG,
+ "Performing op-type:" + type() + " of " + srcInfo.displayName
+ + " (" + srcInfo.derivedUri + ")" + " to " + dstInfo.displayName
+ + " (" + dstInfo.derivedUri + ")");
+
+ processDocument(srcInfo, dstInfo);
+ }
+ }
+
+ /**
+ * Logs progress on the current copy operation. Displays/Updates the progress notification.
+ *
+ * @param bytesCopied
+ */
+ private void makeCopyProgress(long bytesCopied) {
+ onBytesCopied(bytesCopied);
+ if (shouldUpdateProgress()) {
+ updateRemainingTimeEstimate();
+ listener.onProgress(this);
+ }
+ }
+
+ /**
+ * Copies a the given document to the given location.
+ *
+ * @param srcInfo DocumentInfos for the documents to copy.
+ * @param dstDirInfo The destination directory.
+ * @param mode The transfer mode (copy or move).
+ * @return True on success, false on failure.
+ * @throws RemoteException
+ */
+ boolean processDocument(DocumentInfo srcInfo, DocumentInfo dstDirInfo) throws RemoteException {
+
+ // TODO: When optimized copy kicks in, we'll not making any progress updates.
+ // For now. Local storage isn't using optimized copy.
+
+ // When copying within the same provider, try to use optimized copying and moving.
+ // If not supported, then fallback to byte-by-byte copy/move.
+ if (srcInfo.authority.equals(dstDirInfo.authority)) {
+ if ((srcInfo.flags & Document.FLAG_SUPPORTS_COPY) != 0) {
+ if (DocumentsContract.copyDocument(srcClient, srcInfo.derivedUri,
+ dstDirInfo.derivedUri) == null) {
+ onFileFailed(srcInfo);
+ }
+ return false;
+ }
+ }
+
+ // If we couldn't do an optimized copy...we fall back to vanilla byte copy.
+ return byteCopyDocument(srcInfo, dstDirInfo);
+ }
+
+ boolean byteCopyDocument(DocumentInfo srcInfo, DocumentInfo dstDirInfo)
+ throws RemoteException {
+ final String dstMimeType;
+ final String dstDisplayName;
+
+ // If the file is virtual, but can be converted to another format, then try to copy it
+ // as such format. Also, append an extension for the target mime type (if known).
+ if (srcInfo.isVirtualDocument()) {
+ final String[] streamTypes = getContentResolver().getStreamTypes(
+ srcInfo.derivedUri, "*/*");
+ if (streamTypes != null && streamTypes.length > 0) {
+ dstMimeType = streamTypes[0];
+ final String extension = MimeTypeMap.getSingleton().
+ getExtensionFromMimeType(dstMimeType);
+ dstDisplayName = srcInfo.displayName +
+ (extension != null ? "." + extension : srcInfo.displayName);
+ } else {
+ // The virtual file is not available as any alternative streamable format.
+ // TODO: Log failures.
+ onFileFailed(srcInfo);
+ return false;
+ }
+ } else {
+ dstMimeType = srcInfo.mimeType;
+ dstDisplayName = srcInfo.displayName;
+ }
+
+ // Create the target document (either a file or a directory), then copy recursively the
+ // contents (bytes or children).
+ final Uri dstUri = DocumentsContract.createDocument(dstClient,
+ dstDirInfo.derivedUri, dstMimeType, dstDisplayName);
+ if (dstUri == null) {
+ // If this is a directory, the entire subdir will not be copied over.
+ onFileFailed(srcInfo);
+ return false;
+ }
+
+ DocumentInfo dstInfo = null;
+ try {
+ dstInfo = DocumentInfo.fromUri(getContentResolver(), dstUri);
+ } catch (FileNotFoundException e) {
+ onFileFailed(srcInfo);
+ return false;
+ }
+
+ final boolean success;
+ if (Document.MIME_TYPE_DIR.equals(srcInfo.mimeType)) {
+ success = copyDirectoryHelper(srcInfo, dstInfo);
+ } else {
+ success = copyFileHelper(srcInfo, dstInfo, dstMimeType);
+ }
+
+ return success;
+ }
+
+ /**
+ * Handles recursion into a directory and copying its contents. Note that in linux terms, this
+ * does the equivalent of "cp src/* dst", not "cp -r src dst".
+ *
+ * @param srcDirInfo Info of the directory to copy from. The routine will copy the directory's
+ * contents, not the directory itself.
+ * @param dstDirInfo Info of the directory to copy to. Must be created beforehand.
+ * @return True on success, false if some of the children failed to copy.
+ * @throws RemoteException
+ */
+ private boolean copyDirectoryHelper(DocumentInfo srcDirInfo, DocumentInfo dstDirInfo)
+ throws RemoteException {
+ // Recurse into directories. Copy children into the new subdirectory.
+ final String queryColumns[] = new String[] {
+ Document.COLUMN_DISPLAY_NAME,
+ Document.COLUMN_DOCUMENT_ID,
+ Document.COLUMN_MIME_TYPE,
+ Document.COLUMN_SIZE,
+ Document.COLUMN_FLAGS
+ };
+ Cursor cursor = null;
+ boolean success = true;
+ try {
+ // Iterate over srcs in the directory; copy to the destination directory.
+ final Uri queryUri = DocumentsContract.buildChildDocumentsUri(srcDirInfo.authority,
+ srcDirInfo.documentId);
+ cursor = srcClient.query(queryUri, queryColumns, null, null, null);
+ DocumentInfo srcInfo;
+ while (cursor.moveToNext()) {
+ srcInfo = DocumentInfo.fromCursor(cursor, srcDirInfo.authority);
+ success &= processDocument(srcInfo, dstDirInfo);
+ }
+ } finally {
+ IoUtils.closeQuietly(cursor);
+ }
+
+ return success;
+ }
+
+ /**
+ * Handles copying a single file.
+ *
+ * @param srcUriInfo Info of the file to copy from.
+ * @param dstUriInfo Info of the *file* to copy to. Must be created beforehand.
+ * @param mimeType Mime type for the target. Can be different than source for virtual files.
+ * @return True on success, false on error.
+ * @throws RemoteException
+ */
+ private boolean copyFileHelper(DocumentInfo srcInfo, DocumentInfo dstInfo, String mimeType)
+ throws RemoteException {
+ // Copy an individual file.
+ CancellationSignal canceller = new CancellationSignal();
+ ParcelFileDescriptor srcFile = null;
+ ParcelFileDescriptor dstFile = null;
+ InputStream src = null;
+ OutputStream dst = null;
+
+ boolean success = true;
+ try {
+ // If the file is virtual, but can be converted to another format, then try to copy it
+ // as such format.
+ if (srcInfo.isVirtualDocument()) {
+ final AssetFileDescriptor srcFileAsAsset =
+ srcClient.openTypedAssetFileDescriptor(
+ srcInfo.derivedUri, mimeType, null, canceller);
+ srcFile = srcFileAsAsset.getParcelFileDescriptor();
+ src = new AssetFileDescriptor.AutoCloseInputStream(srcFileAsAsset);
+ } else {
+ srcFile = srcClient.openFile(srcInfo.derivedUri, "r", canceller);
+ src = new ParcelFileDescriptor.AutoCloseInputStream(srcFile);
+ }
+
+ dstFile = dstClient.openFile(dstInfo.derivedUri, "w", canceller);
+ dst = new ParcelFileDescriptor.AutoCloseOutputStream(dstFile);
+
+ byte[] buffer = new byte[8192];
+ int len;
+ while ((len = src.read(buffer)) != -1) {
+ if (isCanceled()) {
+ if (DEBUG) Log.d(TAG, "Canceled copy mid-copy. Id:" + id);
+ success = false;
+ break;
+ }
+ dst.write(buffer, 0, len);
+ makeCopyProgress(len);
+ }
+
+ srcFile.checkError();
+ } catch (IOException e) {
+ success = false;
+ onFileFailed(srcInfo);
+
+ if (dstFile != null) {
+ try {
+ dstFile.closeWithError(e.getMessage());
+ } catch (IOException closeError) {
+ Log.e(TAG, "Error closing destination", closeError);
+ }
+ }
+ } finally {
+ // This also ensures the file descriptors are closed.
+ IoUtils.closeQuietly(src);
+ IoUtils.closeQuietly(dst);
+ }
+
+ if (!success) {
+ // Clean up half-copied files.
+ canceller.cancel();
+ try {
+ DocumentsContract.deleteDocument(dstClient, dstInfo.derivedUri);
+ } catch (RemoteException e) {
+ // RemoteExceptions usually signal that the connection is dead, so there's no
+ // point attempting to continue. Propagate the exception up so the copy job is
+ // cancelled.
+ Log.w(TAG, "Failed to cleanup after copy error: " + srcInfo.derivedUri, e);
+ throw e;
+ }
+ }
+
+ return success;
+ }
+
+ /**
+ * Calculates the cumulative size of all the documents in the list. Directories are recursed
+ * into and totaled up.
+ *
+ * @param srcs
+ * @return Size in bytes.
+ * @throws RemoteException
+ */
+ private static long calculateSize(ContentProviderClient client, List<DocumentInfo> srcs)
+ throws RemoteException {
+ long result = 0;
+
+ for (DocumentInfo src : srcs) {
+ if (src.isDirectory()) {
+ // Directories need to be recursed into.
+ result += calculateFileSizesRecursively(client, src.derivedUri);
+ } else {
+ result += src.size;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Calculates (recursively) the cumulative size of all the files under the given directory.
+ *
+ * @throws RemoteException
+ */
+ private static long calculateFileSizesRecursively(
+ ContentProviderClient client, Uri uri) throws RemoteException {
+ final String authority = uri.getAuthority();
+ final Uri queryUri = DocumentsContract.buildChildDocumentsUri(authority,
+ DocumentsContract.getDocumentId(uri));
+ final String queryColumns[] = new String[] {
+ Document.COLUMN_DOCUMENT_ID,
+ Document.COLUMN_MIME_TYPE,
+ Document.COLUMN_SIZE
+ };
+
+ long result = 0;
+ Cursor cursor = null;
+ try {
+ cursor = client.query(queryUri, queryColumns, null, null, null);
+ while (cursor.moveToNext()) {
+ if (Document.MIME_TYPE_DIR.equals(
+ getCursorString(cursor, Document.COLUMN_MIME_TYPE))) {
+ // Recurse into directories.
+ final Uri dirUri = DocumentsContract.buildDocumentUri(authority,
+ getCursorString(cursor, Document.COLUMN_DOCUMENT_ID));
+ result += calculateFileSizesRecursively(client, dirUri);
+ } else {
+ // This may return -1 if the size isn't defined. Ignore those cases.
+ long size = getCursorLong(cursor, Document.COLUMN_SIZE);
+ result += size > 0 ? size : 0;
+ }
+ }
+ } finally {
+ IoUtils.closeQuietly(cursor);
+ }
+
+ return result;
+ }
+
+ @Override
+ void cleanup() {
+ ContentProviderClient.releaseQuietly(srcClient);
+ ContentProviderClient.releaseQuietly(dstClient);
+ }
+
+ /**
+ * Returns true if {@code doc} is a descendant of {@code parentDoc}.
+ * @throws RemoteException
+ */
+ boolean isDescendentOf(DocumentInfo doc, DocumentInfo parentDoc)
+ throws RemoteException {
+ if (parentDoc.isDirectory() && doc.authority.equals(parentDoc.authority)) {
+ return DocumentsContract.isChildDocument(
+ dstClient, doc.derivedUri, parentDoc.derivedUri);
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/FileOperationService.java b/packages/DocumentsUI/src/com/android/documentsui/services/FileOperationService.java
new file mode 100644
index 0000000..6d87ecf
--- /dev/null
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/FileOperationService.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui.services;
+
+import static android.os.SystemClock.elapsedRealtime;
+import static com.android.documentsui.Shared.DEBUG;
+import static com.android.internal.util.Preconditions.checkArgument;
+import static com.android.internal.util.Preconditions.checkNotNull;
+import static com.android.internal.util.Preconditions.checkState;
+
+import android.annotation.IntDef;
+import android.app.IntentService;
+import android.app.NotificationManager;
+import android.content.Intent;
+import android.os.PowerManager;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import android.util.Log;
+
+import com.android.documentsui.Shared;
+import com.android.documentsui.model.DocumentInfo;
+import com.android.documentsui.model.DocumentStack;
+
+import com.google.common.base.Objects;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FileOperationService extends IntentService implements Job.Listener {
+ public static final String TAG = "FileOperationService";
+
+ public static final String EXTRA_JOB_ID = "com.android.documentsui.JOB_ID";
+ public static final String EXTRA_OPERATION = "com.android.documentsui.OPERATION";
+ public static final String EXTRA_CANCEL = "com.android.documentsui.CANCEL";
+ public static final String EXTRA_SRC_LIST = "com.android.documentsui.SRC_LIST";
+ public static final String EXTRA_FAILURE = "com.android.documentsui.FAILURE";
+
+ public static final int OPERATION_UNKNOWN = -1;
+ public static final int OPERATION_COPY = 1;
+ public static final int OPERATION_MOVE = 2;
+ public static final int OPERATION_DELETE = 3;
+
+ @IntDef(flag = true, value = {
+ OPERATION_UNKNOWN,
+ OPERATION_COPY,
+ OPERATION_MOVE,
+ OPERATION_DELETE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface OpType {}
+
+ // TODO: Move it to a shared file when more operations are implemented.
+ public static final int FAILURE_COPY = 1;
+
+ private PowerManager mPowerManager;
+
+ private NotificationManager mNotificationManager;
+
+ // TODO: Rework service to support multiple concurrent jobs.
+ private volatile Job mJob;
+
+ // For testing only.
+ @Nullable private TestOnlyListener mJobFinishedListener;
+
+ public FileOperationService() {
+ super("FileOperationService");
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ if (DEBUG) Log.d(TAG, "Created.");
+ mPowerManager = getSystemService(PowerManager.class);
+ mNotificationManager = getSystemService(NotificationManager.class);
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (DEBUG) Log.d(TAG, "onStartCommand: " + intent);
+ if (intent.hasExtra(EXTRA_CANCEL)) {
+ handleCancel(intent);
+ return START_REDELIVER_INTENT;
+ } else {
+ return super.onStartCommand(intent, flags, startId);
+ }
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ if (DEBUG) Log.d(TAG, "onHandleIntent: " + intent);
+
+ String jobId = intent.getStringExtra(EXTRA_JOB_ID);
+ @OpType int operationType = intent.getIntExtra(EXTRA_OPERATION, OPERATION_UNKNOWN);
+ checkArgument(jobId != null);
+ if (intent.hasExtra(EXTRA_CANCEL)) {
+ handleCancel(intent);
+ return;
+ }
+
+ checkArgument(operationType != OPERATION_UNKNOWN);
+
+ PowerManager.WakeLock wakeLock = mPowerManager.newWakeLock(
+ PowerManager.PARTIAL_WAKE_LOCK, TAG);
+
+ ArrayList<DocumentInfo> srcs = intent.getParcelableArrayListExtra(EXTRA_SRC_LIST);
+ DocumentStack stack = intent.getParcelableExtra(Shared.EXTRA_STACK);
+
+ Job job = createJob(operationType, jobId, srcs, stack);
+
+ try {
+ wakeLock.acquire();
+
+ mNotificationManager.notify(job.id, 0, job.getSetupNotification());
+ job.run(this);
+
+ } catch (Exception e) {
+ // Catch-all to prevent any copy errors from wedging the app.
+ Log.e(TAG, "Exceptions occurred during copying", e);
+ } finally {
+ if (DEBUG) Log.d(TAG, "Cleaning up after copy");
+
+ job.cleanup();
+ wakeLock.release();
+
+ // Dismiss the ongoing copy notification when the copy is done.
+ mNotificationManager.cancel(job.id, 0);
+
+ if (job.failed()) {
+ Log.e(TAG, job.failedFiles.size() + " files failed to copy");
+ mNotificationManager.notify(job.id, 0, job.getFailureNotification());
+ }
+
+ // TEST ONLY CODE...<raised eyebrows>
+ if (mJobFinishedListener != null) {
+ mJobFinishedListener.onFinished(job.failedFiles);
+ }
+
+ deleteJob(job);
+ if (DEBUG) Log.d(TAG, "Done cleaning up");
+ }
+ }
+
+ /**
+ * Cancels the operation corresponding to job id, identified in "EXTRA_JOB_ID".
+ *
+ * @param intent The cancellation intent.
+ */
+ private void handleCancel(Intent intent) {
+ checkArgument(intent.hasExtra(EXTRA_CANCEL));
+ String jobId = checkNotNull(intent.getStringExtra(EXTRA_JOB_ID));
+
+ // Do nothing if the cancelled ID doesn't match the current job ID. This prevents racey
+ // cancellation requests from affecting unrelated copy jobs. However, if the current job ID
+ // is null, the service most likely crashed and was revived by the incoming cancel intent.
+ // In that case, always allow the cancellation to proceed.
+ if (mJob != null && Objects.equal(jobId, mJob.id)) {
+ mJob.cancel();
+ }
+
+ // Dismiss the progress notification here rather than in the copy loop. This preserves
+ // interactivity for the user in case the copy loop is stalled.
+ // Try to cancel it even if we don't have a job id...in case there is some sad
+ // orphan notification.
+ mNotificationManager.cancel(jobId, 0);
+ }
+
+ public static String createJobId() {
+ return String.valueOf(elapsedRealtime());
+ }
+
+ Job createJob(
+ @OpType int operationType, String id, ArrayList<DocumentInfo> srcs,
+ DocumentStack stack) {
+
+ checkState(mJob == null);
+
+ switch (operationType) {
+ case OPERATION_COPY:
+ mJob = new CopyJob(this, getApplicationContext(), this, id, stack, srcs);
+ break;
+ case OPERATION_MOVE:
+ mJob = new MoveJob(this, getApplicationContext(), this, id, stack, srcs);
+ break;
+ case OPERATION_DELETE:
+ throw new UnsupportedOperationException();
+ default:
+ throw new UnsupportedOperationException();
+ }
+
+ return checkNotNull(mJob);
+ }
+
+ void deleteJob(Job job) {
+ checkArgument(job == mJob);
+ mJob = null;
+ }
+
+ @Override
+ public void onProgress(CopyJob job) {
+ if (DEBUG) Log.d(TAG, "On copy progress...");
+ mNotificationManager.notify(job.id, 0, job.getProgressNotification());
+ }
+
+ @Override
+ public void onProgress(MoveJob job) {
+ if (DEBUG) Log.d(TAG, "On move progress...");
+ mNotificationManager.notify(job.id, 0, job.getProgressNotification());
+ }
+
+ /**
+ * Sets a callback to be run when the next run job is finished.
+ * This is test ONLY instrumentation. The alternative is for us to add
+ * broadcast intents SOLELY for the purpose of testing.
+ * @param listener
+ */
+ @VisibleForTesting
+ void addFinishedListener(TestOnlyListener listener) {
+ this.mJobFinishedListener = listener;
+ }
+
+ /**
+ * Only used for testing. Is that obvious enough?
+ */
+ @VisibleForTesting
+ interface TestOnlyListener {
+ void onFinished(List<DocumentInfo> failed);
+ }
+}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/FileOperations.java b/packages/DocumentsUI/src/com/android/documentsui/services/FileOperations.java
new file mode 100644
index 0000000..88bf03b
--- /dev/null
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/FileOperations.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui.services;
+
+import static com.android.documentsui.Shared.DEBUG;
+import static com.android.documentsui.Shared.EXTRA_STACK;
+import static com.android.documentsui.Shared.asArrayList;
+import static com.android.documentsui.Shared.getQuantityString;
+import static com.android.documentsui.services.FileOperationService.EXTRA_CANCEL;
+import static com.android.documentsui.services.FileOperationService.EXTRA_JOB_ID;
+import static com.android.documentsui.services.FileOperationService.EXTRA_OPERATION;
+import static com.android.documentsui.services.FileOperationService.EXTRA_SRC_LIST;
+import static com.android.documentsui.services.FileOperationService.OPERATION_COPY;
+import static com.android.documentsui.services.FileOperationService.OPERATION_DELETE;
+import static com.android.documentsui.services.FileOperationService.OPERATION_MOVE;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Parcelable;
+import android.support.design.widget.Snackbar;
+import android.util.Log;
+
+import com.android.documentsui.R;
+import com.android.documentsui.Snackbars;
+import com.android.documentsui.model.DocumentInfo;
+import com.android.documentsui.model.DocumentStack;
+import com.android.documentsui.services.FileOperationService.OpType;
+
+import java.util.List;
+
+/**
+ * Helper functions for starting various file operations.
+ */
+public final class FileOperations {
+
+ private static final String TAG = "FileOperations";
+
+ private FileOperations() {}
+
+ /**
+ * Tries to start the activity. Returns the job id.
+ */
+ public static String start(
+ Activity activity, List<DocumentInfo> srcDocs, DocumentStack stack,
+ int operationType) {
+
+ if (DEBUG) Log.d(TAG, "Handling generic 'start' call.");
+
+ switch (operationType) {
+ case OPERATION_COPY:
+ return FileOperations.copy(activity, srcDocs, stack);
+ case OPERATION_MOVE:
+ return FileOperations.move(activity, srcDocs, stack);
+ case OPERATION_DELETE:
+ return FileOperations.delete(activity, srcDocs, stack);
+ default:
+ throw new UnsupportedOperationException("Unknown operation: " + operationType);
+ }
+ }
+
+ /**
+ * Makes a best effort to cancel operation identified by jobId.
+ *
+ * @param context Context for the intent.
+ * @param jobId The id of the job to cancel.
+ * Use {@link FileOperationService#createJobId} if you don't have one handy.
+ * @param srcDocs A list of src files to copy.
+ * @param dstStack The copy destination stack.
+ */
+ public static void cancel(Activity activity, String jobId) {
+ if (DEBUG) Log.d(TAG, "Attempting to canceling operation: " + jobId);
+
+ Intent intent = new Intent(activity, FileOperationService.class);
+ intent.putExtra(EXTRA_CANCEL, true);
+ intent.putExtra(EXTRA_JOB_ID, jobId);
+
+ activity.startService(intent);
+ }
+
+ /**
+ * Starts the service for a copy operation.
+ *
+ * @param context Context for the intent.
+ * @param jobId A unique jobid for this job.
+ * Use {@link FileOperationService#createJobId} if you don't have one handy.
+ * @param srcDocs A list of src files to copy.
+ * @param destination The copy destination stack.
+ */
+ public static String copy(
+ Activity activity, List<DocumentInfo> srcDocs, DocumentStack destination) {
+ String jobId = FileOperationService.createJobId();
+ if (DEBUG) Log.d(TAG, "Initiating 'copy' operation id: " + jobId);
+
+ Intent intent = createBaseIntent(OPERATION_COPY, activity, jobId, srcDocs, destination);
+
+ createSharedSnackBar(activity, R.plurals.copy_begin, srcDocs.size())
+ .show();
+
+ activity.startService(intent);
+
+ return jobId;
+ }
+
+ /**
+ * Starts the service for a move operation.
+ *
+ * @param jobId A unique jobid for this job.
+ * Use {@link FileOperationService#createJobId} if you don't have one handy.
+ * @param srcDocs A list of src files to copy.
+ * @param destination The move destination stack.
+ */
+ public static String move(
+ Activity activity, List<DocumentInfo> srcDocs, DocumentStack destination) {
+ String jobId = FileOperationService.createJobId();
+ if (DEBUG) Log.d(TAG, "Initiating 'move' operation id: " + jobId);
+
+ Intent intent = createBaseIntent(OPERATION_MOVE, activity, jobId, srcDocs, destination);
+
+ createSharedSnackBar(activity, R.plurals.move_begin, srcDocs.size())
+ .show();
+
+ activity.startService(intent);
+
+ return jobId;
+ }
+
+ /**
+ * Starts the service for a move operation.
+ *
+ * @param jobId A unique jobid for this job.
+ * Use {@link FileOperationService#createJobId} if you don't have one handy.
+ * @param srcDocs A list of src files to copy.
+ * @return Id of the job.
+ */
+ public static String delete(
+ Activity activity, List<DocumentInfo> srcDocs, DocumentStack location) {
+ String jobId = FileOperationService.createJobId();
+ if (DEBUG) Log.d(TAG, "Initiating 'delete' operation id: " + jobId);
+
+ Intent intent = createBaseIntent(OPERATION_DELETE, activity, jobId, srcDocs, location);
+ activity.startService(intent);
+
+ return jobId;
+ }
+
+ /**
+ * Starts the service for a move operation.
+ *
+ * @param jobId A unique jobid for this job.
+ * Use {@link FileOperationService#createJobId} if you don't have one handy.
+ * @param srcDocs A list of src files to copy.
+ * @return Id of the job.
+ */
+ public static Intent createBaseIntent(
+ @OpType int operationType, Activity activity, String jobId,
+ List<DocumentInfo> srcDocs, DocumentStack localeStack) {
+
+ Intent intent = new Intent(activity, FileOperationService.class);
+ intent.putExtra(EXTRA_JOB_ID, jobId);
+ intent.putParcelableArrayListExtra(
+ EXTRA_SRC_LIST, asArrayList(srcDocs));
+ intent.putExtra(EXTRA_STACK, (Parcelable) localeStack);
+ intent.putExtra(EXTRA_OPERATION, operationType);
+
+ return intent;
+ }
+
+ private static Snackbar createSharedSnackBar(Activity activity, int contentId, int fileCount) {
+ Resources res = activity.getResources();
+ return Snackbars.makeSnackbar(
+ activity,
+ getQuantityString(activity, contentId, fileCount),
+ Snackbar.LENGTH_SHORT);
+ }
+}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/Job.java b/packages/DocumentsUI/src/com/android/documentsui/services/Job.java
new file mode 100644
index 0000000..5c37a87
--- /dev/null
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/Job.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui.services;
+
+import static com.android.documentsui.services.FileOperationService.OPERATION_UNKNOWN;
+import static com.android.internal.util.Preconditions.checkArgument;
+
+import android.annotation.DrawableRes;
+import android.annotation.PluralsRes;
+import android.app.Notification;
+import android.app.Notification.Builder;
+import android.app.PendingIntent;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Parcelable;
+import android.os.RemoteException;
+import android.provider.DocumentsContract;
+
+import com.android.documentsui.FilesActivity;
+import com.android.documentsui.R;
+import com.android.documentsui.Shared;
+import com.android.documentsui.model.DocumentInfo;
+import com.android.documentsui.model.DocumentStack;
+import com.android.documentsui.services.FileOperationService.OpType;
+
+import java.util.ArrayList;
+
+abstract class Job {
+
+ final Context serviceContext;
+ final Context appContext;
+ final Listener listener;
+
+ final @OpType int mOpType;
+ final String id;
+ final DocumentStack stack;
+
+ final ArrayList<DocumentInfo> failedFiles = new ArrayList<>();
+ final Notification.Builder mProgressBuilder;
+
+ private volatile boolean mCanceled;
+
+ /**
+ * A simple progressable job, much like an AsyncTask, but with support
+ * for providing various related notification, progress and navigation information.
+ * @param opType
+ *
+ * @param serviceContext The context of the service in which this job is running.
+ * This is usually just "this".
+ * @param appContext The context of the invoking application. This is usually
+ * just {@code getApplicationContext()}.
+ * @param listener
+ * @param id Arbitrary string ID
+ * @param stack The documents stack context relating to this request. This is the
+ * destination in the Files app where the user will be take when the
+ * navigation intent is invoked (presumably from notification).
+ */
+ Job(@OpType int opType, Context serviceContext, Context appContext, Listener listener,
+ String id, DocumentStack stack) {
+
+ checkArgument(opType != OPERATION_UNKNOWN);
+ this.serviceContext = serviceContext;
+ this.appContext = appContext;
+ this.listener = listener;
+ mOpType = opType;
+
+ this.id = id;
+ this.stack = stack;
+
+ mProgressBuilder = createProgressBuilder();
+ }
+
+ abstract void run(FileOperationService service) throws RemoteException;
+ abstract void cleanup();
+
+ @OpType int type() {
+ return mOpType;
+ }
+
+ abstract Notification getSetupNotification();
+ // TODO: Progress notification for deletes.
+ // abstract Notification getProgressNotification(long bytesCopied);
+ abstract Notification getFailureNotification();
+
+ final void cancel() {
+ mCanceled = true;
+ }
+
+ final boolean isCanceled() {
+ return mCanceled;
+ }
+
+ final ContentResolver getContentResolver() {
+ return serviceContext.getContentResolver();
+ }
+
+ void onFileFailed(DocumentInfo file) {
+ failedFiles.add(file);
+ }
+
+ final boolean failed() {
+ return !failedFiles.isEmpty();
+ }
+
+ Notification getSetupNotification(String content) {
+ mProgressBuilder.setProgress(0, 0, true);
+ mProgressBuilder.setContentText(content);
+ return mProgressBuilder.build();
+ }
+
+ Notification getFailureNotification(@PluralsRes int titleId, @DrawableRes int icon) {
+ final Intent navigateIntent = buildNavigateIntent();
+ navigateIntent.putExtra(FileOperationService.EXTRA_FAILURE, FileOperationService.FAILURE_COPY);
+ navigateIntent.putExtra(FileOperationService.EXTRA_OPERATION, mOpType);
+
+ navigateIntent.putParcelableArrayListExtra(FileOperationService.EXTRA_SRC_LIST, failedFiles);
+
+ final Notification.Builder errorBuilder = new Notification.Builder(serviceContext)
+ .setContentTitle(serviceContext.getResources().getQuantityString(titleId,
+ failedFiles.size(), failedFiles.size()))
+ .setContentText(serviceContext.getString(R.string.notification_touch_for_details))
+ .setContentIntent(PendingIntent.getActivity(appContext, 0, navigateIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT))
+ .setCategory(Notification.CATEGORY_ERROR)
+ .setSmallIcon(icon)
+ .setAutoCancel(true);
+ return errorBuilder.build();
+ }
+
+ abstract Builder createProgressBuilder();
+
+ final Builder createProgressBuilder(
+ String title, @DrawableRes int icon,
+ String actionTitle, @DrawableRes int actionIcon) {
+ Notification.Builder progressBuilder = new Notification.Builder(serviceContext)
+ .setContentTitle(title)
+ .setContentIntent(
+ PendingIntent.getActivity(appContext, 0, buildNavigateIntent(), 0))
+ .setCategory(Notification.CATEGORY_PROGRESS)
+ .setSmallIcon(icon)
+ .setOngoing(true);
+
+ final Intent cancelIntent = createCancelIntent();
+
+ progressBuilder.addAction(
+ actionIcon,
+ actionTitle,
+ PendingIntent.getService(
+ serviceContext,
+ 0,
+ cancelIntent,
+ PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT));
+
+ return progressBuilder;
+ }
+
+ /**
+ * Creates an intent for navigating back to the destination directory.
+ */
+ Intent buildNavigateIntent() {
+ Intent intent = new Intent(serviceContext, FilesActivity.class);
+ intent.setAction(DocumentsContract.ACTION_BROWSE);
+ intent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
+ return intent;
+ }
+
+ Intent createCancelIntent() {
+ final Intent cancelIntent = new Intent(serviceContext, FileOperationService.class);
+ cancelIntent.putExtra(FileOperationService.EXTRA_CANCEL, true);
+ cancelIntent.putExtra(FileOperationService.EXTRA_JOB_ID, id);
+ return cancelIntent;
+ }
+
+ interface Listener {
+ void onProgress(CopyJob job);
+ void onProgress(MoveJob job);
+ }
+}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java b/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java
new file mode 100644
index 0000000..4817f58
--- /dev/null
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.documentsui.services;
+
+import android.app.Notification;
+import android.app.Notification.Builder;
+import android.content.Context;
+import android.os.RemoteException;
+import android.provider.DocumentsContract;
+import android.provider.DocumentsContract.Document;
+import android.util.Log;
+
+import com.android.documentsui.R;
+import com.android.documentsui.model.DocumentInfo;
+import com.android.documentsui.model.DocumentStack;
+
+import java.util.List;
+
+final class MoveJob extends CopyJob {
+
+ private static final String TAG = "MoveJob";
+
+ /**
+ * Moves files to a destination identified by {@code destination}.
+ * Performs most work by delegating to CopyJob, then deleting
+ * a file after it has been copied.
+ *
+ * @see @link {@link Job} constructor for most param descriptions.
+ *
+ * @param srcs List of files to be moved.
+ */
+ MoveJob(Context serviceContext, Context appContext, Listener listener,
+ String id, DocumentStack destination, List<DocumentInfo> srcs) {
+ super(serviceContext, appContext, listener, id, destination, srcs);
+ }
+
+ @Override
+ int type() {
+ return FileOperationService.OPERATION_MOVE;
+ }
+
+ @Override
+ Builder createProgressBuilder() {
+ return super.createProgressBuilder(
+ serviceContext.getString(R.string.move_notification_title),
+ R.drawable.ic_menu_copy,
+ serviceContext.getString(android.R.string.cancel),
+ R.drawable.ic_cab_cancel);
+ }
+
+ @Override
+ public Notification getSetupNotification() {
+ return getSetupNotification(serviceContext.getString(R.string.move_preparing));
+ }
+
+ @Override
+ public Notification getProgressNotification() {
+ return getProgressNotification(R.string.copy_preparing);
+ }
+
+ @Override
+ Notification getFailureNotification() {
+ return getFailureNotification(
+ R.plurals.move_error_notification_title, R.drawable.ic_menu_copy);
+ }
+
+ /**
+ * Copies a the given document to the given location.
+ *
+ * @param srcInfo DocumentInfos for the documents to copy.
+ * @param dstDirInfo The destination directory.
+ * @param mode The transfer mode (copy or move).
+ * @return True on success, false on failure.
+ * @throws RemoteException
+ */
+ @Override
+ boolean processDocument(DocumentInfo srcInfo, DocumentInfo dstDirInfo) throws RemoteException {
+
+ // TODO: When optimized copy kicks in, we're not making any progress updates. FIX IT!
+
+ // When copying within the same provider, try to use optimized copying and moving.
+ // If not supported, then fallback to byte-by-byte copy/move.
+ if (srcInfo.authority.equals(dstDirInfo.authority)) {
+ if ((srcInfo.flags & Document.FLAG_SUPPORTS_MOVE) != 0) {
+ if (DocumentsContract.moveDocument(srcClient, srcInfo.derivedUri,
+ dstDirInfo.derivedUri) == null) {
+ onFileFailed(srcInfo);
+ }
+ return false;
+ }
+ }
+
+ // If we couldn't do an optimized copy...we fall back to vanilla byte copy.
+ boolean success = byteCopyDocument(srcInfo, dstDirInfo);
+
+ if (success) {
+ // This is racey. We should make sure that we never delete a directory after
+ // it changed, so we don't remove a file which had not been copied earlier
+ // to the target location.
+ try {
+ DocumentsContract.deleteDocument(srcClient, srcInfo.derivedUri);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to delete source after copy: " + srcInfo.derivedUri, e);
+ return false;
+ }
+ }
+
+ return success;
+ }
+}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/CopyServiceTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/services/FileOperationServiceTest.java
similarity index 93%
rename from packages/DocumentsUI/tests/src/com/android/documentsui/CopyServiceTest.java
rename to packages/DocumentsUI/tests/src/com/android/documentsui/services/FileOperationServiceTest.java
index 4ce0185..35aad60 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/CopyServiceTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/services/FileOperationServiceTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.documentsui;
+package com.android.documentsui.services;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
@@ -34,6 +34,9 @@
import android.test.suitebuilder.annotation.MediumTest;
import android.util.Log;
+import com.android.documentsui.DocumentsProviderHelper;
+import com.android.documentsui.Shared;
+import com.android.documentsui.StubProvider;
import com.android.documentsui.model.DocumentInfo;
import com.android.documentsui.model.DocumentStack;
import com.android.documentsui.model.RootInfo;
@@ -54,10 +57,10 @@
import java.util.concurrent.TimeoutException;
@MediumTest
-public class CopyServiceTest extends ServiceTestCase<CopyService> {
+public class FileOperationServiceTest extends ServiceTestCase<FileOperationService> {
- public CopyServiceTest() {
- super(CopyService.class);
+ public FileOperationServiceTest() {
+ super(FileOperationService.class);
}
private static String AUTHORITY = "com.android.documentsui.stubprovider";
@@ -139,7 +142,9 @@
testContent.getBytes());
Intent moveIntent = createCopyIntent(Lists.newArrayList(testFile));
- moveIntent.putExtra(CopyService.EXTRA_TRANSFER_MODE, CopyService.TRANSFER_MODE_MOVE);
+ moveIntent.putExtra(
+ FileOperationService.EXTRA_OPERATION,
+ FileOperationService.OPERATION_MOVE);
startService(moveIntent);
// 3 operations: file creation, writing data, deleting original.
@@ -235,7 +240,7 @@
Uri testDir = createTestDirectory(srcPath);
Intent moveIntent = createCopyIntent(Lists.newArrayList(testDir));
- moveIntent.putExtra(CopyService.EXTRA_TRANSFER_MODE, CopyService.TRANSFER_MODE_MOVE);
+ moveIntent.putExtra(FileOperationService.EXTRA_OPERATION, FileOperationService.OPERATION_MOVE);
startService(moveIntent);
// 2 operations: Directory creation, and removal of the original.
@@ -270,7 +275,7 @@
mStorage.createRegularFile(SRC_ROOT, srcFiles[2], "text/plain", testContent[2].getBytes());
Intent moveIntent = createCopyIntent(Lists.newArrayList(testDir));
- moveIntent.putExtra(CopyService.EXTRA_TRANSFER_MODE, CopyService.TRANSFER_MODE_MOVE);
+ moveIntent.putExtra(FileOperationService.EXTRA_OPERATION, FileOperationService.OPERATION_MOVE);
startService(moveIntent);
// dir creation, then creation and writing of 3 files, then removal of src dir and 3 src
@@ -332,7 +337,7 @@
mStorage.simulateReadErrorsForFile(testFile);
Intent moveIntent = createCopyIntent(Lists.newArrayList(testFile));
- moveIntent.putExtra(CopyService.EXTRA_TRANSFER_MODE, CopyService.TRANSFER_MODE_MOVE);
+ moveIntent.putExtra(FileOperationService.EXTRA_OPERATION, FileOperationService.OPERATION_MOVE);
startService(moveIntent);
try {
@@ -374,7 +379,7 @@
mStorage.simulateReadErrorsForFile(errFile);
Intent moveIntent = createCopyIntent(Lists.newArrayList(testDir));
- moveIntent.putExtra(CopyService.EXTRA_TRANSFER_MODE, CopyService.TRANSFER_MODE_MOVE);
+ moveIntent.putExtra(FileOperationService.EXTRA_OPERATION, FileOperationService.OPERATION_MOVE);
startService(moveIntent);
// - dst dir creation,
@@ -422,8 +427,14 @@
DocumentStack stack = new DocumentStack();
stack.push(DocumentInfo.fromUri(mResolver, dst));
- final Intent copyIntent = new Intent(mContext, CopyService.class);
- copyIntent.putParcelableArrayListExtra(CopyService.EXTRA_SRC_LIST, srcDocs);
+ final Intent copyIntent = new Intent(mContext, FileOperationService.class);
+ copyIntent.putExtra(
+ FileOperationService.EXTRA_OPERATION,
+ FileOperationService.OPERATION_COPY);
+ copyIntent.putExtra(
+ FileOperationService.EXTRA_JOB_ID,
+ FileOperationService.createJobId());
+ copyIntent.putParcelableArrayListExtra(FileOperationService.EXTRA_SRC_LIST, srcDocs);
copyIntent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack);
return copyIntent;
@@ -509,7 +520,7 @@
mResolver.addProvider(AUTHORITY, mStorage);
}
- private final class CopyJobListener implements CopyService.TestOnlyListener {
+ private final class CopyJobListener implements FileOperationService.TestOnlyListener {
final CountDownLatch latch = new CountDownLatch(1);
final List<DocumentInfo> failedDocs = new ArrayList<>();
diff --git a/packages/PrintSpooler/res/values/strings.xml b/packages/PrintSpooler/res/values/strings.xml
index 97a7bff..b662c58 100644
--- a/packages/PrintSpooler/res/values/strings.xml
+++ b/packages/PrintSpooler/res/values/strings.xml
@@ -178,12 +178,6 @@
<!-- Template for the notification label for a blocked print job. [CHAR LIMIT=25] -->
<string name="blocked_notification_title_template">Printer blocked <xliff:g id="print_job_name" example="foo.jpg">%1$s</xliff:g></string>
- <!-- Template for the notification label for a composite (multiple items) print jobs notification. [CHAR LIMIT=25] -->
- <plurals name="composite_notification_title_template">
- <item quantity="one"><xliff:g id="print_job_name" example="foo.jpg">%1$d</xliff:g> print job</item>
- <item quantity="other"><xliff:g id="print_job_name" example="foo.jpg">%1$d</xliff:g> print jobs</item>
- </plurals>
-
<!-- Label for the notification button for cancelling a print job. [CHAR LIMIT=25] -->
<string name="cancel">Cancel</string>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/NotificationController.java b/packages/PrintSpooler/src/com/android/printspooler/model/NotificationController.java
index 3dc5d7e..0210693 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/model/NotificationController.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/model/NotificationController.java
@@ -40,6 +40,7 @@
import android.print.PrintJobInfo;
import android.print.PrintManager;
import android.provider.Settings;
+import android.util.ArraySet;
import android.util.Log;
import com.android.printspooler.R;
@@ -61,13 +62,22 @@
private static final String EXTRA_PRINT_JOB_ID = "EXTRA_PRINT_JOB_ID";
+ private static final String PRINT_JOB_NOTIFICATION_GROUP_KEY = "PRINT_JOB_NOTIFICATIONS";
+ private static final String PRINT_JOB_NOTIFICATION_SUMMARY = "PRINT_JOB_NOTIFICATIONS_SUMMARY";
+
private final Context mContext;
private final NotificationManager mNotificationManager;
+ /**
+ * Mapping from printJobIds to their notification Ids.
+ */
+ private final ArraySet<PrintJobId> mNotifications;
+
public NotificationController(Context context) {
mContext = context;
mNotificationManager = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+ mNotifications = new ArraySet<>(0);
}
public void onUpdateNotifications(List<PrintJobInfo> printJobs) {
@@ -81,16 +91,44 @@
}
}
- updateNotification(notifyPrintJobs);
+ updateNotifications(notifyPrintJobs);
}
- private void updateNotification(List<PrintJobInfo> printJobs) {
- if (printJobs.size() <= 0) {
- removeNotification();
- } else if (printJobs.size() == 1) {
- createSimpleNotification(printJobs.get(0));
- } else {
+ /**
+ * Update notifications for the given print jobs, remove all other notifications.
+ *
+ * @param printJobs The print job that we want to create notifications for.
+ */
+ private void updateNotifications(List<PrintJobInfo> printJobs) {
+ ArraySet<PrintJobId> removedPrintJobs = new ArraySet<>(mNotifications);
+
+ final int numPrintJobs = printJobs.size();
+
+ // Create summary notification
+ if (numPrintJobs > 1) {
createStackedNotification(printJobs);
+ } else {
+ mNotificationManager.cancel(PRINT_JOB_NOTIFICATION_SUMMARY, 0);
+ }
+
+ // Create per print job notification
+ for (int i = 0; i < numPrintJobs; i++) {
+ PrintJobInfo printJob = printJobs.get(i);
+ PrintJobId printJobId = printJob.getId();
+
+ removedPrintJobs.remove(printJobId);
+ mNotifications.add(printJobId);
+
+ createSimpleNotification(printJob);
+ }
+
+ // Remove notifications for print jobs that do not exist anymore
+ final int numRemovedPrintJobs = removedPrintJobs.size();
+ for (int i = 0; i < numRemovedPrintJobs; i++) {
+ PrintJobId removedPrintJob = removedPrintJobs.valueAt(i);
+
+ mNotificationManager.cancel(removedPrintJob.flattenToString(), 0);
+ mNotifications.remove(removedPrintJob);
}
}
@@ -148,7 +186,8 @@
.setOngoing(true)
.setShowWhen(true)
.setColor(mContext.getColor(
- com.android.internal.R.color.system_notification_accent_color));
+ com.android.internal.R.color.system_notification_accent_color))
+ .setGroup(PRINT_JOB_NOTIFICATION_GROUP_KEY);
if (firstAction != null) {
builder.addAction(firstAction);
@@ -176,7 +215,7 @@
builder.setContentText(printJob.getPrinterName());
}
- mNotificationManager.notify(0, builder.build());
+ mNotificationManager.notify(printJob.getId().flattenToString(), 0, builder.build());
}
private void createPrintingNotification(PrintJobInfo printJob) {
@@ -204,33 +243,36 @@
.setContentIntent(createContentIntent(null))
.setWhen(System.currentTimeMillis())
.setOngoing(true)
- .setShowWhen(true);
+ .setShowWhen(true)
+ .setGroup(PRINT_JOB_NOTIFICATION_GROUP_KEY)
+ .setGroupSummary(true);
final int printJobCount = printJobs.size();
InboxStyle inboxStyle = new InboxStyle();
- inboxStyle.setBigContentTitle(String.format(mContext.getResources().getQuantityText(
- R.plurals.composite_notification_title_template,
- printJobCount).toString(), printJobCount));
+ int icon = com.android.internal.R.drawable.ic_print;
for (int i = printJobCount - 1; i>= 0; i--) {
PrintJobInfo printJob = printJobs.get(i);
- if (i == printJobCount - 1) {
- builder.setLargeIcon(((BitmapDrawable) mContext.getResources().getDrawable(
- computeNotificationIcon(printJob), null)).getBitmap());
- builder.setSmallIcon(computeNotificationIcon(printJob));
- builder.setContentTitle(computeNotificationTitle(printJob));
- builder.setContentText(printJob.getPrinterName());
- }
+
inboxStyle.addLine(computeNotificationTitle(printJob));
+
+ // if any print job is in an error state show an error icon for the summary
+ if (printJob.getState() == PrintJobInfo.STATE_FAILED
+ || printJob.getState() == PrintJobInfo.STATE_BLOCKED) {
+ icon = com.android.internal.R.drawable.ic_print_error;
+ }
}
+ builder.setSmallIcon(icon);
+ builder.setLargeIcon(
+ ((BitmapDrawable) mContext.getResources().getDrawable(icon, null)).getBitmap());
builder.setNumber(printJobCount);
builder.setStyle(inboxStyle);
builder.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color));
- mNotificationManager.notify(0, builder.build());
+ mNotificationManager.notify(PRINT_JOB_NOTIFICATION_SUMMARY, 0, builder.build());
}
private String computeNotificationTitle(PrintJobInfo printJob) {
@@ -264,10 +306,6 @@
}
}
- private void removeNotification() {
- mNotificationManager.cancel(0);
- }
-
private PendingIntent createContentIntent(PrintJobId printJobId) {
Intent intent = new Intent(Settings.ACTION_PRINT_SETTINGS);
if (printJobId != null) {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java b/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java
index 496a0b0..18160ff 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerService.java
@@ -1416,9 +1416,9 @@
}
@Override
- public void removeApprovedPrintService(ComponentName serviceToRemove) {
+ public void pruneApprovedPrintServices(List<ComponentName> servicesToKeep) {
(new ApprovedPrintServices(PrintSpoolerService.this))
- .removeApprovedService(serviceToRemove);
+ .pruneApprovedServices(servicesToKeep);
}
@Override
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java
index cdfc7ee..81727ab 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/SelectPrinterActivity.java
@@ -66,6 +66,7 @@
import android.widget.SearchView;
import android.widget.TextView;
+import com.android.internal.content.PackageMonitor;
import com.android.printspooler.R;
import java.util.ArrayList;
@@ -101,7 +102,8 @@
private AnnounceFilterResult mAnnounceFilterResult;
/** Monitor if new print services get enabled or disabled */
- private ContentObserver mPrintServicesObserver;
+ private ContentObserver mPrintServicesDisabledObserver;
+ private PackageMonitor mPackageObserver;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -245,28 +247,45 @@
* Register listener for changes to the enabled print services.
*/
private void registerServiceMonitor() {
- mPrintServicesObserver = new ContentObserver(new Handler()) {
+ // Listen for services getting disabled
+ mPrintServicesDisabledObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
onPrintServicesUpdate();
}
};
+ // Listen for services getting installed or uninstalled
+ mPackageObserver = new PackageMonitor() {
+ @Override
+ public void onPackageModified(String packageName) {
+ onPrintServicesUpdate();
+ }
+
+ @Override
+ public void onPackageRemoved(String packageName, int uid) {
+ onPrintServicesUpdate();
+ }
+
+ @Override
+ public void onPackageAdded(String packageName, int uid) {
+ onPrintServicesUpdate();
+ }
+ };
+
getContentResolver().registerContentObserver(
- Settings.Secure.getUriFor(Settings.Secure.ENABLED_PRINT_SERVICES), false,
- mPrintServicesObserver);
+ Settings.Secure.getUriFor(Settings.Secure.DISABLED_PRINT_SERVICES), false,
+ mPrintServicesDisabledObserver);
+
+ mPackageObserver.register(this, getMainLooper(), false);
}
/**
- * Unregister {@link #mPrintServicesObserver listener for changes to the enabled print services}
- * or nothing if the listener is not registered.
+ * Unregister the listeners for changes to the enabled print services.
*/
private void unregisterServiceMonitorIfNeeded() {
- if (mPrintServicesObserver != null) {
- getContentResolver().unregisterContentObserver(mPrintServicesObserver);
-
- mPrintServicesObserver = null;
- }
+ getContentResolver().unregisterContentObserver(mPrintServicesDisabledObserver);
+ mPackageObserver.unregister();
}
@Override
diff --git a/packages/PrintSpooler/src/com/android/printspooler/util/ApprovedPrintServices.java b/packages/PrintSpooler/src/com/android/printspooler/util/ApprovedPrintServices.java
index dd10567..a1e3ef4 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/util/ApprovedPrintServices.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/util/ApprovedPrintServices.java
@@ -23,6 +23,7 @@
import android.printservice.PrintService;
import android.util.ArraySet;
+import java.util.List;
import java.util.Set;
/**
@@ -126,29 +127,27 @@
}
/**
- * If a {@link PrintService} is approved, remove it from the list of approved services.
+ * Remove all approved {@link PrintService print services} that are not in the given set.
*
- * @param serviceToRemove The {@link ComponentName} of the {@link PrintService} to be removed
+ * @param serviceNamesToKeep The {@link ComponentName names } of the services to keep
*/
- public void removeApprovedService(ComponentName serviceToRemove) {
+ public void pruneApprovedServices(List<ComponentName> serviceNamesToKeep) {
synchronized (sLock) {
- if (isApprovedService(serviceToRemove)) {
- // Copy approved services.
- ArraySet<String> approvedServices = new ArraySet<String>(
- mPreferences.getStringSet(APPROVED_SERVICES_PREFERENCE, null));
+ Set<String> approvedServices = getApprovedServices();
+ Set<String> newApprovedServices = new ArraySet<>(approvedServices.size());
+ final int numServiceNamesToKeep = serviceNamesToKeep.size();
+ for(int i = 0; i < numServiceNamesToKeep; i++) {
+ String serviceToKeep = serviceNamesToKeep.get(i).flattenToShortString();
+ if (approvedServices.contains(serviceToKeep)) {
+ newApprovedServices.add(serviceToKeep);
+ }
+ }
+
+ if (approvedServices.size() != newApprovedServices.size()) {
SharedPreferences.Editor editor = mPreferences.edit();
- final int numApprovedServices = approvedServices.size();
- for (int i = 0; i < numApprovedServices; i++) {
- if (approvedServices.valueAt(i)
- .equals(serviceToRemove.flattenToShortString())) {
- approvedServices.removeAt(i);
- break;
- }
- }
-
- editor.putStringSet(APPROVED_SERVICES_PREFERENCE, approvedServices);
+ editor.putStringSet(APPROVED_SERVICES_PREFERENCE, newApprovedServices);
editor.apply();
}
}
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index c6d9e98..7416fb5 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -151,6 +151,14 @@
</intent-filter>
</receiver>
+ <receiver
+ android:name=".RemoteBugreportReceiver"
+ android:permission="android.permission.DUMP">
+ <intent-filter>
+ <action android:name="android.intent.action.REMOTE_BUGREPORT_FINISHED" />
+ </intent-filter>
+ </receiver>
+
<service
android:name=".BugreportProgressService"
android:exported="false"/>
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index f7a2d75..5c807e1 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -21,6 +21,7 @@
import static com.android.shell.BugreportPrefs.getWarningState;
import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -28,10 +29,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import libcore.io.Streams;
@@ -112,6 +116,10 @@
// External intents sent by dumpstate.
static final String INTENT_BUGREPORT_STARTED = "android.intent.action.BUGREPORT_STARTED";
static final String INTENT_BUGREPORT_FINISHED = "android.intent.action.BUGREPORT_FINISHED";
+ static final String INTENT_REMOTE_BUGREPORT_FINISHED =
+ "android.intent.action.REMOTE_BUGREPORT_FINISHED";
+ static final String INTENT_REMOTE_BUGREPORT_DISPATCH =
+ "android.intent.action.REMOTE_BUGREPORT_DISPATCH";
// Internal intents used on notification actions.
static final String INTENT_BUGREPORT_CANCEL = "android.intent.action.BUGREPORT_CANCEL";
@@ -813,6 +821,9 @@
Log.e(TAG, "INTERNAL ERROR: no info for PID " + pid + ": " + mProcesses);
return;
}
+
+ addDetailsToZipFile(info);
+
final Intent sendIntent = buildSendIntent(mContext, info);
final Intent notifIntent;
@@ -868,7 +879,7 @@
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
- info.bugreportFile = zipBugreport(info.bugreportFile);
+ zipBugreport(info);
sendBugreportNotification(context, info);
return null;
}
@@ -879,35 +890,92 @@
* Zips a bugreport file, returning the path to the new file (or to the
* original in case of failure).
*/
- private static File zipBugreport(File bugreportFile) {
- String bugreportPath = bugreportFile.getAbsolutePath();
- String zippedPath = bugreportPath.replace(".txt", ".zip");
+ private static void zipBugreport(BugreportInfo info) {
+ final String bugreportPath = info.bugreportFile.getAbsolutePath();
+ final String zippedPath = bugreportPath.replace(".txt", ".zip");
Log.v(TAG, "zipping " + bugreportPath + " as " + zippedPath);
- File bugreportZippedFile = new File(zippedPath);
- try (InputStream is = new FileInputStream(bugreportFile);
+ final File bugreportZippedFile = new File(zippedPath);
+ try (InputStream is = new FileInputStream(info.bugreportFile);
ZipOutputStream zos = new ZipOutputStream(
new BufferedOutputStream(new FileOutputStream(bugreportZippedFile)))) {
- ZipEntry entry = new ZipEntry(bugreportFile.getName());
- entry.setTime(bugreportFile.lastModified());
- zos.putNextEntry(entry);
- int totalBytes = Streams.copy(is, zos);
- Log.v(TAG, "size of original bugreport: " + totalBytes + " bytes");
- zos.closeEntry();
- // Delete old file;
- boolean deleted = bugreportFile.delete();
+ addEntry(zos, info.bugreportFile.getName(), is);
+ // Delete old file
+ final boolean deleted = info.bugreportFile.delete();
if (deleted) {
Log.v(TAG, "deleted original bugreport (" + bugreportPath + ")");
} else {
Log.e(TAG, "could not delete original bugreport (" + bugreportPath + ")");
}
- return bugreportZippedFile;
+ info.bugreportFile = bugreportZippedFile;
} catch (IOException e) {
Log.e(TAG, "exception zipping file " + zippedPath, e);
- return bugreportFile; // Return original.
}
}
/**
+ * Adds the user-provided info into the bugreport zip file.
+ * <p>
+ * If user provided a title, it will be saved into a {@code title.txt} entry; similarly, the
+ * description will be saved on {@code description.txt}.
+ */
+ private void addDetailsToZipFile(BugreportInfo info) {
+ // It's not possible to add a new entry into an existing file, so we need to create a new
+ // zip, copy all entries, then rename it.
+ final File dir = info.bugreportFile.getParentFile();
+ final File tmpZip = new File(dir, "tmp-" + info.bugreportFile.getName());
+ Log.d(TAG, "Writing temporary zip file (" + tmpZip + ")");
+ try (ZipFile oldZip = new ZipFile(info.bugreportFile);
+ ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmpZip))) {
+
+ // First copy contents from original zip.
+ Enumeration<? extends ZipEntry> entries = oldZip.entries();
+ while (entries.hasMoreElements()) {
+ final ZipEntry entry = entries.nextElement();
+ final String entryName = entry.getName();
+ if (!entry.isDirectory()) {
+ addEntry(zos, entryName, entry.getTime(), oldZip.getInputStream(entry));
+ } else {
+ Log.w(TAG, "skipping directory entry: " + entryName);
+ }
+ }
+
+ // Then add the user-provided info.
+ addEntry(zos, "title.txt", info.title);
+ addEntry(zos, "description.txt", info.description);
+ } catch (IOException e) {
+ Log.e(TAG, "exception zipping file " + tmpZip, e);
+ return;
+ }
+
+ if (!tmpZip.renameTo(info.bugreportFile)) {
+ Log.e(TAG, "Could not rename " + tmpZip + " to " + info.bugreportFile);
+ }
+ }
+
+ private static void addEntry(ZipOutputStream zos, String entry, String text)
+ throws IOException {
+ if (DEBUG) Log.v(TAG, "adding entry '" + entry + "': " + text);
+ if (!TextUtils.isEmpty(text)) {
+ addEntry(zos, entry, new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)));
+ }
+ }
+
+ private static void addEntry(ZipOutputStream zos, String entryName, InputStream is)
+ throws IOException {
+ addEntry(zos, entryName, System.currentTimeMillis(), is);
+ }
+
+ private static void addEntry(ZipOutputStream zos, String entryName, long timestamp,
+ InputStream is) throws IOException {
+ final ZipEntry entry = new ZipEntry(entryName);
+ entry.setTime(timestamp);
+ zos.putNextEntry(entry);
+ final int totalBytes = Streams.copy(is, zos);
+ if (DEBUG) Log.v(TAG, "size of '" + entryName + "' entry: " + totalBytes + " bytes");
+ zos.closeEntry();
+ }
+
+ /**
* Find the best matching {@link Account} based on build properties.
*/
private static Account findSendToAccount(Context context) {
@@ -941,7 +1009,7 @@
return foundAccount;
}
- private static Uri getUri(Context context, File file) {
+ static Uri getUri(Context context, File file) {
return file != null ? FileProvider.getUriForFile(context, AUTHORITY, file) : null;
}
diff --git a/packages/Shell/src/com/android/shell/BugreportReceiver.java b/packages/Shell/src/com/android/shell/BugreportReceiver.java
index b818343..c8898b9 100644
--- a/packages/Shell/src/com/android/shell/BugreportReceiver.java
+++ b/packages/Shell/src/com/android/shell/BugreportReceiver.java
@@ -52,7 +52,7 @@
@Override
public void onReceive(Context context, Intent intent) {
// Clean up older bugreports in background
- cleanupOldFiles(intent);
+ cleanupOldFiles(this, intent, INTENT_BUGREPORT_FINISHED, MIN_KEEP_COUNT, MIN_KEEP_AGE);
// Delegate intent handling to service.
Intent serviceIntent = new Intent(context, BugreportProgressService.class);
@@ -60,8 +60,9 @@
context.startService(serviceIntent);
}
- private void cleanupOldFiles(Intent intent) {
- if (!INTENT_BUGREPORT_FINISHED.equals(intent.getAction())) {
+ static void cleanupOldFiles(BroadcastReceiver br, Intent intent, String expectedAction,
+ final int minCount, final long minAge) {
+ if (!expectedAction.equals(intent.getAction())) {
return;
}
final File bugreportFile = getFileExtra(intent, EXTRA_BUGREPORT);
@@ -69,12 +70,11 @@
Log.e(TAG, "Not deleting old files because file " + bugreportFile + " doesn't exist");
return;
}
- final PendingResult result = goAsync();
+ final PendingResult result = br.goAsync();
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
- FileUtils.deleteOlderFiles(
- bugreportFile.getParentFile(), MIN_KEEP_COUNT, MIN_KEEP_AGE);
+ FileUtils.deleteOlderFiles(bugreportFile.getParentFile(), minCount, minAge);
result.finish();
return null;
}
diff --git a/packages/Shell/src/com/android/shell/RemoteBugreportReceiver.java b/packages/Shell/src/com/android/shell/RemoteBugreportReceiver.java
new file mode 100644
index 0000000..6f783a1
--- /dev/null
+++ b/packages/Shell/src/com/android/shell/RemoteBugreportReceiver.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.shell;
+
+import static com.android.shell.BugreportProgressService.EXTRA_BUGREPORT;
+import static com.android.shell.BugreportProgressService.INTENT_REMOTE_BUGREPORT_FINISHED;
+import static com.android.shell.BugreportProgressService.INTENT_REMOTE_BUGREPORT_DISPATCH;
+import static com.android.shell.BugreportProgressService.getFileExtra;
+import static com.android.shell.BugreportProgressService.getUri;
+import static com.android.shell.BugreportReceiver.cleanupOldFiles;
+
+import java.io.File;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.UserHandle;
+
+/**
+ * Receiver that handles finished remote bugreports, by re-sending
+ * the intent with appended bugreport zip file URI.
+ *
+ * <p> Remote bugreport never contains a screenshot.
+ */
+public class RemoteBugreportReceiver extends BroadcastReceiver {
+
+ private static final String BUGREPORT_MIMETYPE = "application/vnd.android.bugreport";
+ private static final String EXTRA_REMOTE_BUGREPORT_HASH =
+ "android.intent.extra.REMOTE_BUGREPORT_HASH";
+
+ /** Always keep just the last remote bugreport zip file */
+ private static final int MIN_KEEP_COUNT = 1;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ cleanupOldFiles(this, intent, INTENT_REMOTE_BUGREPORT_FINISHED, MIN_KEEP_COUNT, 0);
+
+ final File bugreportFile = getFileExtra(intent, EXTRA_BUGREPORT);
+ final Uri bugreportUri = getUri(context, bugreportFile);
+ final String bugreportHash = intent.getStringExtra(EXTRA_REMOTE_BUGREPORT_HASH);
+
+ final Intent newIntent = new Intent(INTENT_REMOTE_BUGREPORT_DISPATCH);
+ newIntent.setDataAndType(bugreportUri, BUGREPORT_MIMETYPE);
+ newIntent.putExtra(EXTRA_REMOTE_BUGREPORT_HASH, bugreportHash);
+ context.sendBroadcastAsUser(newIntent, UserHandle.SYSTEM,
+ android.Manifest.permission.DUMP);
+ }
+}
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index 8e8924a..d1a07ea 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -60,6 +60,7 @@
import android.support.test.uiautomator.UiObject;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.LargeTest;
+import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
@@ -103,6 +104,12 @@
private static final String NAME = "BUG, Y U NO REPORT?";
private static final String NEW_NAME = "Bug_Forrest_Bug";
private static final String TITLE = "Wimbugdom Champion 2015";
+
+ private static final String NO_DESCRIPTION = null;
+ private static final String NO_NAME = null;
+ private static final String NO_SCREENSHOT = null;
+ private static final String NO_TITLE = null;
+
private String mDescription;
private String mPlainTextPath;
@@ -157,8 +164,8 @@
Bundle extras =
sendBugreportFinishedAndGetSharedIntent(PID, mPlainTextPath, mScreenshotPath);
- assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, NAME, ZIP_FILE,
- null, 1, true);
+ assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, ZIP_FILE,
+ NAME, NO_TITLE, NO_DESCRIPTION, 1, true);
assertServiceNotRunning();
}
@@ -174,13 +181,14 @@
Bundle extras =
sendBugreportFinishedAndGetSharedIntent(PID, mPlainTextPath, mScreenshotPath);
- assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, NAME, ZIP_FILE,
- null, 2, true);
+ assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, ZIP_FILE,
+ NAME, NO_TITLE, NO_DESCRIPTION, 2, true);
assertServiceNotRunning();
}
- public void testProgress_changeDetails() throws Exception {
+ public void testProgress_changeDetailsInvalidInput() throws Exception {
+
resetProperties();
sendBugreportStarted(1000);
waitForScreenshotButtonEnabled(true);
@@ -219,8 +227,47 @@
Bundle extras = sendBugreportFinishedAndGetSharedIntent(PID, mPlainTextPath,
mScreenshotPath);
- assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, NEW_NAME, TITLE,
- mDescription, 1, true);
+ assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, TITLE,
+ NEW_NAME, TITLE, mDescription, 1, true);
+
+ assertServiceNotRunning();
+ }
+
+ public void testProgress_changeDetailsPlainBugreport() throws Exception {
+ changeDetailsTest(true);
+ }
+
+ public void testProgress_changeDetailsZippedBugreport() throws Exception {
+ changeDetailsTest(false);
+ }
+
+ public void changeDetailsTest(boolean plainText) throws Exception {
+
+ resetProperties();
+ sendBugreportStarted(1000);
+ waitForScreenshotButtonEnabled(true);
+
+ DetailsUi detailsUi = new DetailsUi(mUiBot);
+
+ // Check initial name.
+ String actualName = detailsUi.nameField.getText().toString();
+ assertEquals("Wrong value on field 'name'", NAME, actualName);
+
+ // Change fields.
+ detailsUi.reOpen();
+ detailsUi.nameField.setText(NEW_NAME);
+ detailsUi.titleField.setText(TITLE);
+ detailsUi.descField.setText(mDescription);
+
+ detailsUi.clickOk();
+
+ assertPropertyValue(NAME_PROPERTY, NEW_NAME);
+ assertProgressNotification(NEW_NAME, "0.00%");
+
+ Bundle extras = sendBugreportFinishedAndGetSharedIntent(PID,
+ plainText? mPlainTextPath : mZipPath, mScreenshotPath);
+ assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, TITLE,
+ NEW_NAME, TITLE, mDescription, 1, true);
assertServiceNotRunning();
}
@@ -270,8 +317,8 @@
// Finally, share bugreport.
Bundle extras = acceptBugreportAndGetSharedIntent();
- assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, NAME, TITLE,
- mDescription, 1, waitScreenshot);
+ assertActionSendMultiple(extras, BUGREPORT_FILE, BUGREPORT_CONTENT, PID, TITLE,
+ NAME, TITLE, mDescription, 1, waitScreenshot);
assertServiceNotRunning();
}
@@ -296,7 +343,7 @@
// Share the bugreport.
mUiBot.chooseActivity(UI_NAME);
Bundle extras = mListener.getExtras();
- assertActionSendMultiple(extras, BUGREPORT_CONTENT, null);
+ assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT);
// Make sure it's hidden now.
int newState = BugreportPrefs.getWarningState(mContext, BugreportPrefs.STATE_UNKNOWN);
@@ -314,13 +361,13 @@
}
public void testBugreportFinished_plainBugreportAndNoScreenshot() throws Exception {
- Bundle extras = sendBugreportFinishedAndGetSharedIntent(mPlainTextPath, null);
- assertActionSendMultiple(extras, BUGREPORT_CONTENT, null);
+ Bundle extras = sendBugreportFinishedAndGetSharedIntent(mPlainTextPath, NO_SCREENSHOT);
+ assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT);
}
public void testBugreportFinished_zippedBugreportAndNoScreenshot() throws Exception {
- Bundle extras = sendBugreportFinishedAndGetSharedIntent(mZipPath, null);
- assertActionSendMultiple(extras, BUGREPORT_CONTENT, null);
+ Bundle extras = sendBugreportFinishedAndGetSharedIntent(mZipPath, NO_SCREENSHOT);
+ assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT);
}
private void cancelExistingNotifications() {
@@ -426,8 +473,8 @@
*/
private void assertActionSendMultiple(Bundle extras, String bugreportContent,
String screenshotContent) throws IOException {
- assertActionSendMultiple(extras, bugreportContent, screenshotContent, PID, null, ZIP_FILE,
- null, 0, false);
+ assertActionSendMultiple(extras, bugreportContent, screenshotContent, PID, ZIP_FILE,
+ NO_NAME, NO_TITLE, NO_DESCRIPTION, 0, false);
}
/**
@@ -437,14 +484,16 @@
* @param bugreportContent expected content in the bugreport file
* @param screenshotContent expected content in the screenshot file (sent by dumpstate), if any
* @param pid emulated dumpstate pid
- * @param name bugreport name as provided by the user
- * @param title bugreport name as provided by the user (or received by dumpstate)
+ * @param name expected subject
+ * @param name bugreport name as provided by the user (or received by dumpstate)
+ * @param title bugreport name as provided by the user
* @param description bugreport description as provided by the user
* @param numberScreenshots expected number of screenshots taken by Shell.
* @param renamedScreenshots whether the screenshots are expected to be renamed
*/
private void assertActionSendMultiple(Bundle extras, String bugreportContent,
- String screenshotContent, int pid, String name, String title, String description,
+ String screenshotContent, int pid, String subject,
+ String name, String title, String description,
int numberScreenshots, boolean renamedScreenshots) throws IOException {
String body = extras.getString(Intent.EXTRA_TEXT);
assertContainsRegex("missing build info",
@@ -455,7 +504,7 @@
assertContainsRegex("missing description", description, body);
}
- assertEquals("wrong subject", title, extras.getString(Intent.EXTRA_SUBJECT));
+ assertEquals("wrong subject", subject, extras.getString(Intent.EXTRA_SUBJECT));
List<Uri> attachments = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
int expectedNumberScreenshots = numberScreenshots;
@@ -478,6 +527,12 @@
}
assertNotNull("did not get .zip attachment", zipUri);
assertZipContent(zipUri, BUGREPORT_FILE, BUGREPORT_CONTENT);
+ if (!TextUtils.isEmpty(title)) {
+ assertZipContent(zipUri, "title.txt", title);
+ }
+ if (!TextUtils.isEmpty(description)) {
+ assertZipContent(zipUri, "description.txt", description);
+ }
// URI of the screenshot taken by dumpstate.
Uri externalScreenshotUri = null;
diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags
index 6a10c2c..bc18221 100644
--- a/packages/SystemUI/proguard.flags
+++ b/packages/SystemUI/proguard.flags
@@ -10,6 +10,7 @@
public void setGlowScale(float);
}
+-keep class com.android.systemui.statusbar.car.CarStatusBar
-keep class com.android.systemui.statusbar.phone.PhoneStatusBar
-keep class com.android.systemui.statusbar.tv.TvStatusBar
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..6242084
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_carmode.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_carmode.png
new file mode 100644
index 0000000..1b37a47
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home_carmode.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home_carmode.png
new file mode 100644
index 0000000..9e05758
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_home_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..2fcfdde
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..48708a5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..3d73184
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xxhdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-ldrtl-xxhdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..786935d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xxhdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..e4bd4bc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_carmode.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_carmode.png
new file mode 100644
index 0000000..94ccf79
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_carmode.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_carmode.png
new file mode 100644
index 0000000..980bbbc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..201be3b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_carmode.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_carmode.png
new file mode 100644
index 0000000..2770d62
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home_carmode.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home_carmode.png
new file mode 100644
index 0000000..8ac6493
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_home_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..8e3678b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime_carmode.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime_carmode.png
new file mode 100644
index 0000000..6c7cb058
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_back_ime_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home_carmode.png b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home_carmode.png
new file mode 100644
index 0000000..ea2b108
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxhdpi/ic_sysbar_home_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_carmode.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_carmode.png
new file mode 100644
index 0000000..3e11023
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_ime_carmode.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_ime_carmode.png
new file mode 100644
index 0000000..fe8213d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_back_ime_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_home_carmode.png b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_home_carmode.png
new file mode 100644
index 0000000..c117efd
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xxxhdpi/ic_sysbar_home_carmode.png
Binary files differ
diff --git a/packages/SystemUI/res/layout/car_navigation_bar.xml b/packages/SystemUI/res/layout/car_navigation_bar.xml
new file mode 100644
index 0000000..f7f673d
--- /dev/null
+++ b/packages/SystemUI/res/layout/car_navigation_bar.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2016, 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.
+*/
+-->
+
+<com.android.systemui.statusbar.car.CarNavigationBarView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:background="@drawable/system_bar_background">
+
+ <!-- phone.NavigationBarView has rot0 and rot90 but we expect the car head unit to have a fixed
+ rotation so skip this level of the heirarchy.
+ -->
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="horizontal"
+ android:clipChildren="false"
+ android:clipToPadding="false"
+ android:id="@+id/nav_buttons"
+ android:animateLayoutChanges="true">
+
+ <!-- Buttons get populated here from a car_arrays.xml. -->
+ </LinearLayout>
+
+ <!-- lights out layout to match exactly -->
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="horizontal"
+ android:id="@+id/lights_out"
+ android:visibility="gone">
+ <!-- Must match nav_buttons. -->
+ </LinearLayout>
+
+</com.android.systemui.statusbar.car.CarNavigationBarView>
diff --git a/packages/SystemUI/res/layout/keyboard_shortcuts_view.xml b/packages/SystemUI/res/layout/keyboard_shortcuts_view.xml
new file mode 100644
index 0000000..460433e
--- /dev/null
+++ b/packages/SystemUI/res/layout/keyboard_shortcuts_view.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/keyboard_shortcuts_wrapper"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="40dp"
+ android:focusable="true">
+</RelativeLayout>
diff --git a/packages/SystemUI/res/values/arrays_car.xml b/packages/SystemUI/res/values/arrays_car.xml
new file mode 100644
index 0000000..230479d
--- /dev/null
+++ b/packages/SystemUI/res/values/arrays_car.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2015, 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.
+*/
+-->
+<resources>
+ <!-- These should be overriden in an overlay. The default implementation is empty.
+ There needs to be correspondence per index between these arrays, which means that if there
+ isn't a longpress action associated with a shortcut item, put in an empty item to make
+ sure everything lines up.
+ -->
+ <array name="car_shortcut_icons" />
+ <array name="car_shortcut_intent_uris" />
+ <array name="car_shortcut_longpress_intent_uris" />
+</resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 40e8b50..955af82 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -172,7 +172,7 @@
<integer name="recents_nav_bar_scrim_enter_duration">400</integer>
<!-- The animation duration for animating the removal of a task view. -->
- <integer name="recents_animate_task_view_remove_duration">250</integer>
+ <integer name="recents_animate_task_view_remove_duration">175</integer>
<!-- The animation duration for scrolling the stack to a particular item. -->
<integer name="recents_animate_task_stack_scroll_duration">200</integer>
diff --git a/packages/SystemUI/res/values/internal.xml b/packages/SystemUI/res/values/internal.xml
index 67685ee..e0d3cd2 100644
--- a/packages/SystemUI/res/values/internal.xml
+++ b/packages/SystemUI/res/values/internal.xml
@@ -17,6 +17,7 @@
<resources>
<dimen name="status_bar_height">@*android:dimen/status_bar_height</dimen>
<dimen name="navigation_bar_height">@*android:dimen/navigation_bar_height</dimen>
+ <dimen name="navigation_bar_height_car_mode">@*android:dimen/navigation_bar_height_car_mode</dimen>
<color name="screen_pinning_primary_text">@*android:color/primary_text_default_material_light</color>
</resources>
diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml
index f02f763..90cd394 100644
--- a/packages/SystemUI/res/xml/tuner_prefs.xml
+++ b/packages/SystemUI/res/xml/tuner_prefs.xml
@@ -80,7 +80,7 @@
android:summary="@string/overview_initial_state_paging_desc" />
<com.android.systemui.tuner.TunerSwitch
- android:key="overview_fast_toggle"
+ android:key="overview_fast_toggle_via_button"
android:title="@string/overview_fast_toggle_via_button"
android:summary="@string/overview_fast_toggle_via_button_desc" />
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 57074df..e4d8067 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -43,8 +43,10 @@
import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEvent;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
+import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
+import com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideHistoryEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
@@ -56,8 +58,7 @@
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
-import com.android.systemui.recents.events.ui.DismissTaskEvent;
-import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
+import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.events.ui.ShowApplicationInfoEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
@@ -67,7 +68,6 @@
import com.android.systemui.recents.events.ui.focus.FocusPreviousTaskViewEvent;
import com.android.systemui.recents.history.RecentsHistoryView;
import com.android.systemui.recents.misc.DozeTrigger;
-import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsPackageMonitor;
import com.android.systemui.recents.model.RecentsTaskLoadPlan;
@@ -76,7 +76,6 @@
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.SystemBarScrimViews;
-import com.android.systemui.recents.views.ViewAnimation;
import com.android.systemui.statusbar.BaseStatusBar;
import java.util.ArrayList;
@@ -274,7 +273,7 @@
// If we have a focused Task, launch that Task now
if (mRecentsView.launchPreviousTask()) return true;
// If none of the other cases apply, then just go Home
- dismissRecentsToHome(true);
+ dismissRecentsToHome(true /* animateTaskViews */);
}
return false;
}
@@ -288,7 +287,7 @@
// If we have a focused Task, launch that Task now
if (mRecentsView.launchFocusedTask()) return true;
// If none of the other cases apply, then just go Home
- dismissRecentsToHome(true);
+ dismissRecentsToHome(true /* animateTaskViews */);
return true;
}
return false;
@@ -297,32 +296,18 @@
/**
* Dismisses Recents directly to Home without checking whether it is currently visible.
*/
- void dismissRecentsToHome(boolean animated) {
- if (animated) {
- ReferenceCountedTrigger exitTrigger = new ReferenceCountedTrigger();
- exitTrigger.increment();
- exitTrigger.addLastDecrementRunnable(mFinishLaunchHomeRunnable);
- exitTrigger.addLastDecrementRunnable(new Runnable() {
- @Override
- public void run() {
- Recents.getSystemServices().sendCloseSystemWindows(
- BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
- }
- });
- mRecentsView.startExitToHomeAnimation(
- new ViewAnimation.TaskViewExitContext(exitTrigger));
- exitTrigger.decrement();
- } else {
- mFinishLaunchHomeRunnable.run();
- Recents.getSystemServices().sendCloseSystemWindows(
- BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
- }
- }
-
- /** Dismisses Recents directly to Home without transition animation. */
- void dismissRecentsToHomeWithoutTransitionAnimation() {
- finish();
- overridePendingTransition(0, 0);
+ void dismissRecentsToHome(boolean animateTaskViews) {
+ DismissRecentsToHomeAnimationStarted dismissEvent =
+ new DismissRecentsToHomeAnimationStarted(animateTaskViews);
+ dismissEvent.addPostAnimationCallback(mFinishLaunchHomeRunnable);
+ dismissEvent.addPostAnimationCallback(new Runnable() {
+ @Override
+ public void run() {
+ Recents.getSystemServices().sendCloseSystemWindows(
+ BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
+ }
+ });
+ EventBus.getDefault().send(dismissEvent);
}
/** Dismisses Recents directly to Home if we currently aren't transitioning. */
@@ -609,7 +594,7 @@
if (!dismissHistory()) {
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
if (launchState.launchedFromHome) {
- dismissRecentsToHome(true);
+ dismissRecentsToHome(true /* animateTaskViews */);
} else {
dismissRecentsToLaunchTargetTaskOrHome();
}
@@ -650,13 +635,13 @@
hideEvent.addPostAnimationCallback(new Runnable() {
@Override
public void run() {
- dismissRecentsToHome(true /* animated */);
+ dismissRecentsToHome(true /* animateTaskViews */);
}
});
EventBus.getDefault().send(hideEvent);
} else {
- dismissRecentsToHome(true /* animated */);
+ dismissRecentsToHome(true /* animateTaskViews */);
}
} else {
// Do nothing
@@ -665,12 +650,9 @@
public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
// Try and start the enter animation (or restart it on configuration changed)
- ReferenceCountedTrigger t = new ReferenceCountedTrigger();
- ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t);
- ctx.postAnimationTrigger.increment();
if (RecentsDebugFlags.Static.EnableSearchBar) {
if (mSearchWidgetInfo != null) {
- ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
+ event.addPostAnimationCallback(new Runnable() {
@Override
public void run() {
// Start listening for widget package changes if there is one bound
@@ -681,8 +663,6 @@
});
}
}
- mRecentsView.startEnterRecentsAnimation(ctx);
- ctx.postAnimationTrigger.decrement();
}
public final void onBusEvent(EnterRecentsWindowLastAnimationFrameEvent event) {
@@ -727,7 +707,7 @@
MetricsLogger.count(this, "overview_app_info", 1);
}
- public final void onBusEvent(DismissTaskEvent event) {
+ public final void onBusEvent(DeleteTaskDataEvent event) {
// Remove any stored data from the loader
RecentsTaskLoader loader = Recents.getTaskLoader();
loader.deleteTaskData(event.task, false);
@@ -743,7 +723,7 @@
mRecentsView.showEmptyView();
} else {
// Just go straight home (no animation necessary because there are no more task views)
- dismissRecentsToHome(false /* animated */);
+ dismissRecentsToHome(false /* animateTaskViews */);
}
// Keep track of all-deletions
@@ -756,7 +736,7 @@
public final void onBusEvent(LaunchTaskFailedEvent event) {
// Return to Home
- dismissRecentsToHome(true);
+ dismissRecentsToHome(true /* animateTaskViews */);
MetricsLogger.count(this, "overview_task_launch_failed", 1);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index cfbd1cb..67135d5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -19,7 +19,6 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
-import android.provider.Settings;
import com.android.systemui.R;
import com.android.systemui.recents.misc.SystemServicesProxy;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index fd00289..213018a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -338,7 +338,6 @@
if (topTask != null && ssp.isRecentsTopMost(topTask, isTopTaskHome)) {
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
- RecentsDebugFlags flags = Recents.getDebugFlags();
if (!launchState.launchedWithAltTab) {
// Notify recents to move onto the next task
EventBus.getDefault().post(new IterateRecentsEvent());
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java b/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java
index 5c49ac3..b0c8ff3 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/EventBus.java
@@ -27,7 +27,6 @@
import android.os.UserHandle;
import android.util.Log;
import android.util.MutableBoolean;
-
import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import java.lang.ref.WeakReference;
@@ -663,8 +662,6 @@
/**
* Registers a new subscriber.
- *
- * @return return whether or not this
*/
private void registerSubscriber(Object subscriber, int priority,
MutableBoolean hasInterprocessEventsChangedOut) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/DismissRecentsToHomeAnimationStarted.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/DismissRecentsToHomeAnimationStarted.java
index 5f3e830..e7be858 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/DismissRecentsToHomeAnimationStarted.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/DismissRecentsToHomeAnimationStarted.java
@@ -21,6 +21,11 @@
/**
* This is sent when the task animation when dismissing Recents starts.
*/
-public class DismissRecentsToHomeAnimationStarted extends EventBus.Event {
- // Simple event
+public class DismissRecentsToHomeAnimationStarted extends EventBus.AnimatedEvent {
+
+ public final boolean animated;
+
+ public DismissRecentsToHomeAnimationStarted(boolean animated) {
+ this.animated = animated;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/EnterRecentsWindowAnimationCompletedEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/EnterRecentsWindowAnimationCompletedEvent.java
index b31f320..918875a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/EnterRecentsWindowAnimationCompletedEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/EnterRecentsWindowAnimationCompletedEvent.java
@@ -23,6 +23,6 @@
* we can start in-app animations so that they don't conflict with the window transition into
* Recents.
*/
-public class EnterRecentsWindowAnimationCompletedEvent extends EventBus.Event {
+public class EnterRecentsWindowAnimationCompletedEvent extends EventBus.AnimatedEvent {
// Simple event
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/ExitRecentsWindowFirstAnimationFrameEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/ExitRecentsWindowFirstAnimationFrameEvent.java
similarity index 94%
rename from packages/SystemUI/src/com/android/systemui/recents/ExitRecentsWindowFirstAnimationFrameEvent.java
rename to packages/SystemUI/src/com/android/systemui/recents/events/activity/ExitRecentsWindowFirstAnimationFrameEvent.java
index 8ae8c53..fa806eb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/ExitRecentsWindowFirstAnimationFrameEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/ExitRecentsWindowFirstAnimationFrameEvent.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.recents;
+package com.android.systemui.recents.events.activity;
import com.android.systemui.recents.events.EventBus;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/HideHistoryEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/HideHistoryEvent.java
index e85dea3..af3eeb0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/HideHistoryEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/HideHistoryEvent.java
@@ -17,7 +17,6 @@
package com.android.systemui.recents.events.activity;
import com.android.systemui.recents.events.EventBus;
-import com.android.systemui.recents.misc.ReferenceCountedTrigger;
/**
* This is sent when the history view will be closed.
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskEvent.java
index 457d81e..21b9301 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskEvent.java
@@ -22,7 +22,7 @@
import com.android.systemui.recents.views.TaskView;
/**
- * This is sent to launch a task from Recents.
+ * This event is sent to request that a particular task is launched.
*/
public class LaunchTaskEvent extends EventBus.Event {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskStartedEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskStartedEvent.java
new file mode 100644
index 0000000..3925ab1
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchTaskStartedEvent.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.events.activity;
+
+import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.views.TaskView;
+
+/**
+ * This event is sent following {@link LaunchTaskEvent} after the call to the system is made to
+ * start the task.
+ */
+public class LaunchTaskStartedEvent extends EventBus.AnimatedEvent {
+
+ public final TaskView taskView;
+ public final boolean screenPinningRequested;
+
+ public LaunchTaskStartedEvent(TaskView taskView, boolean screenPinningRequested) {
+ this.taskView = taskView;
+ this.screenPinningRequested = screenPinningRequested;
+ }
+
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/ShowHistoryEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/ShowHistoryEvent.java
index 94e5a97..b39d645 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/ShowHistoryEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/ShowHistoryEvent.java
@@ -17,7 +17,6 @@
package com.android.systemui.recents.events.activity;
import com.android.systemui.recents.events.EventBus;
-import com.android.systemui.recents.misc.ReferenceCountedTrigger;
/**
* This is sent when the history view button is clicked.
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java
index b94ed7b..7579cd8 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/TaskStackUpdatedEvent.java
@@ -16,7 +16,6 @@
package com.android.systemui.recents.events.activity;
-import com.android.systemui.recents.RecentsAppWidgetHost;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.model.TaskStack;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/DeleteTaskDataEvent.java
similarity index 80%
rename from packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskEvent.java
rename to packages/SystemUI/src/com/android/systemui/recents/events/ui/DeleteTaskDataEvent.java
index bcbbde8..4ed0270 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/DeleteTaskDataEvent.java
@@ -18,16 +18,16 @@
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.model.Task;
-import com.android.systemui.recents.views.TaskView;
/**
- * This is sent when a {@link Task} has been dismissed.
+ * This is sent when the data associated with a given {@link Task} should be deleted from the
+ * system.
*/
-public class DismissTaskEvent extends EventBus.Event {
+public class DeleteTaskDataEvent extends EventBus.Event {
public final Task task;
- public DismissTaskEvent(Task task) {
+ public DeleteTaskDataEvent(Task task) {
this.task = task;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskViewEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskViewEvent.java
index 968890a..1165f4e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskViewEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskViewEvent.java
@@ -21,15 +21,15 @@
import com.android.systemui.recents.views.TaskView;
/**
- * This is sent when a {@link TaskView} has been dismissed.
+ * This event is sent to request that the given {@link TaskView} is dismissed.
*/
-public class DismissTaskViewEvent extends EventBus.Event {
+public class DismissTaskViewEvent extends EventBus.AnimatedEvent {
- public final Task task;
public final TaskView taskView;
+ public final Task task;
- public DismissTaskViewEvent(Task task, TaskView taskView) {
- this.task = task;
+ public DismissTaskViewEvent(TaskView taskView, Task task) {
this.taskView = taskView;
+ this.task = task;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskViewDismissedEvent.java
similarity index 75%
copy from packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskEvent.java
copy to packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskViewDismissedEvent.java
index bcbbde8..7bd0958 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/DismissTaskEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/TaskViewDismissedEvent.java
@@ -21,13 +21,15 @@
import com.android.systemui.recents.views.TaskView;
/**
- * This is sent when a {@link Task} has been dismissed.
+ * This event is sent when a {@link TaskView} has been dismissed and is no longer visible.
*/
-public class DismissTaskEvent extends EventBus.Event {
+public class TaskViewDismissedEvent extends EventBus.Event {
public final Task task;
+ public final TaskView taskView;
- public DismissTaskEvent(Task task) {
+ public TaskViewDismissedEvent(Task task, TaskView taskView) {
this.task = task;
+ this.taskView = taskView;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/dragndrop/DragEndEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/dragndrop/DragEndEvent.java
index 8aa4631..73c282f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/dragndrop/DragEndEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/dragndrop/DragEndEvent.java
@@ -17,7 +17,6 @@
package com.android.systemui.recents.events.ui.dragndrop;
import com.android.systemui.recents.events.EventBus;
-import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.views.DropTarget;
import com.android.systemui.recents.views.TaskView;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/ui/focus/DismissFocusedTaskViewEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/ui/focus/DismissFocusedTaskViewEvent.java
index 9f3e9d5..df74018 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/events/ui/focus/DismissFocusedTaskViewEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/ui/focus/DismissFocusedTaskViewEvent.java
@@ -17,9 +17,10 @@
package com.android.systemui.recents.events.ui.focus;
import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.views.TaskView;
/**
- * Dismisses the currently focused task view.
+ * This event is sent to request that the currently focused {@link TaskView} is dismissed.
*/
public class DismissFocusedTaskViewEvent extends EventBus.Event {
// Simple event
diff --git a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java
index 72ec7b7..f0fa1da 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryAdapter.java
@@ -185,7 +185,6 @@
* remove the task from the TaskStack since the TaskStackView will also receive this event.
*/
public void removeTasks(String packageName, int userId) {
- boolean packagesRemoved = false;
for (int i = mRows.size() - 1; i >= 0; i--) {
Row row = mRows.get(i);
if (row.getViewType() == TASK_ROW_VIEW_TYPE) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryItemTouchCallbacks.java b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryItemTouchCallbacks.java
index e0a2730..a91ea7e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryItemTouchCallbacks.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryItemTouchCallbacks.java
@@ -22,7 +22,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.events.EventBus;
-import com.android.systemui.recents.events.ui.DismissTaskEvent;
+import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
/**
@@ -65,7 +65,7 @@
RecentsHistoryAdapter.TaskRow taskRow = (RecentsHistoryAdapter.TaskRow) row;
// Remove the task from the system
- EventBus.getDefault().send(new DismissTaskEvent(taskRow.task));
+ EventBus.getDefault().send(new DeleteTaskDataEvent(taskRow.task));
mAdapter.onTaskRemoved(taskRow.task, position);
// Keep track of deletions by swiping within history
diff --git a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryView.java b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryView.java
index 9524da5..a2f5159 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/history/RecentsHistoryView.java
@@ -35,7 +35,6 @@
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.PackagesChangedEvent;
import com.android.systemui.recents.misc.ReferenceCountedTrigger;
-import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.TaskStack;
/**
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/ReferenceCountedTrigger.java b/packages/SystemUI/src/com/android/systemui/recents/misc/ReferenceCountedTrigger.java
index 367f2e2..2637d88 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/ReferenceCountedTrigger.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/ReferenceCountedTrigger.java
@@ -18,8 +18,6 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
-import android.content.Context;
-import android.util.Log;
import java.util.ArrayList;
@@ -30,8 +28,8 @@
public class ReferenceCountedTrigger {
int mCount;
- ArrayList<Runnable> mFirstIncRunnables = new ArrayList<Runnable>();
- ArrayList<Runnable> mLastDecRunnables = new ArrayList<Runnable>();
+ ArrayList<Runnable> mFirstIncRunnables = new ArrayList<>();
+ ArrayList<Runnable> mLastDecRunnables = new ArrayList<>();
Runnable mErrorRunnable;
// Convenience runnables
@@ -107,16 +105,20 @@
mLastDecRunnables.clear();
}
- /** Convenience method to decrement this trigger as a runnable. */
- public Runnable decrementAsRunnable() {
- return mDecrementRunnable;
- }
- /** Convenience method to decrement this trigger as a animator listener. */
+ /**
+ * Convenience method to decrement this trigger as a animator listener. This listener is
+ * guarded to prevent being called back multiple times, and will trigger a decrement once and
+ * only once.
+ */
public Animator.AnimatorListener decrementOnAnimationEnd() {
return new AnimatorListenerAdapter() {
+ private boolean hasEnded;
+
@Override
public void onAnimationEnd(Animator animation) {
+ if (hasEnded) return;
decrement();
+ hasEnded = true;
}
};
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 108029d..dfcf41bc 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -68,7 +68,6 @@
import com.android.systemui.R;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.RecentsImpl;
-import com.android.systemui.statusbar.BaseStatusBar;
import java.io.IOException;
import java.util.ArrayList;
@@ -79,7 +78,6 @@
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT;
/**
@@ -470,7 +468,7 @@
try {
mIam.positionTaskInStack(taskId, stackId, 0);
- } catch (RemoteException e) {
+ } catch (RemoteException | IllegalArgumentException e) {
e.printStackTrace();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
index 2bf2ccb..086fb58 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java
@@ -88,6 +88,15 @@
}
/**
+ * Cancels an animation.
+ */
+ public static void cancelAnimation(Animator animator) {
+ if (animator != null) {
+ animator.cancel();
+ }
+ }
+
+ /**
* Cancels an animation ensuring that if it has listeners, onCancel and onEnd
* are not called.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index d6262ac..d8dfce5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -25,7 +25,6 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArraySet;
-import android.util.Log;
import com.android.systemui.Prefs;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsConfiguration;
@@ -115,8 +114,6 @@
* - least-recent to most-recent freeform tasks
*/
public synchronized void preloadPlan(RecentsTaskLoader loader, boolean isTopTaskHome) {
- RecentsConfiguration config = Recents.getConfiguration();
- SystemServicesProxy ssp = Recents.getSystemServices();
Resources res = mContext.getResources();
ArrayList<Task> allTasks = new ArrayList<>();
if (mRawTasks == null) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index d030fc1..f7e2b9d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -230,8 +230,7 @@
public void notifyTaskDataUnloaded(Bitmap defaultThumbnail, Drawable defaultApplicationIcon) {
icon = defaultApplicationIcon;
thumbnail = defaultThumbnail;
- int callbackCount = mCallbacks.size();
- for (int i = 0; i < callbackCount; i++) {
+ for (int i = mCallbacks.size() - 1; i >= 0; i--) {
mCallbacks.get(i).onTaskDataUnloaded();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index 5e720cb..856200d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -495,9 +495,6 @@
// Sort all the tasks to ensure they are ordered correctly
Collections.sort(newTasks, FREEFORM_LAST_ACTIVE_TIME_COMPARATOR);
- // TODO: Update screen pinning for the new front-most task post refactoring lockToTask out
- // of the Task
-
// Filter out the historical tasks from this new list
ArrayList<Task> stackTasks = new ArrayList<>();
ArrayList<Task> historyTasks = new ArrayList<>();
@@ -564,6 +561,22 @@
}
/**
+ * Returns the set of "freeform" tasks in the stack.
+ */
+ public ArrayList<Task> getFreeformTasks() {
+ ArrayList<Task> freeformTasks = new ArrayList<>();
+ ArrayList<Task> tasks = mStackTaskList.getTasks();
+ int taskCount = tasks.size();
+ for (int i = 0; i < taskCount; i++) {
+ Task task = tasks.get(i);
+ if (task.isFreeformTask()) {
+ freeformTasks.add(task);
+ }
+ }
+ return freeformTasks;
+ }
+
+ /**
* Computes a set of all the active and historical tasks ordered by their last active time.
*/
public ArrayList<Task> computeAllTasksList() {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java
index c0b8a9d..b8bbf51 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java
@@ -18,8 +18,6 @@
import android.graphics.Outline;
import android.graphics.Rect;
-import android.util.IntProperty;
-import android.util.Property;
import android.view.View;
import android.view.ViewOutlineProvider;
@@ -29,23 +27,11 @@
View mSourceView;
Rect mClipRect = new Rect();
Rect mClipBounds = new Rect();
+ Rect mLastClipBounds = new Rect();
int mCornerRadius;
float mAlpha = 1f;
final float mMinAlpha = 0.25f;
- public static final Property<AnimateableViewBounds, Integer> CLIP_BOTTOM =
- new IntProperty<AnimateableViewBounds>("clipBottom") {
- @Override
- public void setValue(AnimateableViewBounds object, int clip) {
- object.setClipBottom(clip, false /* force */);
- }
-
- @Override
- public Integer get(AnimateableViewBounds object) {
- return object.getClipBottom();
- }
- };
-
public AnimateableViewBounds(View source, int cornerRadius) {
mSourceView = source;
mCornerRadius = cornerRadius;
@@ -77,11 +63,9 @@
}
/** Sets the bottom clip. */
- public void setClipBottom(int bottom, boolean force) {
- if (bottom != mClipRect.bottom || force) {
- mClipRect.bottom = bottom;
- updateClipBounds();
- }
+ public void setClipBottom(int bottom) {
+ mClipRect.bottom = bottom;
+ updateClipBounds();
}
/** Returns the bottom clip. */
@@ -93,7 +77,10 @@
mClipBounds.set(Math.max(0, mClipRect.left), Math.max(0, mClipRect.top),
mSourceView.getWidth() - Math.max(0, mClipRect.right),
mSourceView.getHeight() - Math.max(0, mClipRect.bottom));
- mSourceView.setClipBounds(mClipBounds);
- mSourceView.invalidateOutline();
+ if (!mLastClipBounds.equals(mClipBounds)) {
+ mSourceView.setClipBounds(mClipBounds);
+ mSourceView.invalidateOutline();
+ mLastClipBounds.set(mClipBounds);
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java
index 7f907ef..fce916b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java
@@ -19,8 +19,6 @@
import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.util.Log;
-
import com.android.systemui.R;
import com.android.systemui.recents.model.Task;
@@ -33,9 +31,6 @@
*/
public class FreeformWorkspaceLayoutAlgorithm {
- private static final String TAG = "FreeformWorkspaceLayoutAlgorithm";
- private static final boolean DEBUG = false;
-
// Optimization, allows for quick lookup of task -> rect
private HashMap<Task.TaskKey, RectF> mTaskRectMap = new HashMap<>();
@@ -177,10 +172,6 @@
transformOut.rect.offset(stackLayout.mFreeformRect.left, stackLayout.mFreeformRect.top);
transformOut.visible = true;
transformOut.p = 1f;
-
- if (DEBUG) {
- Log.d(TAG, "getTransform: " + task.key + ", " + transformOut);
- }
return transformOut;
}
return null;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
index 0af7c1e..51cae86 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
@@ -32,15 +32,15 @@
import android.view.IAppTransitionAnimationSpecsFuture;
import android.view.WindowManagerGlobal;
import com.android.internal.annotations.GuardedBy;
-import com.android.systemui.recents.ExitRecentsWindowFirstAnimationFrameEvent;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
+import com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent;
import com.android.systemui.recents.events.activity.LaunchTaskFailedEvent;
+import com.android.systemui.recents.events.activity.LaunchTaskStartedEvent;
import com.android.systemui.recents.events.activity.LaunchTaskSucceededEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
-import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
@@ -90,7 +90,7 @@
*/
public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task,
final TaskStackView stackView, final TaskView taskView,
- final boolean lockToTask, final Rect bounds, int destinationStack) {
+ final boolean screenPinningRequested, final Rect bounds, int destinationStack) {
final ActivityOptions opts = ActivityOptions.makeBasic();
if (bounds != null) {
opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
@@ -109,7 +109,7 @@
EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
- if (lockToTask) {
+ if (screenPinningRequested) {
// Request screen pinning after the animation runs
mHandler.postDelayed(mStartScreenPinningRunnable, 350);
}
@@ -131,16 +131,19 @@
// task views, and we can launch immediately
startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
} else {
+ LaunchTaskStartedEvent launchStartedEvent = new LaunchTaskStartedEvent(taskView,
+ screenPinningRequested);
if (task.group != null && !task.group.isFrontMostTask(task)) {
- stackView.startLaunchTaskAnimation(taskView, new Runnable() {
+ launchStartedEvent.addPostAnimationCallback(new Runnable() {
@Override
public void run() {
startTaskActivity(stack, task, taskView, opts, transitionFuture,
animStartedListener);
}
- }, lockToTask);
+ });
+ EventBus.getDefault().send(launchStartedEvent);
} else {
- stackView.startLaunchTaskAnimation(taskView, null, lockToTask);
+ EventBus.getDefault().send(launchStartedEvent);
startTaskActivity(stack, task, taskView, opts, transitionFuture,
animStartedListener);
}
@@ -167,7 +170,7 @@
EventBus.getDefault().send(new LaunchTaskSucceededEvent(taskIndexFromFront));
} else {
// Dismiss the task if we fail to launch it
- EventBus.getDefault().send(new DismissTaskViewEvent(task, taskView));
+ taskView.dismissTask();
// Keep track of failed launches
EventBus.getDefault().send(new LaunchTaskFailedEvent());
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index c95c73b..e28e2b3 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -16,8 +16,9 @@
package com.android.systemui.recents.views;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -32,8 +33,8 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
-import com.android.internal.logging.MetricsLogger;
import android.widget.TextView;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivity;
@@ -43,7 +44,6 @@
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
-import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.HideHistoryButtonEvent;
import com.android.systemui.recents.events.activity.HideHistoryEvent;
@@ -65,6 +65,7 @@
import com.android.systemui.statusbar.FlingAnimationUtils;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
@@ -116,7 +117,6 @@
public RecentsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- Resources res = context.getResources();
setWillNotDraw(false);
mHandler = new Handler();
mTransitionHelper = new RecentsTransitionHelper(getContext(), mHandler);
@@ -145,14 +145,11 @@
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
mStack = stack;
- // Disable reusing task stack views until the visibility bug is fixed. b/25998134
- if (false && launchState.launchedReuseTaskStackViews) {
+ if (launchState.launchedReuseTaskStackViews) {
if (mTaskStackView != null) {
// If onRecentsHidden is not triggered, we need to the stack view again here
mTaskStackView.reset();
mTaskStackView.setStack(stack);
- removeView(mTaskStackView);
- addView(mTaskStackView);
} else {
mTaskStackView = new TaskStackView(getContext(), stack);
addView(mTaskStackView);
@@ -216,7 +213,6 @@
/** Launches the focused task from the first stack if possible */
public boolean launchFocusedTask() {
if (mTaskStackView != null) {
- TaskStack stack = mTaskStackView.getStack();
Task task = mTaskStackView.getFocusedTask();
if (task != null) {
TaskView taskView = mTaskStackView.getChildViewForTask(task);
@@ -246,7 +242,6 @@
/** Launches a given task. */
public boolean launchTask(Task task, Rect taskBounds, int destinationStack) {
if (mTaskStackView != null) {
- TaskStack stack = mTaskStackView.getStack();
// Iterate the stack views and try and find the given task.
List<TaskView> taskViews = mTaskStackView.getTaskViews();
int taskViewCount = taskViews.size();
@@ -262,39 +257,6 @@
return false;
}
- /** Requests all task stacks to start their enter-recents animation */
- public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) {
- // We have to increment/decrement the post animation trigger in case there are no children
- // to ensure that it runs
- ctx.postAnimationTrigger.increment();
- if (mTaskStackView != null) {
- mTaskStackView.startEnterRecentsAnimation(ctx);
- }
- ctx.postAnimationTrigger.decrement();
- }
-
- /** Requests all task stacks to start their exit-recents animation */
- public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
- // We have to increment/decrement the post animation trigger in case there are no children
- // to ensure that it runs
- ctx.postAnimationTrigger.increment();
- if (mTaskStackView != null) {
- mTaskStackView.startExitToHomeAnimation(ctx);
- }
- ctx.postAnimationTrigger.decrement();
-
- // Hide the history button
- int taskViewExitToHomeDuration = getResources().getInteger(
- R.integer.recents_task_exit_to_home_duration);
- hideHistoryButton(taskViewExitToHomeDuration);
-
- // If we are going home, cancel the previous task's window transition
- EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
-
- // Notify sof the exit animation
- EventBus.getDefault().send(new DismissRecentsToHomeAnimationStarted());
- }
-
/** Adds the search bar */
public void setSearchBar(RecentsAppWidgetHostView searchBar) {
// Remove the previous search bar if one exists
@@ -496,6 +458,16 @@
event.screenPinningRequested, event.targetTaskBounds, event.targetTaskStack);
}
+ public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
+ // Hide the history button
+ int taskViewExitToHomeDuration = getResources().getInteger(
+ R.integer.recents_task_exit_to_home_duration);
+ hideHistoryButton(taskViewExitToHomeDuration);
+
+ // If we are going home, cancel the previous task's window transition
+ EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
+ }
+
public final void onBusEvent(DragStartEvent event) {
updateVisibleDockRegions(mTouchHandler.getDockStatesForCurrentOrientation(),
TaskStack.DockState.NONE.viewState.dockAreaAlpha);
@@ -517,23 +489,25 @@
// Handle the case where we drop onto a dock region
if (event.dropTarget instanceof TaskStack.DockState) {
- final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
+ TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
+ TaskStackLayoutAlgorithm stackLayout = mTaskStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mTaskStackView.getScroller();
+ TaskViewTransform tmpTransform = new TaskViewTransform();
- // Remove the task after it is docked
- event.taskView.animate()
- .alpha(0f)
- .setDuration(150)
- .setInterpolator(mFastOutLinearInInterpolator)
- .setUpdateListener(null)
- .setListener(null)
- .withEndAction(new Runnable() {
- @Override
- public void run() {
- mTaskStackView.getStack().removeTask(event.task);
- }
- })
- .withLayer()
- .start();
+ // Remove the task view after it is docked
+ stackLayout.getStackTransform(event.task, stackScroller.getStackScroll(), tmpTransform,
+ null);
+ tmpTransform.scale = event.taskView.getScaleX();
+ tmpTransform.rect.offset(event.taskView.getTranslationX(),
+ event.taskView.getTranslationY());
+ mTaskStackView.updateTaskViewToTransform(event.taskView, tmpTransform,
+ new TaskViewAnimation(150, mFastOutLinearInInterpolator,
+ new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mTaskStackView.getStack().removeTask(event.task);
+ }
+ }));
// Dock the task and launch it
SystemServicesProxy ssp = Recents.getSystemServices();
@@ -613,21 +587,23 @@
private void showHistoryButton(final int duration,
final ReferenceCountedTrigger postHideHistoryAnimationTrigger) {
- mHistoryButton.setVisibility(View.VISIBLE);
- mHistoryButton.setAlpha(0f);
mHistoryButton.setText(getContext().getString(R.string.recents_history_label_format,
mStack.getHistoricalTasks().size()));
- postHideHistoryAnimationTrigger.addLastDecrementRunnable(new Runnable() {
- @Override
- public void run() {
- mHistoryButton.animate()
- .alpha(1f)
- .setDuration(duration)
- .setInterpolator(mFastOutSlowInInterpolator)
- .withLayer()
- .start();
- }
- });
+ if (mHistoryButton.getVisibility() == View.INVISIBLE) {
+ mHistoryButton.setVisibility(View.VISIBLE);
+ mHistoryButton.setAlpha(0f);
+ postHideHistoryAnimationTrigger.addLastDecrementRunnable(new Runnable() {
+ @Override
+ public void run() {
+ mHistoryButton.animate()
+ .alpha(1f)
+ .setDuration(duration)
+ .setInterpolator(mFastOutSlowInInterpolator)
+ .withLayer()
+ .start();
+ }
+ });
+ }
}
/**
@@ -641,20 +617,22 @@
private void hideHistoryButton(int duration,
final ReferenceCountedTrigger postHideStackAnimationTrigger) {
- mHistoryButton.animate()
- .alpha(0f)
- .setDuration(duration)
- .setInterpolator(mFastOutLinearInInterpolator)
- .withEndAction(new Runnable() {
- @Override
- public void run() {
- mHistoryButton.setVisibility(View.INVISIBLE);
- postHideStackAnimationTrigger.decrement();
- }
- })
- .withLayer()
- .start();
- postHideStackAnimationTrigger.increment();
+ if (mHistoryButton.getVisibility() == View.VISIBLE) {
+ mHistoryButton.animate()
+ .alpha(0f)
+ .setDuration(duration)
+ .setInterpolator(mFastOutLinearInInterpolator)
+ .withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ mHistoryButton.setVisibility(View.INVISIBLE);
+ postHideStackAnimationTrigger.decrement();
+ }
+ })
+ .withLayer()
+ .start();
+ postHideStackAnimationTrigger.increment();
+ }
}
/**
@@ -663,9 +641,7 @@
private void updateVisibleDockRegions(TaskStack.DockState[] newDockStates, int overrideAlpha) {
ArraySet<TaskStack.DockState> newDockStatesSet = new ArraySet<>();
if (newDockStates != null) {
- for (TaskStack.DockState dockState : newDockStates) {
- newDockStatesSet.add(dockState);
- }
+ Collections.addAll(newDockStatesSet, newDockStates);
}
for (TaskStack.DockState dockState : mVisibleDockStates) {
TaskStack.DockState.ViewState viewState = dockState.viewState;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
index 318801d..473334b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
@@ -26,7 +26,6 @@
import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragStartInitializeDropTargetsEvent;
-import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
@@ -58,9 +57,6 @@
*/
public class RecentsViewTouchHandler {
- private static final String TAG = "RecentsViewTouchHandler";
- private static final boolean DEBUG = false;
-
private RecentsView mRv;
private Task mDragTask;
@@ -128,7 +124,6 @@
mTaskView.setTranslationX(x);
mTaskView.setTranslationY(y);
- RecentsConfiguration config = Recents.getConfiguration();
if (!ssp.hasDockedTask()) {
// Add the dock state drop targets (these take priority)
TaskStack.DockState[] dockStates = getDockStatesForCurrentOrientation();
@@ -150,7 +145,6 @@
/**
* Handles dragging touch events
- * @param ev
*/
private void handleTouchEvent(MotionEvent ev) {
int action = ev.getAction();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java b/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java
index f84eb53..9618f212d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/SystemBarScrimViews.java
@@ -22,9 +22,6 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import com.android.systemui.R;
-import com.android.systemui.recents.Recents;
-import com.android.systemui.recents.RecentsActivityLaunchState;
-import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
@@ -64,8 +61,6 @@
*/
public void prepareEnterRecentsAnimation(boolean hasStatusBarScrim, boolean animateStatusBarScrim,
boolean hasNavBarScrim, boolean animateNavBarScrim) {
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
mHasNavBarScrim = hasStatusBarScrim;
mShouldAnimateStatusBarScrim = animateStatusBarScrim;
mHasStatusBarScrim = hasNavBarScrim;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java
new file mode 100644
index 0000000..80a35de
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.views;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.RectF;
+import android.view.View;
+import android.view.animation.AnimationUtils;
+import android.view.animation.Interpolator;
+import com.android.systemui.R;
+import com.android.systemui.recents.Recents;
+import com.android.systemui.recents.RecentsActivityLaunchState;
+import com.android.systemui.recents.RecentsConfiguration;
+import com.android.systemui.recents.misc.ReferenceCountedTrigger;
+import com.android.systemui.recents.model.Task;
+import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+
+import java.util.List;
+
+/**
+ * A helper class to create task view animations for {@link TaskView}s in a {@link TaskStackView},
+ * but not the contents of the {@link TaskView}s.
+ */
+public class TaskStackAnimationHelper {
+
+ /**
+ * Callbacks from the helper to coordinate view-content animations with view animations.
+ */
+ public interface Callbacks {
+ /**
+ * Callback to prepare for the start animation for the launch target {@link TaskView}.
+ */
+ void onPrepareLaunchTargetForEnterAnimation();
+
+ /**
+ * Callback to start the animation for the launch target {@link TaskView}.
+ */
+ void onStartLaunchTargetEnterAnimation(int duration, boolean screenPinningEnabled,
+ ReferenceCountedTrigger postAnimationTrigger);
+
+ /**
+ * Callback to start the animation for the launch target {@link TaskView} when it is
+ * launched from Recents.
+ */
+ void onStartLaunchTargetLaunchAnimation(int duration, boolean screenPinningRequested,
+ ReferenceCountedTrigger postAnimationTrigger);
+ }
+
+ private TaskStackView mStackView;
+
+ private Interpolator mFastOutSlowInInterpolator;
+ private Interpolator mFastOutLinearInInterpolator;
+ private Interpolator mQuintOutInterpolator;
+
+ private TaskViewTransform mTmpTransform = new TaskViewTransform();
+
+ public TaskStackAnimationHelper(Context context, TaskStackView stackView) {
+ mStackView = stackView;
+ mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
+ com.android.internal.R.interpolator.fast_out_slow_in);
+ mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
+ com.android.internal.R.interpolator.fast_out_linear_in);
+ mQuintOutInterpolator = AnimationUtils.loadInterpolator(context,
+ com.android.internal.R.interpolator.decelerate_quint);
+ }
+
+ /**
+ * Prepares the stack views and puts them in their initial animation state while visible, before
+ * the in-app enter animations start (after the window-transition completes).
+ */
+ public void prepareForEnterAnimation() {
+ RecentsConfiguration config = Recents.getConfiguration();
+ RecentsActivityLaunchState launchState = config.getLaunchState();
+ Resources res = mStackView.getResources();
+
+ TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mStackView.getScroller();
+ TaskStack stack = mStackView.getStack();
+ Task launchTargetTask = stack.getLaunchTarget();
+
+ // Break early if there are no tasks
+ if (stack.getStackTaskCount() == 0) {
+ return;
+ }
+
+ int offscreenY = stackLayout.mStackRect.bottom;
+ int taskViewAffiliateGroupEnterOffset = res.getDimensionPixelSize(
+ R.dimen.recents_task_view_affiliate_group_enter_offset);
+
+ // Prepare each of the task views for their enter animation from front to back
+ List<TaskView> taskViews = mStackView.getTaskViews();
+ for (int i = taskViews.size() - 1; i >= 0; i--) {
+ TaskView tv = taskViews.get(i);
+ Task task = tv.getTask();
+ boolean currentTaskOccludesLaunchTarget = (launchTargetTask != null &&
+ launchTargetTask.group.isTaskAboveTask(task, launchTargetTask));
+ boolean hideTask = (launchTargetTask != null &&
+ launchTargetTask.isFreeformTask() && task.isFreeformTask());
+
+ // Get the current transform for the task, which will be used to position it offscreen
+ stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
+ null);
+
+ if (hideTask) {
+ tv.setVisibility(View.INVISIBLE);
+ } else if (launchState.launchedHasConfigurationChanged) {
+ // Just load the views as-is
+ } else if (launchState.launchedFromAppWithThumbnail) {
+ if (task.isLaunchTarget) {
+ tv.onPrepareLaunchTargetForEnterAnimation();
+ } else if (currentTaskOccludesLaunchTarget) {
+ // Move the task view slightly lower so we can animate it in
+ RectF bounds = new RectF(mTmpTransform.rect);
+ bounds.offset(0, taskViewAffiliateGroupEnterOffset);
+ tv.setAlpha(0f);
+ tv.setLeftTopRightBottom((int) bounds.left, (int) bounds.top,
+ (int) bounds.right, (int) bounds.bottom);
+ }
+ } else if (launchState.launchedFromHome) {
+ // Move the task view off screen (below) so we can animate it in
+ RectF bounds = new RectF(mTmpTransform.rect);
+ bounds.offset(0, offscreenY);
+ tv.setLeftTopRightBottom((int) bounds.left, (int) bounds.top, (int) bounds.right,
+ (int) bounds.bottom);
+ }
+ }
+ }
+
+ /**
+ * Starts the in-app enter animation, which animates the {@link TaskView}s to their final places
+ * depending on how Recents was triggered.
+ */
+ public void startEnterAnimation(final ReferenceCountedTrigger postAnimationTrigger) {
+ RecentsConfiguration config = Recents.getConfiguration();
+ RecentsActivityLaunchState launchState = config.getLaunchState();
+ Resources res = mStackView.getResources();
+
+ TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mStackView.getScroller();
+ TaskStack stack = mStackView.getStack();
+ Task launchTargetTask = stack.getLaunchTarget();
+
+ // Break early if there are no tasks
+ if (stack.getStackTaskCount() == 0) {
+ return;
+ }
+
+ int taskViewEnterFromAppDuration = res.getInteger(
+ R.integer.recents_task_enter_from_app_duration);
+ int taskViewEnterFromHomeDuration = res.getInteger(
+ R.integer.recents_task_enter_from_home_duration);
+ int taskViewEnterFromHomeStaggerDelay = res.getInteger(
+ R.integer.recents_task_enter_from_home_stagger_delay);
+
+ // Create enter animations for each of the views from front to back
+ List<TaskView> taskViews = mStackView.getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = taskViewCount - 1; i >= 0; i--) {
+ TaskView tv = taskViews.get(i);
+ Task task = tv.getTask();
+ boolean currentTaskOccludesLaunchTarget = false;
+ if (launchTargetTask != null) {
+ currentTaskOccludesLaunchTarget = launchTargetTask.group.isTaskAboveTask(task,
+ launchTargetTask);
+ }
+
+ // Get the current transform for the task, which will be updated to the final transform
+ // to animate to depending on how recents was invoked
+ stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
+ null);
+
+ if (launchState.launchedFromAppWithThumbnail) {
+ if (task.isLaunchTarget) {
+ tv.onStartLaunchTargetEnterAnimation(taskViewEnterFromAppDuration,
+ mStackView.mScreenPinningEnabled, postAnimationTrigger);
+ } else {
+ // Animate the task up if it was occluding the launch target
+ if (currentTaskOccludesLaunchTarget) {
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(
+ taskViewEnterFromAppDuration, PhoneStatusBar.ALPHA_IN,
+ postAnimationTrigger.decrementOnAnimationEnd());
+ postAnimationTrigger.increment();
+ mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
+ }
+ }
+
+ } else if (launchState.launchedFromHome) {
+ // Animate the tasks up
+ int frontIndex = (taskViewCount - i - 1);
+ int delay = frontIndex * taskViewEnterFromHomeStaggerDelay;
+ int duration = taskViewEnterFromHomeDuration +
+ frontIndex * taskViewEnterFromHomeStaggerDelay;
+
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(delay,
+ duration, mQuintOutInterpolator,
+ postAnimationTrigger.decrementOnAnimationEnd());
+ postAnimationTrigger.increment();
+ mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
+ }
+ }
+ }
+
+ /**
+ * Starts an in-app animation to hide all the task views so that we can transition back home.
+ */
+ public void startExitToHomeAnimation(boolean animated,
+ ReferenceCountedTrigger postAnimationTrigger) {
+ Resources res = mStackView.getResources();
+ TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mStackView.getScroller();
+ TaskStack stack = mStackView.getStack();
+
+ // Break early if there are no tasks
+ if (stack.getStackTaskCount() == 0) {
+ return;
+ }
+
+ int offscreenY = stackLayout.mStackRect.bottom;
+ int taskViewExitToHomeDuration = res.getInteger(
+ R.integer.recents_task_exit_to_home_duration);
+
+ // Create the animations for each of the tasks
+ List<TaskView> taskViews = mStackView.getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = 0; i < taskViewCount; i++) {
+ TaskView tv = taskViews.get(i);
+ Task task = tv.getTask();
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(
+ animated ? taskViewExitToHomeDuration : 0, mFastOutLinearInInterpolator,
+ postAnimationTrigger.decrementOnAnimationEnd());
+ postAnimationTrigger.increment();
+
+ stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
+ null);
+ mTmpTransform.rect.offset(0, offscreenY);
+ mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
+ }
+ }
+
+ /**
+ * Starts the animation for the launching task view, hiding any tasks that might occlude the
+ * window transition for the launching task.
+ */
+ public void startLaunchTaskAnimation(TaskView launchingTaskView, boolean screenPinningRequested,
+ final ReferenceCountedTrigger postAnimationTrigger) {
+ Resources res = mStackView.getResources();
+ TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mStackView.getScroller();
+
+ int taskViewExitToAppDuration = res.getInteger(
+ R.integer.recents_task_exit_to_app_duration);
+ int taskViewAffiliateGroupEnterOffset = res.getDimensionPixelSize(
+ R.dimen.recents_task_view_affiliate_group_enter_offset);
+
+ Task launchingTask = launchingTaskView.getTask();
+ List<TaskView> taskViews = mStackView.getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = 0; i < taskViewCount; i++) {
+ TaskView tv = taskViews.get(i);
+ Task task = tv.getTask();
+ boolean currentTaskOccludesLaunchTarget = (launchingTask != null &&
+ launchingTask.group.isTaskAboveTask(task, launchingTask));
+
+ if (tv == launchingTaskView) {
+ tv.setClipViewInStack(false);
+ tv.onStartLaunchTargetLaunchAnimation(taskViewExitToAppDuration,
+ screenPinningRequested, postAnimationTrigger);
+ } else if (currentTaskOccludesLaunchTarget) {
+ // Animate this task out of view
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(
+ taskViewExitToAppDuration, mFastOutLinearInInterpolator,
+ postAnimationTrigger.decrementOnAnimationEnd());
+ postAnimationTrigger.increment();
+
+ stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
+ null);
+ mTmpTransform.alpha = 0f;
+ mTmpTransform.rect.offset(0, taskViewAffiliateGroupEnterOffset);
+ mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
+ }
+ }
+ }
+
+ /**
+ * Starts the delete animation for the specified {@link TaskView}.
+ */
+ public void startDeleteTaskAnimation(Task deleteTask, final TaskView deleteTaskView,
+ final ReferenceCountedTrigger postAnimationTrigger) {
+ Resources res = mStackView.getResources();
+ TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mStackView.getScroller();
+
+ int taskViewRemoveAnimDuration = res.getInteger(
+ R.integer.recents_animate_task_view_remove_duration);
+ int taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize(
+ R.dimen.recents_task_view_remove_anim_translation_x);
+
+ // Disabling clipping with the stack while the view is animating away
+ deleteTaskView.setClipViewInStack(false);
+
+ // Compose the new animation and transform and star the animation
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(taskViewRemoveAnimDuration,
+ PhoneStatusBar.ALPHA_OUT, new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ postAnimationTrigger.decrement();
+
+ // Re-enable clipping with the stack (we will reuse this view)
+ deleteTaskView.setClipViewInStack(true);
+ }
+ });
+ postAnimationTrigger.increment();
+
+ stackLayout.getStackTransform(deleteTask, stackScroller.getStackScroll(), mTmpTransform,
+ null);
+ mTmpTransform.alpha = 0f;
+ mTmpTransform.rect.offset(taskViewRemoveAnimTranslationXPx, 0);
+ mStackView.updateTaskViewToTransform(deleteTaskView, mTmpTransform, taskAnimation);
+ }
+
+ /**
+ * Starts the animation to hide the {@link TaskView}s when the history is shown. The history
+ * view's animation will be deferred until all the {@link TaskView}s are finished animating.
+ */
+ public void startShowHistoryAnimation(ReferenceCountedTrigger postAnimationTrigger) {
+ Resources res = mStackView.getResources();
+ TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ TaskStackViewScroller stackScroller = mStackView.getScroller();
+
+ int historyTransitionDuration = res.getInteger(
+ R.integer.recents_history_transition_duration);
+
+ List<TaskView> taskViews = mStackView.getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = taskViewCount - 1; i >= 0; i--) {
+ TaskView tv = taskViews.get(i);
+ Task task = tv.getTask();
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(
+ historyTransitionDuration, PhoneStatusBar.ALPHA_OUT,
+ postAnimationTrigger.decrementOnAnimationEnd());
+ postAnimationTrigger.increment();
+
+ stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
+ null);
+ mTmpTransform.alpha = 0f;
+ mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
+ }
+ }
+
+ /**
+ * Starts the animation to show the {@link TaskView}s when the history is hidden. The
+ * {@link TaskView} animations will be deferred until the history view has been animated away.
+ */
+ public void startHideHistoryAnimation(final ReferenceCountedTrigger postAnimationTrigger) {
+ final Resources res = mStackView.getResources();
+ final TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
+ final TaskStackViewScroller stackScroller = mStackView.getScroller();
+
+ final int historyTransitionDuration = res.getInteger(
+ R.integer.recents_history_transition_duration);
+
+ List<TaskView> taskViews = mStackView.getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = taskViewCount - 1; i >= 0; i--) {
+ final TaskView tv = taskViews.get(i);
+ postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
+ @Override
+ public void run() {
+ TaskViewAnimation taskAnimation = new TaskViewAnimation(
+ historyTransitionDuration, PhoneStatusBar.ALPHA_IN);
+ stackLayout.getStackTransform(tv.getTask(), stackScroller.getStackScroll(),
+ mTmpTransform, null);
+ mTmpTransform.alpha = 1f;
+ mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
+ }
+ });
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index 9d391b0..726e453 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -22,7 +22,6 @@
import android.graphics.Path;
import android.graphics.Rect;
import android.util.FloatProperty;
-import android.util.Log;
import android.util.Property;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
@@ -103,9 +102,6 @@
*/
public class TaskStackLayoutAlgorithm {
- private static final String TAG = "TaskStackViewLayoutAlgorithm";
- private static final boolean DEBUG = false;
-
// The scale factor to apply to the user movement in the stack to unfocus it
private static final float UNFOCUS_MULTIPLIER = 0.8f;
@@ -130,7 +126,7 @@
* allocate to the freeform workspace
* @param freeformBackgroundAlpha the background alpha for the freeform workspace
*/
- StackState(float freeformHeightPct, int freeformBackgroundAlpha) {
+ private StackState(float freeformHeightPct, int freeformBackgroundAlpha) {
this.freeformHeightPct = freeformHeightPct;
this.freeformBackgroundAlpha = freeformBackgroundAlpha;
}
@@ -212,7 +208,6 @@
}
Context mContext;
- private TaskStackView mStackView;
private Interpolator mLinearOutSlowInInterpolator;
private StackState mState = StackState.SPLIT;
@@ -280,9 +275,12 @@
// The freeform workspace layout
FreeformWorkspaceLayoutAlgorithm mFreeformLayoutAlgorithm;
- public TaskStackLayoutAlgorithm(Context context, TaskStackView stackView) {
+ // The transform to place TaskViews at the front and back of the stack respectively
+ TaskViewTransform mBackOfStackTransform = new TaskViewTransform();
+ TaskViewTransform mFrontOfStackTransform = new TaskViewTransform();
+
+ public TaskStackLayoutAlgorithm(Context context) {
Resources res = context.getResources();
- mStackView = stackView;
mFocusedRange = new Range(res.getFloat(R.integer.recents_layout_focused_range_min),
res.getFloat(R.integer.recents_layout_focused_range_max));
@@ -318,7 +316,7 @@
*/
public void setFocusState(float focusState) {
mFocusState = focusState;
- mStackView.requestSynchronizeStackViewsWithModel();
+ updateFrontBackTransforms();
}
/**
@@ -368,14 +366,7 @@
mUnfocusedCurveInterpolator = new FreePathInterpolator(mUnfocusedCurve);
mFocusedCurve = constructFocusedCurve();
mFocusedCurveInterpolator = new FreePathInterpolator(mFocusedCurve);
-
- if (DEBUG) {
- Log.d(TAG, "initialize");
- Log.d(TAG, "\tmFreeformRect: " + mFreeformRect);
- Log.d(TAG, "\tmStackRect: " + mStackRect);
- Log.d(TAG, "\tmTaskRect: " + mTaskRect);
- Log.d(TAG, "\tmSystemInsets: " + mSystemInsets);
- }
+ updateFrontBackTransforms();
}
/**
@@ -455,13 +446,6 @@
mInitialScrollP = (mNumStackTasks - 1) - mUnfocusedRange.getAbsoluteX(normX);
}
}
-
- if (DEBUG) {
- Log.d(TAG, "mNumStackTasks: " + mNumStackTasks);
- Log.d(TAG, "mNumFreeformTasks: " + mNumFreeformTasks);
- Log.d(TAG, "mMinScrollP: " + mMinScrollP);
- Log.d(TAG, "mMaxScrollP: " + mMaxScrollP);
- }
}
/**
@@ -471,7 +455,7 @@
Utilities.cancelAnimationWithoutCallbacks(mFocusStateAnimator);
if (mFocusState > STATE_UNFOCUSED) {
float delta = (float) yMovement / (UNFOCUS_MULTIPLIER * mStackRect.height());
- mFocusState -= Math.min(mFocusState, Math.abs(delta));
+ setFocusState(mFocusState - Math.min(mFocusState, Math.abs(delta)));
}
}
@@ -497,27 +481,23 @@
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
RecentsDebugFlags debugFlags = Recents.getDebugFlags();
if (launchState.launchedWithAltTab || debugFlags.isInitialStatePaging()) {
- return 1f;
+ return STATE_FOCUSED;
}
- return 0f;
+ return STATE_UNFOCUSED;
}
/**
- * Returns the task progress that would put the task just off the back of the stack.
+ * Returns the TaskViewTransform that would put the task just off the back of the stack.
*/
- public float getStackBackTaskProgress(float stackScroll) {
- float min = mUnfocusedRange.relativeMin +
- mFocusState * (mFocusedRange.relativeMin - mUnfocusedRange.relativeMin);
- return stackScroll + min;
+ public TaskViewTransform getBackOfStackTransform() {
+ return mBackOfStackTransform;
}
/**
- * Returns the task progress that would put the task just off the front of the stack.
+ * Returns the TaskViewTransform that would put the task just off the front of the stack.
*/
- public float getStackFrontTaskProgress(float stackScroll) {
- float max = mUnfocusedRange.relativeMax +
- mFocusState * (mFocusedRange.relativeMax - mUnfocusedRange.relativeMax);
- return stackScroll + max;
+ public TaskViewTransform getFrontOfStackTransform() {
+ return mFrontOfStackTransform;
}
/**
@@ -617,9 +597,6 @@
if (task.thumbnail != null) {
transformOut.thumbnailScale = (float) mTaskRect.width() / task.thumbnail.getWidth();
}
- if (DEBUG) {
- Log.d(TAG, "getTransform: " + task.key + ", " + transformOut);
- }
return transformOut;
}
}
@@ -769,4 +746,23 @@
p.cubicTo(0.5f, 1f - peekHeightPct, cpoint2X, cpoint2Y, 1f, 0f);
return p;
}
+
+ /**
+ * Updates the current transforms that would put a TaskView at the front and back of the stack.
+ */
+ private void updateFrontBackTransforms() {
+ // Return early if we have not yet initialized
+ if (mStackRect.isEmpty()) {
+ return;
+ }
+
+ float min = mUnfocusedRange.relativeMin +
+ mFocusState * (mFocusedRange.relativeMin - mUnfocusedRange.relativeMin);
+ float max = mUnfocusedRange.relativeMax +
+ mFocusState * (mFocusedRange.relativeMax - mUnfocusedRange.relativeMax);
+ getStackTransform(min, 0f, mBackOfStackTransform, null);
+ getStackTransform(max, 0f, mFrontOfStackTransform, null);
+ mBackOfStackTransform.visible = true;
+ mFrontOfStackTransform.visible = true;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 94fae13..9568fac 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -23,14 +23,12 @@
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
-import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.provider.Settings;
import android.util.IntProperty;
-import android.util.Log;
import android.util.Property;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -47,19 +45,22 @@
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
+import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.HideHistoryButtonEvent;
import com.android.systemui.recents.events.activity.HideHistoryEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchTaskEvent;
+import com.android.systemui.recents.events.activity.LaunchTaskStartedEvent;
import com.android.systemui.recents.events.activity.PackagesChangedEvent;
import com.android.systemui.recents.events.activity.ShowHistoryButtonEvent;
import com.android.systemui.recents.events.activity.ShowHistoryEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
-import com.android.systemui.recents.events.ui.DismissTaskEvent;
+import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
+import com.android.systemui.recents.events.ui.TaskViewDismissedEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragDropTargetChangedEvent;
@@ -76,7 +77,6 @@
import com.android.systemui.recents.model.TaskStack;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -91,9 +91,6 @@
TaskView.TaskViewCallbacks, TaskStackViewScroller.TaskStackViewScrollerCallbacks,
ViewPool.ViewPoolConsumer<TaskView, Task> {
- private final static String TAG = "TaskStackView";
- private final static boolean DEBUG = false;
-
private final static String KEY_SAVED_STATE_SUPER = "saved_instance_state_super";
private final static String KEY_SAVED_STATE_LAYOUT_FOCUSED_STATE =
"saved_instance_state_layout_focused_state";
@@ -105,6 +102,8 @@
private static final float HIDE_HISTORY_BUTTON_SCROLL_THRESHOLD = 0.3f;
private static final int DEFAULT_SYNC_STACK_DURATION = 200;
+ private static final int DRAG_SCALE_DURATION = 175;
+ private static final float DRAG_SCALE_FACTOR = 1.05f;
public static final Property<Drawable, Integer> DRAWABLE_ALPHA =
new IntProperty<Drawable>("drawableAlpha") {
@@ -123,37 +122,34 @@
TaskStackLayoutAlgorithm mLayoutAlgorithm;
TaskStackViewScroller mStackScroller;
TaskStackViewTouchHandler mTouchHandler;
+ TaskStackAnimationHelper mAnimationHelper;
GradientDrawable mFreeformWorkspaceBackground;
ObjectAnimator mFreeformWorkspaceBackgroundAnimator;
ViewPool<TaskView, Task> mViewPool;
+
+ ArrayList<TaskView> mTaskViews = new ArrayList<>();
ArrayList<TaskViewTransform> mCurrentTaskTransforms = new ArrayList<>();
+ TaskViewAnimation mDeferredTaskViewUpdateAnimation = null;
+
DozeTrigger mUIDozeTrigger;
Task mFocusedTask;
- // Optimizations
- int mStackViewsAnimationDuration;
+
int mTaskCornerRadiusPx;
- boolean mStackViewsDirty = true;
- boolean mStackViewsClipDirty = true;
+
+ boolean mTaskViewsClipDirty = true;
boolean mAwaitingFirstLayout = true;
boolean mEnterAnimationComplete = false;
- boolean mStartEnterAnimationRequestedAfterLayout;
- ViewAnimation.TaskViewEnterContext mStartEnterAnimationContext;
+ boolean mTouchExplorationEnabled;
+ boolean mScreenPinningEnabled;
Rect mTaskStackBounds = new Rect();
int[] mTmpVisibleRange = new int[2];
Rect mTmpRect = new Rect();
- RectF mTmpTaskRect = new RectF();
- TaskViewTransform mTmpStackBackTransform = new TaskViewTransform();
- TaskViewTransform mTmpStackFrontTransform = new TaskViewTransform();
HashMap<Task, TaskView> mTmpTaskViewMap = new HashMap<>();
- ArrayList<TaskView> mTaskViews = new ArrayList<>();
- List<TaskView> mImmutableTaskViews = new ArrayList<>();
List<TaskView> mTmpTaskViews = new ArrayList<>();
+ TaskViewTransform mTmpTransform = new TaskViewTransform();
LayoutInflater mInflater;
- boolean mTouchExplorationEnabled;
- boolean mScreenPinningEnabled;
-
Interpolator mFastOutSlowInInterpolator;
// A convenience update listener to request updating clipping of tasks
@@ -161,7 +157,8 @@
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- requestUpdateStackViewsClip();
+ mTaskViewsClipDirty = true;
+ invalidate();
}
};
@@ -189,10 +186,11 @@
setStack(stack);
mViewPool = new ViewPool<>(context, this);
mInflater = LayoutInflater.from(context);
- mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this);
+ mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context);
mStackScroller = new TaskStackViewScroller(context, mLayoutAlgorithm);
mStackScroller.setCallbacks(this);
mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller);
+ mAnimationHelper = new TaskStackAnimationHelper(context, this);
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
com.android.internal.R.interpolator.fast_out_slow_in);
mTaskCornerRadiusPx = res.getDimensionPixelSize(
@@ -265,12 +263,11 @@
mTaskViews.add((TaskView) v);
}
}
- mImmutableTaskViews = Collections.unmodifiableList(mTaskViews);
}
/** Gets the list of task views */
List<TaskView> getTaskViews() {
- return mImmutableTaskViews;
+ return mTaskViews;
}
/**
@@ -329,44 +326,16 @@
// Reset the stack state
mStack.reset();
- mStackViewsDirty = true;
- mStackViewsClipDirty = true;
+ mTaskViewsClipDirty = true;
mAwaitingFirstLayout = true;
mEnterAnimationComplete = false;
- if (mUIDozeTrigger != null) {
- mUIDozeTrigger.stopDozing();
- mUIDozeTrigger.resetTrigger();
- }
+ mUIDozeTrigger.stopDozing();
+ mUIDozeTrigger.resetTrigger();
mStackScroller.reset();
mLayoutAlgorithm.reset();
requestLayout();
}
- /** Requests that the views be synchronized with the model */
- void requestSynchronizeStackViewsWithModel() {
- requestSynchronizeStackViewsWithModel(0);
- }
- void requestSynchronizeStackViewsWithModel(int duration) {
- if (!mStackViewsDirty) {
- invalidate();
- mStackViewsDirty = true;
- }
- if (mAwaitingFirstLayout) {
- // Skip the animation if we are awaiting first layout
- mStackViewsAnimationDuration = 0;
- } else {
- mStackViewsAnimationDuration = Math.max(mStackViewsAnimationDuration, duration);
- }
- }
-
- /** Requests that the views clipping be updated. */
- void requestUpdateStackViewsClip() {
- if (!mStackViewsClipDirty) {
- invalidate();
- mStackViewsClipDirty = true;
- }
- }
-
/** Returns the stack algorithm for this task stack. */
public TaskStackLayoutAlgorithm getStackAlgorithm() {
return mLayoutAlgorithm;
@@ -400,15 +369,15 @@
TaskViewTransform frontTransform = null;
for (int i = taskCount - 1; i >= 0; i--) {
Task task = tasks.get(i);
+ TaskViewTransform transform = mLayoutAlgorithm.getStackTransform(task, stackScroll,
+ taskTransforms.get(i), frontTransform);
+
+ // For freeform tasks, only calculate the stack transform and skip the calculation of
+ // the visible stack indices
if (task.isFreeformTask()) {
continue;
}
- TaskViewTransform transform = mLayoutAlgorithm.getStackTransform(task, stackScroll,
- taskTransforms.get(i), frontTransform);
- if (DEBUG) {
- Log.d(TAG, "updateStackTransform: " + i + ", " + transform.visible);
- }
if (transform.visible) {
if (frontMostVisibleIndex < 0) {
frontMostVisibleIndex = i;
@@ -434,144 +403,155 @@
return frontMostVisibleIndex != -1 && backMostVisibleIndex != -1;
}
- /** Synchronizes the views with the model */
- boolean synchronizeStackViewsWithModel() {
- if (mStackViewsDirty) {
- // Get all the task transforms
- ArrayList<Task> tasks = mStack.getStackTasks();
- float stackScroll = mStackScroller.getStackScroll();
- int[] visibleStackRange = mTmpVisibleRange;
- boolean isValidVisibleStackRange = updateStackTransforms(mCurrentTaskTransforms, tasks,
- stackScroll, visibleStackRange);
- boolean hasStackBackTransform = false;
- boolean hasStackFrontTransform = false;
- if (DEBUG) {
- Log.d(TAG, "visibleRange: " + visibleStackRange[0] + " to " + visibleStackRange[1]);
- }
+ /**
+ * Updates the children {@link TaskView}s to match the tasks in the current {@link TaskStack}.
+ * This call does not update the {@link TaskView}s to their position in the layout except when
+ * they are initially picked up from the pool, when they will be placed in a suitable initial
+ * position.
+ */
+ private void bindTaskViewsWithStack() {
+ final float stackScroll = mStackScroller.getStackScroll();
+ final int[] visibleStackRange = mTmpVisibleRange;
- // Return all the invisible children to the pool
- mTmpTaskViewMap.clear();
- List<TaskView> taskViews = getTaskViews();
- int lastFocusedTaskIndex = -1;
- int taskViewCount = taskViews.size();
- for (int i = taskViewCount - 1; i >= 0; i--) {
- TaskView tv = taskViews.get(i);
- Task task = tv.getTask();
- int taskIndex = mStack.indexOfStackTask(task);
- if (task.isFreeformTask() ||
- visibleStackRange[1] <= taskIndex && taskIndex <= visibleStackRange[0]) {
- mTmpTaskViewMap.put(task, tv);
- } else {
- if (mTouchExplorationEnabled) {
- lastFocusedTaskIndex = taskIndex;
- resetFocusedTask(task);
- }
- if (DEBUG) {
- Log.d(TAG, "returning to pool: " + task.key);
- }
- mViewPool.returnViewToPool(tv);
+ // Get all the task transforms
+ final ArrayList<Task> tasks = mStack.getStackTasks();
+ final boolean isValidVisibleStackRange = updateStackTransforms(mCurrentTaskTransforms, tasks,
+ stackScroll, visibleStackRange);
+
+ // Return all the invisible children to the pool
+ mTmpTaskViewMap.clear();
+ final List<TaskView> taskViews = getTaskViews();
+ final int taskViewCount = taskViews.size();
+ int lastFocusedTaskIndex = -1;
+ for (int i = taskViewCount - 1; i >= 0; i--) {
+ final TaskView tv = taskViews.get(i);
+ final Task task = tv.getTask();
+ final int taskIndex = mStack.indexOfStackTask(task);
+
+ if (task.isFreeformTask() ||
+ visibleStackRange[1] <= taskIndex && taskIndex <= visibleStackRange[0]) {
+ mTmpTaskViewMap.put(task, tv);
+ } else {
+ if (mTouchExplorationEnabled) {
+ lastFocusedTaskIndex = taskIndex;
+ resetFocusedTask(task);
}
+ mViewPool.returnViewToPool(tv);
}
-
- // Pick up all the freeform tasks
- int firstVisStackIndex = isValidVisibleStackRange ? visibleStackRange[0] : 0;
- for (int i = mStack.getStackTaskCount() - 1; i >= firstVisStackIndex; i--) {
- Task task = tasks.get(i);
- if (!task.isFreeformTask()) {
- continue;
- }
- TaskViewTransform transform = mLayoutAlgorithm.getStackTransform(task, stackScroll,
- mCurrentTaskTransforms.get(i), null);
- TaskView tv = mTmpTaskViewMap.get(task);
- if (tv == null) {
- if (DEBUG) {
- Log.d(TAG, "picking up from pool: " + task.key);
- }
- tv = mViewPool.pickUpViewFromPool(task, task);
- } else {
- // Reattach it in the right z order
- int taskIndex = mStack.indexOfStackTask(task);
- int insertIndex = findTaskViewInsertIndex(task, taskIndex);
- if (insertIndex != getTaskViews().indexOf(tv)){
- detachViewFromParent(tv);
- attachViewToParent(tv, insertIndex, tv.getLayoutParams());
- }
- }
-
- // Animate the task into place
- tv.updateViewPropertiesToTaskTransform(transform, 0,
- mStackViewsAnimationDuration, mFastOutSlowInInterpolator,
- mRequestUpdateClippingListener);
-
- // Update the task views list after adding the new task view
- updateTaskViewsList();
- }
-
- // Pick up all the newly visible children and update all the existing children
- for (int i = visibleStackRange[0];
- isValidVisibleStackRange && i >= visibleStackRange[1]; i--) {
- Task task = tasks.get(i);
- TaskViewTransform transform = mCurrentTaskTransforms.get(i);
- TaskView tv = mTmpTaskViewMap.get(task);
-
- if (tv == null) {
- tv = mViewPool.pickUpViewFromPool(task, task);
- if (mStackViewsAnimationDuration > 0) {
- // For items in the list, put them in start animating them from the
- // approriate ends of the list where they are expected to appear
- if (Float.compare(transform.p, 0f) <= 0) {
- if (!hasStackBackTransform) {
- hasStackBackTransform = true;
- mLayoutAlgorithm.getStackTransform(
- mLayoutAlgorithm.getStackBackTaskProgress(0f), 0f,
- mTmpStackBackTransform, null);
- }
- tv.updateViewPropertiesToTaskTransform(mTmpStackBackTransform, 0, 0,
- mFastOutSlowInInterpolator, mRequestUpdateClippingListener);
- } else {
- if (!hasStackFrontTransform) {
- hasStackFrontTransform = true;
- mLayoutAlgorithm.getStackTransform(
- mLayoutAlgorithm.getStackFrontTaskProgress(0f), 0f,
- mTmpStackFrontTransform, null);
- }
- tv.updateViewPropertiesToTaskTransform(mTmpStackFrontTransform, 0, 0,
- mFastOutSlowInInterpolator, mRequestUpdateClippingListener);
- }
- }
- }
-
- // Animate the task into place, the clip for stack tasks will be calculated in
- // clipTaskViews()
- tv.updateViewPropertiesToTaskTransform(transform,
- tv.getViewBounds().getClipBottom(), mStackViewsAnimationDuration,
- mFastOutSlowInInterpolator, mRequestUpdateClippingListener);
- }
-
- // Update the focus if the previous focused task was returned to the view pool
- if (lastFocusedTaskIndex != -1) {
- if (lastFocusedTaskIndex < visibleStackRange[1]) {
- setFocusedTask(visibleStackRange[1], false /* animated */,
- true /* requestViewFocus */);
- } else {
- setFocusedTask(visibleStackRange[0], false /* animated */,
- true /* requestViewFocus */);
- }
- }
-
- // Reset the request-synchronize params
- mStackViewsAnimationDuration = 0;
- mStackViewsDirty = false;
- mStackViewsClipDirty = true;
- return true;
}
- return false;
+
+ // Pick up all the newly visible children
+ int lastVisStackIndex = isValidVisibleStackRange ? visibleStackRange[1] : 0;
+ for (int i = mStack.getStackTaskCount() - 1; i >= lastVisStackIndex; i--) {
+ final Task task = tasks.get(i);
+ final TaskViewTransform transform = mCurrentTaskTransforms.get(i);
+
+ // Skip the invisible non-freeform stack tasks
+ if (i > visibleStackRange[0] && !task.isFreeformTask()) {
+ continue;
+ }
+
+ TaskView tv = mTmpTaskViewMap.get(task);
+ if (tv == null) {
+ tv = mViewPool.pickUpViewFromPool(task, task);
+ if (task.isFreeformTask()) {
+ tv.updateViewPropertiesToTaskTransform(transform, TaskViewAnimation.IMMEDIATE,
+ mRequestUpdateClippingListener);
+ } else {
+ if (Float.compare(transform.p, 0f) <= 0) {
+ tv.updateViewPropertiesToTaskTransform(
+ mLayoutAlgorithm.getBackOfStackTransform(),
+ TaskViewAnimation.IMMEDIATE, mRequestUpdateClippingListener);
+ } else {
+ tv.updateViewPropertiesToTaskTransform(
+ mLayoutAlgorithm.getFrontOfStackTransform(),
+ TaskViewAnimation.IMMEDIATE, mRequestUpdateClippingListener);
+ }
+ }
+ } else {
+ // Reattach it in the right z order
+ final int taskIndex = mStack.indexOfStackTask(task);
+ final int insertIndex = findTaskViewInsertIndex(task, taskIndex);
+ if (insertIndex != getTaskViews().indexOf(tv)){
+ detachViewFromParent(tv);
+ attachViewToParent(tv, insertIndex, tv.getLayoutParams());
+ updateTaskViewsList();
+ }
+ }
+ }
+
+ // Update the focus if the previous focused task was returned to the view pool
+ if (lastFocusedTaskIndex != -1) {
+ if (lastFocusedTaskIndex < visibleStackRange[1]) {
+ setFocusedTask(visibleStackRange[1], false /* scrollToTask */,
+ true /* requestViewFocus */);
+ } else {
+ setFocusedTask(visibleStackRange[0], false /* scrollToTask */,
+ true /* requestViewFocus */);
+ }
+ }
+ }
+
+ /**
+ * Cancels any existing {@link TaskView} animations, and updates each {@link TaskView} to its
+ * current position as defined by the {@link TaskStackLayoutAlgorithm}.
+ */
+ private void updateTaskViewsToLayout(TaskViewAnimation animation) {
+ // If we had a deferred animation, cancel that
+ mDeferredTaskViewUpdateAnimation = null;
+
+ // Cancel all task view animations
+ cancelAllTaskViewAnimations();
+
+ // Fetch the current set of TaskViews
+ bindTaskViewsWithStack();
+
+ // Animate them to their final transforms with the given animation
+ List<TaskView> taskViews = getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = 0; i < taskViewCount; i++) {
+ final TaskView tv = taskViews.get(i);
+ final int taskIndex = mStack.indexOfStackTask(tv.getTask());
+ final TaskViewTransform transform = mCurrentTaskTransforms.get(taskIndex);
+
+ updateTaskViewToTransform(tv, transform, animation);
+ }
+ }
+
+ /**
+ * Posts an update to synchronize the {@link TaskView}s with the stack on the next frame.
+ */
+ private void updateTaskViewsToLayoutOnNextFrame(TaskViewAnimation animation) {
+ mDeferredTaskViewUpdateAnimation = animation;
+ postInvalidateOnAnimation();
+ }
+
+ /**
+ * Called to update a specific {@link TaskView} to a given {@link TaskViewTransform} with a
+ * given set of {@link TaskViewAnimation} properties.
+ */
+ public void updateTaskViewToTransform(TaskView taskView, TaskViewTransform transform,
+ TaskViewAnimation animation) {
+ taskView.updateViewPropertiesToTaskTransform(transform, animation,
+ mRequestUpdateClippingListener);
+ }
+
+ /**
+ * Cancels all {@link TaskView} animations.
+ */
+ private void cancelAllTaskViewAnimations() {
+ List<TaskView> taskViews = getTaskViews();
+ int taskViewCount = taskViews.size();
+ for (int i = 0; i < taskViewCount; i++) {
+ final TaskView tv = taskViews.get(i);
+ tv.cancelTransformAnimation();
+ }
}
/**
* Updates the clip for each of the task views from back to front.
*/
- void clipTaskViews(boolean forceUpdate) {
+ private void clipTaskViews() {
RecentsConfiguration config = Recents.getConfiguration();
// Update the clip on each task child
@@ -586,6 +566,7 @@
// Find the next view to clip against
for (int j = i + 1; j < taskViewCount; j++) {
tmpTv = taskViews.get(j);
+
if (tmpTv.shouldClipViewInStack()) {
frontTv = tmpTv;
break;
@@ -604,12 +585,12 @@
}
}
}
- tv.getViewBounds().setClipBottom(clipBottom, forceUpdate);
+ tv.getViewBounds().setClipBottom(clipBottom);
if (!config.useHardwareLayers) {
tv.mThumbnailView.updateThumbnailVisibility(clipBottom - tv.getPaddingBottom());
}
}
- mStackViewsClipDirty = false;
+ mTaskViewsClipDirty = false;
}
/** Updates the min and max virtual scroll bounds */
@@ -640,16 +621,7 @@
*
* @return whether or not the stack will scroll as a part of this focus change
*/
- private boolean setFocusedTask(int taskIndex, boolean scrollToTask, final boolean animated) {
- return setFocusedTask(taskIndex, scrollToTask, animated, true);
- }
-
- /**
- * Sets the focused task to the provided (bounded taskIndex).
- *
- * @return whether or not the stack will scroll as a part of this focus change
- */
- private boolean setFocusedTask(int taskIndex, boolean scrollToTask, final boolean animated,
+ private boolean setFocusedTask(int taskIndex, boolean scrollToTask,
final boolean requestViewFocus) {
// Find the next task to focus
int newFocusedTaskIndex = mStack.getStackTaskCount() > 0 ?
@@ -670,7 +642,7 @@
public void run() {
TaskView tv = getChildViewForTask(newFocusedTask);
if (tv != null) {
- tv.setFocusedState(true, animated, requestViewFocus);
+ tv.setFocusedState(true, requestViewFocus);
}
}
};
@@ -685,10 +657,7 @@
// Cancel any running enter animations at this point when we scroll as well
if (!mEnterAnimationComplete) {
- final List<TaskView> taskViews = getTaskViews();
- for (TaskView tv : taskViews) {
- tv.cancelEnterRecentsAnimation();
- }
+ cancelAllTaskViewAnimations();
}
} else {
focusTaskRunnable.run();
@@ -763,7 +732,8 @@
}
}
if (newIndex != -1) {
- boolean willScroll = setFocusedTask(newIndex, true, animated);
+ boolean willScroll = setFocusedTask(newIndex, true /* scrollToTask */,
+ true /* requestViewFocus */);
if (willScroll && cancelWindowAnimations) {
// As we iterate to the next/previous task, cancel any current/lagging window
// transition animations
@@ -779,7 +749,7 @@
if (task != null) {
TaskView tv = getChildViewForTask(task);
if (tv != null) {
- tv.setFocusedState(false, false /* animated */, false /* requestViewFocus */);
+ tv.setFocusedState(false, false /* requestViewFocus */);
}
}
mFocusedTask = null;
@@ -884,12 +854,18 @@
@Override
public void computeScroll() {
- mStackScroller.computeScroll();
- // Synchronize the views
- synchronizeStackViewsWithModel();
- clipTaskViews(false /* forceUpdate */);
- // Notify accessibility
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED);
+ if (mStackScroller.computeScroll()) {
+ // Notify accessibility
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED);
+ }
+ if (mDeferredTaskViewUpdateAnimation != null) {
+ updateTaskViewsToLayout(mDeferredTaskViewUpdateAnimation);
+ mTaskViewsClipDirty = true;
+ mDeferredTaskViewUpdateAnimation = null;
+ }
+ if (mTaskViewsClipDirty) {
+ clipTaskViews();
+ }
}
/** Computes the stack and task rects */
@@ -936,13 +912,12 @@
// Compute our stack/task rects
computeRects(mTaskStackBounds);
- // If this is the first layout, then scroll to the front of the stack and synchronize the
- // stack views immediately to load all the views
+ // If this is the first layout, then scroll to the front of the stack, then update the
+ // TaskViews with the stack so that we can lay them out
if (mAwaitingFirstLayout) {
mStackScroller.setStackScrollToInitialState();
- requestSynchronizeStackViewsWithModel();
- synchronizeStackViewsWithModel();
}
+ bindTaskViewsWithStack();
// Measure each of the TaskViews
mTmpTaskViews.clear();
@@ -992,52 +967,25 @@
taskRect.right + mTmpRect.right, taskRect.bottom + mTmpRect.bottom);
}
- if (mAwaitingFirstLayout) {
- mAwaitingFirstLayout = false;
- onFirstLayout();
- }
-
- requestSynchronizeStackViewsWithModel();
if (changed) {
if (mStackScroller.isScrollOutOfBounds()) {
mStackScroller.boundScroll();
}
- synchronizeStackViewsWithModel();
- requestUpdateStackViewsClip();
- clipTaskViews(true /* forceUpdate */);
+ }
+ updateTaskViewsToLayout(TaskViewAnimation.IMMEDIATE);
+ clipTaskViews();
+
+ if (mAwaitingFirstLayout || !mEnterAnimationComplete) {
+ mAwaitingFirstLayout = false;
+ onFirstLayout();
+ return;
}
}
/** Handler for the first layout. */
void onFirstLayout() {
- int offscreenY = mLayoutAlgorithm.mStackRect.bottom;
-
- // Find the launch target task
- Task launchTargetTask = mStack.getLaunchTarget();
- List<TaskView> taskViews = getTaskViews();
- int taskViewCount = taskViews.size();
-
- // Prepare the first view for its enter animation
- for (int i = taskViewCount - 1; i >= 0; i--) {
- TaskView tv = taskViews.get(i);
- Task task = tv.getTask();
- boolean hideTask = false;
- boolean occludesLaunchTarget = false;
- if (launchTargetTask != null) {
- occludesLaunchTarget = launchTargetTask.group.isTaskAboveTask(task,
- launchTargetTask);
- hideTask = launchTargetTask.isFreeformTask() && task.isFreeformTask();
- }
- tv.prepareEnterRecentsAnimation(hideTask, occludesLaunchTarget, offscreenY);
- }
-
- // If the enter animation started already and we haven't completed a layout yet, do the
- // enter animation now
- if (mStartEnterAnimationRequestedAfterLayout) {
- startEnterRecentsAnimation(mStartEnterAnimationContext);
- mStartEnterAnimationRequestedAfterLayout = false;
- mStartEnterAnimationContext = null;
- }
+ // Setup the view for the enter animation
+ mAnimationHelper.prepareForEnterAnimation();
// Animate in the freeform workspace
animateFreeformWorkspaceBackgroundAlpha(
@@ -1050,7 +998,7 @@
RecentsActivityLaunchState launchState = config.getLaunchState();
int focusedTaskIndex = launchState.getInitialFocusTaskIndex(mStack.getStackTaskCount());
if (focusedTaskIndex != -1) {
- setFocusedTask(focusedTaskIndex, false /* scrollToTask */, false /* animated */,
+ setFocusedTask(focusedTaskIndex, false /* scrollToTask */,
false /* requestViewFocus */);
}
@@ -1061,102 +1009,6 @@
} else {
EventBus.getDefault().send(new HideHistoryButtonEvent());
}
-
- // Start dozing
- mUIDozeTrigger.startDozing();
- }
-
- /** Requests this task stacks to start it's enter-recents animation */
- public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) {
- // If we are still waiting to layout, then just defer until then
- if (mAwaitingFirstLayout) {
- mStartEnterAnimationRequestedAfterLayout = true;
- mStartEnterAnimationContext = ctx;
- return;
- }
-
- if (mStack.getStackTaskCount() > 0) {
- // Find the launch target task
- Task launchTargetTask = mStack.getLaunchTarget();
- List<TaskView> taskViews = getTaskViews();
- int taskViewCount = taskViews.size();
-
- // Animate all the task views into view
- for (int i = taskViewCount - 1; i >= 0; i--) {
- TaskView tv = taskViews.get(i);
- Task task = tv.getTask();
- ctx.currentTaskTransform = new TaskViewTransform();
- ctx.currentStackViewIndex = i;
- ctx.currentStackViewCount = taskViewCount;
- ctx.currentTaskRect = mLayoutAlgorithm.mTaskRect;
- ctx.currentTaskOccludesLaunchTarget = (launchTargetTask != null) &&
- launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
- ctx.isScreenPinningEnabled = mScreenPinningEnabled;
- ctx.updateListener = mRequestUpdateClippingListener;
- mLayoutAlgorithm.getStackTransform(task, mStackScroller.getStackScroll(),
- ctx.currentTaskTransform, null);
- tv.startEnterRecentsAnimation(ctx);
- }
-
- // Add a runnable to the post animation ref counter to clear all the views
- ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
- @Override
- public void run() {
- // Poke the dozer to restart the trigger after the animation completes
- mUIDozeTrigger.poke();
-
- // Update the focused state here -- since we only set the focused task without
- // requesting view focus in onFirstLayout(), actually request view focus and
- // animate the focused state if we are alt-tabbing now, after the window enter
- // animation is completed
- if (mFocusedTask != null) {
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
- setFocusedTask(mStack.indexOfStackTask(mFocusedTask),
- false /* scrollToTask */, launchState.launchedWithAltTab);
- }
- }
- });
- }
- }
-
- /** Requests this task stack to start it's exit-recents animation. */
- public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
- // Stop any scrolling
- mStackScroller.stopScroller();
- mStackScroller.stopBoundScrollAnimation();
- // Animate all the task views out of view
- ctx.offscreenTranslationY = mLayoutAlgorithm.mStackRect.bottom;
- // Dismiss the freeform workspace background
- int taskViewExitToHomeDuration = getResources().getInteger(
- R.integer.recents_task_exit_to_home_duration);
- animateFreeformWorkspaceBackgroundAlpha(0, taskViewExitToHomeDuration,
- mFastOutSlowInInterpolator);
-
- List<TaskView> taskViews = getTaskViews();
- int taskViewCount = taskViews.size();
- for (int i = 0; i < taskViewCount; i++) {
- TaskView tv = taskViews.get(i);
- tv.startExitToHomeAnimation(ctx);
- }
- }
-
- /** Animates a task view in this stack as it launches. */
- public void startLaunchTaskAnimation(TaskView tv, Runnable r, boolean lockToTask) {
- Task launchTargetTask = tv.getTask();
- List<TaskView> taskViews = getTaskViews();
- int taskViewCount = taskViews.size();
- for (int i = 0; i < taskViewCount; i++) {
- TaskView t = taskViews.get(i);
- if (t == tv) {
- t.setClipViewInStack(false);
- t.startLaunchTaskAnimation(r, true, true, lockToTask);
- } else {
- boolean occludesLaunchTarget = launchTargetTask.group.isTaskAboveTask(t.getTask(),
- launchTargetTask);
- t.startLaunchTaskAnimation(null, false, occludesLaunchTarget, lockToTask);
- }
- }
}
public boolean isTransformedTouchPointInView(float x, float y, TaskView tv) {
@@ -1194,11 +1046,14 @@
* Launches the freeform tasks.
*/
public boolean launchFreeformTasks() {
- Task frontTask = mStack.getStackFrontMostTask();
- if (frontTask != null && frontTask.isFreeformTask()) {
- EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(frontTask),
- frontTask, null, INVALID_STACK_ID, false));
- return true;
+ ArrayList<Task> tasks = mStack.getFreeformTasks();
+ if (!tasks.isEmpty()) {
+ Task frontTask = tasks.get(tasks.size() - 1);
+ if (frontTask != null && frontTask.isFreeformTask()) {
+ EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(frontTask),
+ frontTask, null, INVALID_STACK_ID, false));
+ return true;
+ }
}
return false;
}
@@ -1211,7 +1066,8 @@
updateLayout(true);
// Animate all the tasks into place
- requestSynchronizeStackViewsWithModel(DEFAULT_SYNC_STACK_DURATION);
+ updateTaskViewsToLayout(new TaskViewAnimation(DEFAULT_SYNC_STACK_DURATION,
+ mFastOutSlowInInterpolator));
}
@Override
@@ -1258,9 +1114,6 @@
mStackScroller.setStackScroll(mStackScroller.getStackScroll() + stackScrollOffset);
mStackScroller.boundScroll();
}
-
- // Animate all the tasks into place
- requestSynchronizeStackViewsWithModel(DEFAULT_SYNC_STACK_DURATION);
} else {
// Remove the view associated with this task, we can't rely on updateTransforms
// to work here because the task is no longer in the list
@@ -1271,11 +1124,12 @@
// Update the min/max scroll and animate other task views into their new positions
updateLayout(true);
-
- // Animate all the tasks into place
- requestSynchronizeStackViewsWithModel(DEFAULT_SYNC_STACK_DURATION);
}
+ // Animate all the tasks into place
+ updateTaskViewsToLayout(new TaskViewAnimation(DEFAULT_SYNC_STACK_DURATION,
+ mFastOutSlowInInterpolator));
+
// Update the new front most task's action button
if (mScreenPinningEnabled && newFrontMostTask != null) {
TaskView frontTv = getChildViewForTask(newFrontMostTask);
@@ -1319,19 +1173,15 @@
// Reset the view properties and view state
tv.resetViewProperties();
- tv.setFocusedState(false, false /* animated */, false /* requestViewFocus */);
+ tv.setFocusedState(false, false /* requestViewFocus */);
tv.setClipViewInStack(false);
if (mScreenPinningEnabled) {
- tv.hideActionButton();
+ tv.hideActionButton(false /* fadeOut */, 0 /* duration */, false /* scaleDown */, null);
}
}
@Override
public void prepareViewToLeavePool(TaskView tv, Task task, boolean isNewView) {
- // It is possible for a view to be returned to the view pool before it is laid out,
- // which means that we will need to relayout the view when it is first used next.
- boolean requiresRelayout = tv.getWidth() <= 0 && !isNewView;
-
// Rebind the task and request that this task's data be filled into the TaskView
tv.onTaskBound(task);
@@ -1350,9 +1200,6 @@
addView(tv, insertIndex);
} else {
attachViewToParent(tv, insertIndex, tv.getLayoutParams());
- if (requiresRelayout) {
- tv.requestLayout();
- }
}
// Update the task views list after adding the new task view
updateTaskViewsList();
@@ -1362,7 +1209,7 @@
tv.setTouchEnabled(true);
tv.setClipViewInStack(true);
if (mFocusedTask == task) {
- tv.setFocusedState(true, false /* animated */, false /* requestViewFocus */);
+ tv.setFocusedState(true, false /* requestViewFocus */);
}
// Restore the action button visibility if it is the front most task view
@@ -1380,16 +1227,15 @@
@Override
public void onTaskViewClipStateChanged(TaskView tv) {
- requestUpdateStackViewsClip();
+ clipTaskViews();
}
/**** TaskStackViewScroller.TaskStackViewScrollerCallbacks ****/
@Override
- public void onScrollChanged(float prevScroll, float curScroll) {
+ public void onScrollChanged(float prevScroll, float curScroll, TaskViewAnimation animation) {
mUIDozeTrigger.poke();
- requestSynchronizeStackViewsWithModel();
- postInvalidateOnAnimation();
+ updateTaskViewsToLayoutOnNextFrame(animation);
if (shouldShowHistoryButton() &&
prevScroll > SHOW_HISTORY_BUTTON_SCROLL_THRESHOLD &&
@@ -1416,12 +1262,7 @@
final TaskView tv = getChildViewForTask(t);
if (tv != null) {
// For visible children, defer removing the task until after the animation
- tv.startDeleteTaskAnimation(new Runnable() {
- @Override
- public void run() {
- removeTaskViewFromStack(tv);
- }
- }, 0);
+ tv.dismissTask();
} else {
// Otherwise, remove the task from the stack immediately
mStack.removeTask(t);
@@ -1435,17 +1276,24 @@
mUIDozeTrigger.stopDozing();
}
- public final void onBusEvent(DismissTaskViewEvent event) {
- removeTaskViewFromStack(event.taskView);
- EventBus.getDefault().send(new DismissTaskEvent(event.task));
+ public final void onBusEvent(LaunchTaskStartedEvent event) {
+ mAnimationHelper.startLaunchTaskAnimation(event.taskView, event.screenPinningRequested,
+ event.getAnimationTrigger());
}
- public final void onBusEvent(FocusNextTaskViewEvent event) {
- setRelativeFocusedTask(true, false /* stackTasksOnly */, true /* animated */);
- }
+ public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
+ // Stop any scrolling
+ mStackScroller.stopScroller();
+ mStackScroller.stopBoundScrollAnimation();
- public final void onBusEvent(FocusPreviousTaskViewEvent event) {
- setRelativeFocusedTask(false, false /* stackTasksOnly */, true /* animated */);
+ // Start the task animations
+ mAnimationHelper.startExitToHomeAnimation(event.animated, event.getAnimationTrigger());
+
+ // Dismiss the freeform workspace background
+ int taskViewExitToHomeDuration = getResources().getInteger(
+ R.integer.recents_task_exit_to_home_duration);
+ animateFreeformWorkspaceBackgroundAlpha(0, taskViewExitToHomeDuration,
+ mFastOutSlowInInterpolator);
}
public final void onBusEvent(DismissFocusedTaskViewEvent event) {
@@ -1458,6 +1306,25 @@
}
}
+ public final void onBusEvent(final DismissTaskViewEvent event) {
+ // For visible children, defer removing the task until after the animation
+ mAnimationHelper.startDeleteTaskAnimation(event.task, event.taskView,
+ event.getAnimationTrigger());
+ }
+
+ public final void onBusEvent(TaskViewDismissedEvent event) {
+ removeTaskViewFromStack(event.taskView);
+ EventBus.getDefault().send(new DeleteTaskDataEvent(event.task));
+ }
+
+ public final void onBusEvent(FocusNextTaskViewEvent event) {
+ setRelativeFocusedTask(true, false /* stackTasksOnly */, true /* animated */);
+ }
+
+ public final void onBusEvent(FocusPreviousTaskViewEvent event) {
+ setRelativeFocusedTask(false, false /* stackTasksOnly */, true /* animated */);
+ }
+
public final void onBusEvent(UserInteractionEvent event) {
// Poke the doze trigger on user interaction
mUIDozeTrigger.poke();
@@ -1475,6 +1342,14 @@
mStackScroller.animateScroll(mStackScroller.getStackScroll(),
mLayoutAlgorithm.mInitialScrollP, null);
}
+
+ // Enlarge the dragged view slightly
+ float finalScale = event.taskView.getScaleX() * DRAG_SCALE_FACTOR;
+ mLayoutAlgorithm.getStackTransform(event.task, getScroller().getStackScroll(),
+ mTmpTransform, null);
+ mTmpTransform.scale = finalScale;
+ updateTaskViewToTransform(event.taskView, mTmpTransform,
+ new TaskViewAnimation(DRAG_SCALE_DURATION, mFastOutSlowInInterpolator));
}
public final void onBusEvent(DragStartInitializeDropTargetsEvent event) {
@@ -1520,8 +1395,6 @@
}
});
}
- event.getAnimationTrigger().increment();
- event.taskView.animate().withEndAction(event.getAnimationTrigger().decrementAsRunnable());
// We translated the view but we need to animate it back from the current layout-space rect
// to its final layout-space rect
@@ -1535,8 +1408,15 @@
event.taskView.setLeftTopRightBottom(taskViewRect.left, taskViewRect.top,
taskViewRect.right, taskViewRect.bottom);
- // Animate the tack view back into position
- requestSynchronizeStackViewsWithModel(250);
+ // Animate all the TaskViews back into position
+ mLayoutAlgorithm.getStackTransform(event.task, getScroller().getStackScroll(),
+ mTmpTransform, null);
+ event.getAnimationTrigger().increment();
+ updateTaskViewsToLayout(new TaskViewAnimation(DEFAULT_SYNC_STACK_DURATION,
+ mFastOutSlowInInterpolator));
+ updateTaskViewToTransform(event.taskView, mTmpTransform,
+ new TaskViewAnimation(DEFAULT_SYNC_STACK_DURATION, mFastOutSlowInInterpolator,
+ event.getAnimationTrigger().decrementOnAnimationEnd()));
}
public final void onBusEvent(StackViewScrolledEvent event) {
@@ -1548,11 +1428,35 @@
// Cancel the previous task's window transition before animating the focused state
EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
}
- mLayoutAlgorithm.animateFocusState(mLayoutAlgorithm.getDefaultFocusState());
}
public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
mEnterAnimationComplete = true;
+
+ if (mStack.getStackTaskCount() > 0) {
+ // Start the task enter animations
+ mAnimationHelper.startEnterAnimation(event.getAnimationTrigger());
+
+ // Add a runnable to the post animation ref counter to clear all the views
+ event.addPostAnimationCallback(new Runnable() {
+ @Override
+ public void run() {
+ // Start the dozer to trigger to trigger any UI that shows after a timeout
+ mUIDozeTrigger.startDozing();
+
+ // Update the focused state here -- since we only set the focused task without
+ // requesting view focus in onFirstLayout(), actually request view focus and
+ // animate the focused state if we are alt-tabbing now, after the window enter
+ // animation is completed
+ if (mFocusedTask != null) {
+ RecentsConfiguration config = Recents.getConfiguration();
+ RecentsActivityLaunchState launchState = config.getLaunchState();
+ setFocusedTask(mStack.indexOfStackTask(mFocusedTask),
+ false /* scrollToTask */, launchState.launchedWithAltTab);
+ }
+ }
+ });
+ }
}
public final void onBusEvent(UpdateFreeformTaskViewVisibilityEvent event) {
@@ -1568,48 +1472,11 @@
}
public final void onBusEvent(ShowHistoryEvent event) {
- // The history view's animation will be deferred until all the stack task views are animated
- // away
- int historyTransitionDuration =
- getResources().getInteger(R.integer.recents_history_transition_duration);
- List<TaskView> taskViews = getTaskViews();
- int taskViewCount = taskViews.size();
- for (int i = taskViewCount - 1; i >= 0; i--) {
- TaskView tv = taskViews.get(i);
- tv.animate()
- .alpha(0f)
- .setDuration(historyTransitionDuration)
- .setUpdateListener(null)
- .setListener(null)
- .withLayer()
- .withEndAction(event.getAnimationTrigger().decrementAsRunnable())
- .start();
- event.getAnimationTrigger().increment();
- }
+ mAnimationHelper.startShowHistoryAnimation(event.getAnimationTrigger());
}
public final void onBusEvent(HideHistoryEvent event) {
- // The stack task view animations will be deferred until the history view has been animated
- // away
- final int historyTransitionDuration =
- getResources().getInteger(R.integer.recents_history_transition_duration);
- List<TaskView> taskViews = getTaskViews();
- int taskViewCount = taskViews.size();
- for (int i = taskViewCount - 1; i >= 0; i--) {
- final TaskView tv = taskViews.get(i);
- event.addPostAnimationCallback(new Runnable() {
- @Override
- public void run() {
- tv.animate()
- .alpha(1f)
- .setDuration(historyTransitionDuration)
- .setUpdateListener(null)
- .setListener(null)
- .withLayer()
- .start();
- }
- });
- }
+ mAnimationHelper.startHideHistoryAnimation(event.getAnimationTrigger());
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
index 56942a8..32f02ac 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java
@@ -34,7 +34,7 @@
private static final boolean DEBUG = false;
public interface TaskStackViewScrollerCallbacks {
- void onScrollChanged(float prevScroll, float curScroll);
+ void onScrollChanged(float prevScroll, float curScroll, TaskViewAnimation animation);
}
Context mContext;
@@ -57,7 +57,6 @@
mLayoutAlgorithm = layoutAlgorithm;
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
com.android.internal.R.interpolator.linear_out_slow_in);
- setStackScroll(getStackScroll());
}
/** Resets the task scroller. */
@@ -75,12 +74,22 @@
return mStackScrollP;
}
- /** Sets the current stack scroll */
+ /**
+ * Sets the current stack scroll immediately.
+ */
public void setStackScroll(float s) {
+ setStackScroll(s, TaskViewAnimation.IMMEDIATE);
+ }
+
+ /**
+ * Sets the current stack scroll, but indicates to the callback the preferred animation to
+ * update to this new scroll.
+ */
+ public void setStackScroll(float s, TaskViewAnimation animation) {
float prevStackScroll = mStackScrollP;
mStackScrollP = s;
if (mCb != null) {
- mCb.onScrollChanged(prevStackScroll, mStackScrollP);
+ mCb.onScrollChanged(prevStackScroll, mStackScrollP, animation);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index 1a6f129..c748efc 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -33,8 +33,8 @@
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
-import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
+import com.android.systemui.recents.events.ui.TaskViewDismissedEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.statusbar.FlingAnimationUtils;
@@ -295,6 +295,7 @@
Rect freeformRect = mSv.mLayoutAlgorithm.mFreeformRect;
if (freeformRect.top <= y && y <= freeformRect.bottom) {
if (mSv.launchFreeformTasks()) {
+ // TODO: Animate Recents away as we launch the freeform tasks
return;
}
}
@@ -367,7 +368,7 @@
// Re-enable touch events from this task view
tv.setTouchEnabled(true);
// Remove the task view from the stack
- EventBus.getDefault().send(new DismissTaskViewEvent(tv.getTask(), tv));
+ EventBus.getDefault().send(new TaskViewDismissedEvent(tv.getTask(), tv));
// Keep track of deletions by keyboard
MetricsLogger.histogram(tv.getContext(), "overview_task_dismissed_source",
Constants.Metrics.DismissSourceSwipeGesture);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 14909c5..e8652f5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -31,7 +31,9 @@
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.Log;
+import android.util.FloatProperty;
+import android.util.IntProperty;
+import android.util.Property;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewOutlineProvider;
@@ -42,35 +44,64 @@
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivity;
-import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.LaunchTaskEvent;
import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
+import com.android.systemui.recents.events.ui.TaskViewDismissedEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent;
import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent;
+import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
+import java.util.ArrayList;
+
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
/* A task view */
public class TaskView extends FrameLayout implements Task.TaskCallbacks,
- View.OnClickListener, View.OnLongClickListener {
-
- private final static String TAG = "TaskView";
- private final static boolean DEBUG = false;
+ TaskStackAnimationHelper.Callbacks, View.OnClickListener, View.OnLongClickListener {
/** The TaskView callbacks */
interface TaskViewCallbacks {
void onTaskViewClipStateChanged(TaskView tv);
}
+ /**
+ * The dim overlay is generally calculated from the task progress, but occasionally (like when
+ * launching) needs to be animated independently of the task progress.
+ */
+ public static final Property<TaskView, Integer> DIM =
+ new IntProperty<TaskView>("dim") {
+ @Override
+ public void setValue(TaskView tv, int dim) {
+ tv.setDim(dim);
+ }
+
+ @Override
+ public Integer get(TaskView tv) {
+ return tv.getDim();
+ }
+ };
+
+ public static final Property<TaskView, Float> TASK_PROGRESS =
+ new FloatProperty<TaskView>("taskProgress") {
+ @Override
+ public void setValue(TaskView tv, float p) {
+ tv.setTaskProgress(p);
+ }
+
+ @Override
+ public Float get(TaskView tv) {
+ return tv.getTaskProgress();
+ }
+ };
+
float mTaskProgress;
- ObjectAnimator mTaskProgressAnimator;
float mMaxDimScale;
int mDimAlpha;
AccelerateInterpolator mDimInterpolator = new AccelerateInterpolator(3f);
@@ -80,9 +111,11 @@
Task mTask;
boolean mTaskDataLoaded;
- boolean mClipViewInStack;
+ boolean mClipViewInStack = true;
AnimateableViewBounds mViewBounds;
- private AnimatorSet mClipAnimation;
+
+ private AnimatorSet mTransformAnimation;
+ private ArrayList<Animator> mTmpAnimators = new ArrayList<>();
View mContent;
TaskViewThumbnail mThumbnailView;
@@ -93,18 +126,6 @@
Point mDownTouchPos = new Point();
Interpolator mFastOutSlowInInterpolator;
- Interpolator mFastOutLinearInInterpolator;
- Interpolator mQuintOutInterpolator;
-
- // Optimizations
- ValueAnimator.AnimatorUpdateListener mUpdateDimListener =
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- setTaskProgress((Float) animation.getAnimatedValue());
- }
- };
-
public TaskView(Context context) {
this(context, null);
@@ -123,17 +144,10 @@
RecentsConfiguration config = Recents.getConfiguration();
Resources res = context.getResources();
mMaxDimScale = res.getInteger(R.integer.recents_max_task_stack_view_dim) / 255f;
- mClipViewInStack = true;
mViewBounds = new AnimateableViewBounds(this, res.getDimensionPixelSize(
R.dimen.recents_task_view_rounded_corners_radius));
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
com.android.internal.R.interpolator.fast_out_slow_in);
- mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
- com.android.internal.R.interpolator.fast_out_linear_in);
- mQuintOutInterpolator = AnimationUtils.loadInterpolator(context,
- com.android.internal.R.interpolator.decelerate_quint);
- setTaskProgress(getTaskProgress());
- setDim(getDim());
if (config.fakeShadows) {
setBackground(new FakeShadowDrawable(res, config));
}
@@ -227,294 +241,69 @@
invalidateOutline();
}
- /** Synchronizes this view's properties with the task's transform */
- void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, int clipBottom,
- int duration, Interpolator interpolator,
- ValueAnimator.AnimatorUpdateListener updateCallback) {
+ void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform,
+ TaskViewAnimation toAnimation, ValueAnimator.AnimatorUpdateListener updateCallback) {
RecentsConfiguration config = Recents.getConfiguration();
- Utilities.cancelAnimationWithoutCallbacks(mClipAnimation);
+ Utilities.cancelAnimation(mTransformAnimation);
- // Apply the transform
- toTransform.applyToTaskView(this, duration, interpolator, false,
- !config.fakeShadows, updateCallback);
-
- // Update the clipping
- if (duration > 0) {
- mClipAnimation = new AnimatorSet();
- mClipAnimation.playTogether(
- ObjectAnimator.ofInt(mViewBounds, AnimateableViewBounds.CLIP_BOTTOM,
- mViewBounds.getClipBottom(), clipBottom),
- ObjectAnimator.ofInt(this, TaskViewTransform.LEFT, getLeft(),
- (int) toTransform.rect.left),
- ObjectAnimator.ofInt(this, TaskViewTransform.TOP, getTop(),
- (int) toTransform.rect.top),
- ObjectAnimator.ofInt(this, TaskViewTransform.RIGHT, getRight(),
- (int) toTransform.rect.right),
- ObjectAnimator.ofInt(this, TaskViewTransform.BOTTOM, getBottom(),
- (int) toTransform.rect.bottom),
- ObjectAnimator.ofFloat(mThumbnailView, TaskViewThumbnail.BITMAP_SCALE,
- mThumbnailView.getBitmapScale(), toTransform.thumbnailScale));
- mClipAnimation.setStartDelay(toTransform.startDelay);
- mClipAnimation.setDuration(duration);
- mClipAnimation.setInterpolator(interpolator);
- mClipAnimation.start();
- } else {
- mViewBounds.setClipBottom(clipBottom, false /* forceUpdate */);
+ // Compose the animations for the transform
+ mTmpAnimators.clear();
+ boolean requiresHwLayers = toTransform.applyToTaskView(this, mTmpAnimators, toAnimation,
+ !config.fakeShadows);
+ if (toAnimation.isImmediate()) {
mThumbnailView.setBitmapScale(toTransform.thumbnailScale);
- setLeftTopRightBottom((int) toTransform.rect.left, (int) toTransform.rect.top,
- (int) toTransform.rect.right, (int) toTransform.rect.bottom);
- }
- if (!config.useHardwareLayers) {
- mThumbnailView.updateThumbnailVisibility(clipBottom - getPaddingBottom());
- }
-
- // Update the task progress
- Utilities.cancelAnimationWithoutCallbacks(mTaskProgressAnimator);
- if (duration <= 0) {
setTaskProgress(toTransform.p);
+ if (toAnimation.listener != null) {
+ toAnimation.listener.onAnimationEnd(null);
+ }
} else {
- mTaskProgressAnimator = ObjectAnimator.ofFloat(this, "taskProgress", toTransform.p);
- mTaskProgressAnimator.setDuration(duration);
- mTaskProgressAnimator.addUpdateListener(mUpdateDimListener);
- mTaskProgressAnimator.start();
+ if (Float.compare(mThumbnailView.getBitmapScale(), toTransform.thumbnailScale) != 0) {
+ mTmpAnimators.add(ObjectAnimator.ofFloat(mThumbnailView,
+ TaskViewThumbnail.BITMAP_SCALE, mThumbnailView.getBitmapScale(),
+ toTransform.thumbnailScale));
+ }
+ if (Float.compare(getTaskProgress(), toTransform.p) != 0) {
+ mTmpAnimators.add(ObjectAnimator.ofFloat(this, TASK_PROGRESS, getTaskProgress(),
+ toTransform.p));
+ }
+ ValueAnimator updateCallbackAnim = ValueAnimator.ofInt(0, 1);
+ updateCallbackAnim.addUpdateListener(updateCallback);
+ mTmpAnimators.add(updateCallbackAnim);
+
+ // Create the animator
+ mTransformAnimation = toAnimation.createAnimator(mTmpAnimators);
+ if (requiresHwLayers) {
+ setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ mTransformAnimation.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ setLayerType(View.LAYER_TYPE_NONE, null);
+ }
+ });
+ }
+ mTransformAnimation.start();
}
}
/** Resets this view's properties */
void resetViewProperties() {
+ Utilities.cancelAnimation(mTransformAnimation);
setDim(0);
setVisibility(View.VISIBLE);
getViewBounds().reset();
TaskViewTransform.reset(this);
- if (mActionButtonView != null) {
- mActionButtonView.setScaleX(1f);
- mActionButtonView.setScaleY(1f);
- mActionButtonView.setAlpha(1f);
- mActionButtonView.setTranslationZ(mActionButtonTranslationZ);
- }
+
+ mActionButtonView.setScaleX(1f);
+ mActionButtonView.setScaleY(1f);
+ mActionButtonView.setAlpha(1f);
+ mActionButtonView.setTranslationZ(mActionButtonTranslationZ);
}
- /** Prepares this task view for the enter-recents animations. This is called earlier in the
- * first layout because the actual animation into recents may take a long time. */
- void prepareEnterRecentsAnimation(boolean hideTask, boolean occludesLaunchTarget,
- int offscreenY) {
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
- int initialDim = getDim();
- if (hideTask) {
- setVisibility(View.INVISIBLE);
- } else if (launchState.launchedHasConfigurationChanged) {
- // Just load the views as-is
- } else if (launchState.launchedFromAppWithThumbnail) {
- if (mTask.isLaunchTarget) {
- // Set the dim to 0 so we can animate it in
- initialDim = 0;
- // Hide the action button
- mActionButtonView.setAlpha(0f);
- } else if (occludesLaunchTarget) {
- // Move the task view off screen (below) so we can animate it in
- setTranslationY(offscreenY);
- }
-
- } else if (launchState.launchedFromHome) {
- // Move the task view off screen (below) so we can animate it in
- setTranslationY(offscreenY);
- setTranslationZ(0);
- setScaleX(1f);
- setScaleY(1f);
- }
- // Apply the current dim
- setDim(initialDim);
- }
-
- /** Animates this task view as it enters recents */
- void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) {
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
- Resources res = mContext.getResources();
- final TaskViewTransform transform = ctx.currentTaskTransform;
- final int taskViewEnterFromAppDuration = res.getInteger(
- R.integer.recents_task_enter_from_app_duration);
- final int taskViewEnterFromHomeDuration = res.getInteger(
- R.integer.recents_task_enter_from_home_duration);
- final int taskViewEnterFromHomeStaggerDelay = res.getInteger(
- R.integer.recents_task_enter_from_home_stagger_delay);
- final int taskViewAffiliateGroupEnterOffset = res.getDimensionPixelSize(
- R.dimen.recents_task_view_affiliate_group_enter_offset);
-
- if (launchState.launchedFromAppWithThumbnail) {
- if (mTask.isLaunchTarget) {
- ctx.postAnimationTrigger.increment();
- // Start the dim animation
- animateDimToProgress(taskViewEnterFromAppDuration,
- ctx.postAnimationTrigger.decrementOnAnimationEnd());
-
- // Start the action button animation
- if (ctx.isScreenPinningEnabled) {
- showActionButton(true /* fadeIn */,
- taskViewEnterFromAppDuration /* fadeInDuration */);
- }
- } else {
- // Animate the task up if it was occluding the launch target
- if (ctx.currentTaskOccludesLaunchTarget) {
- setTranslationY(taskViewAffiliateGroupEnterOffset);
- setAlpha(0f);
- animate().alpha(1f)
- .translationY(0)
- .setUpdateListener(null)
- .setListener(new AnimatorListenerAdapter() {
- private boolean hasEnded;
-
- // We use the animation listener instead of withEndAction() to
- // ensure that onAnimationEnd() is called when the animator is
- // cancelled
- @Override
- public void onAnimationEnd(Animator animation) {
- if (hasEnded) return;
- ctx.postAnimationTrigger.decrement();
- hasEnded = true;
- }
- })
- .setInterpolator(mFastOutSlowInInterpolator)
- .setDuration(taskViewEnterFromHomeDuration)
- .start();
- ctx.postAnimationTrigger.increment();
- }
- }
-
- } else if (launchState.launchedFromHome) {
- // Animate the tasks up
- int frontIndex = (ctx.currentStackViewCount - ctx.currentStackViewIndex - 1);
- int delay = frontIndex * taskViewEnterFromHomeStaggerDelay;
-
- setScaleX(transform.scale);
- setScaleY(transform.scale);
- if (!config.fakeShadows) {
- animate().translationZ(transform.translationZ);
- }
- animate()
- .translationY(0)
- .setStartDelay(delay)
- .setUpdateListener(ctx.updateListener)
- .setListener(new AnimatorListenerAdapter() {
- private boolean hasEnded;
-
- // We use the animation listener instead of withEndAction() to ensure that
- // onAnimationEnd() is called when the animator is cancelled
- @Override
- public void onAnimationEnd(Animator animation) {
- if (hasEnded) return;
- ctx.postAnimationTrigger.decrement();
- hasEnded = true;
- }
- })
- .setInterpolator(mQuintOutInterpolator)
- .setDuration(taskViewEnterFromHomeDuration +
- frontIndex * taskViewEnterFromHomeStaggerDelay)
- .start();
- ctx.postAnimationTrigger.increment();
- }
- }
-
- public void cancelEnterRecentsAnimation() {
- animate().cancel();
- }
-
- /** Animates this task view as it leaves recents by pressing home. */
- void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
- int taskViewExitToHomeDuration = getResources().getInteger(
- R.integer.recents_task_exit_to_home_duration);
- animate()
- .translationY(ctx.offscreenTranslationY)
- .setStartDelay(0)
- .setUpdateListener(null)
- .setListener(null)
- .setInterpolator(mFastOutLinearInInterpolator)
- .setDuration(taskViewExitToHomeDuration)
- .withEndAction(ctx.postAnimationTrigger.decrementAsRunnable())
- .start();
- ctx.postAnimationTrigger.increment();
- }
-
- /** Animates this task view as it exits recents */
- void startLaunchTaskAnimation(final Runnable postAnimRunnable, boolean isLaunchingTask,
- boolean occludesLaunchTarget, boolean lockToTask) {
- final int taskViewExitToAppDuration = mContext.getResources().getInteger(
- R.integer.recents_task_exit_to_app_duration);
- final int taskViewAffiliateGroupEnterOffset = mContext.getResources().getDimensionPixelSize(
- R.dimen.recents_task_view_affiliate_group_enter_offset);
-
- if (isLaunchingTask) {
- // Animate the dim
- if (mDimAlpha > 0) {
- ObjectAnimator anim = ObjectAnimator.ofInt(this, "dim", 0);
- anim.setDuration(taskViewExitToAppDuration);
- anim.setInterpolator(mFastOutLinearInInterpolator);
- anim.start();
- }
-
- // Animate the action button away
- if (!lockToTask) {
- float toScale = 0.9f;
- mActionButtonView.animate()
- .scaleX(toScale)
- .scaleY(toScale);
- }
- mActionButtonView.animate()
- .alpha(0f)
- .setStartDelay(0)
- .setDuration(taskViewExitToAppDuration)
- .setInterpolator(PhoneStatusBar.ALPHA_OUT)
- .withEndAction(postAnimRunnable)
- .withLayer()
- .start();
- } else {
- // Hide the dismiss button
- mHeaderView.startLaunchTaskDismissAnimation(postAnimRunnable);
- // If this is another view in the task grouping and is in front of the launch task,
- // animate it away first
- if (occludesLaunchTarget) {
- animate().alpha(0f)
- .translationY(getTranslationY() + taskViewAffiliateGroupEnterOffset)
- .setStartDelay(0)
- .setUpdateListener(null)
- .setListener(null)
- .setInterpolator(mFastOutLinearInInterpolator)
- .setDuration(taskViewExitToAppDuration)
- .start();
- }
- }
- }
-
- /** Animates the deletion of this task view */
- void startDeleteTaskAnimation(final Runnable r, int delay) {
- int taskViewRemoveAnimDuration = getResources().getInteger(
- R.integer.recents_animate_task_view_remove_duration);
- int taskViewRemoveAnimTranslationXPx = getResources().getDimensionPixelSize(
- R.dimen.recents_task_view_remove_anim_translation_x);
-
- // Disabling clipping with the stack while the view is animating away
- setClipViewInStack(false);
-
- animate().translationX(taskViewRemoveAnimTranslationXPx)
- .alpha(0f)
- .setStartDelay(delay)
- .setUpdateListener(null)
- .setListener(null)
- .setInterpolator(mFastOutSlowInInterpolator)
- .setDuration(taskViewRemoveAnimDuration)
- .withEndAction(new Runnable() {
- @Override
- public void run() {
- if (r != null) {
- r.run();
- }
-
- // Re-enable clipping with the stack (we will reuse this view)
- setClipViewInStack(true);
- }
- })
- .start();
+ /**
+ * Cancels any current transform animations.
+ */
+ public void cancelTransformAnimation() {
+ Utilities.cancelAnimation(mTransformAnimation);
}
/** Enables/disables handling touch on this task view. */
@@ -541,12 +330,14 @@
void dismissTask() {
// Animate out the view and call the callback
final TaskView tv = this;
- startDeleteTaskAnimation(new Runnable() {
+ DismissTaskViewEvent dismissEvent = new DismissTaskViewEvent(tv, mTask);
+ dismissEvent.addPostAnimationCallback(new Runnable() {
@Override
public void run() {
- EventBus.getDefault().send(new DismissTaskViewEvent(mTask, tv));
+ EventBus.getDefault().send(new TaskViewDismissedEvent(mTask, tv));
}
- }, 0);
+ });
+ EventBus.getDefault().send(dismissEvent);
}
/**
@@ -597,12 +388,8 @@
}
} else {
float dimAlpha = mDimAlpha / 255.0f;
- if (mThumbnailView != null) {
- mThumbnailView.setDimAlpha(dimAlpha);
- }
- if (mHeaderView != null) {
- mHeaderView.setDimAlpha(dim);
- }
+ mThumbnailView.setDimAlpha(dimAlpha);
+ mHeaderView.setDimAlpha(dim);
}
}
@@ -612,18 +399,18 @@
}
/** Animates the dim to the task progress. */
- void animateDimToProgress(int duration, Animator.AnimatorListener postAnimRunnable) {
+ void animateDimToProgress(int duration, Animator.AnimatorListener animListener) {
// Animate the dim into view as well
int toDim = getDimFromTaskProgress();
if (toDim != getDim()) {
- ObjectAnimator anim = ObjectAnimator.ofInt(TaskView.this, "dim", toDim);
+ ObjectAnimator anim = ObjectAnimator.ofInt(this, DIM, getDim(), toDim);
anim.setDuration(duration);
- if (postAnimRunnable != null) {
- anim.addListener(postAnimRunnable);
+ if (animListener != null) {
+ anim.addListener(animListener);
}
anim.start();
} else {
- postAnimRunnable.onAnimationEnd(null);
+ animListener.onAnimationEnd(null);
}
}
@@ -644,14 +431,7 @@
/**
* Explicitly sets the focused state of this task.
*/
- public void setFocusedState(boolean isFocused, boolean animated, boolean requestViewFocus) {
- if (DEBUG) {
- Log.d(TAG, "setFocusedState: " + mTask.title + " focused: " + isFocused +
- " animated: " + animated + " requestViewFocus: " + requestViewFocus +
- " isFocused(): " + isFocused() +
- " isAccessibilityFocused(): " + isAccessibilityFocused());
- }
-
+ public void setFocusedState(boolean isFocused, boolean requestViewFocus) {
SystemServicesProxy ssp = Recents.getSystemServices();
if (isFocused) {
if (requestViewFocus && !isFocused()) {
@@ -678,28 +458,101 @@
if (fadeIn) {
if (mActionButtonView.getAlpha() < 1f) {
- mActionButtonView.setAlpha(0f);
- mActionButtonView.animate().alpha(1f)
+ mActionButtonView.animate()
+ .alpha(1f)
+ .scaleX(1f)
+ .scaleY(1f)
.setDuration(fadeInDuration)
.setInterpolator(PhoneStatusBar.ALPHA_IN)
.withLayer()
.start();
}
} else {
+ mActionButtonView.setScaleX(1f);
+ mActionButtonView.setScaleY(1f);
mActionButtonView.setAlpha(1f);
+ mActionButtonView.setTranslationZ(mActionButtonTranslationZ);
}
}
/**
* Immediately hides the action button.
+ *
+ * @param fadeOut whether or not to animate the action button out.
*/
- public void hideActionButton() {
- mActionButtonView.setVisibility(View.INVISIBLE);
+ public void hideActionButton(boolean fadeOut, int fadeOutDuration, boolean scaleDown,
+ final Animator.AnimatorListener animListener) {
+ if (fadeOut) {
+ if (mActionButtonView.getAlpha() > 0f) {
+ if (scaleDown) {
+ float toScale = 0.9f;
+ mActionButtonView.animate()
+ .scaleX(toScale)
+ .scaleY(toScale);
+ }
+ mActionButtonView.animate()
+ .alpha(0f)
+ .setDuration(fadeOutDuration)
+ .setInterpolator(PhoneStatusBar.ALPHA_OUT)
+ .withEndAction(new Runnable() {
+ @Override
+ public void run() {
+ if (animListener != null) {
+ animListener.onAnimationEnd(null);
+ }
+ mActionButtonView.setVisibility(View.INVISIBLE);
+ }
+ })
+ .withLayer()
+ .start();
+ }
+ } else {
+ mActionButtonView.setAlpha(0f);
+ mActionButtonView.setVisibility(View.INVISIBLE);
+ if (animListener != null) {
+ animListener.onAnimationEnd(null);
+ }
+ }
+ }
+
+ /**** TaskStackAnimationHelper.Callbacks Implementation ****/
+
+ @Override
+ public void onPrepareLaunchTargetForEnterAnimation() {
+ // These values will be animated in when onStartLaunchTargetEnterAnimation() is called
+ setDim(0);
+ mActionButtonView.setAlpha(0f);
+ }
+
+ @Override
+ public void onStartLaunchTargetEnterAnimation(int duration, boolean screenPinningEnabled,
+ ReferenceCountedTrigger postAnimationTrigger) {
+ postAnimationTrigger.increment();
+ animateDimToProgress(duration, postAnimationTrigger.decrementOnAnimationEnd());
+
+ if (screenPinningEnabled) {
+ showActionButton(true /* fadeIn */, duration /* fadeInDuration */);
+ }
+ }
+
+ @Override
+ public void onStartLaunchTargetLaunchAnimation(int duration, boolean screenPinningRequested,
+ ReferenceCountedTrigger postAnimationTrigger) {
+ if (mDimAlpha > 0) {
+ ObjectAnimator anim = ObjectAnimator.ofInt(this, DIM, getDim(), 0);
+ anim.setDuration(duration);
+ anim.setInterpolator(PhoneStatusBar.ALPHA_OUT);
+ anim.start();
+ }
+
+ postAnimationTrigger.increment();
+ hideActionButton(true /* fadeOut */, duration,
+ !screenPinningRequested /* scaleDown */,
+ postAnimationTrigger.decrementOnAnimationEnd());
}
/**** TaskCallbacks Implementation ****/
- /** Binds this task view to the task */
public void onTaskBound(Task t) {
mTask = t;
mTask.addCallback(this);
@@ -707,22 +560,18 @@
@Override
public void onTaskDataLoaded(Task task) {
- if (mThumbnailView != null && mHeaderView != null) {
- // Bind each of the views to the new task data
- mThumbnailView.rebindToTask(mTask);
- mHeaderView.rebindToTask(mTask);
- }
+ // Bind each of the views to the new task data
+ mThumbnailView.rebindToTask(mTask);
+ mHeaderView.rebindToTask(mTask);
mTaskDataLoaded = true;
}
@Override
public void onTaskDataUnloaded() {
- if (mThumbnailView != null && mHeaderView != null) {
- // Unbind each of the views from the task data and remove the task callback
- mTask.removeCallback(this);
- mThumbnailView.unbindFromTask();
- mHeaderView.unbindFromTask();
- }
+ // Unbind each of the views from the task data and remove the task callback
+ mTask.removeCallback(this);
+ mThumbnailView.unbindFromTask();
+ mHeaderView.unbindFromTask();
mTaskDataLoaded = false;
}
@@ -758,17 +607,6 @@
// Start listening for drag events
setClipViewInStack(false);
- // Enlarge the view slightly
- final float finalScale = getScaleX() * 1.05f;
- animate()
- .scaleX(finalScale)
- .scaleY(finalScale)
- .setDuration(175)
- .setUpdateListener(null)
- .setListener(null)
- .setInterpolator(mFastOutSlowInInterpolator)
- .start();
-
mDownTouchPos.x += ((1f - getScaleX()) * getWidth()) / 2;
mDownTouchPos.y += ((1f - getScaleY()) * getHeight()) / 2;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAnimation.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAnimation.java
new file mode 100644
index 0000000..363ad66
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAnimation.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.views;
+
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.view.animation.Interpolator;
+import android.view.animation.LinearInterpolator;
+
+import java.util.List;
+
+/**
+ * The animation properties to animate a {@link TaskView} to a given {@link TaskViewTransform}.
+ */
+public class TaskViewAnimation {
+
+ public static final TaskViewAnimation IMMEDIATE = new TaskViewAnimation(0,
+ new LinearInterpolator());
+
+ public final int startDelay;
+ public final int duration;
+ public final Interpolator interpolator;
+ public final Animator.AnimatorListener listener;
+
+ public TaskViewAnimation(int duration, Interpolator interpolator) {
+ this(0 /* startDelay */, duration, interpolator, null);
+ }
+
+ public TaskViewAnimation(int duration, Interpolator interpolator,
+ Animator.AnimatorListener listener) {
+ this(0 /* startDelay */, duration, interpolator, listener);
+ }
+
+ public TaskViewAnimation(int startDelay, int duration, Interpolator interpolator,
+ Animator.AnimatorListener listener) {
+ this.startDelay = startDelay;
+ this.duration = duration;
+ this.interpolator = interpolator;
+ this.listener = listener;
+ }
+
+ /**
+ * Creates a new {@link AnimatorSet} that will animate the given animators with the current
+ * animation properties.
+ */
+ public AnimatorSet createAnimator(List<Animator> animators) {
+ AnimatorSet anim = new AnimatorSet();
+ anim.setStartDelay(startDelay);
+ anim.setDuration(duration);
+ anim.setInterpolator(interpolator);
+ if (listener != null) {
+ anim.addListener(listener);
+ }
+ anim.playTogether(animators);
+ return anim;
+ }
+
+ /**
+ * Returns whether this animation has any duration.
+ */
+ public boolean isImmediate() {
+ return duration <= 0;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index 9a2ffe7..e8b7574 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -291,22 +291,6 @@
mMoveTaskButton.setOnClickListener(null);
}
- /** Animates this task bar dismiss button when launching a task. */
- void startLaunchTaskDismissAnimation(final Runnable postAnimationRunanble) {
- if (mDismissButton.getVisibility() == View.VISIBLE) {
- int taskViewExitToAppDuration = mContext.getResources().getInteger(
- R.integer.recents_task_exit_to_app_duration);
- mDismissButton.animate().cancel();
- mDismissButton.animate()
- .alpha(0f)
- .setStartDelay(0)
- .setInterpolator(mFastOutSlowInInterpolator)
- .setDuration(taskViewExitToAppDuration)
- .withEndAction(postAnimationRunanble)
- .start();
- }
- }
-
/** Animates this task bar if the user does not interact with the stack after a certain time. */
void startNoUserInteractionAnimation() {
if (mDismissButton.getVisibility() != View.VISIBLE) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewTransform.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewTransform.java
index 3ee50ac..14bab64 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewTransform.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewTransform.java
@@ -16,16 +16,19 @@
package com.android.systemui.recents.views;
-import android.animation.ValueAnimator;
+import android.animation.Animator;
+import android.animation.ObjectAnimator;
+import android.animation.PropertyValuesHolder;
import android.graphics.RectF;
import android.util.IntProperty;
import android.util.Property;
import android.view.View;
-import android.view.ViewPropertyAnimator;
-import android.view.animation.Interpolator;
+import java.util.ArrayList;
-/* The transform state for a task view */
+/**
+ * The visual properties for a {@link TaskView}.
+ */
public class TaskViewTransform {
public static final Property<View, Integer> LEFT =
@@ -80,9 +83,6 @@
}
};
- // TODO: Move this out of the transform
- public int startDelay = 0;
-
public float translationZ = 0;
public float scale = 1f;
public float alpha = 1f;
@@ -94,15 +94,10 @@
// This is a window-space rect used for positioning the task in the stack and freeform workspace
public RectF rect = new RectF();
- public TaskViewTransform() {
- // Do nothing
- }
-
/**
* Resets the current transform.
*/
public void reset() {
- startDelay = 0;
translationZ = 0;
scale = 1f;
alpha = 1f;
@@ -116,50 +111,34 @@
public boolean hasAlphaChangedFrom(float v) {
return (Float.compare(alpha, v) != 0);
}
+
public boolean hasScaleChangedFrom(float v) {
return (Float.compare(scale, v) != 0);
}
+
public boolean hasTranslationZChangedFrom(float v) {
return (Float.compare(translationZ, v) != 0);
}
- /** Applies this transform to a view. */
- public void applyToTaskView(TaskView v, int duration, Interpolator interp, boolean allowLayers,
- boolean allowShadows, ValueAnimator.AnimatorUpdateListener updateCallback) {
- // Check to see if any properties have changed, and update the task view
- if (duration > 0) {
- ViewPropertyAnimator anim = v.animate();
- boolean requiresLayers = false;
+ public boolean hasRectChangedFrom(View v) {
+ return ((int) rect.left != v.getLeft()) || ((int) rect.right != v.getRight()) ||
+ ((int) rect.top != v.getTop()) || ((int) rect.bottom != v.getBottom());
+ }
- // Animate to the final state
- if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) {
- anim.translationZ(translationZ);
- }
- if (hasScaleChangedFrom(v.getScaleX())) {
- anim.scaleX(scale)
- .scaleY(scale);
- requiresLayers = true;
- }
- if (hasAlphaChangedFrom(v.getAlpha())) {
- // Use layers if we animate alpha
- anim.alpha(alpha);
- requiresLayers = true;
- }
- if (requiresLayers && allowLayers) {
- anim.withLayer();
- }
- if (updateCallback != null) {
- anim.setUpdateListener(updateCallback);
- } else {
- anim.setUpdateListener(null);
- }
- anim.setListener(null);
- anim.setStartDelay(startDelay)
- .setDuration(duration)
- .setInterpolator(interp)
- .start();
- } else {
- // Set the changed properties
+ /**
+ * Applies this transform to a view.
+ *
+ * @return whether hardware layers are required for this animation.
+ */
+ public boolean applyToTaskView(TaskView v, ArrayList<Animator> animators,
+ TaskViewAnimation taskAnimation, boolean allowShadows) {
+ // Return early if not visible
+ boolean requiresHwLayers = false;
+ if (!visible) {
+ return requiresHwLayers;
+ }
+
+ if (taskAnimation.isImmediate()) {
if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) {
v.setTranslationZ(translationZ);
}
@@ -170,29 +149,45 @@
if (hasAlphaChangedFrom(v.getAlpha())) {
v.setAlpha(alpha);
}
+ if (hasRectChangedFrom(v)) {
+ v.setLeftTopRightBottom((int) rect.left, (int) rect.top, (int) rect.right,
+ (int) rect.bottom);
+ }
+ } else {
+ if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) {
+ animators.add(ObjectAnimator.ofFloat(v, View.TRANSLATION_Z, v.getTranslationZ(),
+ translationZ));
+ }
+ if (hasScaleChangedFrom(v.getScaleX())) {
+ animators.add(ObjectAnimator.ofPropertyValuesHolder(v,
+ PropertyValuesHolder.ofFloat(View.SCALE_X, v.getScaleX(), scale),
+ PropertyValuesHolder.ofFloat(View.SCALE_Y, v.getScaleX(), scale)));
+ }
+ if (hasAlphaChangedFrom(v.getAlpha())) {
+ animators.add(ObjectAnimator.ofFloat(v, View.ALPHA, v.getAlpha(), alpha));
+ requiresHwLayers = true;
+ }
+ if (hasRectChangedFrom(v)) {
+ animators.add(ObjectAnimator.ofPropertyValuesHolder(v,
+ PropertyValuesHolder.ofInt(LEFT, v.getLeft(), (int) rect.left),
+ PropertyValuesHolder.ofInt(TOP, v.getTop(), (int) rect.top),
+ PropertyValuesHolder.ofInt(RIGHT, v.getRight(), (int) rect.right),
+ PropertyValuesHolder.ofInt(BOTTOM, v.getBottom(), (int) rect.bottom)));
+ }
}
+ return requiresHwLayers;
}
/** Reset the transform on a view. */
public static void reset(TaskView v) {
- // Cancel any running animations and reset the translation in case something else (like a
- // dismiss animation) changes it
- v.animate().cancel();
v.setTranslationX(0f);
v.setTranslationY(0f);
v.setTranslationZ(0f);
v.setScaleX(1f);
v.setScaleY(1f);
v.setAlpha(1f);
- v.getViewBounds().setClipBottom(0, false /* forceUpdate */);
+ v.getViewBounds().setClipBottom(0);
v.setLeftTopRightBottom(0, 0, 0, 0);
v.mThumbnailView.setBitmapScale(1f);
}
-
- @Override
- public String toString() {
- return "TaskViewTransform delay: " + startDelay + " z: " + translationZ +
- " scale: " + scale + " alpha: " + alpha + " visible: " + visible +
- " rect: " + rect + " p: " + p;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/ViewAnimation.java b/packages/SystemUI/src/com/android/systemui/recents/views/ViewAnimation.java
deleted file mode 100644
index eaef51c..0000000
--- a/packages/SystemUI/src/com/android/systemui/recents/views/ViewAnimation.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.recents.views;
-
-import android.animation.ValueAnimator;
-import android.graphics.Rect;
-import com.android.systemui.recents.misc.ReferenceCountedTrigger;
-
-/* Common code related to view animations */
-public class ViewAnimation {
-
- /* The animation context for a task view animation into Recents */
- public static class TaskViewEnterContext {
- // A trigger to run some logic when all the animations complete. This works around the fact
- // that it is difficult to coordinate ViewPropertyAnimators
- public ReferenceCountedTrigger postAnimationTrigger;
- // An update listener to notify as the enter animation progresses (used for the home transition)
- ValueAnimator.AnimatorUpdateListener updateListener;
-
- // These following properties are updated for each task view we start the enter animation on
-
- // Whether or not screen pinning is enabled
- boolean isScreenPinningEnabled;
- // Whether or not the current task occludes the launch target
- boolean currentTaskOccludesLaunchTarget;
- // The task rect for the current stack
- Rect currentTaskRect;
- // The transform of the current task view
- TaskViewTransform currentTaskTransform;
- // The view index of the current task view
- int currentStackViewIndex;
- // The total number of task views
- int currentStackViewCount;
-
- public TaskViewEnterContext(ReferenceCountedTrigger t) {
- postAnimationTrigger = t;
- }
- }
-
- /* The animation context for a task view animation out of Recents */
- public static class TaskViewExitContext {
- // A trigger to run some logic when all the animations complete. This works around the fact
- // that it is difficult to coordinate ViewPropertyAnimators
- ReferenceCountedTrigger postAnimationTrigger;
-
- // The translationY to apply to a TaskView to move it off the bottom of the task stack
- int offscreenTranslationY;
-
- public TaskViewExitContext(ReferenceCountedTrigger t) {
- postAnimationTrigger = t;
- }
- }
-
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 5906bda..fdfce6c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -16,8 +16,6 @@
package com.android.systemui.statusbar;
-import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_MAX;
-
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
@@ -80,11 +78,8 @@
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.AnimationUtils;
-import android.widget.DateTimeView;
-import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RemoteViews;
-import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -116,6 +111,7 @@
import java.util.List;
import java.util.Locale;
+import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_MAX;
import static com.android.keyguard.KeyguardHostView.OnDismissAction;
public abstract class BaseStatusBar extends SystemUI implements
@@ -126,9 +122,6 @@
public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
public static final boolean MULTIUSER_DEBUG = false;
- // STOPSHIP disable once we resolve b/18102199
- private static final boolean NOTIFICATION_CLICK_DEBUG = true;
-
public static final boolean ENABLE_REMOTE_INPUT =
SystemProperties.getBoolean("debug.enable_remote_input", true);
public static final boolean ENABLE_CHILD_NOTIFICATIONS
@@ -141,11 +134,9 @@
protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023;
protected static final int MSG_SHOW_NEXT_AFFILIATED_TASK = 1024;
protected static final int MSG_SHOW_PREV_AFFILIATED_TASK = 1025;
- protected static final int MSG_SHOW_KEYBOARD_SHORTCUTS_MENU = 1026;
+ protected static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU = 1026;
protected static final boolean ENABLE_HEADS_UP = true;
- // scores above this threshold should be displayed in heads up mode.
- protected static final int INTERRUPTION_THRESHOLD = 10;
protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up";
// Should match the values in PhoneWindowManager
@@ -200,14 +191,10 @@
protected IDreamManager mDreamManager;
PowerManager mPowerManager;
protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
- protected int mRowMinHeightLegacy;
- protected int mRowMinHeight;
- protected int mRowMaxHeight;
// public mode, private notifications, etc
private boolean mLockscreenPublicMode = false;
private final SparseBooleanArray mUsersAllowingPrivateNotifications = new SparseBooleanArray();
- private NotificationColorUtil mNotificationColorUtil;
private UserManager mUserManager;
@@ -237,6 +224,8 @@
private TimeInterpolator mLinearOutSlowIn, mFastOutLinearIn;
+ private KeyboardShortcuts mKeyboardShortcuts;
+
/**
* The {@link StatusBarState} of the status bar.
*/
@@ -357,9 +346,6 @@
ViewGroup actionGroup = (ViewGroup) parent;
index = actionGroup.indexOfChild(view);
}
- if (NOTIFICATION_CLICK_DEBUG) {
- Log.d(TAG, "Clicked on button " + index + " for " + key);
- }
try {
mBarService.onNotificationActionClick(key, index);
} catch (RemoteException e) {
@@ -617,8 +603,6 @@
mDevicePolicyManager = (DevicePolicyManager)mContext.getSystemService(
Context.DEVICE_POLICY_SERVICE);
- mNotificationColorUtil = NotificationColorUtil.getInstance(mContext);
-
mNotificationData = new NotificationData(this);
mAccessibilityManager = (AccessibilityManager)
@@ -987,6 +971,7 @@
row.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+ guts.saveImportance(sbn);
dismissPopups();
}
});
@@ -1118,8 +1103,8 @@
}
@Override
- public void showKeyboardShortcutsMenu() {
- int msg = MSG_SHOW_KEYBOARD_SHORTCUTS_MENU;
+ public void toggleKeyboardShortcutsMenu() {
+ int msg = MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU;
mHandler.removeMessages(msg);
mHandler.sendEmptyMessage(msg);
}
@@ -1142,7 +1127,7 @@
return new H();
}
- static void sendCloseSystemWindows(Context context, String reason) {
+ protected void sendCloseSystemWindows(String reason) {
if (ActivityManagerNative.isSystemReady()) {
try {
ActivityManagerNative.getDefault().closeSystemDialogs(reason);
@@ -1177,7 +1162,7 @@
protected void showRecents(boolean triggeredFromAltTab) {
if (mRecents != null) {
- sendCloseSystemWindows(mContext, SYSTEM_DIALOG_REASON_RECENT_APPS);
+ sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
mRecents.showRecents(triggeredFromAltTab, getStatusBarView());
}
}
@@ -1200,8 +1185,8 @@
}
}
- protected void showKeyboardShortcuts() {
- Toast.makeText(mContext, "Show keyboard shortcuts screen", Toast.LENGTH_LONG).show();
+ protected void toggleKeyboardShortcuts() {
+ getKeyboardShortcuts().toggleKeyboardShortcuts(mContext);
}
protected void cancelPreloadingRecents() {
@@ -1324,8 +1309,8 @@
case MSG_SHOW_PREV_AFFILIATED_TASK:
showRecentsPreviousAffiliatedTask();
break;
- case MSG_SHOW_KEYBOARD_SHORTCUTS_MENU:
- showKeyboardShortcuts();
+ case MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU:
+ toggleKeyboardShortcuts();
break;
}
}
@@ -1531,6 +1516,14 @@
}
}
+ protected KeyboardShortcuts getKeyboardShortcuts() {
+ if (mKeyboardShortcuts == null) {
+ mKeyboardShortcuts = new KeyboardShortcuts();
+ }
+
+ return mKeyboardShortcuts;
+ }
+
public void startPendingIntentDismissingKeyguard(final PendingIntent intent) {
if (!isDeviceProvisioned()) return;
@@ -1613,9 +1606,6 @@
}
});
- if (NOTIFICATION_CLICK_DEBUG) {
- Log.d(TAG, "Clicked on content of " + notificationKey);
- }
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
final boolean afterKeyguardGone = intent.isActivity()
&& PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index deedae0..5a2758d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -65,7 +65,7 @@
private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT;
private static final int MSG_START_ASSIST = 23 << MSG_SHIFT;
private static final int MSG_CAMERA_LAUNCH_GESTURE = 24 << MSG_SHIFT;
- private static final int MSG_SHOW_KEYBOARD_SHORTCUTS = 25 << MSG_SHIFT;
+ private static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS = 25 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -100,7 +100,7 @@
public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
public void toggleRecentApps();
public void preloadRecentApps();
- public void showKeyboardShortcutsMenu();
+ public void toggleKeyboardShortcutsMenu();
public void cancelPreloadRecentApps();
public void setWindowState(int window, int state);
public void buzzBeepBlinked();
@@ -229,10 +229,10 @@
}
@Override
- public void showKeyboardShortcutsMenu() {
+ public void toggleKeyboardShortcutsMenu() {
synchronized (mList) {
- mHandler.removeMessages(MSG_SHOW_KEYBOARD_SHORTCUTS);
- mHandler.obtainMessage(MSG_SHOW_KEYBOARD_SHORTCUTS).sendToTarget();
+ mHandler.removeMessages(MSG_TOGGLE_KEYBOARD_SHORTCUTS);
+ mHandler.obtainMessage(MSG_TOGGLE_KEYBOARD_SHORTCUTS).sendToTarget();
}
}
@@ -380,8 +380,8 @@
case MSG_CANCEL_PRELOAD_RECENT_APPS:
mCallbacks.cancelPreloadRecentApps();
break;
- case MSG_SHOW_KEYBOARD_SHORTCUTS:
- mCallbacks.showKeyboardShortcutsMenu();
+ case MSG_TOGGLE_KEYBOARD_SHORTCUTS:
+ mCallbacks.toggleKeyboardShortcutsMenu();
break;
case MSG_SET_WINDOW_STATE:
mCallbacks.setWindowState(msg.arg1, msg.arg2);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
new file mode 100644
index 0000000..3e0ea90
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui.statusbar;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+import com.android.systemui.R;
+
+/**
+ * Contains functionality for handling keyboard shortcuts.
+ */
+public class KeyboardShortcuts {
+ private Dialog mKeyboardShortcutsDialog;
+
+ public KeyboardShortcuts() {}
+
+ public void toggleKeyboardShortcuts(Context context) {
+ if (mKeyboardShortcutsDialog == null) {
+ // Create dialog.
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ final View keyboardShortcutsView = inflater.inflate(
+ R.layout.keyboard_shortcuts_view, null);
+
+ populateKeyboardShortcuts(keyboardShortcutsView.findViewById(
+ R.id.keyboard_shortcuts_wrapper));
+ dialogBuilder.setView(keyboardShortcutsView);
+ mKeyboardShortcutsDialog = dialogBuilder.create();
+ mKeyboardShortcutsDialog.setCanceledOnTouchOutside(true);
+
+ // Setup window.
+ Window keyboardShortcutsWindow = mKeyboardShortcutsDialog.getWindow();
+ keyboardShortcutsWindow.setType(
+ WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
+ keyboardShortcutsWindow.setBackgroundDrawable(
+ new ColorDrawable(android.graphics.Color.TRANSPARENT));
+ keyboardShortcutsWindow.setGravity(Gravity.TOP);
+ mKeyboardShortcutsDialog.show();
+ } else {
+ dismissKeyboardShortcutsDialog();
+ }
+ }
+
+ public void dismissKeyboardShortcutsDialog() {
+ if (mKeyboardShortcutsDialog != null) {
+ mKeyboardShortcutsDialog.dismiss();
+ mKeyboardShortcutsDialog = null;
+ }
+ }
+
+ /**
+ * @return {@code true} if the keyboard shortcuts have been successfully populated.
+ */
+ private boolean populateKeyboardShortcuts(View keyboardShortcutsLayout) {
+ // TODO: Populate shortcuts.
+ return true;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java
index 6850f7ec..20a6e7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java
@@ -46,6 +46,10 @@
private int mClipTopAmount;
private int mActualHeight;
private boolean mExposed;
+ private RadioButton mApplyToTopic;
+ private SeekBar mSeekBar;
+ private Notification.Topic mTopic;
+ private INotificationManager mINotificationManager;
public NotificationGuts(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -98,67 +102,39 @@
void bindImportance(final StatusBarNotification sbn, final ExpandableNotificationRow row,
final int importance) {
- final INotificationManager sINM = INotificationManager.Stub.asInterface(
+ mINotificationManager = INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
- final Notification.Topic topic = sbn.getNotification().getTopic() == null
+ mTopic = sbn.getNotification().getTopic() == null
? new Notification.Topic(Notification.TOPIC_DEFAULT, mContext.getString(
com.android.internal.R.string.default_notification_topic_label))
: sbn.getNotification().getTopic();
boolean doesAppUseTopics = false;
try {
- doesAppUseTopics = sINM.doesAppUseTopics(sbn.getPackageName(), sbn.getUid());
+ doesAppUseTopics =
+ mINotificationManager.doesAppUseTopics(sbn.getPackageName(), sbn.getUid());
} catch (RemoteException e) {}
final boolean appUsesTopics = doesAppUseTopics;
- final RadioButton applyToTopic = (RadioButton) row.findViewById(R.id.apply_to_topic);
- applyToTopic.setChecked(true);
+ mApplyToTopic = (RadioButton) row.findViewById(R.id.apply_to_topic);
+ if (appUsesTopics) {
+ mApplyToTopic.setChecked(true);
+ }
final View applyToApp = row.findViewById(R.id.apply_to_app);
final TextView topicSummary = ((TextView) row.findViewById(R.id.summary));
final TextView topicTitle = ((TextView) row.findViewById(R.id.title));
- final SeekBar seekBar = (SeekBar) row.findViewById(R.id.seekbar);
- final RadioGroup applyTo = (RadioGroup) row.findViewById(R.id.apply_to);
- applyTo.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
- try {
- switch (checkedId) {
- case R.id.apply_to_topic:
- sINM.setTopicImportance(sbn.getPackageName(), sbn.getUid(), topic,
- seekBar.getProgress());
- break;
- default:
- sINM.setAppImportance(sbn.getPackageName(), sbn.getUid(),
- seekBar.getProgress());
- }
- } catch (RemoteException e) {
- // :(
- }
- }
- });
-
- seekBar.setMax(4);
- seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ mSeekBar = (SeekBar) row.findViewById(R.id.seekbar);
+ mSeekBar.setMax(4);
+ mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
updateTitleAndSummary(progress);
if (fromUser) {
if (appUsesTopics) {
- applyToTopic.setVisibility(View.VISIBLE);
-
- applyToTopic.setText(
- mContext.getString(R.string.apply_to_topic, topic.getLabel()));
+ mApplyToTopic.setVisibility(View.VISIBLE);
+ mApplyToTopic.setText(
+ mContext.getString(R.string.apply_to_topic, mTopic.getLabel()));
applyToApp.setVisibility(View.VISIBLE);
}
- try {
- if (applyToTopic.isChecked()) {
- sINM.setTopicImportance(sbn.getPackageName(), sbn.getUid(), topic,
- progress);
- } else {
- sINM.setAppImportance(sbn.getPackageName(), sbn.getUid(), progress);
- }
- } catch (RemoteException e) {
- // :(
- }
}
}
@@ -202,7 +178,22 @@
}
}
});
- seekBar.setProgress(importance);
+ mSeekBar.setProgress(importance);
+ }
+
+ void saveImportance(final StatusBarNotification sbn) {
+ int progress = mSeekBar.getProgress();
+ try {
+ if (mApplyToTopic.isChecked()) {
+ mINotificationManager.setTopicImportance(sbn.getPackageName(), sbn.getUid(), mTopic,
+ progress);
+ } else {
+ mINotificationManager.setAppImportance(
+ sbn.getPackageName(), sbn.getUid(), progress);
+ }
+ } catch (RemoteException e) {
+ // :(
+ }
}
public void setActualHeight(int actualHeight) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
index f243b00..d7e47c2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
@@ -30,11 +30,11 @@
public class RemoteInputController {
private final ArrayList<WeakReference<NotificationData.Entry>> mRemoteInputs = new ArrayList<>();
- private final StatusBarWindowManager mStatusBarWindowManager;
+ private final ArrayList<Callback> mCallbacks = new ArrayList<>(3);
private final HeadsUpManager mHeadsUpManager;
public RemoteInputController(StatusBarWindowManager sbwm, HeadsUpManager headsUpManager) {
- mStatusBarWindowManager = sbwm;
+ addCallback(sbwm);
mHeadsUpManager = headsUpManager;
}
@@ -59,8 +59,12 @@
}
private void apply(NotificationData.Entry entry) {
- mStatusBarWindowManager.setRemoteInputActive(isRemoteInputActive());
mHeadsUpManager.setRemoteInputActive(entry, isRemoteInputActive(entry));
+ boolean remoteInputActive = isRemoteInputActive();
+ int N = mCallbacks.size();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.get(i).onRemoteInputActive(remoteInputActive);
+ }
}
/**
@@ -99,4 +103,12 @@
}
+ public void addCallback(Callback callback) {
+ Preconditions.checkNotNull(callback);
+ mCallbacks.add(callback);
+ }
+
+ public interface Callback {
+ void onRemoteInputActive(boolean active);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java
new file mode 100644
index 0000000..5c0f38c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.car;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.R.color;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView.ScaleType;
+import android.widget.LinearLayout;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.ActivityStarter;
+import com.android.systemui.statusbar.phone.NavigationBarView;
+import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
+import com.android.systemui.statusbar.policy.KeyButtonView;
+
+import java.net.URISyntaxException;
+
+/**
+ * A custom navigation bar for the automotive use case.
+ * <p>
+ * The navigation bar in the automotive use case is more like a list of shortcuts, which we
+ * expect to be customizable by the car OEMs. This implementation populates the nav_buttons layout
+ * from resources rather than the layout file so customization would then mean updating
+ * arrays_car.xml appropriately in an overlay.
+ */
+class CarNavigationBarView extends NavigationBarView {
+ private ActivityStarter mActivityStarter;
+
+ public CarNavigationBarView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void onFinishInflate() {
+ // Read up arrays_car.xml and populate the navigation bar here.
+ Context context = getContext();
+ Resources r = getContext().getResources();
+ TypedArray icons = r.obtainTypedArray(R.array.car_shortcut_icons);
+ TypedArray intents = r.obtainTypedArray(R.array.car_shortcut_intent_uris);
+ TypedArray longpressIntents =
+ r.obtainTypedArray(R.array.car_shortcut_longpress_intent_uris);
+
+ if (icons.length() != intents.length()) {
+ throw new RuntimeException("car_shortcut_icons and car_shortcut_intents do not match");
+ }
+
+ LinearLayout navButtons = (LinearLayout) findViewById(R.id.nav_buttons);
+ LinearLayout lightsOut = (LinearLayout) findViewById(R.id.lights_out);
+
+ for (int i = 0; i < icons.length(); i++) {
+ Drawable icon = icons.getDrawable(i);
+
+ try {
+ Intent intent = Intent.parseUri(intents.getString(i), Intent.URI_INTENT_SCHEME);
+ Intent longpress = null;
+ String longpressUri = longpressIntents.getString(i);
+ if (!longpressUri.isEmpty()) {
+ longpress = Intent.parseUri(longpressUri, Intent.URI_INTENT_SCHEME);
+ }
+
+ // nav_buttons and lights_out should match exactly.
+ navButtons.addView(makeButton(context, icon, intent, longpress));
+ lightsOut.addView(makeButton(context, icon, intent, longpress));
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Malformed intent uri", e);
+ }
+ }
+ }
+
+ private ImageButton makeButton(Context context, Drawable icon,
+ final Intent intent, final Intent longpress) {
+ ImageButton button = new ImageButton(context);
+
+ button.setImageDrawable(icon);
+ button.setScaleType(ScaleType.CENTER);
+ button.setBackgroundColor(color.transparent);
+ LinearLayout.LayoutParams lp =
+ new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
+ button.setLayoutParams(lp);
+
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mActivityStarter != null) {
+ mActivityStarter.startActivity(intent, true);
+ }
+ }
+ });
+
+ // Long click handlers are optional.
+ if (longpress != null) {
+ button.setLongClickable(true);
+ button.setOnLongClickListener(new OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (mActivityStarter != null) {
+ mActivityStarter.startActivity(longpress, true);
+ return true;
+ }
+ return false;
+ }
+ });
+ } else {
+ button.setLongClickable(false);
+ }
+
+ return button;
+ }
+
+ public void setActivityStarter(ActivityStarter activityStarter) {
+ mActivityStarter = activityStarter;
+ }
+
+ @Override
+ public void setDisabledFlags(int disabledFlags, boolean force) {
+ // TODO: Populate.
+ }
+
+ @Override
+ public void reorient() {
+ // We expect the car head unit to always have a fixed rotation so we ignore this. The super
+ // class implentation expects mRotatedViews to be populated, so if you call into it, there
+ // is a possibility of a NullPointerException.
+ }
+
+ @Override
+ public View getCurrentView() {
+ return this;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
new file mode 100644
index 0000000..a72b5d0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.car;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.view.WindowManager;
+
+import com.android.systemui.R;
+import com.android.systemui.statusbar.phone.PhoneStatusBar;
+
+/**
+ * A status bar (and navigation bar) tailored for the automotive use case.
+ */
+public class CarStatusBar extends PhoneStatusBar {
+ @Override
+ protected void addNavigationBar() {
+ WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
+ WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
+ | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
+ | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
+ | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+ PixelFormat.TRANSLUCENT);
+ lp.setTitle("CarNavigationBar");
+ lp.windowAnimations = 0;
+ mWindowManager.addView(mNavigationBarView, lp);
+ }
+
+ @Override
+ protected void createNavigationBarView(Context context) {
+ if (mNavigationBarView != null) {
+ return;
+ }
+
+ CarNavigationBarView carNavBar =
+ (CarNavigationBarView) View.inflate(context, R.layout.car_navigation_bar, null);
+ carNavBar.setActivityStarter(this);
+ mNavigationBarView = carNavBar;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index a3d0ce6..55c7cb7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -69,7 +69,6 @@
View mCurrentView = null;
View[] mRotatedViews = new View[4];
- int mBarSize;
boolean mVertical;
boolean mScreenOn;
@@ -78,6 +77,9 @@
int mNavigationIconHints = 0;
private Drawable mBackIcon, mBackLandIcon, mBackAltIcon, mBackAltLandIcon;
+ private Drawable mBackCarModeIcon, mBackLandCarModeIcon;
+ private Drawable mBackAltCarModeIcon, mBackAltLandCarModeIcon;
+ private Drawable mHomeDefaultIcon, mHomeCarModeIcon;
private Drawable mRecentIcon;
private Drawable mRecentLandIcon;
@@ -96,6 +98,7 @@
private boolean mIsLayoutRtl;
private boolean mLayoutTransitionsEnabled = true;
private boolean mWakeAndUnlocking;
+ private boolean mCarMode = false;
private class NavTransitionListener implements TransitionListener {
private boolean mBackTransitioning;
@@ -157,8 +160,8 @@
final String how = "" + m.obj;
final int w = getWidth();
final int h = getHeight();
- final int vw = mCurrentView.getWidth();
- final int vh = mCurrentView.getHeight();
+ final int vw = getCurrentView().getWidth();
+ final int vh = getCurrentView().getHeight();
if (h != vh || w != vw) {
Log.w(TAG, String.format(
@@ -176,16 +179,15 @@
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
- mDisplay = ((WindowManager)context.getSystemService(
+ mDisplay = ((WindowManager) context.getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
final Resources res = getContext().getResources();
- mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
mVertical = false;
mShowMenu = false;
mGestureHelper = new NavigationBarGestureHelper(context);
- getIcons(res);
+ getIcons(context);
mBarTransitions = new NavigationBarTransitions(this);
}
@@ -230,41 +232,53 @@
}
public KeyButtonView getRecentsButton() {
- return (KeyButtonView) mCurrentView.findViewById(R.id.recent_apps);
+ return (KeyButtonView) getCurrentView().findViewById(R.id.recent_apps);
}
public View getMenuButton() {
- return mCurrentView.findViewById(R.id.menu);
+ return getCurrentView().findViewById(R.id.menu);
}
public View getBackButton() {
- return mCurrentView.findViewById(R.id.back);
+ return getCurrentView().findViewById(R.id.back);
}
public KeyButtonView getHomeButton() {
- return (KeyButtonView) mCurrentView.findViewById(R.id.home);
+ return (KeyButtonView) getCurrentView().findViewById(R.id.home);
}
public View getImeSwitchButton() {
- return mCurrentView.findViewById(R.id.ime_switcher);
+ return getCurrentView().findViewById(R.id.ime_switcher);
}
public View getAppShelf() {
- return mCurrentView.findViewById(R.id.app_shelf);
+ return getCurrentView().findViewById(R.id.app_shelf);
}
- private void getIcons(Resources res) {
- mBackIcon = res.getDrawable(R.drawable.ic_sysbar_back);
+ private void getCarModeIcons(Context ctx) {
+ mBackCarModeIcon = ctx.getDrawable(R.drawable.ic_sysbar_back_carmode);
+ mBackLandCarModeIcon = mBackCarModeIcon;
+ mBackAltCarModeIcon = ctx.getDrawable(R.drawable.ic_sysbar_back_ime_carmode);
+ mBackAltLandCarModeIcon = mBackAltCarModeIcon;
+ mHomeCarModeIcon = ctx.getDrawable(R.drawable.ic_sysbar_home_carmode);
+ }
+
+ private void getIcons(Context ctx) {
+ mBackIcon = ctx.getDrawable(R.drawable.ic_sysbar_back);
mBackLandIcon = mBackIcon;
- mBackAltIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime);
+ mBackAltIcon = ctx.getDrawable(R.drawable.ic_sysbar_back_ime);
mBackAltLandIcon = mBackAltIcon;
- mRecentIcon = res.getDrawable(R.drawable.ic_sysbar_recent);
+
+ mHomeDefaultIcon = ctx.getDrawable(R.drawable.ic_sysbar_home);
+
+ mRecentIcon = ctx.getDrawable(R.drawable.ic_sysbar_recent);
mRecentLandIcon = mRecentIcon;
+ getCarModeIcons(ctx);
}
@Override
public void setLayoutDirection(int layoutDirection) {
- getIcons(getContext().getResources());
+ getIcons(getContext());
super.setLayoutDirection(layoutDirection);
}
@@ -278,6 +292,18 @@
setNavigationIconHints(hints, false);
}
+ private Drawable getBackIconWithAlt(boolean carMode, boolean landscape) {
+ return landscape
+ ? carMode ? mBackAltLandCarModeIcon : mBackAltLandIcon
+ : carMode ? mBackAltCarModeIcon : mBackAltIcon;
+ }
+
+ private Drawable getBackIcon(boolean carMode, boolean landscape) {
+ return landscape
+ ? carMode ? mBackLandCarModeIcon : mBackLandIcon
+ : carMode ? mBackCarModeIcon : mBackIcon;
+ }
+
public void setNavigationIconHints(int hints, boolean force) {
if (!force && hints == mNavigationIconHints) return;
final boolean backAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
@@ -292,11 +318,23 @@
mNavigationIconHints = hints;
- ((ImageView)getBackButton()).setImageDrawable(backAlt
- ? (mVertical ? mBackAltLandIcon : mBackAltIcon)
- : (mVertical ? mBackLandIcon : mBackIcon));
+ // We have to replace or restore the back and home button icons when exiting or entering
+ // carmode, respectively. Recents are not available in CarMode in nav bar so change
+ // to recent icon is not required.
+ Drawable backIcon = (backAlt)
+ ? getBackIconWithAlt(mCarMode, mVertical)
+ : getBackIcon(mCarMode, mVertical);
- ((ImageView)getRecentsButton()).setImageDrawable(mVertical ? mRecentLandIcon : mRecentIcon);
+ ((ImageView) getBackButton()).setImageDrawable(backIcon);
+
+ ((ImageView) getRecentsButton()).setImageDrawable(
+ mVertical ? mRecentLandIcon : mRecentIcon);
+
+ if (mCarMode) {
+ ((ImageView) getHomeButton()).setImageDrawable(mHomeCarModeIcon);
+ } else {
+ ((ImageView) getHomeButton()).setImageDrawable(mHomeDefaultIcon);
+ }
final boolean showImeButton = ((hints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0);
getImeSwitchButton().setVisibility(showImeButton ? View.VISIBLE : View.INVISIBLE);
@@ -326,7 +364,7 @@
setSlippery(disableHome && disableRecent && disableBack && disableSearch);
}
- ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
+ ViewGroup navButtons = (ViewGroup) getCurrentView().findViewById(R.id.nav_buttons);
if (navButtons != null) {
LayoutTransition lt = navButtons.getLayoutTransition();
if (lt != null) {
@@ -379,7 +417,7 @@
private void updateLayoutTransitionsEnabled() {
boolean enabled = !mWakeAndUnlocking && mLayoutTransitionsEnabled;
- ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
+ ViewGroup navButtons = (ViewGroup) getCurrentView().findViewById(R.id.nav_buttons);
LayoutTransition lt = navButtons.getLayoutTransition();
if (lt != null) {
if (enabled) {
@@ -546,8 +584,33 @@
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ boolean uiCarModeChanged = updateCarMode(newConfig);
updateRTLOrder();
updateTaskSwitchHelper();
+ if (uiCarModeChanged) {
+ // uiMode changed either from carmode or to carmode.
+ // replace the nav bar button icons based on which mode
+ // we are switching to.
+ setNavigationIconHints(mNavigationIconHints, true);
+ }
+ }
+
+ /**
+ * If the configuration changed, update the carmode and return that it was updated.
+ */
+ private boolean updateCarMode(Configuration newConfig) {
+ boolean uiCarModeChanged = false;
+ if (newConfig != null) {
+ int uiMode = newConfig.uiMode & Configuration.UI_MODE_TYPE_MASK;
+ if (mCarMode && uiMode != Configuration.UI_MODE_TYPE_CAR) {
+ mCarMode = false;
+ uiCarModeChanged = true;
+ } else if (uiMode == Configuration.UI_MODE_TYPE_CAR) {
+ mCarMode = true;
+ uiCarModeChanged = true;
+ }
+ }
+ return uiCarModeChanged;
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 42fd872..ba20679 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -1318,7 +1318,6 @@
mHeader.setExpansion(getHeaderExpansionFraction());
setQsTranslation(height);
requestScrollerTopPaddingUpdate(false /* animate */);
- updateNotificationScrim(height);
if (mKeyguardShowing) {
updateHeaderKeyguard();
}
@@ -1355,12 +1354,6 @@
}
}
- private void updateNotificationScrim(float height) {
- int startDistance = mQsMinExpansionHeight + mNotificationScrimWaitDistance;
- float progress = (height - startDistance) / (mQsMaxExpansionHeight - startDistance);
- progress = Math.max(0.0f, Math.min(progress, 1.0f));
- }
-
private float getHeaderExpansionFraction() {
if (!mKeyguardShowing) {
return getQsExpansionFraction();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index e1a400d..6aa072f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -71,7 +71,6 @@
Log.e(TAG, "setPanelHolder: null PanelHolder", new Throwable());
return;
}
- ph.setBar(this);
mPanelHolder = ph;
final int N = ph.getChildCount();
for (int i=0; i<N; i++) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java
index d7f34d5..5095ebb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java
@@ -28,7 +28,6 @@
public static final boolean DEBUG_GESTURES = true;
private int mSelectedPanelIndex = -1;
- private PanelBar mBar;
public PanelHolder(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -79,8 +78,4 @@
}
return false;
}
-
- public void setBar(PanelBar panelBar) {
- mBar = panelBar;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 5e54ba7..7b2498f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -58,7 +58,6 @@
private float mPeekHeight;
private float mHintDistance;
- private int mEdgeTapAreaWidth;
private float mInitialOffsetOnTouch;
private boolean mCollapsedAndHeadsUpOnDown;
private float mExpandedFraction = 0;
@@ -202,7 +201,6 @@
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
mTouchSlop = configuration.getScaledTouchSlop();
mHintDistance = res.getDimension(R.dimen.hint_move_distance);
- mEdgeTapAreaWidth = res.getDimensionPixelSize(R.dimen.edge_tap_area_width);
mUnlockFalsingThreshold = res.getDimensionPixelSize(R.dimen.unlock_falsing_threshold);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 78d09e3..d688250 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -728,32 +728,7 @@
boolean showNav = mWindowManagerService.hasNavigationBar();
if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
if (showNav) {
- // Optionally show app shortcuts in the nav bar "shelf" area.
- if (shouldShowAppShelf()) {
- mNavigationBarView = (NavigationBarView) View.inflate(
- context, R.layout.navigation_bar_with_apps, null);
- } else {
- mNavigationBarView = (NavigationBarView) View.inflate(
- context, R.layout.navigation_bar, null);
- }
- mNavigationBarView.setDisabledFlags(mDisabled1);
- mNavigationBarView.setComponents(mRecents, getComponent(Divider.class));
- mNavigationBarView.setOnVerticalChangedListener(
- new NavigationBarView.OnVerticalChangedListener() {
- @Override
- public void onVerticalChanged(boolean isVertical) {
- if (mAssistManager != null) {
- mAssistManager.onConfigurationChanged();
- }
- mNotificationPanel.setQsScrimEnabled(!isVertical);
- }
- });
- mNavigationBarView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- checkUserAutohide(v, event);
- return false;
- }});
+ createNavigationBarView(context);
}
} catch (RemoteException ex) {
// no window manager? good luck with that
@@ -979,6 +954,35 @@
return mStatusBarView;
}
+ protected void createNavigationBarView(Context context) {
+ // Optionally show app shortcuts in the nav bar "shelf" area.
+ if (shouldShowAppShelf()) {
+ mNavigationBarView = (NavigationBarView) View.inflate(
+ context, R.layout.navigation_bar_with_apps, null);
+ } else {
+ mNavigationBarView = (NavigationBarView) View.inflate(
+ context, R.layout.navigation_bar, null);
+ }
+ mNavigationBarView.setDisabledFlags(mDisabled1);
+ mNavigationBarView.setComponents(mRecents, getComponent(Divider.class));
+ mNavigationBarView.setOnVerticalChangedListener(
+ new NavigationBarView.OnVerticalChangedListener() {
+ @Override
+ public void onVerticalChanged(boolean isVertical) {
+ if (mAssistManager != null) {
+ mAssistManager.onConfigurationChanged();
+ }
+ mNotificationPanel.setQsScrimEnabled(!isVertical);
+ }
+ });
+ mNavigationBarView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ checkUserAutohide(v, event);
+ return false;
+ }});
+ }
+
/** Returns true if the app shelf should be shown in the nav bar. */
private boolean shouldShowAppShelf() {
// Allow adb to override the default shelf behavior:
@@ -1086,6 +1090,7 @@
mKeyguardIndicationController.setStatusBarKeyguardViewManager(
mStatusBarKeyguardViewManager);
mFingerprintUnlockController.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
+ mRemoteInputController.addCallback(mStatusBarKeyguardViewManager);
mKeyguardViewMediatorCallback = keyguardViewMediator.getViewMediatorCallback();
}
@@ -1191,7 +1196,7 @@
}
// For small-screen devices (read: phones) that lack hardware navigation buttons
- private void addNavigationBar() {
+ protected void addNavigationBar() {
if (DEBUG) Log.v(TAG, "addNavigationBar: about to add " + mNavigationBarView);
if (mNavigationBarView == null) return;
@@ -2987,6 +2992,7 @@
if (DEBUG) Log.v(TAG, "onReceive: " + intent);
String action = intent.getAction();
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
+ getKeyboardShortcuts().dismissKeyboardShortcutsDialog();
if (isCurrentProfile(getSendingUserId())) {
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
String reason = intent.getStringExtra("reason");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index c0887ca..ab37e6a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -51,7 +51,6 @@
public PhoneStatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
- Resources res = getContext().getResources();
mBarTransitions = new PhoneStatusBarTransitions(this);
}
@@ -102,7 +101,6 @@
@Override
public PanelView selectPanelForTouch(MotionEvent touch) {
- // No double swiping. If either panel is open, nothing else can be pulled down.
return mNotificationPanel.getExpandedHeight() > 0
? null
: mNotificationPanel;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 05f6e57..f14f0d4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -31,6 +31,7 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.statusbar.CommandQueue;
+import com.android.systemui.statusbar.RemoteInputController;
import static com.android.keyguard.KeyguardHostView.OnDismissAction;
@@ -40,7 +41,7 @@
* which is in turn, reported to this class by the current
* {@link com.android.keyguard.KeyguardViewBase}.
*/
-public class StatusBarKeyguardViewManager {
+public class StatusBarKeyguardViewManager implements RemoteInputController.Callback {
// When hiding the Keyguard with timing supplied from WindowManager, better be early than late.
private static final long HIDE_TIMING_CORRECTION_MS = -3 * 16;
@@ -69,12 +70,15 @@
private KeyguardBouncer mBouncer;
private boolean mShowing;
private boolean mOccluded;
+ private boolean mRemoteInputActive;
private boolean mFirstUpdate = true;
private boolean mLastShowing;
private boolean mLastOccluded;
private boolean mLastBouncerShowing;
private boolean mLastBouncerDismissible;
+ private boolean mLastRemoteInputActive;
+
private OnDismissAction mAfterKeyguardGoneAction;
private boolean mDeviceWillWakeUp;
private boolean mDeferScrimFadeOut;
@@ -199,6 +203,12 @@
mPhoneStatusBar.onScreenTurnedOn();
}
+ @Override
+ public void onRemoteInputActive(boolean active) {
+ mRemoteInputActive = active;
+ updateStates();
+ }
+
public void onScreenTurnedOff() {
mScreenTurnedOn = false;
}
@@ -429,18 +439,21 @@
boolean occluded = mOccluded;
boolean bouncerShowing = mBouncer.isShowing();
boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();
+ boolean remoteInputActive = mRemoteInputActive;
- if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing)
+ if ((bouncerDismissible || !showing || remoteInputActive) !=
+ (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive)
|| mFirstUpdate) {
- if (bouncerDismissible || !showing) {
+ if (bouncerDismissible || !showing || remoteInputActive) {
mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK);
} else {
mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK);
}
}
- boolean navBarVisible = (!(showing && !occluded) || bouncerShowing);
- boolean lastNavBarVisible = (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing);
+ boolean navBarVisible = (!(showing && !occluded) || bouncerShowing || remoteInputActive);
+ boolean lastNavBarVisible = (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing
+ || mLastRemoteInputActive);
if (navBarVisible != lastNavBarVisible || mFirstUpdate) {
if (mPhoneStatusBar.getNavigationBarView() != null) {
if (navBarVisible) {
@@ -477,6 +490,7 @@
mLastOccluded = occluded;
mLastBouncerShowing = bouncerShowing;
mLastBouncerDismissible = bouncerDismissible;
+ mLastRemoteInputActive = remoteInputActive;
mPhoneStatusBar.onKeyguardViewManagerStatesUpdated();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index abe51ac..9d2f0de 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -30,6 +30,7 @@
import com.android.keyguard.R;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.statusbar.BaseStatusBar;
+import com.android.systemui.statusbar.RemoteInputController;
import com.android.systemui.statusbar.StatusBarState;
import java.io.FileDescriptor;
@@ -39,7 +40,7 @@
/**
* Encapsulates all logic for the status bar window state management.
*/
-public class StatusBarWindowManager {
+public class StatusBarWindowManager implements RemoteInputController.Callback {
private final Context mContext;
private final WindowManager mWindowManager;
@@ -292,7 +293,8 @@
apply(mCurrentState);
}
- public void setRemoteInputActive(boolean remoteInputActive) {
+ @Override
+ public void onRemoteInputActive(boolean remoteInputActive) {
mCurrentState.remoteInputActive = remoteInputActive;
apply(mCurrentState);
}
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 4348913..9dda321 100755
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -1244,7 +1244,7 @@
sInfo.applicationInfo.uid, sInfo.packageName, callingPid);
if (allowed != ActivityManager.APP_START_MODE_NORMAL) {
Slog.w(TAG, "Background execution not allowed: service "
- + r.intent + " to " + name.flattenToShortString()
+ + service + " to " + name.flattenToShortString()
+ " from pid=" + callingPid + " uid=" + callingUid
+ " pkg=" + callingPackage);
return null;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index fb62a95..bac2295 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -9462,23 +9462,23 @@
}
@Override
- public void moveActivityToStack(IBinder token, int stackId) throws RemoteException {
- if (stackId == HOME_STACK_ID) {
- throw new IllegalArgumentException(
- "moveActivityToStack: Attempt to move token " + token + " to home stack");
- }
+ public void exitFreeformMode(IBinder token) throws RemoteException {
synchronized (this) {
long ident = Binder.clearCallingIdentity();
try {
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
if (r == null) {
throw new IllegalArgumentException(
- "moveActivityToStack: No activity record matching token=" + token);
+ "exitFreeformMode: No activity record matching token=" + token);
}
- if (DEBUG_STACK) Slog.d(TAG_STACK, "moveActivityToStack: moving r=" + r
- + " to stackId=" + stackId);
- mStackSupervisor.moveTaskToStackLocked(r.task.taskId, stackId, ON_TOP, !FORCE_FOCUS,
- "moveActivityToStack", ANIMATE);
+ final ActivityStack stack = r.getStackLocked(token);
+ if (stack == null || stack.mStackId != FREEFORM_WORKSPACE_STACK_ID) {
+ throw new IllegalStateException(
+ "exitFreeformMode: You can only go fullscreen from freeform.");
+ }
+ if (DEBUG_STACK) Slog.d(TAG_STACK, "exitFreeformMode: " + r);
+ mStackSupervisor.moveTaskToStackLocked(r.task.taskId, FULLSCREEN_WORKSPACE_STACK_ID,
+ ON_TOP, !FORCE_FOCUS, "exitFreeformMode", ANIMATE);
} finally {
Binder.restoreCallingIdentity(ident);
}
@@ -12252,6 +12252,17 @@
com.android.internal.R.dimen.thumbnail_height);
mDefaultPinnedStackBounds = Rect.unflattenFromString(res.getString(
com.android.internal.R.string.config_defaultPictureInPictureBounds));
+ final String appsNotReportingCrashes = res.getString(
+ com.android.internal.R.string.config_appsNotReportingCrashes);
+ if (appsNotReportingCrashes != null) {
+ final String[] split = appsNotReportingCrashes.split(",");
+ if (split.length > 0) {
+ mAppsNotReportingCrashes = new ArraySet<>();
+ for (int i = 0; i < split.length; i++) {
+ mAppsNotReportingCrashes.add(split[i]);
+ }
+ }
+ }
}
}
@@ -17839,6 +17850,11 @@
"Unable to find instrumentation target package: " + ii.targetPackage);
return false;
}
+ if (!ai.hasCode()) {
+ reportStartInstrumentationFailure(watcher, className,
+ "Instrumentation target has no code: " + ii.targetPackage);
+ return false;
+ }
int match = mContext.getPackageManager().checkSignatures(
ii.targetPackage, ii.packageName);
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 8d9cb58..e123dbd 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -21,8 +21,13 @@
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
+import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
+import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT;
+import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
+import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
+import static android.content.res.Configuration.SCREENLAYOUT_UNDEFINED;
import static com.android.server.am.ActivityManagerDebugConfig.*;
import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
@@ -4224,20 +4229,20 @@
int taskChanges = oldTaskOverride.diff(taskConfig);
// We don't want to use size changes if they don't cross boundaries that are important to
// the app.
- if ((taskChanges & ActivityInfo.CONFIG_SCREEN_SIZE) != 0) {
+ if ((taskChanges & CONFIG_SCREEN_SIZE) != 0) {
final boolean crosses = record.crossesHorizontalSizeThreshold(
oldTaskOverride.screenWidthDp, taskConfig.screenWidthDp)
|| record.crossesVerticalSizeThreshold(
oldTaskOverride.screenHeightDp, taskConfig.screenHeightDp);
if (!crosses) {
- taskChanges &= ~ActivityInfo.CONFIG_SCREEN_SIZE;
+ taskChanges &= ~CONFIG_SCREEN_SIZE;
}
}
- if ((taskChanges & ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) != 0) {
+ if ((taskChanges & CONFIG_SMALLEST_SCREEN_SIZE) != 0) {
final int oldSmallest = oldTaskOverride.smallestScreenWidthDp;
final int newSmallest = taskConfig.smallestScreenWidthDp;
if (!record.crossesSmallestSizeThreshold(oldSmallest, newSmallest)) {
- taskChanges &= ~ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+ taskChanges &= ~CONFIG_SMALLEST_SCREEN_SIZE;
}
}
return catchConfigChangesFromUnset(taskConfig, oldTaskOverride, taskChanges);
@@ -4249,7 +4254,7 @@
// {@link Configuration#diff} doesn't catch changes from unset values.
// Check for changes we care about.
if (oldTaskOverride.orientation != taskConfig.orientation) {
- taskChanges |= ActivityInfo.CONFIG_ORIENTATION;
+ taskChanges |= CONFIG_ORIENTATION;
}
// We want to explicitly track situations where the size configuration goes from
// undefined to defined. We don't care about crossing the threshold in that case,
@@ -4259,29 +4264,35 @@
final int undefinedHeight = Configuration.SCREEN_HEIGHT_DP_UNDEFINED;
if ((oldHeight == undefinedHeight && newHeight != undefinedHeight)
|| (oldHeight != undefinedHeight && newHeight == undefinedHeight)) {
- taskChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
+ taskChanges |= CONFIG_SCREEN_SIZE;
}
final int oldWidth = oldTaskOverride.screenWidthDp;
final int newWidth = taskConfig.screenWidthDp;
final int undefinedWidth = Configuration.SCREEN_WIDTH_DP_UNDEFINED;
if ((oldWidth == undefinedWidth && newWidth != undefinedWidth)
|| (oldWidth != undefinedWidth && newWidth == undefinedWidth)) {
- taskChanges |= ActivityInfo.CONFIG_SCREEN_SIZE;
+ taskChanges |= CONFIG_SCREEN_SIZE;
}
final int oldSmallest = oldTaskOverride.smallestScreenWidthDp;
final int newSmallest = taskConfig.smallestScreenWidthDp;
final int undefinedSmallest = Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
if ((oldSmallest == undefinedSmallest && newSmallest != undefinedSmallest)
|| (oldSmallest != undefinedSmallest && newSmallest == undefinedSmallest)) {
- taskChanges |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+ taskChanges |= CONFIG_SMALLEST_SCREEN_SIZE;
+ }
+ final int oldLayout = oldTaskOverride.screenLayout;
+ final int newLayout = taskConfig.screenLayout;
+ if ((oldLayout == SCREENLAYOUT_UNDEFINED && newLayout != SCREENLAYOUT_UNDEFINED)
+ || (oldLayout != SCREENLAYOUT_UNDEFINED && newLayout == SCREENLAYOUT_UNDEFINED)) {
+ taskChanges |= CONFIG_SCREEN_LAYOUT;
}
}
return taskChanges;
}
private static boolean isResizeOnlyChange(int change) {
- return (change & ~(ActivityInfo.CONFIG_SCREEN_SIZE
- | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION)) == 0;
+ return (change & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE | CONFIG_ORIENTATION
+ | CONFIG_SCREEN_LAYOUT)) == 0;
}
private void relaunchActivityLocked(
@@ -4595,7 +4606,7 @@
a.forceNewConfig = true;
if (starting != null && a == starting && a.visible) {
a.startFreezingScreenLocked(starting.app,
- ActivityInfo.CONFIG_SCREEN_LAYOUT);
+ CONFIG_SCREEN_LAYOUT);
}
}
}
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index c97d09c..ae987e6 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -1298,6 +1298,9 @@
(mOverrideConfig.screenWidthDp <= mOverrideConfig.screenHeightDp)
? Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
+ final int sl = Configuration.resetScreenLayout(serviceConfig.screenLayout);
+ mOverrideConfig.screenLayout = Configuration.reduceScreenLayout(
+ sl, mOverrideConfig.screenWidthDp, mOverrideConfig.screenHeightDp);
}
if (mFullscreen != oldFullscreen) {
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 276c6ba..f7043a6 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -570,13 +570,13 @@
ZenLog.traceConfig(reason, mConfig, config);
final boolean policyChanged = !Objects.equals(getNotificationPolicy(mConfig),
getNotificationPolicy(config));
- mConfig = config;
- if (config.equals(mConfig)) {
+ if (!config.equals(mConfig)) {
dispatchOnConfigChanged();
}
if (policyChanged) {
dispatchOnPolicyChanged();
}
+ mConfig = config;
final String val = Integer.toString(config.hashCode());
Global.putString(mContext.getContentResolver(), Global.ZEN_MODE_CONFIG_ETAG, val);
if (!evaluateZenMode(reason, setRingerMode)) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 99f4031..9e0f3ce 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -602,7 +602,9 @@
boolean mResolverReplaced = false;
- private final ComponentName mIntentFilterVerifierComponent;
+ private final @Nullable ComponentName mIntentFilterVerifierComponent;
+ private final @Nullable IntentFilterVerifier<ActivityIntentInfo> mIntentFilterVerifier;
+
private int mIntentFilterVerificationToken = 0;
/** Component that knows whether or not an ephemeral application exists */
@@ -838,8 +840,6 @@
filter.hasDataScheme(IntentFilter.SCHEME_HTTPS));
}
- private IntentFilterVerifier mIntentFilterVerifier;
-
// Set of pending broadcasts for aggregating enable/disable of components.
static class PendingPackageBroadcasts {
// for each user id, a map of <package name -> components within that package>
@@ -974,8 +974,8 @@
private static final String TAG_DEFAULT_APPS = "da";
private static final String TAG_INTENT_FILTER_VERIFICATION = "iv";
- final String mRequiredVerifierPackage;
- final String mRequiredInstallerPackage;
+ final @Nullable String mRequiredVerifierPackage;
+ final @Nullable String mRequiredInstallerPackage;
private final PackageUsage mPackageUsage = new PackageUsage();
@@ -2362,15 +2362,21 @@
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_READY,
SystemClock.uptimeMillis());
- mRequiredVerifierPackage = getRequiredVerifierLPr();
- mRequiredInstallerPackage = getRequiredInstallerLPr();
+ if (!mOnlyCore) {
+ mRequiredVerifierPackage = getRequiredVerifierLPr();
+ mRequiredInstallerPackage = getRequiredInstallerLPr();
+ mIntentFilterVerifierComponent = getIntentFilterVerifierComponentNameLPr();
+ mIntentFilterVerifier = new IntentVerifierProxy(mContext,
+ mIntentFilterVerifierComponent);
+ } else {
+ mRequiredVerifierPackage = null;
+ mRequiredInstallerPackage = null;
+ mIntentFilterVerifierComponent = null;
+ mIntentFilterVerifier = null;
+ }
mInstallerService = new PackageInstallerService(context, this);
- mIntentFilterVerifierComponent = getIntentFilterVerifierComponentNameLPr();
- mIntentFilterVerifier = new IntentVerifierProxy(mContext,
- mIntentFilterVerifierComponent);
-
final ComponentName ephemeralResolverComponent = getEphemeralResolverLPr();
final ComponentName ephemeralInstallerComponent = getEphemeralInstallerLPr();
// both the installer and resolver must be present to enable ephemeral
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 72611b7..f13d964 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -18,6 +18,8 @@
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
+import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
+import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN;
@@ -313,8 +315,10 @@
boolean mCanHideNavigationBar = false;
boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?
boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*?
- int[] mNavigationBarHeightForRotation = new int[4];
- int[] mNavigationBarWidthForRotation = new int[4];
+ int[] mNavigationBarHeightForRotationDefault = new int[4];
+ int[] mNavigationBarWidthForRotationDefault = new int[4];
+ int[] mNavigationBarHeightForRotationInCarMode = new int[4];
+ int[] mNavigationBarWidthForRotationInCarMode = new int[4];
// Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key.
// This is for car dock and this is updated from resource.
@@ -1674,20 +1678,37 @@
res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
// Height of the navigation bar when presented horizontally at bottom
- mNavigationBarHeightForRotation[mPortraitRotation] =
- mNavigationBarHeightForRotation[mUpsideDownRotation] =
+ mNavigationBarHeightForRotationDefault[mPortraitRotation] =
+ mNavigationBarHeightForRotationDefault[mUpsideDownRotation] =
res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
- mNavigationBarHeightForRotation[mLandscapeRotation] =
- mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize(
+ mNavigationBarHeightForRotationDefault[mLandscapeRotation] =
+ mNavigationBarHeightForRotationDefault[mSeascapeRotation] = res.getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_height_landscape);
// Width of the navigation bar when presented vertically along one side
- mNavigationBarWidthForRotation[mPortraitRotation] =
- mNavigationBarWidthForRotation[mUpsideDownRotation] =
- mNavigationBarWidthForRotation[mLandscapeRotation] =
- mNavigationBarWidthForRotation[mSeascapeRotation] =
+ mNavigationBarWidthForRotationDefault[mPortraitRotation] =
+ mNavigationBarWidthForRotationDefault[mUpsideDownRotation] =
+ mNavigationBarWidthForRotationDefault[mLandscapeRotation] =
+ mNavigationBarWidthForRotationDefault[mSeascapeRotation] =
res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
+ // Height of the navigation bar when presented horizontally at bottom
+ mNavigationBarHeightForRotationInCarMode[mPortraitRotation] =
+ mNavigationBarHeightForRotationInCarMode[mUpsideDownRotation] =
+ res.getDimensionPixelSize(
+ com.android.internal.R.dimen.navigation_bar_height_car_mode);
+ mNavigationBarHeightForRotationInCarMode[mLandscapeRotation] =
+ mNavigationBarHeightForRotationInCarMode[mSeascapeRotation] = res.getDimensionPixelSize(
+ com.android.internal.R.dimen.navigation_bar_height_landscape_car_mode);
+
+ // Width of the navigation bar when presented vertically along one side
+ mNavigationBarWidthForRotationInCarMode[mPortraitRotation] =
+ mNavigationBarWidthForRotationInCarMode[mUpsideDownRotation] =
+ mNavigationBarWidthForRotationInCarMode[mLandscapeRotation] =
+ mNavigationBarWidthForRotationInCarMode[mSeascapeRotation] =
+ res.getDimensionPixelSize(
+ com.android.internal.R.dimen.navigation_bar_width_car_mode);
+
// SystemUI (status bar) layout policy
int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density;
int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density;
@@ -2239,42 +2260,61 @@
return windowTypeToLayerLw(TYPE_STATUS_BAR);
}
+ private int getNavigationBarWidth(int rotation, int uiMode) {
+ if ((uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR) {
+ return mNavigationBarWidthForRotationInCarMode[rotation];
+ } else {
+ return mNavigationBarWidthForRotationDefault[rotation];
+ }
+ }
+
@Override
- public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) {
+ public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
+ int uiMode) {
if (mHasNavigationBar) {
// For a basic navigation bar, when we are in landscape mode we place
// the navigation bar to the side.
if (mNavigationBarCanMove && fullWidth > fullHeight) {
- return fullWidth - mNavigationBarWidthForRotation[rotation];
+ return fullWidth - getNavigationBarWidth(rotation, uiMode);
}
}
return fullWidth;
}
+ private int getNavigationBarHeight(int rotation, int uiMode) {
+ if ((uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR) {
+ return mNavigationBarHeightForRotationInCarMode[rotation];
+ } else {
+ return mNavigationBarHeightForRotationDefault[rotation];
+ }
+ }
+
@Override
- public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) {
+ public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
+ int uiMode) {
if (mHasNavigationBar) {
// For a basic navigation bar, when we are in portrait mode we place
// the navigation bar to the bottom.
if (!mNavigationBarCanMove || fullWidth < fullHeight) {
- return fullHeight - mNavigationBarHeightForRotation[rotation];
+ return fullHeight - getNavigationBarHeight(rotation, uiMode);
}
}
return fullHeight;
}
@Override
- public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) {
- return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation);
+ public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode) {
+ return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation, uiMode);
}
@Override
- public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) {
+ public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode) {
// There is a separate status bar at the top of the display. We don't count that as part
// of the fixed decor, since it can hide; however, for purposes of configurations,
// we do want to exclude it since applications can't generally use that part
// of the screen.
- return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight;
+ return getNonDecorDisplayHeight(
+ fullWidth, fullHeight, rotation, uiMode) - mStatusBarHeight;
}
@Override
@@ -2879,7 +2919,7 @@
} else if (keyCode == KeyEvent.KEYCODE_SLASH && event.isMetaPressed()) {
if (down) {
if (repeatCount == 0) {
- showKeyboardShortcutsMenu();
+ toggleKeyboardShortcutsMenu();
}
}
} else if (keyCode == KeyEvent.KEYCODE_ASSIST) {
@@ -3311,11 +3351,11 @@
}
}
- private void showKeyboardShortcutsMenu() {
+ private void toggleKeyboardShortcutsMenu() {
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
- statusbar.showKeyboardShortcutsMenu();
+ statusbar.toggleKeyboardShortcutsMenu();
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing keyboard shortcuts menu", e);
@@ -3550,7 +3590,7 @@
/** {@inheritDoc} */
@Override
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
- int displayRotation) {
+ int displayRotation, int uiMode) {
mDisplayRotation = displayRotation;
final int overscanLeft, overscanTop, overscanRight, overscanBottom;
if (isDefaultDisplay) {
@@ -3661,7 +3701,7 @@
navVisible |= !canHideNavigationBar();
boolean updateSysUiVisibility = layoutNavigationBar(displayWidth, displayHeight,
- displayRotation, overscanRight, overscanBottom, dcf, navVisible, navTranslucent,
+ displayRotation, uiMode, overscanRight, overscanBottom, dcf, navVisible, navTranslucent,
navAllowedHidden);
if (DEBUG_LAYOUT) Slog.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)",
mDockLeft, mDockTop, mDockRight, mDockBottom));
@@ -3740,7 +3780,7 @@
}
private boolean layoutNavigationBar(int displayWidth, int displayHeight, int displayRotation,
- int overscanRight, int overscanBottom, Rect dcf, boolean navVisible,
+ int uiMode, int overscanRight, int overscanBottom, Rect dcf, boolean navVisible,
boolean navTranslucent, boolean navAllowedHidden) {
if (mNavigationBar != null) {
boolean transientNavBarShowing = mNavigationBarController.isTransientShowing();
@@ -3752,7 +3792,7 @@
if (mNavigationBarOnBottom) {
// It's a system nav bar or a portrait screen; nav bar goes on bottom.
int top = displayHeight - overscanBottom
- - mNavigationBarHeightForRotation[displayRotation];
+ - getNavigationBarHeight(displayRotation, uiMode);
mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom);
mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top;
if (transientNavBarShowing) {
@@ -3777,7 +3817,7 @@
} else {
// Landscape screen; nav bar goes to the right.
int left = displayWidth - overscanRight
- - mNavigationBarWidthForRotation[displayRotation];
+ - getNavigationBarWidth(displayRotation, uiMode);
mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
if (transientNavBarShowing) {
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 6498dd9..290019c 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -16,21 +16,8 @@
package com.android.server.power;
-import android.app.ActivityManager;
-import android.util.SparseIntArray;
-import com.android.internal.app.IAppOpsService;
-import com.android.internal.app.IBatteryStats;
-import com.android.internal.os.BackgroundThread;
-import com.android.server.EventLogTags;
-import com.android.server.ServiceThread;
-import com.android.server.SystemService;
-import com.android.server.am.BatteryStatsService;
-import com.android.server.lights.Light;
-import com.android.server.lights.LightsManager;
-import com.android.server.Watchdog;
-
import android.Manifest;
-import android.app.AppOpsManager;
+import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -65,22 +52,32 @@
import android.service.dreams.DreamManagerInternal;
import android.util.EventLog;
import android.util.Slog;
+import android.util.SparseIntArray;
import android.util.TimeUtils;
import android.view.Display;
import android.view.WindowManagerPolicy;
+import com.android.internal.app.IAppOpsService;
+import com.android.internal.app.IBatteryStats;
+import com.android.internal.os.BackgroundThread;
+import com.android.server.EventLogTags;
+import com.android.server.ServiceThread;
+import com.android.server.SystemService;
+import com.android.server.Watchdog;
+import com.android.server.am.BatteryStatsService;
+import com.android.server.lights.Light;
+import com.android.server.lights.LightsManager;
+import libcore.util.Objects;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
-import libcore.util.Objects;
-
import static android.os.PowerManagerInternal.POWER_HINT_INTERACTION;
import static android.os.PowerManagerInternal.WAKEFULNESS_ASLEEP;
import static android.os.PowerManagerInternal.WAKEFULNESS_AWAKE;
-import static android.os.PowerManagerInternal.WAKEFULNESS_DREAMING;
import static android.os.PowerManagerInternal.WAKEFULNESS_DOZING;
+import static android.os.PowerManagerInternal.WAKEFULNESS_DREAMING;
/**
* The power manager service is responsible for coordinating power management
@@ -771,6 +768,10 @@
intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcast(intent);
+ // Send internal version that requires signature permission.
+ mContext.sendBroadcastAsUser(new Intent(
+ PowerManager.ACTION_POWER_SAVE_MODE_CHANGED_INTERNAL), UserHandle.ALL,
+ Manifest.permission.DEVICE_POWER);
}
});
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index fc27170..2d38da5 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -503,10 +503,10 @@
}
@Override
- public void showKeyboardShortcutsMenu() {
+ public void toggleKeyboardShortcutsMenu() {
if (mBar != null) {
try {
- mBar.showKeyboardShortcutsMenu();
+ mBar.toggleKeyboardShortcutsMenu();
} catch (RemoteException ex) {}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a7f7f04..45e28e1 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -578,31 +578,23 @@
final ArrayList<WindowState> mTmpWindows = new ArrayList<>();
boolean mHardKeyboardAvailable;
- boolean mShowImeWithHardKeyboard;
WindowManagerInternal.OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener;
SettingsObserver mSettingsObserver;
private final class SettingsObserver extends ContentObserver {
- private final Uri mShowImeWithHardKeyboardUri =
- Settings.Secure.getUriFor(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD);
-
private final Uri mDisplayInversionEnabledUri =
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
public SettingsObserver() {
super(new Handler());
ContentResolver resolver = mContext.getContentResolver();
- resolver.registerContentObserver(mShowImeWithHardKeyboardUri, false, this,
- UserHandle.USER_ALL);
resolver.registerContentObserver(mDisplayInversionEnabledUri, false, this,
UserHandle.USER_ALL);
}
@Override
public void onChange(boolean selfChange, Uri uri) {
- if (mShowImeWithHardKeyboardUri.equals(uri)) {
- updateShowImeWithHardKeyboard();
- } else if (mDisplayInversionEnabledUri.equals(uri)) {
+ if (mDisplayInversionEnabledUri.equals(uri)) {
updateCircularDisplayMaskIfNeeded();
}
}
@@ -946,7 +938,6 @@
mContext.registerReceiver(mBroadcastReceiver, filter);
mSettingsObserver = new SettingsObserver();
- updateShowImeWithHardKeyboard();
mHoldingScreenWakeLock = mPowerManager.newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG_WM);
@@ -2238,9 +2229,8 @@
// trigger its removal.
final boolean lastWinStartingNotAnimating = startingWindow && appToken!= null
&& appToken.allAppWindows.size() == 1 && !isAnimating;
- if (!lastWinStartingNotAnimating && (win.mExiting || isAnimating)) {
+ if (!lastWinStartingNotAnimating && win.mExiting) {
// The exit animation is running... wait for it!
- win.mExiting = true;
win.mRemoveOnExit = true;
win.setDisplayLayoutNeeded();
final boolean focusChanged = updateFocusedWindowLocked(
@@ -3478,6 +3468,7 @@
// the value of the previous configuration.
mTempConfiguration.setToDefaults();
mTempConfiguration.fontScale = currentConfig.fontScale;
+ mTempConfiguration.uiMode = currentConfig.uiMode;
computeScreenConfigurationLocked(mTempConfiguration);
if (currentConfig.diff(mTempConfiguration) != 0) {
mWaitingForConfig = true;
@@ -6295,7 +6286,7 @@
// the top of the method, the caller is obligated to call computeNewConfigurationLocked().
// By updating the Display info here it will be available to
// computeScreenConfigurationLocked later.
- updateDisplayAndOrientationLocked();
+ updateDisplayAndOrientationLocked(mCurConfiguration.uiMode);
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
if (!inTransaction) {
@@ -6862,16 +6853,17 @@
return config;
}
- private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation, int dw, int dh) {
+ private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int rotation, int uiMode,
+ int dw, int dh) {
// TODO: Multidisplay: for now only use with default display.
- final int width = mPolicy.getConfigDisplayWidth(dw, dh, rotation);
+ final int width = mPolicy.getConfigDisplayWidth(dw, dh, rotation, uiMode);
if (width < displayInfo.smallestNominalAppWidth) {
displayInfo.smallestNominalAppWidth = width;
}
if (width > displayInfo.largestNominalAppWidth) {
displayInfo.largestNominalAppWidth = width;
}
- final int height = mPolicy.getConfigDisplayHeight(dw, dh, rotation);
+ final int height = mPolicy.getConfigDisplayHeight(dw, dh, rotation, uiMode);
if (height < displayInfo.smallestNominalAppHeight) {
displayInfo.smallestNominalAppHeight = height;
}
@@ -6881,11 +6873,11 @@
}
private int reduceConfigLayout(int curLayout, int rotation, float density,
- int dw, int dh) {
+ int dw, int dh, int uiMode) {
// TODO: Multidisplay: for now only use with default display.
// Get the app screen size at this rotation.
- int w = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation);
- int h = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation);
+ int w = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode);
+ int h = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode);
// Compute the screen layout size class for this rotation.
int longSize = w;
@@ -6901,7 +6893,7 @@
}
private void computeSizeRangesAndScreenLayout(DisplayInfo displayInfo, boolean rotated,
- int dw, int dh, float density, Configuration outConfig) {
+ int uiMode, int dw, int dh, float density, Configuration outConfig) {
// TODO: Multidisplay: for now only use with default display.
// We need to determine the smallest width that will occur under normal
@@ -6920,24 +6912,24 @@
displayInfo.smallestNominalAppHeight = 1<<30;
displayInfo.largestNominalAppWidth = 0;
displayInfo.largestNominalAppHeight = 0;
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, unrotDw, unrotDh);
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, unrotDh, unrotDw);
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, unrotDw, unrotDh);
- adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, unrotDh, unrotDw);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_0, uiMode, unrotDw, unrotDh);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_90, uiMode, unrotDh, unrotDw);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_180, uiMode, unrotDw, unrotDh);
+ adjustDisplaySizeRanges(displayInfo, Surface.ROTATION_270, uiMode, unrotDh, unrotDw);
int sl = Configuration.resetScreenLayout(outConfig.screenLayout);
- sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh);
- sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw);
- sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh);
- sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh, uiMode);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw, uiMode);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh, uiMode);
+ sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw, uiMode);
outConfig.smallestScreenWidthDp = (int)(displayInfo.smallestNominalAppWidth / density);
outConfig.screenLayout = sl;
}
- private int reduceCompatConfigWidthSize(int curSize, int rotation, DisplayMetrics dm,
- int dw, int dh) {
+ private int reduceCompatConfigWidthSize(int curSize, int rotation, int uiMode,
+ DisplayMetrics dm, int dw, int dh) {
// TODO: Multidisplay: for now only use with default display.
- dm.noncompatWidthPixels = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation);
- dm.noncompatHeightPixels = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation);
+ dm.noncompatWidthPixels = mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode);
+ dm.noncompatHeightPixels = mPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode);
float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
if (curSize == 0 || size < curSize) {
@@ -6946,7 +6938,7 @@
return curSize;
}
- private int computeCompatSmallestWidth(boolean rotated, DisplayMetrics dm, int dw, int dh) {
+ private int computeCompatSmallestWidth(boolean rotated, int uiMode, DisplayMetrics dm, int dw, int dh) {
// TODO: Multidisplay: for now only use with default display.
mTmpDisplayMetrics.setTo(dm);
final DisplayMetrics tmpDm = mTmpDisplayMetrics;
@@ -6958,15 +6950,15 @@
unrotDw = dw;
unrotDh = dh;
}
- int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, tmpDm, unrotDw, unrotDh);
- sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, tmpDm, unrotDh, unrotDw);
- sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, tmpDm, unrotDw, unrotDh);
- sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, tmpDm, unrotDh, unrotDw);
+ int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, uiMode, tmpDm, unrotDw, unrotDh);
+ sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, uiMode, tmpDm, unrotDh, unrotDw);
+ sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, uiMode, tmpDm, unrotDw, unrotDh);
+ sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, uiMode, tmpDm, unrotDh, unrotDw);
return sw;
}
/** Do not call if mDisplayReady == false */
- DisplayInfo updateDisplayAndOrientationLocked() {
+ DisplayInfo updateDisplayAndOrientationLocked(int uiMode) {
// TODO(multidisplay): For now, apply Configuration to main screen only.
final DisplayContent displayContent = getDefaultDisplayContentLocked();
@@ -6997,8 +6989,8 @@
}
// Update application display metrics.
- final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation);
- final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation);
+ final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation, uiMode);
+ final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation, uiMode);
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
displayInfo.rotation = mRotation;
displayInfo.logicalWidth = dw;
@@ -7030,20 +7022,24 @@
/** Do not call if mDisplayReady == false */
void computeScreenConfigurationLocked(Configuration config) {
- final DisplayInfo displayInfo = updateDisplayAndOrientationLocked();
+ final DisplayInfo displayInfo = updateDisplayAndOrientationLocked(
+ config.uiMode);
final int dw = displayInfo.logicalWidth;
final int dh = displayInfo.logicalHeight;
config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT :
Configuration.ORIENTATION_LANDSCAPE;
config.screenWidthDp =
- (int)(mPolicy.getConfigDisplayWidth(dw, dh, mRotation) / mDisplayMetrics.density);
+ (int)(mPolicy.getConfigDisplayWidth(dw, dh, mRotation, config.uiMode) /
+ mDisplayMetrics.density);
config.screenHeightDp =
- (int)(mPolicy.getConfigDisplayHeight(dw, dh, mRotation) / mDisplayMetrics.density);
+ (int)(mPolicy.getConfigDisplayHeight(dw, dh, mRotation, config.uiMode) /
+ mDisplayMetrics.density);
final boolean rotated = (mRotation == Surface.ROTATION_90
|| mRotation == Surface.ROTATION_270);
- computeSizeRangesAndScreenLayout(displayInfo, rotated, dw, dh, mDisplayMetrics.density,
- config);
+
+ computeSizeRangesAndScreenLayout(displayInfo, rotated, config.uiMode, dw, dh,
+ mDisplayMetrics.density, config);
config.screenLayout = (config.screenLayout & ~Configuration.SCREENLAYOUT_ROUND_MASK)
| ((displayInfo.flags & Display.FLAG_ROUND) != 0
@@ -7052,7 +7048,7 @@
config.compatScreenWidthDp = (int)(config.screenWidthDp / mCompatibleScreenScale);
config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale);
- config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated,
+ config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, config.uiMode,
mDisplayMetrics, dw, dh);
config.densityDpi = displayInfo.logicalDensityDpi;
@@ -7111,9 +7107,6 @@
mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
}
- if (mShowImeWithHardKeyboard) {
- config.keyboard = Configuration.KEYBOARD_NOKEYS;
- }
// Let the policy update hidden states.
config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
@@ -7122,18 +7115,6 @@
mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
}
- public void updateShowImeWithHardKeyboard() {
- synchronized (mWindowMap) {
- final boolean showImeWithHardKeyboard = Settings.Secure.getIntForUser(
- mContext.getContentResolver(), Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD, 0,
- mCurrentUserId) == 1;
- if (mShowImeWithHardKeyboard != showImeWithHardKeyboard) {
- mShowImeWithHardKeyboard = showImeWithHardKeyboard;
- mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
- }
- }
- }
-
void notifyHardKeyboardStatusChange() {
final boolean available;
final WindowManagerInternal.OnHardKeyboardStatusChangeListener listener;
@@ -8471,6 +8452,7 @@
boolean configChanged = updateOrientationFromAppTokensLocked(false);
mTempConfiguration.setToDefaults();
mTempConfiguration.fontScale = mCurConfiguration.fontScale;
+ mTempConfiguration.uiMode = mCurConfiguration.uiMode;
computeScreenConfigurationLocked(mTempConfiguration);
configChanged |= mCurConfiguration.diff(mTempConfiguration) != 0;
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index feeab27..f77e5a6 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -859,7 +859,8 @@
+ displayContent.layoutNeeded + " dw=" + dw + " dh=" + dh);
}
- mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation);
+ mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation,
+ mService.mCurConfiguration.uiMode);
if (isDefaultDisplay) {
// Not needed on non-default displays.
mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw();
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 53edc789..dd58b3c 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -129,6 +129,7 @@
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.devicepolicy.DevicePolicyManagerService.ActiveAdmin.TrustAgentInfo;
+import com.android.server.pm.UserManagerService;
import com.android.server.pm.UserRestrictionsUtils;
import org.xmlpull.v1.XmlPullParser;
@@ -426,6 +427,7 @@
private static final String TAG_USER_RESTRICTIONS = "user-restrictions";
private static final String TAG_SHORT_SUPPORT_MESSAGE = "short-support-message";
private static final String TAG_LONG_SUPPORT_MESSAGE = "long-support-message";
+ private static final String TAG_PARENT_ADMIN = "parent-admin";
final DeviceAdminInfo info;
@@ -478,6 +480,9 @@
boolean disableScreenCapture = false; // Can only be set by a device/profile owner.
boolean requireAutoTime = false; // Can only be set by a device owner.
+ ActiveAdmin parentAdmin;
+ final boolean isParent;
+
static class TrustAgentInfo {
public PersistableBundle options;
TrustAgentInfo(PersistableBundle bundle) {
@@ -515,8 +520,16 @@
String shortSupportMessage = null;
String longSupportMessage = null;
- ActiveAdmin(DeviceAdminInfo _info) {
+ ActiveAdmin(DeviceAdminInfo _info, boolean parent) {
info = _info;
+ isParent = parent;
+ }
+
+ ActiveAdmin getParentActiveAdmin() {
+ if (parentAdmin == null && !isParent) {
+ parentAdmin = new ActiveAdmin(info, /* parent */ true);
+ }
+ return parentAdmin;
}
int getUid() { return info.getActivityInfo().applicationInfo.uid; }
@@ -704,6 +717,11 @@
out.text(longSupportMessage);
out.endTag(null, TAG_LONG_SUPPORT_MESSAGE);
}
+ if (parentAdmin != null) {
+ out.startTag(null, TAG_PARENT_ADMIN);
+ parentAdmin.writeToXml(out);
+ out.endTag(null, TAG_PARENT_ADMIN);
+ }
}
void writePackageListToXml(XmlSerializer out, String outerTag,
@@ -831,6 +849,9 @@
} else {
Log.w(LOG_TAG, "Missing text when loading long support message");
}
+ } else if (TAG_PARENT_ADMIN.equals(tag)) {
+ parentAdmin = new ActiveAdmin(info, /* parent */ true);
+ parentAdmin.readFromXml(parser);
} else {
Slog.w(LOG_TAG, "Unknown admin tag: " + tag);
XmlUtils.skipCurrentTag(parser);
@@ -2014,7 +2035,7 @@
+ userHandle);
}
if (dai != null) {
- ActiveAdmin ap = new ActiveAdmin(dai);
+ ActiveAdmin ap = new ActiveAdmin(dai, /* parent */ false);
ap.readFromXml(parser);
policy.mAdminMap.put(ap.info.getComponent(), ap);
}
@@ -2405,7 +2426,7 @@
&& getActiveAdminUncheckedLocked(adminReceiver, userHandle) != null) {
throw new IllegalArgumentException("Admin is already added");
}
- ActiveAdmin newAdmin = new ActiveAdmin(info);
+ ActiveAdmin newAdmin = new ActiveAdmin(info, /* parent */ false);
policy.mAdminMap.put(adminReceiver, newAdmin);
int replaceIndex = -1;
final int N = policy.mAdminList.size();
@@ -2540,8 +2561,14 @@
}
}
+ private boolean isAdminApiLevelPreN(@NonNull ComponentName who, int userHandle) {
+ DeviceAdminInfo adminInfo = findAdmin(who, userHandle, false);
+ return adminInfo.getActivityInfo().applicationInfo.targetSdkVersion
+ < Build.VERSION_CODES.N;
+ }
+
@Override
- public void setPasswordQuality(ComponentName who, int quality) {
+ public void setPasswordQuality(ComponentName who, int quality, boolean parent) {
if (!mHasFeature) {
return;
}
@@ -2552,6 +2579,9 @@
synchronized (this) {
ActiveAdmin ap = getActiveAdminForCallerLocked(who,
DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD);
+ if (parent) {
+ ap = ap.getParentActiveAdmin();
+ }
if (ap.passwordQuality != quality) {
ap.passwordQuality = quality;
saveSettingsLocked(userHandle);
@@ -2560,7 +2590,7 @@
}
@Override
- public int getPasswordQuality(ComponentName who, int userHandle) {
+ public int getPasswordQuality(ComponentName who, int userHandle, boolean parent) {
if (!mHasFeature) {
return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
}
@@ -2570,20 +2600,43 @@
if (who != null) {
ActiveAdmin admin = getActiveAdminUncheckedLocked(who, userHandle);
+ if (parent && admin != null) {
+ admin = admin.getParentActiveAdmin();
+ }
return admin != null ? admin.passwordQuality : mode;
}
- // Return strictest policy for this user and profiles that are visible from this user.
- List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
- for (UserInfo userInfo : profiles) {
- DevicePolicyData policy = getUserDataUnchecked(userInfo.id);
+ if (LockPatternUtils.isSeparateWorkChallengeEnabled() && !parent) {
+ // If a Work Challenge is in use, only return its restrictions.
+ DevicePolicyData policy = getUserDataUnchecked(userHandle);
final int N = policy.mAdminList.size();
- for (int i=0; i<N; i++) {
+ for (int i = 0; i < N; i++) {
ActiveAdmin admin = policy.mAdminList.get(i);
if (mode < admin.passwordQuality) {
mode = admin.passwordQuality;
}
}
+ } else {
+ // Return strictest policy for this user and profiles that are visible from this
+ // user that do not use a separate work challenge.
+ // TODO: When there are separate parent restrictions the profile should just
+ // obey its own.
+ List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
+ for (UserInfo userInfo : profiles) {
+ // Only aggregate data for the parent profile plus the non-work challenge
+ // enabled profiles.
+ if (!(userInfo.isManagedProfile()
+ && LockPatternUtils.isSeparateWorkChallengeEnabled())) {
+ DevicePolicyData policy = getUserDataUnchecked(userInfo.id);
+ final int N = policy.mAdminList.size();
+ for (int i = 0; i < N; i++) {
+ ActiveAdmin admin = policy.mAdminList.get(i);
+ if (mode < admin.passwordQuality) {
+ mode = admin.passwordQuality;
+ }
+ }
+ }
+ }
}
return mode;
}
@@ -3143,7 +3196,7 @@
}
@Override
- public boolean isActivePasswordSufficient(int userHandle) {
+ public boolean isActivePasswordSufficient(int userHandle, boolean parent) {
if (!mHasFeature) {
return true;
}
@@ -3155,8 +3208,14 @@
// This API can only be called by an active device admin,
// so try to retrieve it to check that the caller is one.
- getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD);
- if (policy.mActivePasswordQuality < getPasswordQuality(null, userHandle)
+ ActiveAdmin admin =
+ getActiveAdminForCallerLocked(null, DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD);
+ ComponentName adminComponentName = admin.info.getComponent();
+ // TODO: Include the Admin sdk level check in LockPatternUtils check.
+ ComponentName who = !isAdminApiLevelPreN(adminComponentName, userHandle)
+ && LockPatternUtils.isSeparateWorkChallengeEnabled()
+ ? adminComponentName : null;
+ if (policy.mActivePasswordQuality < getPasswordQuality(who, userHandle, parent)
|| policy.mActivePasswordLength < getPasswordMinimumLength(null, userHandle)) {
return false;
}
@@ -3321,7 +3380,7 @@
}
}
}
- quality = getPasswordQuality(null, userHandle);
+ quality = getPasswordQuality(null, userHandle, false);
if (quality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
int realQuality = LockPatternUtils.computePasswordQuality(password);
if (realQuality < quality
diff --git a/services/print/java/com/android/server/print/PrintManagerService.java b/services/print/java/com/android/server/print/PrintManagerService.java
index d5f384d..d250739 100644
--- a/services/print/java/com/android/server/print/PrintManagerService.java
+++ b/services/print/java/com/android/server/print/PrintManagerService.java
@@ -24,7 +24,6 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.graphics.drawable.Icon;
@@ -56,7 +55,6 @@
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
/**
* SystemService wrapper for the PrintManager implementation. Publishes
@@ -88,11 +86,6 @@
}
class PrintManagerImpl extends IPrintManager.Stub {
- private static final char COMPONENT_NAME_SEPARATOR = ':';
-
- private static final String EXTRA_PRINT_SERVICE_COMPONENT_NAME =
- "EXTRA_PRINT_SERVICE_COMPONENT_NAME";
-
private static final int BACKGROUND_USER_ID = -10;
private final Object mLock = new Object();
@@ -487,7 +480,7 @@
private void registerContentObservers() {
final Uri enabledPrintServicesUri = Settings.Secure.getUriFor(
- Settings.Secure.ENABLED_PRINT_SERVICES);
+ Settings.Secure.DISABLED_PRINT_SERVICES);
ContentObserver observer = new ContentObserver(BackgroundThread.getHandler()) {
@Override
public void onChange(boolean selfChange, Uri uri, int userId) {
@@ -511,8 +504,7 @@
private void registerBroadcastReceivers() {
PackageMonitor monitor = new PackageMonitor() {
- @Override
- public void onPackageModified(String packageName) {
+ private void updateServices(String packageName) {
if (!mUserManager.isUserUnlocked(getChangingUserId())) return;
synchronized (mLock) {
// A background user/profile's print jobs are running but there is
@@ -520,11 +512,15 @@
// to handle it as the change may affect ongoing print jobs.
boolean servicesChanged = false;
UserState userState = getOrCreateUserStateLocked(getChangingUserId());
- Iterator<ComponentName> iterator = userState.getEnabledServices().iterator();
- while (iterator.hasNext()) {
- ComponentName componentName = iterator.next();
- if (packageName.equals(componentName.getPackageName())) {
+
+ List<PrintServiceInfo> installedServices = userState
+ .getInstalledPrintServices();
+ final int numInstalledServices = installedServices.size();
+ for (int i = 0; i < numInstalledServices; i++) {
+ if (installedServices.get(i).getResolveInfo().serviceInfo.packageName
+ .equals(packageName)) {
servicesChanged = true;
+ break;
}
}
if (servicesChanged) {
@@ -534,30 +530,15 @@
}
@Override
+ public void onPackageModified(String packageName) {
+ updateServices(packageName);
+ getOrCreateUserStateLocked(getChangingUserId()).prunePrintServices();
+ }
+
+ @Override
public void onPackageRemoved(String packageName, int uid) {
- if (!mUserManager.isUserUnlocked(getChangingUserId())) return;
- synchronized (mLock) {
- // A background user/profile's print jobs are running but there is
- // no UI shown. Hence, if the packages of such a user change we need
- // to handle it as the change may affect ongoing print jobs.
- boolean servicesRemoved = false;
- UserState userState = getOrCreateUserStateLocked(getChangingUserId());
- Iterator<ComponentName> iterator = userState.getEnabledServices().iterator();
- while (iterator.hasNext()) {
- ComponentName componentName = iterator.next();
- if (packageName.equals(componentName.getPackageName())) {
- userState.removeApprovedPrintService(componentName);
- iterator.remove();
- servicesRemoved = true;
- }
- }
- if (servicesRemoved) {
- persistComponentNamesToSettingLocked(
- Settings.Secure.ENABLED_PRINT_SERVICES,
- userState.getEnabledServices(), getChangingUserId());
- userState.updateIfNeededLocked();
- }
- }
+ updateServices(packageName);
+ getOrCreateUserStateLocked(getChangingUserId()).prunePrintServices();
}
@Override
@@ -570,10 +551,10 @@
// to handle it as the change may affect ongoing print jobs.
UserState userState = getOrCreateUserStateLocked(getChangingUserId());
boolean stoppedSomePackages = false;
- Iterator<ComponentName> iterator = userState.getEnabledServices()
+ Iterator<PrintServiceInfo> iterator = userState.getEnabledPrintServices()
.iterator();
while (iterator.hasNext()) {
- ComponentName componentName = iterator.next();
+ ComponentName componentName = iterator.next().getComponentName();
String componentPackage = componentName.getPackageName();
for (String stoppedPackage : stoppedPackages) {
if (componentPackage.equals(stoppedPackage)) {
@@ -606,48 +587,11 @@
.queryIntentServicesAsUser(intent, PackageManager.GET_SERVICES,
getChangingUserId());
- if (installedServices == null) {
- return;
- }
-
- // Enable all added services by default
- synchronized (mLock) {
+ if (installedServices != null) {
UserState userState = getOrCreateUserStateLocked(getChangingUserId());
-
- Set<ComponentName> enabledServices = userState.getEnabledServices();
- boolean servicesAdded = false;
-
- final int installedServiceCount = installedServices.size();
- for (int i = 0; i < installedServiceCount; i++) {
- ServiceInfo serviceInfo = installedServices.get(i).serviceInfo;
- ComponentName component = new ComponentName(serviceInfo.packageName,
- serviceInfo.name);
-
- enabledServices.add(component);
- servicesAdded = true;
- }
-
- if (servicesAdded) {
- persistComponentNamesToSettingLocked(
- Settings.Secure.ENABLED_PRINT_SERVICES, enabledServices,
- getChangingUserId());
- userState.updateIfNeededLocked();
- }
+ userState.updateIfNeededLocked();
}
}
-
- private void persistComponentNamesToSettingLocked(String settingName,
- Set<ComponentName> componentNames, int userId) {
- StringBuilder builder = new StringBuilder();
- for (ComponentName componentName : componentNames) {
- if (builder.length() > 0) {
- builder.append(COMPONENT_NAME_SEPARATOR);
- }
- builder.append(componentName.flattenToShortString());
- }
- Settings.Secure.putStringForUser(mContext.getContentResolver(),
- settingName, builder.toString(), userId);
- }
};
// package changes
diff --git a/services/print/java/com/android/server/print/RemotePrintSpooler.java b/services/print/java/com/android/server/print/RemotePrintSpooler.java
index 40a8880..d179b95 100644
--- a/services/print/java/com/android/server/print/RemotePrintSpooler.java
+++ b/services/print/java/com/android/server/print/RemotePrintSpooler.java
@@ -37,17 +37,18 @@
import android.print.PrintJobId;
import android.print.PrintJobInfo;
import android.print.PrinterId;
+import android.printservice.PrintService;
import android.util.Slog;
import android.util.TimedRemoteCaller;
+import libcore.io.IoUtils;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.concurrent.TimeoutException;
-import libcore.io.IoUtils;
-
/**
* This represents the remote print spooler as a local object to the
* PrintManagerService. It is responsible to connecting to the remote
@@ -439,26 +440,24 @@
}
/**
- * Connect to the print spooler service and remove an approved print service.
+ * Remove all approved {@link PrintService print services} that are not in the given set.
*
- * @param serviceToRemove The {@link ComponentName} of the service to be removed.
+ * @param servicesToKeep The {@link ComponentName names } of the services to keep
*/
- public final void removeApprovedPrintService(ComponentName serviceToRemove) {
+ public final void pruneApprovedPrintServices(List<ComponentName> servicesToKeep) {
throwIfCalledOnMainThread();
synchronized (mLock) {
throwIfDestroyedLocked();
mCanUnbind = false;
}
try {
- getRemoteInstanceLazy().removeApprovedPrintService(serviceToRemove);
- } catch (RemoteException re) {
- Slog.e(LOG_TAG, "Error removing approved print service.", re);
- } catch (TimeoutException te) {
- Slog.e(LOG_TAG, "Error removing approved print service.", te);
+ getRemoteInstanceLazy().pruneApprovedPrintServices(servicesToKeep);
+ } catch (RemoteException|TimeoutException re) {
+ Slog.e(LOG_TAG, "Error pruning approved print services.", re);
} finally {
if (DEBUG) {
Slog.i(LOG_TAG, "[user: " + mUserHandle.getIdentifier()
- + "] removing approved print service()");
+ + "] pruneApprovedPrintServices()");
}
synchronized (mLock) {
mCanUnbind = true;
diff --git a/services/print/java/com/android/server/print/UserState.java b/services/print/java/com/android/server/print/UserState.java
index 63d3301..dcc02a3 100644
--- a/services/print/java/com/android/server/print/UserState.java
+++ b/services/print/java/com/android/server/print/UserState.java
@@ -21,11 +21,9 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.AsyncTask;
@@ -98,7 +96,7 @@
private final List<PrintServiceInfo> mInstalledServices =
new ArrayList<PrintServiceInfo>();
- private final Set<ComponentName> mEnabledServices =
+ private final Set<ComponentName> mDisabledServices =
new ArraySet<ComponentName>();
private final PrintJobForAppCache mPrintJobForAppCache =
@@ -126,8 +124,15 @@
mLock = lock;
mSpooler = new RemotePrintSpooler(context, userId, this);
mHandler = new UserStateHandler(context.getMainLooper());
+
synchronized (mLock) {
- enableSystemPrintServicesLocked();
+ readInstalledPrintServicesLocked();
+ upgradePersistentStateIfNeeded();
+ readDisabledPrintServicesLocked();
+
+ // Some print services might have gotten installed before the User State came up
+ prunePrintServices();
+
onConfigurationChangedLocked();
}
}
@@ -320,15 +325,6 @@
}
}
- /**
- * Remove an approved print service.
- *
- * @param serviceToRemove The {@link ComponentName} of the service to be removed.
- */
- public void removeApprovedPrintService(ComponentName serviceToRemove) {
- mSpooler.removeApprovedPrintService(serviceToRemove);
- }
-
public void restartPrintJob(PrintJobId printJobId, int appId) {
PrintJobInfo printJobInfo = getPrintJobInfo(printJobId, appId);
if (printJobInfo == null || printJobInfo.getState() != PrintJobInfo.STATE_FAILED) {
@@ -597,13 +593,6 @@
}
}
- public Set<ComponentName> getEnabledServices() {
- synchronized(mLock) {
- throwIfDestroyedLocked();
- return mEnabledServices;
- }
- }
-
public void destroyLocked() {
throwIfDestroyedLocked();
mSpooler.destroy();
@@ -612,7 +601,7 @@
}
mActiveServices.clear();
mInstalledServices.clear();
- mEnabledServices.clear();
+ mDisabledServices.clear();
if (mPrinterDiscoverySession != null) {
mPrinterDiscoverySession.destroyLocked();
mPrinterDiscoverySession = null;
@@ -646,12 +635,12 @@
.append(installedService.getAdvancedOptionsActivityName()).println();
}
- pw.append(prefix).append(tab).append("enabled services:").println();
- for (ComponentName enabledService : mEnabledServices) {
- String enabledServicePrefix = prefix + tab + tab;
- pw.append(enabledServicePrefix).append("service:").println();
- pw.append(enabledServicePrefix).append(tab).append("componentName=")
- .append(enabledService.flattenToString());
+ pw.append(prefix).append(tab).append("disabled services:").println();
+ for (ComponentName disabledService : mDisabledServices) {
+ String disabledServicePrefix = prefix + tab + tab;
+ pw.append(disabledServicePrefix).append("service:").println();
+ pw.append(disabledServicePrefix).append(tab).append("componentName=")
+ .append(disabledService.flattenToString());
pw.println();
}
@@ -679,7 +668,7 @@
private boolean readConfigurationLocked() {
boolean somethingChanged = false;
somethingChanged |= readInstalledPrintServicesLocked();
- somethingChanged |= readEnabledPrintServicesLocked();
+ somethingChanged |= readDisabledPrintServicesLocked();
return somethingChanged;
}
@@ -742,13 +731,50 @@
return false;
}
- private boolean readEnabledPrintServicesLocked() {
- Set<ComponentName> tempEnabledServiceNameSet = new HashSet<ComponentName>();
- readPrintServicesFromSettingLocked(Settings.Secure.ENABLED_PRINT_SERVICES,
- tempEnabledServiceNameSet);
- if (!tempEnabledServiceNameSet.equals(mEnabledServices)) {
- mEnabledServices.clear();
- mEnabledServices.addAll(tempEnabledServiceNameSet);
+ /**
+ * Update persistent state from a previous version of Android.
+ */
+ private void upgradePersistentStateIfNeeded() {
+ String enabledSettingValue = Settings.Secure.getStringForUser(mContext.getContentResolver(),
+ Settings.Secure.ENABLED_PRINT_SERVICES, mUserId);
+
+ // Pre N we store the enabled services, in N and later we store the disabled services.
+ // Hence if enabledSettingValue is still set, we need to upgrade.
+ if (enabledSettingValue != null) {
+ Set<ComponentName> enabledServiceNameSet = new HashSet<ComponentName>();
+ readPrintServicesFromSettingLocked(Settings.Secure.ENABLED_PRINT_SERVICES,
+ enabledServiceNameSet);
+
+ ArraySet<ComponentName> disabledServices = new ArraySet<>();
+ final int numInstalledServices = mInstalledServices.size();
+ for (int i = 0; i < numInstalledServices; i++) {
+ ComponentName serviceName = mInstalledServices.get(i).getComponentName();
+ if (!enabledServiceNameSet.contains(serviceName)) {
+ disabledServices.add(serviceName);
+ }
+ }
+
+ writeDisabledPrintServicesLocked(disabledServices);
+
+ // We won't needed ENABLED_PRINT_SERVICES anymore, set to null to prevent upgrade to run
+ // again.
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.ENABLED_PRINT_SERVICES, null, mUserId);
+ }
+ }
+
+ /**
+ * Read the set of disabled print services from the secure settings.
+ *
+ * @return true if the state changed.
+ */
+ private boolean readDisabledPrintServicesLocked() {
+ Set<ComponentName> tempDisabledServiceNameSet = new HashSet<ComponentName>();
+ readPrintServicesFromSettingLocked(Settings.Secure.DISABLED_PRINT_SERVICES,
+ tempDisabledServiceNameSet);
+ if (!tempDisabledServiceNameSet.equals(mDisabledServices)) {
+ mDisabledServices.clear();
+ mDisabledServices.addAll(tempDisabledServiceNameSet);
return true;
}
return false;
@@ -774,70 +800,28 @@
}
}
- private void enableSystemPrintServicesLocked() {
- // Load enabled and installed services.
- readEnabledPrintServicesLocked();
- readInstalledPrintServicesLocked();
-
- // Load the system services once enabled on first boot.
- Set<ComponentName> enabledOnFirstBoot = new HashSet<ComponentName>();
- readPrintServicesFromSettingLocked(
- Settings.Secure.ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES,
- enabledOnFirstBoot);
-
+ /**
+ * Persist the disabled print services to the secure settings.
+ */
+ private void writeDisabledPrintServicesLocked(Set<ComponentName> disabledServices) {
StringBuilder builder = new StringBuilder();
-
- final int serviceCount = mInstalledServices.size();
- for (int i = 0; i < serviceCount; i++) {
- ServiceInfo serviceInfo = mInstalledServices.get(i).getResolveInfo().serviceInfo;
- // Enable system print services if we never did that and are not enabled.
- if ((serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
- ComponentName serviceName = new ComponentName(
- serviceInfo.packageName, serviceInfo.name);
- if (!mEnabledServices.contains(serviceName)
- && !enabledOnFirstBoot.contains(serviceName)) {
- if (builder.length() > 0) {
- builder.append(":");
- }
- builder.append(serviceName.flattenToString());
- }
+ for (ComponentName componentName : disabledServices) {
+ if (builder.length() > 0) {
+ builder.append(COMPONENT_NAME_SEPARATOR);
}
- }
-
- // Nothing to be enabled - done.
- if (builder.length() <= 0) {
- return;
- }
-
- String servicesToEnable = builder.toString();
-
- // Update the enabled services setting.
- String enabledServices = Settings.Secure.getStringForUser(
- mContext.getContentResolver(), Settings.Secure.ENABLED_PRINT_SERVICES, mUserId);
- if (TextUtils.isEmpty(enabledServices)) {
- enabledServices = servicesToEnable;
- } else {
- enabledServices = enabledServices + ":" + servicesToEnable;
+ builder.append(componentName.flattenToShortString());
}
Settings.Secure.putStringForUser(mContext.getContentResolver(),
- Settings.Secure.ENABLED_PRINT_SERVICES, enabledServices, mUserId);
-
- // Update the enabled on first boot services setting.
- String enabledOnFirstBootServices = Settings.Secure.getStringForUser(
- mContext.getContentResolver(),
- Settings.Secure.ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES, mUserId);
- if (TextUtils.isEmpty(enabledOnFirstBootServices)) {
- enabledOnFirstBootServices = servicesToEnable;
- } else {
- enabledOnFirstBootServices = enabledOnFirstBootServices + ":" + enabledServices;
- }
- Settings.Secure.putStringForUser(mContext.getContentResolver(),
- Settings.Secure.ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES,
- enabledOnFirstBootServices, mUserId);
+ Settings.Secure.DISABLED_PRINT_SERVICES, builder.toString(), mUserId);
}
- private void onConfigurationChangedLocked() {
- Set<ComponentName> installedComponents = new ArraySet<ComponentName>();
+ /**
+ * Get the {@link ComponentName names} of the installed print services
+ *
+ * @return The names of the installed print services
+ */
+ private ArrayList<ComponentName> getInstalledComponents() {
+ ArrayList<ComponentName> installedComponents = new ArrayList<ComponentName>();
final int installedCount = mInstalledServices.size();
for (int i = 0; i < installedCount; i++) {
@@ -846,8 +830,37 @@
resolveInfo.serviceInfo.name);
installedComponents.add(serviceName);
+ }
- if (mEnabledServices.contains(serviceName)) {
+ return installedComponents;
+ }
+
+ /**
+ * Prune persistent state if a print service was uninstalled
+ */
+ public void prunePrintServices() {
+ synchronized (mLock) {
+ ArrayList<ComponentName> installedComponents = getInstalledComponents();
+
+ // Remove unnecessary entries from persistent state "disabled services"
+ boolean disabledServicesUninstalled = mDisabledServices.retainAll(installedComponents);
+ if (disabledServicesUninstalled) {
+ writeDisabledPrintServicesLocked(mDisabledServices);
+ }
+
+ // Remove unnecessary entries from persistent state "approved services"
+ mSpooler.pruneApprovedPrintServices(installedComponents);
+ }
+ }
+
+ private void onConfigurationChangedLocked() {
+ ArrayList<ComponentName> installedComponents = getInstalledComponents();
+
+ final int installedCount = installedComponents.size();
+ for (int i = 0; i < installedCount; i++) {
+ ComponentName serviceName = installedComponents.get(i);
+
+ if (!mDisabledServices.contains(serviceName)) {
if (!mActiveServices.containsKey(serviceName)) {
RemotePrintService service = new RemotePrintService(
mContext, serviceName, mUserId, mSpooler, this);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 0b5aaa3..913cb18 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -24,6 +24,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.net.Uri;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.os.Bundle;
@@ -31,6 +32,7 @@
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
import android.util.Log;
import com.android.internal.telecom.ITelecomService;
@@ -4865,4 +4867,43 @@
}
return null;
}
+
+ /**
+ * Returns the URI for the per-account voicemail ringtone set in Phone settings.
+ *
+ * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
+ * voicemail ringtone.
+ * @return The URI for the ringtone to play when receiving a voicemail from a specific
+ * PhoneAccount.
+ */
+ public Uri getVoicemailRingtoneUri(PhoneAccountHandle accountHandle) {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.getVoicemailRingtoneUri(accountHandle);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#getVoicemailRingtoneUri", e);
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether vibration is set for voicemail notification in Phone settings.
+ *
+ * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
+ * voicemail vibration setting.
+ * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise.
+ */
+ public boolean isVoicemailVibrationEnabled(PhoneAccountHandle accountHandle) {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.isVoicemailVibrationEnabled(accountHandle);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isVoicemailVibrationEnabled", e);
+ }
+ return false;
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 8172e94..d1badc9 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -18,7 +18,9 @@
import android.content.Intent;
import android.os.Bundle;
+import android.net.Uri;
import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
import android.telephony.CellInfo;
import android.telephony.IccOpenLogicalChannelResponse;
import android.telephony.ModemActivityInfo;
@@ -966,7 +968,7 @@
* Returns the Status of Wi-Fi Calling
*/
boolean isWifiCallingAvailable();
-
+
/**
* Returns the Status of Volte
*/
@@ -1014,4 +1016,23 @@
* @return Service state on specified subscription.
*/
ServiceState getServiceStateForSubscriber(int subId, String callingPackage);
+
+ /**
+ * Returns the URI for the per-account voicemail ringtone set in Phone settings.
+ *
+ * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
+ * voicemail ringtone.
+ * @return The URI for the ringtone to play when receiving a voicemail from a specific
+ * PhoneAccount.
+ */
+ Uri getVoicemailRingtoneUri(in PhoneAccountHandle accountHandle);
+
+ /**
+ * Returns whether vibration is set for voicemail notification in Phone settings.
+ *
+ * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
+ * voicemail vibration setting.
+ * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise.
+ */
+ boolean isVoicemailVibrationEnabled(in PhoneAccountHandle accountHandle);
}
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
index 85d567d..5381e4ef6 100644
--- a/test-runner/src/android/test/mock/MockPackageManager.java
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -96,11 +96,27 @@
}
@Override
-
public int[] getPackageGids(String packageName) throws NameNotFoundException {
throw new UnsupportedOperationException();
}
+ @Override
+ public int[] getPackageGids(String packageName, int flags) throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getPackageUid(String packageName, int flags) throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ @Override
+ public int getPackageUidAsUser(String packageName, int flags, int userHandle)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
/** @hide */
@Override
public int getPackageUidAsUser(String packageName, int userHandle)
diff --git a/tests/RenderScriptTests/Android.mk b/tests/RenderScriptTests/Android.mk
deleted file mode 100644
index 5053e7d..0000000
--- a/tests/RenderScriptTests/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-subdir-makefiles)
diff --git a/tests/RenderScriptTests/FBOTest/Android.mk b/tests/RenderScriptTests/FBOTest/Android.mk
deleted file mode 100644
index 7a578d9..0000000
--- a/tests/RenderScriptTests/FBOTest/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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := FBOTest
-
-LOCAL_SDK_VERSION := 17
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/FBOTest/AndroidManifest.xml b/tests/RenderScriptTests/FBOTest/AndroidManifest.xml
deleted file mode 100644
index 788e856..0000000
--- a/tests/RenderScriptTests/FBOTest/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="com.android.fbotest">
- <application android:label="_FBOTest">
- <activity android:name="FBOTest"
- android:label="FBO Base Test"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity android:name="FBOSync"
- android:label="FBO Sync Test"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/FBOTest/res/drawable-nodpi/robot.png b/tests/RenderScriptTests/FBOTest/res/drawable-nodpi/robot.png
deleted file mode 100644
index f7353fd..0000000
--- a/tests/RenderScriptTests/FBOTest/res/drawable-nodpi/robot.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/FBOTest/res/raw/robot.a3d b/tests/RenderScriptTests/FBOTest/res/raw/robot.a3d
deleted file mode 100644
index f48895c..0000000
--- a/tests/RenderScriptTests/FBOTest/res/raw/robot.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSync.java b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSync.java
deleted file mode 100644
index d30ad7e..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSync.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.fbotest;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.MenuInflater;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-import android.net.Uri;
-
-import java.lang.Runtime;
-
-public class FBOSync extends Activity {
-
- private FBOSyncView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new FBOSyncView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onPause();
- mView.pause();
- }
-}
-
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSyncRS.java b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSyncRS.java
deleted file mode 100644
index 57a117c..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSyncRS.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.fbotest;
-
-import java.io.Writer;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Element.DataType;
-import android.renderscript.Element.DataKind;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.renderscript.Type.Builder;
-import android.util.Log;
-
-
-public class FBOSyncRS {
-
- public FBOSyncRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- public void surfaceChanged() {
- mRS.getWidth();
- mRS.getHeight();
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private Sampler mSampler;
- private ProgramStore mPSBackground;
- private ProgramFragment mPFBackground;
- private ProgramVertex mPVBackground;
- private ProgramVertexFixedFunction.Constants mPVA;
-
- private Allocation mGridImage;
- private Allocation mOffscreen;
- private Allocation mOffscreenDepth;
- private Allocation mAllocPV;
- private Allocation mReadBackTest;
-
- private Font mItalic;
- private Allocation mTextAlloc;
-
- private ScriptField_MeshInfo mMeshes;
- private ScriptC_fbosync mScript;
-
-
- public void onActionDown(float x, float y) {
- mScript.invoke_onActionDown(x, y);
- }
-
- public void onActionScale(float scale) {
- mScript.invoke_onActionScale(scale);
- }
-
- public void onActionMove(float x, float y) {
- mScript.invoke_onActionMove(x, y);
- }
-
- private void initPFS() {
- ProgramStore.Builder b = new ProgramStore.Builder(mRS);
-
- b.setDepthFunc(ProgramStore.DepthFunc.LESS);
- b.setDitherEnabled(false);
- b.setDepthMaskEnabled(true);
- mPSBackground = b.create();
-
- mScript.set_gPFSBackground(mPSBackground);
- }
-
- private void initPF() {
- Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMinification(Sampler.Value.LINEAR);
- bs.setMagnification(Sampler.Value.LINEAR);
- bs.setWrapS(Sampler.Value.CLAMP);
- bs.setWrapT(Sampler.Value.CLAMP);
- mSampler = bs.create();
-
- ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
- b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mPFBackground = b.create();
- mPFBackground.bindSampler(mSampler, 0);
-
- mScript.set_gPFBackground(mPFBackground);
- }
-
- private void initPV() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mPVBackground = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mPVBackground).bindConstants(mPVA);
-
- mScript.set_gPVBackground(mPVBackground);
- }
-
- private void loadImage() {
- mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- mScript.set_gTGrid(mGridImage);
- }
-
- private void initTextAllocation(String fileName) {
- String allocString = "Displaying file: " + fileName;
- mTextAlloc = Allocation.createFromString(mRS, allocString, Allocation.USAGE_SCRIPT);
- mScript.set_gTextAlloc(mTextAlloc);
- }
-
- private void initMeshes(FileA3D model) {
- int numEntries = model.getIndexEntryCount();
- int numMeshes = 0;
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- numMeshes ++;
- }
- }
-
- if (numMeshes > 0) {
- mMeshes = new ScriptField_MeshInfo(mRS, numMeshes);
-
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- Mesh mesh = entry.getMesh();
- mMeshes.set_mMesh(i, mesh, false);
- mMeshes.set_mNumIndexSets(i, mesh.getPrimitiveCount(), false);
- }
- }
- mMeshes.copyAll();
- } else {
- throw new RSRuntimeException("No valid meshes in file");
- }
-
- mScript.bind_gMeshes(mMeshes);
- mScript.invoke_updateMeshInfo();
- }
-
- public void loadA3DFile(String path) {
- FileA3D model = FileA3D.createFromFile(mRS, path);
- initMeshes(model);
- initTextAllocation(path);
- }
-
- private void initRS() {
-
- mScript = new ScriptC_fbosync(mRS, mRes, R.raw.fbosync);
-
- initPFS();
- initPF();
- initPV();
-
- loadImage();
-
- Type.Builder b = new Type.Builder(mRS, Element.RGBA_8888(mRS));
- b.setX(512).setY(512);
- mOffscreen = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_SCRIPT |
- Allocation.USAGE_GRAPHICS_TEXTURE |
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gOffscreen(mOffscreen);
-
- mReadBackTest = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_SCRIPT |
- Allocation.USAGE_GRAPHICS_TEXTURE);
- mScript.set_gReadBackTest(mReadBackTest);
-
- b = new Type.Builder(mRS,
- Element.createPixel(mRS, DataType.UNSIGNED_16,
- DataKind.PIXEL_DEPTH));
- b.setX(512).setY(512);
- mOffscreenDepth = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gOffscreenDepth(mOffscreenDepth);
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
- initMeshes(model);
-
- mItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8);
- mScript.set_gItalic(mItalic);
-
- initTextAllocation("R.raw.robot");
-
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSyncView.java b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSyncView.java
deleted file mode 100644
index 6a85628..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOSyncView.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.fbotest;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.ScaleGestureDetector;
-import android.util.Log;
-
-public class FBOSyncView extends RSSurfaceView {
-
- private RenderScriptGL mRS;
- private FBOSyncRS mRender;
-
- private ScaleGestureDetector mScaleDetector;
-
- private static final int INVALID_POINTER_ID = -1;
- private int mActivePointerId = INVALID_POINTER_ID;
-
- public FBOSyncView(Context context) {
- super(context);
- ensureRenderScript();
- mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
- }
-
- private void ensureRenderScript() {
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRender = new FBOSyncRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- mRender.surfaceChanged();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- public void loadA3DFile(String path) {
- mRender.loadA3DFile(path);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mScaleDetector.onTouchEvent(ev);
-
- boolean ret = false;
- float x = ev.getX();
- float y = ev.getY();
-
- final int action = ev.getAction();
-
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: {
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(0);
- ret = true;
- break;
- }
- case MotionEvent.ACTION_MOVE: {
- if (!mScaleDetector.isInProgress()) {
- mRender.onActionMove(x, y);
- }
- mRender.onActionDown(x, y);
- ret = true;
- break;
- }
-
- case MotionEvent.ACTION_UP: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_CANCEL: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_POINTER_UP: {
- final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
- final int pointerId = ev.getPointerId(pointerIndex);
- if (pointerId == mActivePointerId) {
- // This was our active pointer going up. Choose a new
- // active pointer and adjust accordingly.
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- x = ev.getX(newPointerIndex);
- y = ev.getY(newPointerIndex);
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(newPointerIndex);
- }
- break;
- }
- }
-
- return ret;
- }
-
- private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- mRender.onActionScale(detector.getScaleFactor());
- return true;
- }
- }
-}
-
-
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTest.java b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTest.java
deleted file mode 100644
index 72aa3ea..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTest.java
+++ /dev/null
@@ -1,72 +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.
- */
-
-package com.android.fbotest;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.MenuInflater;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-import android.net.Uri;
-
-import java.lang.Runtime;
-
-public class FBOTest extends Activity {
-
- private FBOTestView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new FBOTestView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onPause();
- mView.pause();
- }
-}
-
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTestRS.java b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTestRS.java
deleted file mode 100644
index 9e30c4b5..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTestRS.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.fbotest;
-
-import java.io.Writer;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Element.DataType;
-import android.renderscript.Element.DataKind;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.renderscript.Type.Builder;
-import android.util.Log;
-
-
-public class FBOTestRS {
-
- public FBOTestRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- public void surfaceChanged() {
- mRS.getWidth();
- mRS.getHeight();
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private Sampler mSampler;
- private ProgramStore mPSBackground;
- private ProgramFragment mPFBackground;
- private ProgramVertex mPVBackground;
- private ProgramVertexFixedFunction.Constants mPVA;
-
- private Allocation mGridImage;
- private Allocation mOffscreen;
- private Allocation mOffscreenDepth;
- private Allocation mAllocPV;
-
- private Font mItalic;
- private Allocation mTextAlloc;
-
- private ScriptField_MeshInfo mMeshes;
- private ScriptC_fbotest mScript;
-
-
- public void onActionDown(float x, float y) {
- mScript.invoke_onActionDown(x, y);
- }
-
- public void onActionScale(float scale) {
- mScript.invoke_onActionScale(scale);
- }
-
- public void onActionMove(float x, float y) {
- mScript.invoke_onActionMove(x, y);
- }
-
- private void initPFS() {
- ProgramStore.Builder b = new ProgramStore.Builder(mRS);
-
- b.setDepthFunc(ProgramStore.DepthFunc.LESS);
- b.setDitherEnabled(false);
- b.setDepthMaskEnabled(true);
- mPSBackground = b.create();
-
- mScript.set_gPFSBackground(mPSBackground);
- }
-
- private void initPF() {
- Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMinification(Sampler.Value.LINEAR);
- bs.setMagnification(Sampler.Value.LINEAR);
- bs.setWrapS(Sampler.Value.CLAMP);
- bs.setWrapT(Sampler.Value.CLAMP);
- mSampler = bs.create();
-
- ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
- b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mPFBackground = b.create();
- mPFBackground.bindSampler(mSampler, 0);
-
- mScript.set_gPFBackground(mPFBackground);
- }
-
- private void initPV() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mPVBackground = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mPVBackground).bindConstants(mPVA);
-
- mScript.set_gPVBackground(mPVBackground);
- }
-
- private void loadImage() {
- mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- mScript.set_gTGrid(mGridImage);
- }
-
- private void initTextAllocation(String fileName) {
- String allocString = "Displaying file: " + fileName;
- mTextAlloc = Allocation.createFromString(mRS, allocString, Allocation.USAGE_SCRIPT);
- mScript.set_gTextAlloc(mTextAlloc);
- }
-
- private void initMeshes(FileA3D model) {
- int numEntries = model.getIndexEntryCount();
- int numMeshes = 0;
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- numMeshes ++;
- }
- }
-
- if (numMeshes > 0) {
- mMeshes = new ScriptField_MeshInfo(mRS, numMeshes);
-
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- Mesh mesh = entry.getMesh();
- mMeshes.set_mMesh(i, mesh, false);
- mMeshes.set_mNumIndexSets(i, mesh.getPrimitiveCount(), false);
- }
- }
- mMeshes.copyAll();
- } else {
- throw new RSRuntimeException("No valid meshes in file");
- }
-
- mScript.bind_gMeshes(mMeshes);
- mScript.invoke_updateMeshInfo();
- }
-
- public void loadA3DFile(String path) {
- FileA3D model = FileA3D.createFromFile(mRS, path);
- initMeshes(model);
- initTextAllocation(path);
- }
-
- private void initRS() {
-
- mScript = new ScriptC_fbotest(mRS, mRes, R.raw.fbotest);
-
- initPFS();
- initPF();
- initPV();
-
- loadImage();
-
- Type.Builder b = new Type.Builder(mRS, Element.RGBA_8888(mRS));
- b.setX(512).setY(512);
- mOffscreen = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_GRAPHICS_TEXTURE |
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gOffscreen(mOffscreen);
-
- b = new Type.Builder(mRS,
- Element.createPixel(mRS, DataType.UNSIGNED_16,
- DataKind.PIXEL_DEPTH));
- b.setX(512).setY(512);
- mOffscreenDepth = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gOffscreenDepth(mOffscreenDepth);
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
- initMeshes(model);
-
- mItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8);
- mScript.set_gItalic(mItalic);
-
- initTextAllocation("R.raw.robot");
-
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTestView.java b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTestView.java
deleted file mode 100644
index c9598ee..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/FBOTestView.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.fbotest;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.ScaleGestureDetector;
-import android.util.Log;
-
-public class FBOTestView extends RSSurfaceView {
-
- private RenderScriptGL mRS;
- private FBOTestRS mRender;
-
- private ScaleGestureDetector mScaleDetector;
-
- private static final int INVALID_POINTER_ID = -1;
- private int mActivePointerId = INVALID_POINTER_ID;
-
- public FBOTestView(Context context) {
- super(context);
- ensureRenderScript();
- mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
- }
-
- private void ensureRenderScript() {
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRender = new FBOTestRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- mRender.surfaceChanged();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- public void loadA3DFile(String path) {
- mRender.loadA3DFile(path);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mScaleDetector.onTouchEvent(ev);
-
- boolean ret = false;
- float x = ev.getX();
- float y = ev.getY();
-
- final int action = ev.getAction();
-
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: {
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(0);
- ret = true;
- break;
- }
- case MotionEvent.ACTION_MOVE: {
- if (!mScaleDetector.isInProgress()) {
- mRender.onActionMove(x, y);
- }
- mRender.onActionDown(x, y);
- ret = true;
- break;
- }
-
- case MotionEvent.ACTION_UP: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_CANCEL: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_POINTER_UP: {
- final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
- final int pointerId = ev.getPointerId(pointerIndex);
- if (pointerId == mActivePointerId) {
- // This was our active pointer going up. Choose a new
- // active pointer and adjust accordingly.
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- x = ev.getX(newPointerIndex);
- y = ev.getY(newPointerIndex);
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(newPointerIndex);
- }
- break;
- }
- }
-
- return ret;
- }
-
- private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- mRender.onActionScale(detector.getScaleFactor());
- return true;
- }
- }
-}
-
-
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs
deleted file mode 100644
index 0c177ef..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbosync.rs
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.fbotest)
-
-#include "rs_graphics.rsh"
-
-rs_program_vertex gPVBackground;
-rs_program_fragment gPFBackground;
-
-rs_allocation gTGrid;
-
-rs_program_store gPFSBackground;
-
-rs_font gItalic;
-rs_allocation gTextAlloc;
-
-rs_allocation gOffscreen;
-rs_allocation gOffscreenDepth;
-rs_allocation gReadBackTest;
-
-typedef struct MeshInfo {
- rs_mesh mMesh;
- int mNumIndexSets;
- float3 bBoxMin;
- float3 bBoxMax;
-} MeshInfo_t;
-
-MeshInfo_t *gMeshes;
-
-static float3 gLookAt;
-
-static float gRotateX;
-static float gRotateY;
-static float gZoom;
-
-static float gLastX;
-static float gLastY;
-
-void onActionDown(float x, float y) {
- gLastX = x;
- gLastY = y;
-}
-
-void onActionScale(float scale) {
-
- gZoom *= 1.0f / scale;
- gZoom = max(0.1f, min(gZoom, 500.0f));
-}
-
-void onActionMove(float x, float y) {
- float dx = gLastX - x;
- float dy = gLastY - y;
-
- if (fabs(dy) <= 2.0f) {
- dy = 0.0f;
- }
- if (fabs(dx) <= 2.0f) {
- dx = 0.0f;
- }
-
- gRotateY -= dx;
- if (gRotateY > 360) {
- gRotateY -= 360;
- }
- if (gRotateY < 0) {
- gRotateY += 360;
- }
-
- gRotateX -= dy;
- gRotateX = min(gRotateX, 80.0f);
- gRotateX = max(gRotateX, -80.0f);
-
- gLastX = x;
- gLastY = y;
-}
-
-void init() {
- gRotateX = 0.0f;
- gRotateY = 0.0f;
- gZoom = 50.0f;
- gLookAt = 0.0f;
-}
-
-void updateMeshInfo() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- float minX, minY, minZ, maxX, maxY, maxZ;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgMeshComputeBoundingBox(info->mMesh,
- &minX, &minY, &minZ,
- &maxX, &maxY, &maxZ);
- info->bBoxMin = (float3){minX, minY, minZ};
- info->bBoxMax = (float3){maxX, maxY, maxZ};
- gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f;
- }
- gLookAt = gLookAt / (float)size;
-}
-
-static void renderAllMeshes() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgDrawMesh(info->mMesh);
- }
-}
-
-static void drawDescription() {
- uint height = rsgGetHeight();
- int left = 0, right = 0, top = 0, bottom = 0;
-
- rsgBindFont(gItalic);
-
- rsgMeasureText(gTextAlloc, &left, &right, &top, &bottom);
- rsgDrawText(gTextAlloc, 2 -left, height - 2 + bottom);
-}
-
-static void renderOffscreen(bool useDepth) {
-
- rsgBindColorTarget(gOffscreen, 0);
- if (useDepth) {
- rsgBindDepthTarget(gOffscreenDepth);
- rsgClearDepth(1.0f);
- } else {
- rsgClearDepthTarget();
- }
- rsgClearColor(0.8f, 0.0f, 0.0f, 1.0f);
-
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsAllocationGetDimX(gOffscreen) / (float)rsAllocationGetDimY(gOffscreen);
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gTGrid);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- // Position our models on the screen
- rsMatrixTranslate(&matrix, gLookAt.x, gLookAt.y, gLookAt.z - gZoom);
- rsMatrixRotate(&matrix, gRotateX, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- renderAllMeshes();
-
- // Render into the frambuffer
- rsgClearAllRenderTargets();
-}
-
-static void drawOffscreenResult(int posX, int posY, rs_allocation texture) {
- // display the result
- rs_matrix4x4 proj, matrix;
- rsMatrixLoadOrtho(&proj, 0, rsgGetWidth(), rsgGetHeight(), 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
- rsgBindTexture(gPFBackground, 0, texture);
- float startX = posX, startY = posY;
- float width = 256, height = 256;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 1,
- startX, startY + height, 0, 0, 0,
- startX + width, startY + height, 0, 1, 0,
- startX + width, startY, 0, 1, 1);
-}
-
-int root(void) {
-
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
-
- renderOffscreen(true);
- drawOffscreenResult(0, 0, gOffscreen);
-
-
- uint32_t w = rsAllocationGetDimX(gOffscreen);
- uint32_t h = rsAllocationGetDimY(gOffscreen);
-
- rsgAllocationSyncAll(gOffscreen, RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET);
-
- rsAllocationCopy2DRange(gReadBackTest, 0, 0, 0,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, w, h,
- gOffscreen, 0, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X);
-
- rsgAllocationSyncAll(gReadBackTest);
- drawOffscreenResult(0, 300, gReadBackTest);
-
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gTGrid);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- // Position our models on the screen
- rsMatrixTranslate(&matrix, gLookAt.x, gLookAt.y, gLookAt.z - gZoom);
- rsMatrixRotate(&matrix, gRotateX, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- renderAllMeshes();
-
- drawDescription();
-
- return 0;
-}
diff --git a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs b/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs
deleted file mode 100644
index 13a3c85..0000000
--- a/tests/RenderScriptTests/FBOTest/src/com/android/fbotest/fbotest.rs
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.fbotest)
-
-#include "rs_graphics.rsh"
-
-rs_program_vertex gPVBackground;
-rs_program_fragment gPFBackground;
-
-rs_allocation gTGrid;
-
-rs_program_store gPFSBackground;
-
-rs_font gItalic;
-rs_allocation gTextAlloc;
-
-rs_allocation gOffscreen;
-rs_allocation gOffscreenDepth;
-
-typedef struct MeshInfo {
- rs_mesh mMesh;
- int mNumIndexSets;
- float3 bBoxMin;
- float3 bBoxMax;
-} MeshInfo_t;
-
-MeshInfo_t *gMeshes;
-
-static float3 gLookAt;
-
-static float gRotateX;
-static float gRotateY;
-static float gZoom;
-
-static float gLastX;
-static float gLastY;
-
-void onActionDown(float x, float y) {
- gLastX = x;
- gLastY = y;
-}
-
-void onActionScale(float scale) {
-
- gZoom *= 1.0f / scale;
- gZoom = max(0.1f, min(gZoom, 500.0f));
-}
-
-void onActionMove(float x, float y) {
- float dx = gLastX - x;
- float dy = gLastY - y;
-
- if (fabs(dy) <= 2.0f) {
- dy = 0.0f;
- }
- if (fabs(dx) <= 2.0f) {
- dx = 0.0f;
- }
-
- gRotateY -= dx;
- if (gRotateY > 360) {
- gRotateY -= 360;
- }
- if (gRotateY < 0) {
- gRotateY += 360;
- }
-
- gRotateX -= dy;
- gRotateX = min(gRotateX, 80.0f);
- gRotateX = max(gRotateX, -80.0f);
-
- gLastX = x;
- gLastY = y;
-}
-
-void init() {
- gRotateX = 0.0f;
- gRotateY = 0.0f;
- gZoom = 50.0f;
- gLookAt = 0.0f;
-}
-
-void updateMeshInfo() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- float minX, minY, minZ, maxX, maxY, maxZ;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgMeshComputeBoundingBox(info->mMesh,
- &minX, &minY, &minZ,
- &maxX, &maxY, &maxZ);
- info->bBoxMin = (float3){minX, minY, minZ};
- info->bBoxMax = (float3){maxX, maxY, maxZ};
- gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f;
- }
- gLookAt = gLookAt / (float)size;
-}
-
-static void renderAllMeshes() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgDrawMesh(info->mMesh);
- }
-}
-
-static void drawDescription() {
- uint height = rsgGetHeight();
- int left = 0, right = 0, top = 0, bottom = 0;
-
- rsgBindFont(gItalic);
-
- rsgMeasureText(gTextAlloc, &left, &right, &top, &bottom);
- rsgDrawText(gTextAlloc, 2 -left, height - 2 + bottom);
-}
-
-static void renderOffscreen(bool useDepth) {
-
- rsgBindColorTarget(gOffscreen, 0);
- if (useDepth) {
- rsgBindDepthTarget(gOffscreenDepth);
- rsgClearDepth(1.0f);
- } else {
- rsgClearDepthTarget();
- }
- rsgClearColor(0.8f, 0.8f, 0.8f, 1.0f);
-
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsAllocationGetDimX(gOffscreen) / (float)rsAllocationGetDimY(gOffscreen);
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gTGrid);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- // Position our models on the screen
- rsMatrixTranslate(&matrix, gLookAt.x, gLookAt.y, gLookAt.z - gZoom);
- rsMatrixRotate(&matrix, gRotateX, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- renderAllMeshes();
-
- // Render into the frambuffer
- rsgClearAllRenderTargets();
-}
-
-static void drawOffscreenResult(int posX, int posY) {
- // display the result
- rs_matrix4x4 proj, matrix;
- rsMatrixLoadOrtho(&proj, 0, rsgGetWidth(), rsgGetHeight(), 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
- rsgBindTexture(gPFBackground, 0, gOffscreen);
- float startX = posX, startY = posY;
- float width = 256, height = 256;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 1,
- startX, startY + height, 0, 0, 0,
- startX + width, startY + height, 0, 1, 0,
- startX + width, startY, 0, 1, 1);
-}
-
-int root(void) {
-
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
-
- renderOffscreen(true);
- drawOffscreenResult(0, 0);
-
- renderOffscreen(false);
- drawOffscreenResult(0, 256);
-
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gTGrid);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- // Position our models on the screen
- rsMatrixTranslate(&matrix, gLookAt.x, gLookAt.y, gLookAt.z - gZoom);
- rsMatrixRotate(&matrix, gRotateX, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- renderAllMeshes();
-
- drawDescription();
-
- return 0;
-}
diff --git a/tests/RenderScriptTests/HelloWorld/Android.mk b/tests/RenderScriptTests/HelloWorld/Android.mk
deleted file mode 100644
index c1c08ec..0000000
--- a/tests/RenderScriptTests/HelloWorld/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsHelloWorld
-
-LOCAL_SDK_VERSION := 17
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/HelloWorld/AndroidManifest.xml b/tests/RenderScriptTests/HelloWorld/AndroidManifest.xml
deleted file mode 100644
index 1d37dc9..0000000
--- a/tests/RenderScriptTests/HelloWorld/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.helloworld">
- <uses-sdk android:minSdkVersion="11" />
- <application android:label="RsHelloWorld"
- android:icon="@drawable/test_pattern">
- <activity android:name="HelloWorld"
- android:label="RsHelloWorld"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/HelloWorld/_index.html b/tests/RenderScriptTests/HelloWorld/_index.html
deleted file mode 100644
index 4cab738..0000000
--- a/tests/RenderScriptTests/HelloWorld/_index.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>A Renderscript graphics application that draws the text "Hello, World!" where the user touches.</p>
\ No newline at end of file
diff --git a/tests/RenderScriptTests/HelloWorld/res/drawable/test_pattern.png b/tests/RenderScriptTests/HelloWorld/res/drawable/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/HelloWorld/res/drawable/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorld.java b/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorld.java
deleted file mode 100644
index 9b1697b..0000000
--- a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorld.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.rs.helloworld;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-// Renderscript activity
-public class HelloWorld extends Activity {
-
- // Custom view to use with RenderScript
- private HelloWorldView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our view and set it as the content of our Activity
- mView = new HelloWorldView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally an app should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally an app should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldRS.java b/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldRS.java
deleted file mode 100644
index 4316411..0000000
--- a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldRS.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.rs.helloworld;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-
-// This is the renderer for the HelloWorldView
-public class HelloWorldRS {
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private ScriptC_helloworld mScript;
-
- public HelloWorldRS() {
- }
-
- // This provides us with the renderscript context and resources that
- // allow us to create the script that does rendering
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- public void onActionDown(int x, int y) {
- mScript.set_gTouchX(x);
- mScript.set_gTouchY(y);
- }
-
- private void initRS() {
- mScript = new ScriptC_helloworld(mRS, mRes, R.raw.helloworld);
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldView.java b/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldView.java
deleted file mode 100644
index 557ebc5..0000000
--- a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldView.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.rs.helloworld;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.view.MotionEvent;
-
-public class HelloWorldView extends RSSurfaceView {
- // Renderscipt context
- private RenderScriptGL mRS;
- // Script that does the rendering
- private HelloWorldRS mRender;
-
- public HelloWorldView(Context context) {
- super(context);
- ensureRenderScript();
- }
-
- private void ensureRenderScript() {
- if (mRS == null) {
- // Initialize renderscript with desired surface characteristics.
- // In this case, just use the defaults
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- // Create an instance of the script that does the rendering
- mRender = new HelloWorldRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- // Handle the system event and clean up
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- // Pass touch events from the system to the rendering script
- if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- mRender.onActionDown((int)ev.getX(), (int)ev.getY());
- return true;
- }
-
- return false;
- }
-}
-
-
diff --git a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/helloworld.rs b/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/helloworld.rs
deleted file mode 100644
index bcf624e..0000000
--- a/tests/RenderScriptTests/HelloWorld/src/com/example/android/rs/helloworld/helloworld.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-// Tell which java package name the reflected files should belong to
-#pragma rs java_package_name(com.example.android.rs.helloworld)
-
-// Built-in header with graphics API's
-#include "rs_graphics.rsh"
-
-// gTouchX and gTouchY are variables that will be reflected for use
-// by the java API. We can use them to notify the script of touch events.
-int gTouchX;
-int gTouchY;
-
-// This is invoked automatically when the script is created
-void init() {
- gTouchX = 50.0f;
- gTouchY = 50.0f;
-}
-
-int root(void) {
-
- // Clear the background color
- rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- // Tell the runtime what the font color should be
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- // Introuduce ourselves to the world by drawing a greeting
- // at the position user touched on the screen
- rsgDrawText("Hello World!", gTouchX, gTouchY);
-
- // Return value tells RS roughly how often to redraw
- // in this case 20 ms
- return 20;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/Android.mk b/tests/RenderScriptTests/MiscSamples/Android.mk
deleted file mode 100644
index ee3567b..0000000
--- a/tests/RenderScriptTests/MiscSamples/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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_PACKAGE_NAME := RsMiscSamples
-
-LOCAL_SDK_VERSION := 17
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/MiscSamples/AndroidManifest.xml b/tests/RenderScriptTests/MiscSamples/AndroidManifest.xml
deleted file mode 100644
index 08a3976..0000000
--- a/tests/RenderScriptTests/MiscSamples/AndroidManifest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.miscsamples">
- <uses-sdk android:minSdkVersion="11" />
- <application android:label="RsMiscSamples"
- android:icon="@drawable/test_pattern">
- <activity android:name="RsList"
- android:label="RsList"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <activity android:name="RsRenderStates"
- android:label="RsStates"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/MiscSamples/_index.html b/tests/RenderScriptTests/MiscSamples/_index.html
deleted file mode 100644
index 5872431..0000000
--- a/tests/RenderScriptTests/MiscSamples/_index.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>A set of samples that demonstrate how to use various features of the Renderscript APIs.</p>
\ No newline at end of file
diff --git a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/checker.png b/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/checker.png
deleted file mode 100644
index b631e1e..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/checker.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/cubemap_test.png b/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/cubemap_test.png
deleted file mode 100644
index baf35d0..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/cubemap_test.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/data.png b/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/data.png
deleted file mode 100644
index 8e34714..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/data.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/leaf.png b/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/leaf.png
deleted file mode 100644
index 3cd3775..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/leaf.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/test_pattern.png b/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/torusmap.png b/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/torusmap.png
deleted file mode 100644
index 1e08f3b..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/drawable-nodpi/torusmap.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/multitexf.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/multitexf.glsl
deleted file mode 100644
index e492a47..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/multitexf.glsl
+++ /dev/null
@@ -1,13 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- vec2 t0 = varTex0.xy;
- lowp vec4 col0 = texture2D(UNI_Tex0, t0).rgba;
- lowp vec4 col1 = texture2D(UNI_Tex1, t0*4.0).rgba;
- lowp vec4 col2 = texture2D(UNI_Tex2, t0).rgba;
- col0.xyz = col0.xyz*col1.xyz*1.5;
- col0.xyz = mix(col0.xyz, col2.xyz, col2.w);
- col0.w = 0.5;
- gl_FragColor = col0;
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shader2f.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shader2f.glsl
deleted file mode 100644
index 5fc05f1..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shader2f.glsl
+++ /dev/null
@@ -1,29 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(-varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = normalize(UNI_light0_Posision.xyz - varWorldPos);
- vec3 light0R = -reflect(light0Vec, worldNorm);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light0_Diffuse;
- float light0Spec = clamp(dot(light0R, V), 0.001, 1.0);
- float light0_Specular = pow(light0Spec, UNI_light0_CosinePower) * UNI_light0_Specular;
-
- vec3 light1Vec = normalize(UNI_light1_Posision.xyz - varWorldPos);
- vec3 light1R = reflect(light1Vec, worldNorm);
- float light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light1_Diffuse;
- float light1Spec = clamp(dot(light1R, V), 0.001, 1.0);
- float light1_Specular = pow(light1Spec, UNI_light1_CosinePower) * UNI_light1_Specular;
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_Tex0, t0).rgba;
- col.xyz = col.xyz * (light0_Diffuse * UNI_light0_DiffuseColor.xyz + light1_Diffuse * UNI_light1_DiffuseColor.xyz);
- col.xyz += light0_Specular * UNI_light0_SpecularColor.xyz;
- col.xyz += light1_Specular * UNI_light1_SpecularColor.xyz;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shader2movev.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shader2movev.glsl
deleted file mode 100644
index a2c807e..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shader2movev.glsl
+++ /dev/null
@@ -1,21 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 objPos = ATTRIB_position;
- vec3 oldPos = objPos.xyz;
- objPos.xyz += 0.1*sin(objPos.xyz*2.0 + UNI_time);
- objPos.xyz += 0.05*sin(objPos.xyz*4.0 + UNI_time*0.5);
- objPos.xyz += 0.02*sin(objPos.xyz*7.0 + UNI_time*0.75);
- vec4 worldPos = UNI_model * objPos;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * (ATTRIB_normal + oldPos - objPos.xyz);
-
- varWorldPos = worldPos.xyz;
- varWorldNormal = worldNorm;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shader2v.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shader2v.glsl
deleted file mode 100644
index e6885a3..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shader2v.glsl
+++ /dev/null
@@ -1,17 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 objPos = ATTRIB_position;
- vec4 worldPos = UNI_model * objPos;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * ATTRIB_normal;
-
- varWorldPos = worldPos.xyz;
- varWorldNormal = worldNorm;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shaderarrayf.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shaderarrayf.glsl
deleted file mode 100644
index 238ecad..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shaderarrayf.glsl
+++ /dev/null
@@ -1,16 +0,0 @@
-
-varying lowp float light0_Diffuse;
-varying lowp float light0_Specular;
-varying lowp float light1_Diffuse;
-varying lowp float light1_Specular;
-varying vec2 varTex0;
-
-void main() {
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_Tex0, t0).rgba;
- col.xyz = col.xyz * (light0_Diffuse * UNI_light_DiffuseColor[0].xyz + light1_Diffuse * UNI_light_DiffuseColor[1].xyz);
- col.xyz += light0_Specular * UNI_light_SpecularColor[0].xyz;
- col.xyz += light1_Specular * UNI_light_SpecularColor[1].xyz;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shaderarrayv.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shaderarrayv.glsl
deleted file mode 100644
index 7a1310a..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shaderarrayv.glsl
+++ /dev/null
@@ -1,32 +0,0 @@
-varying float light0_Diffuse;
-varying float light0_Specular;
-varying float light1_Diffuse;
-varying float light1_Specular;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 worldPos = UNI_model[0] * ATTRIB_position;
- worldPos = UNI_model[1] * worldPos;
- gl_Position = UNI_proj * worldPos;
-
- mat4 model0 = UNI_model[0];
- mat3 model3 = mat3(model0[0].xyz, model0[1].xyz, model0[2].xyz);
- vec3 worldNorm = model3 * ATTRIB_normal;
- vec3 V = normalize(-worldPos.xyz);
-
- vec3 light0Vec = normalize(UNI_light_Posision[0].xyz - worldPos.xyz);
- vec3 light0R = -reflect(light0Vec, worldNorm);
- light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light_Diffuse[0];
- float light0Spec = clamp(dot(light0R, V), 0.001, 1.0);
- light0_Specular = pow(light0Spec, UNI_light_CosinePower[0]) * UNI_light_Specular[0];
-
- vec3 light1Vec = normalize(UNI_light_Posision[1].xyz - worldPos.xyz);
- vec3 light1R = reflect(light1Vec, worldNorm);
- light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light_Diffuse[1];
- float light1Spec = clamp(dot(light1R, V), 0.001, 1.0);
- light1_Specular = pow(light1Spec, UNI_light_CosinePower[1]) * UNI_light_Specular[1];
-
- gl_PointSize = 1.0;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shadercubef.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shadercubef.glsl
deleted file mode 100644
index 15696a4..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shadercubef.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-
-varying vec3 worldNormal;
-
-void main() {
- lowp vec4 col = textureCube(UNI_Tex0, worldNormal);
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shadercubev.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shadercubev.glsl
deleted file mode 100644
index 70f5cd6..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shadercubev.glsl
+++ /dev/null
@@ -1,10 +0,0 @@
-varying vec3 worldNormal;
-
-// This is where actual shader code begins
-void main() {
- vec4 worldPos = UNI_model * ATTRIB_position;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- worldNormal = model3 * ATTRIB_normal;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shaderf.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shaderf.glsl
deleted file mode 100644
index d56e203..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shaderf.glsl
+++ /dev/null
@@ -1,16 +0,0 @@
-
-varying lowp float light0_Diffuse;
-varying lowp float light0_Specular;
-varying lowp float light1_Diffuse;
-varying lowp float light1_Specular;
-varying vec2 varTex0;
-
-void main() {
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_Tex0, t0).rgba;
- col.xyz = col.xyz * (light0_Diffuse * UNI_light0_DiffuseColor.xyz + light1_Diffuse * UNI_light1_DiffuseColor.xyz);
- col.xyz += light0_Specular * UNI_light0_SpecularColor.xyz;
- col.xyz += light1_Specular * UNI_light1_SpecularColor.xyz;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/shaderv.glsl b/tests/RenderScriptTests/MiscSamples/res/raw/shaderv.glsl
deleted file mode 100644
index f7d01de..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/shaderv.glsl
+++ /dev/null
@@ -1,30 +0,0 @@
-varying float light0_Diffuse;
-varying float light0_Specular;
-varying float light1_Diffuse;
-varying float light1_Specular;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 worldPos = UNI_model * ATTRIB_position;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * ATTRIB_normal;
- vec3 V = normalize(-worldPos.xyz);
-
- vec3 light0Vec = normalize(UNI_light0_Posision.xyz - worldPos.xyz);
- vec3 light0R = -reflect(light0Vec, worldNorm);
- light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light0_Diffuse;
- float light0Spec = clamp(dot(light0R, V), 0.001, 1.0);
- light0_Specular = pow(light0Spec, UNI_light0_CosinePower) * UNI_light0_Specular;
-
- vec3 light1Vec = normalize(UNI_light1_Posision.xyz - worldPos.xyz);
- vec3 light1R = reflect(light1Vec, worldNorm);
- light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light1_Diffuse;
- float light1Spec = clamp(dot(light1R, V), 0.001, 1.0);
- light1_Specular = pow(light1Spec, UNI_light1_CosinePower) * UNI_light1_Specular;
-
- gl_PointSize = 1.0;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/res/raw/torus.a3d b/tests/RenderScriptTests/MiscSamples/res/raw/torus.a3d
deleted file mode 100644
index 0322b01..0000000
--- a/tests/RenderScriptTests/MiscSamples/res/raw/torus.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsList.java b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsList.java
deleted file mode 100644
index dade3b3..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsList.java
+++ /dev/null
@@ -1,53 +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.
- */
-
-package com.example.android.rs.miscsamples;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class RsList extends Activity {
-
- private RsListView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new RsListView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsListRS.java b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsListRS.java
deleted file mode 100644
index eeb2480..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsListRS.java
+++ /dev/null
@@ -1,140 +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.
- */
-
-package com.example.android.rs.miscsamples;
-
-import java.io.Writer;
-import java.util.Vector;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-
-
-public class RsListRS {
-
- private final int STATE_LAST_FOCUS = 1;
-
- private static final String[] DATA_LIST = {
- "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
- "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
- "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
- "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
- "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
- "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil",
- "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria",
- "Burkina Faso", "Burundi", "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
- "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
- "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
- "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic",
- "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic",
- "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
- "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland",
- "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia",
- "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar",
- "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau",
- "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
- "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica",
- "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
- "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
- "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
- "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
- "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia",
- "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand",
- "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas",
- "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru",
- "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar",
- "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena",
- "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon",
- "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal",
- "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands",
- "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea",
- "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden",
- "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas",
- "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
- "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda",
- "Ukraine", "United Arab Emirates", "United Kingdom",
- "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan",
- "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara",
- "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
- };
-
- public RsListRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private Font mItalic;
-
- ScriptField_ListAllocs_s mListAllocs;
-
- private ScriptC_rslist mScript;
-
- int mLastX;
- int mLastY;
-
- public void onActionDown(int x, int y) {
- mScript.set_gDY(0.0f);
-
- mLastX = x;
- mLastY = y;
- }
-
- public void onActionMove(int x, int y) {
- int dx = mLastX - x;
- int dy = mLastY - y;
-
- if (Math.abs(dy) <= 2) {
- dy = 0;
- }
-
- mScript.set_gDY(dy);
-
- mLastX = x;
- mLastY = y;
- }
-
- private void initRS() {
-
- mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist);
-
- mListAllocs = new ScriptField_ListAllocs_s(mRS, DATA_LIST.length);
- for (int i = 0; i < DATA_LIST.length; i ++) {
- ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
- listElem.text = Allocation.createFromString(mRS, DATA_LIST[i], Allocation.USAGE_SCRIPT);
- mListAllocs.set(listElem, i, false);
- }
-
- mListAllocs.copyAll();
-
- mScript.bind_gList(mListAllocs);
-
- mItalic = Font.create(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8);
- mScript.set_gItalic(mItalic);
-
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsListView.java b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsListView.java
deleted file mode 100644
index db6e6c5..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsListView.java
+++ /dev/null
@@ -1,75 +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.
- */
-
-package com.example.android.rs.miscsamples;
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.view.MotionEvent;
-
-public class RsListView extends RSSurfaceView {
-
- public RsListView(Context context) {
- super(context);
- ensureRenderScript();
- }
-
- private RenderScriptGL mRS;
- private RsListRS mRender;
-
- private void ensureRenderScript() {
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- mRender = new RsListRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev)
- {
- boolean ret = false;
- int act = ev.getAction();
- if (act == MotionEvent.ACTION_DOWN) {
- mRender.onActionDown((int)ev.getX(), (int)ev.getY());
- ret = true;
- } else if (act == MotionEvent.ACTION_MOVE) {
- mRender.onActionMove((int)ev.getX(), (int)ev.getY());
- ret = true;
- }
-
- return ret;
- }
-}
-
-
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStates.java b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStates.java
deleted file mode 100644
index f4ea76e..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStates.java
+++ /dev/null
@@ -1,53 +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.
- */
-
-package com.example.android.rs.miscsamples;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class RsRenderStates extends Activity {
-
- private RsRenderStatesView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new RsRenderStatesView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onPause();
- mView.pause();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStatesRS.java b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStatesRS.java
deleted file mode 100644
index 0e319fe..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStatesRS.java
+++ /dev/null
@@ -1,422 +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.
- */
-
-package com.example.android.rs.miscsamples;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.renderscript.*;
-import android.renderscript.Font.Style;
-import android.renderscript.Program.TextureType;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.renderscript.ProgramStore.BlendSrcFunc;
-import android.renderscript.ProgramStore.BlendDstFunc;
-import android.renderscript.Sampler.Value;
-import android.util.Log;
-
-
-public class RsRenderStatesRS {
-
- int mWidth;
- int mHeight;
-
- public RsRenderStatesRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mWidth = mRS.getWidth();
- mHeight = mRS.getHeight();
- mRes = res;
- mOptionsARGB.inScaled = false;
- mOptionsARGB.inPreferredConfig = Bitmap.Config.ARGB_8888;
- mMode = 0;
- mMaxModes = 0;
- initRS();
- }
-
- public void surfaceChanged() {
- mWidth = mRS.getWidth();
- mHeight = mRS.getHeight();
-
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(mWidth, mHeight);
- mPVA.setProjection(proj);
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private Sampler mLinearClamp;
- private Sampler mLinearWrap;
- private Sampler mMipLinearWrap;
- private Sampler mNearestClamp;
- private Sampler mMipLinearAniso8;
- private Sampler mMipLinearAniso15;
-
- private ProgramStore mProgStoreBlendNoneDepth;
- private ProgramStore mProgStoreBlendNone;
- private ProgramStore mProgStoreBlendAlpha;
- private ProgramStore mProgStoreBlendAdd;
-
- private ProgramFragment mProgFragmentTexture;
- private ProgramFragment mProgFragmentColor;
-
- private ProgramVertex mProgVertex;
- private ProgramVertexFixedFunction.Constants mPVA;
-
- // Custom shaders
- private ProgramVertex mProgVertexCustom;
- private ProgramFragment mProgFragmentCustom;
- private ProgramFragment mProgFragmentMultitex;
- private ScriptField_VertexShaderConstants_s mVSConst;
- private ScriptField_VertexShaderConstants2_s mVSConst2;
- private ScriptField_FragentShaderConstants_s mFSConst;
- private ScriptField_FragentShaderConstants2_s mFSConst2;
-
- private ProgramVertex mProgVertexCustom2;
- private ProgramFragment mProgFragmentCustom2;
-
- private ProgramVertex mProgVertexCube;
- private ProgramFragment mProgFragmentCube;
-
- private ProgramRaster mCullBack;
- private ProgramRaster mCullFront;
- private ProgramRaster mCullNone;
-
- private Allocation mTexTorus;
- private Allocation mTexOpaque;
- private Allocation mTexTransparent;
- private Allocation mTexChecker;
- private Allocation mTexCube;
-
- private Mesh mMbyNMesh;
- private Mesh mTorus;
-
- Font mFontSans;
- Font mFontSerif;
- Font mFontSerifBold;
- Font mFontSerifItalic;
- Font mFontSerifBoldItalic;
- Font mFontMono;
- private Allocation mTextAlloc;
-
- private ScriptC_rsrenderstates mScript;
-
- private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
-
- int mMode;
- int mMaxModes;
-
- public void onActionDown(int x, int y) {
- mMode ++;
- mMode = mMode % mMaxModes;
- mScript.set_gDisplayMode(mMode);
- }
-
- ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) {
- ProgramStore.Builder builder = new ProgramStore.Builder(rs);
- builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
- builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
- builder.setDitherEnabled(false);
- builder.setDepthMaskEnabled(false);
- return builder.create();
- }
-
- private Mesh getMbyNMesh(float width, float height, int wResolution, int hResolution) {
-
- Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
- 2, Mesh.TriangleMeshBuilder.TEXTURE_0);
-
- for (int y = 0; y <= hResolution; y++) {
- final float normalizedY = (float)y / hResolution;
- final float yOffset = (normalizedY - 0.5f) * height;
- for (int x = 0; x <= wResolution; x++) {
- float normalizedX = (float)x / wResolution;
- float xOffset = (normalizedX - 0.5f) * width;
- tmb.setTexture(normalizedX, normalizedY);
- tmb.addVertex(xOffset, yOffset);
- }
- }
-
- for (int y = 0; y < hResolution; y++) {
- final int curY = y * (wResolution + 1);
- final int belowY = (y + 1) * (wResolution + 1);
- for (int x = 0; x < wResolution; x++) {
- int curV = curY + x;
- int belowV = belowY + x;
- tmb.addTriangle(curV, belowV, curV + 1);
- tmb.addTriangle(belowV, belowV + 1, curV + 1);
- }
- }
-
- return tmb.create(true);
- }
-
- private void initProgramStore() {
- // Use stock the stock program store object
- mProgStoreBlendNoneDepth = ProgramStore.BLEND_NONE_DEPTH_TEST(mRS);
- mProgStoreBlendNone = ProgramStore.BLEND_NONE_DEPTH_NONE(mRS);
-
- // Create a custom program store
- ProgramStore.Builder builder = new ProgramStore.Builder(mRS);
- builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
- builder.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA,
- ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
- builder.setDitherEnabled(false);
- builder.setDepthMaskEnabled(false);
- mProgStoreBlendAlpha = builder.create();
-
- mProgStoreBlendAdd = BLEND_ADD_DEPTH_NONE(mRS);
-
- mScript.set_gProgStoreBlendNoneDepth(mProgStoreBlendNoneDepth);
- mScript.set_gProgStoreBlendNone(mProgStoreBlendNone);
- mScript.set_gProgStoreBlendAlpha(mProgStoreBlendAlpha);
- mScript.set_gProgStoreBlendAdd(mProgStoreBlendAdd);
- }
-
- private void initProgramFragment() {
-
- ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mProgFragmentTexture = texBuilder.create();
- mProgFragmentTexture.bindSampler(mLinearClamp, 0);
-
- ProgramFragmentFixedFunction.Builder colBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- colBuilder.setVaryingColor(false);
- mProgFragmentColor = colBuilder.create();
-
- mScript.set_gProgFragmentColor(mProgFragmentColor);
- mScript.set_gProgFragmentTexture(mProgFragmentTexture);
- }
-
- private void initProgramVertex() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mProgVertex = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mProgVertex).bindConstants(mPVA);
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(mWidth, mHeight);
- mPVA.setProjection(proj);
-
- mScript.set_gProgVertex(mProgVertex);
- }
-
- private void initCustomShaders() {
- mVSConst = new ScriptField_VertexShaderConstants_s(mRS, 1);
- mVSConst2 = new ScriptField_VertexShaderConstants2_s(mRS, 1);
- mFSConst = new ScriptField_FragentShaderConstants_s(mRS, 1);
- mFSConst2 = new ScriptField_FragentShaderConstants2_s(mRS, 1);
-
- mScript.bind_gVSConstants(mVSConst);
- mScript.bind_gVSConstants2(mVSConst2);
- mScript.bind_gFSConstants(mFSConst);
- mScript.bind_gFSConstants2(mFSConst2);
-
- // Initialize the shader builder
- ProgramVertex.Builder pvbCustom = new ProgramVertex.Builder(mRS);
- // Specify the resource that contains the shader string
- pvbCustom.setShader(mRes, R.raw.shaderv);
- // Use a script field to spcify the input layout
- pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
- // Define the constant input layout
- pvbCustom.addConstant(mVSConst.getAllocation().getType());
- mProgVertexCustom = pvbCustom.create();
- // Bind the source of constant data
- mProgVertexCustom.bindConstants(mVSConst.getAllocation(), 0);
-
- ProgramFragment.Builder pfbCustom = new ProgramFragment.Builder(mRS);
- // Specify the resource that contains the shader string
- pfbCustom.setShader(mRes, R.raw.shaderf);
- //Tell the builder how many textures we have
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- // Define the constant input layout
- pfbCustom.addConstant(mFSConst.getAllocation().getType());
- mProgFragmentCustom = pfbCustom.create();
- // Bind the source of constant data
- mProgFragmentCustom.bindConstants(mFSConst.getAllocation(), 0);
-
- pvbCustom = new ProgramVertex.Builder(mRS);
- pvbCustom.setShader(mRes, R.raw.shaderarrayv);
- pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
- pvbCustom.addConstant(mVSConst2.getAllocation().getType());
- mProgVertexCustom2 = pvbCustom.create();
- mProgVertexCustom2.bindConstants(mVSConst2.getAllocation(), 0);
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.shaderarrayf);
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- pfbCustom.addConstant(mFSConst2.getAllocation().getType());
- mProgFragmentCustom2 = pfbCustom.create();
- mProgFragmentCustom2.bindConstants(mFSConst2.getAllocation(), 0);
-
- // Cubemap test shaders
- pvbCustom = new ProgramVertex.Builder(mRS);
- pvbCustom.setShader(mRes, R.raw.shadercubev);
- pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
- pvbCustom.addConstant(mVSConst.getAllocation().getType());
- mProgVertexCube = pvbCustom.create();
- mProgVertexCube.bindConstants(mVSConst.getAllocation(), 0);
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.shadercubef);
- pfbCustom.addTexture(Program.TextureType.TEXTURE_CUBE);
- mProgFragmentCube = pfbCustom.create();
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.multitexf);
- for (int texCount = 0; texCount < 3; texCount ++) {
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- }
- mProgFragmentMultitex = pfbCustom.create();
-
- mScript.set_gProgVertexCustom(mProgVertexCustom);
- mScript.set_gProgFragmentCustom(mProgFragmentCustom);
- mScript.set_gProgVertexCustom2(mProgVertexCustom2);
- mScript.set_gProgFragmentCustom2(mProgFragmentCustom2);
- mScript.set_gProgVertexCube(mProgVertexCube);
- mScript.set_gProgFragmentCube(mProgFragmentCube);
- mScript.set_gProgFragmentMultitex(mProgFragmentMultitex);
- }
-
- private Allocation loadTextureRGB(int id) {
- return Allocation.createFromBitmapResource(mRS, mRes, id,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- private Allocation loadTextureARGB(int id) {
- Bitmap b = BitmapFactory.decodeResource(mRes, id, mOptionsARGB);
- return Allocation.createFromBitmap(mRS, b,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- private void loadImages() {
- mTexTorus = loadTextureRGB(R.drawable.torusmap);
- mTexOpaque = loadTextureRGB(R.drawable.data);
- mTexTransparent = loadTextureARGB(R.drawable.leaf);
- mTexChecker = loadTextureRGB(R.drawable.checker);
- Bitmap b = BitmapFactory.decodeResource(mRes, R.drawable.cubemap_test);
- mTexCube = Allocation.createCubemapFromBitmap(mRS, b);
-
- mScript.set_gTexTorus(mTexTorus);
- mScript.set_gTexOpaque(mTexOpaque);
- mScript.set_gTexTransparent(mTexTransparent);
- mScript.set_gTexChecker(mTexChecker);
- mScript.set_gTexCube(mTexCube);
- }
-
- private void initFonts() {
- // Sans font by family name
- mFontSans = Font.create(mRS, mRes, "sans-serif", Font.Style.NORMAL, 8);
- mFontSerif = Font.create(mRS, mRes, "serif", Font.Style.NORMAL, 8);
- // Create fonts by family and style
- mFontSerifBold = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8);
- mFontSerifItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8);
- mFontSerifBoldItalic = Font.create(mRS, mRes, "serif", Font.Style.BOLD_ITALIC, 8);
- mFontMono = Font.create(mRS, mRes, "mono", Font.Style.NORMAL, 8);
-
- mTextAlloc = Allocation.createFromString(mRS, "String from allocation", Allocation.USAGE_SCRIPT);
-
- mScript.set_gFontSans(mFontSans);
- mScript.set_gFontSerif(mFontSerif);
- mScript.set_gFontSerifBold(mFontSerifBold);
- mScript.set_gFontSerifItalic(mFontSerifItalic);
- mScript.set_gFontSerifBoldItalic(mFontSerifBoldItalic);
- mScript.set_gFontMono(mFontMono);
- mScript.set_gTextAlloc(mTextAlloc);
- }
-
- private void initMesh() {
- mMbyNMesh = getMbyNMesh(256, 256, 10, 10);
- mScript.set_gMbyNMesh(mMbyNMesh);
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus);
- FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) {
- Log.e("rs", "could not load model");
- } else {
- mTorus = (Mesh)entry.getObject();
- mScript.set_gTorusMesh(mTorus);
- }
- }
-
- private void initSamplers() {
- Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMinification(Sampler.Value.LINEAR);
- bs.setMagnification(Sampler.Value.LINEAR);
- bs.setWrapS(Sampler.Value.WRAP);
- bs.setWrapT(Sampler.Value.WRAP);
- mLinearWrap = bs.create();
-
- mLinearClamp = Sampler.CLAMP_LINEAR(mRS);
- mNearestClamp = Sampler.CLAMP_NEAREST(mRS);
- mMipLinearWrap = Sampler.WRAP_LINEAR_MIP_LINEAR(mRS);
-
- bs = new Sampler.Builder(mRS);
- bs.setMinification(Sampler.Value.LINEAR_MIP_LINEAR);
- bs.setMagnification(Sampler.Value.LINEAR);
- bs.setWrapS(Sampler.Value.WRAP);
- bs.setWrapT(Sampler.Value.WRAP);
- bs.setAnisotropy(8.0f);
- mMipLinearAniso8 = bs.create();
- bs.setAnisotropy(15.0f);
- mMipLinearAniso15 = bs.create();
-
- mScript.set_gLinearClamp(mLinearClamp);
- mScript.set_gLinearWrap(mLinearWrap);
- mScript.set_gMipLinearWrap(mMipLinearWrap);
- mScript.set_gMipLinearAniso8(mMipLinearAniso8);
- mScript.set_gMipLinearAniso15(mMipLinearAniso15);
- mScript.set_gNearestClamp(mNearestClamp);
- }
-
- private void initProgramRaster() {
- mCullBack = ProgramRaster.CULL_BACK(mRS);
- mCullFront = ProgramRaster.CULL_FRONT(mRS);
- mCullNone = ProgramRaster.CULL_NONE(mRS);
-
- mScript.set_gCullBack(mCullBack);
- mScript.set_gCullFront(mCullFront);
- mScript.set_gCullNone(mCullNone);
- }
-
- private void initRS() {
-
- mScript = new ScriptC_rsrenderstates(mRS, mRes, R.raw.rsrenderstates);
-
- mMaxModes = mScript.get_gMaxModes();
-
- initSamplers();
- initProgramStore();
- initProgramFragment();
- initProgramVertex();
- initFonts();
- loadImages();
- initMesh();
- initProgramRaster();
- initCustomShaders();
-
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStatesView.java b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStatesView.java
deleted file mode 100644
index a15e38f..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/RsRenderStatesView.java
+++ /dev/null
@@ -1,78 +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.
- */
-
-package com.example.android.rs.miscsamples;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-
-public class RsRenderStatesView extends RSSurfaceView {
-
- public RsRenderStatesView(Context context) {
- super(context);
- ensureRenderScript();
- }
-
- private RenderScriptGL mRS;
- private RsRenderStatesRS mRender;
-
- private void ensureRenderScript() {
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRender = new RsRenderStatesRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- mRender.surfaceChanged();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- if (ev.getAction() == MotionEvent.ACTION_DOWN) {
- mRender.onActionDown((int)ev.getX(), (int)ev.getY());
- return true;
- }
-
- return false;
- }
-}
-
-
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/rslist.rs b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/rslist.rs
deleted file mode 100644
index d9d450d..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/rslist.rs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.example.android.rs.miscsamples)
-
-#include "rs_graphics.rsh"
-
-float gDY;
-
-rs_font gItalic;
-
-typedef struct ListAllocs_s {
- rs_allocation text;
-} ListAllocs;
-
-ListAllocs *gList;
-
-void init() {
- gDY = 0.0f;
-}
-
-int textPos = 0;
-
-int root(void) {
-
- rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
- textPos -= (int)gDY*2;
- gDY *= 0.95;
-
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- rsgBindFont(gItalic);
-
- rs_allocation listAlloc;
- listAlloc = rsGetAllocation(gList);
- int allocSize = rsAllocationGetDimX(listAlloc);
-
- int width = rsgGetWidth();
- int height = rsgGetHeight();
-
- int itemHeight = 80;
- int currentYPos = itemHeight + textPos;
-
- for (int i = 0; i < allocSize; i ++) {
- if (currentYPos - itemHeight > height) {
- break;
- }
-
- if (currentYPos > 0) {
- rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0);
- rsgDrawText(gList[i].text, 30, currentYPos - 32);
- }
- currentYPos += itemHeight;
- }
-
- return 10;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/rsrenderstates.rs b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/rsrenderstates.rs
deleted file mode 100644
index 5dabd00..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/rsrenderstates.rs
+++ /dev/null
@@ -1,680 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.example.android.rs.miscsamples)
-
-#include "rs_graphics.rsh"
-#include "shader_def.rsh"
-
-const int gMaxModes = 11;
-
-rs_program_vertex gProgVertex;
-rs_program_fragment gProgFragmentColor;
-rs_program_fragment gProgFragmentTexture;
-
-rs_program_store gProgStoreBlendNoneDepth;
-rs_program_store gProgStoreBlendNone;
-rs_program_store gProgStoreBlendAlpha;
-rs_program_store gProgStoreBlendAdd;
-
-rs_allocation gTexOpaque;
-rs_allocation gTexTorus;
-rs_allocation gTexTransparent;
-rs_allocation gTexChecker;
-rs_allocation gTexCube;
-
-rs_mesh gMbyNMesh;
-rs_mesh gTorusMesh;
-
-rs_font gFontSans;
-rs_font gFontSerif;
-rs_font gFontSerifBold;
-rs_font gFontSerifItalic;
-rs_font gFontSerifBoldItalic;
-rs_font gFontMono;
-rs_allocation gTextAlloc;
-
-int gDisplayMode;
-
-rs_sampler gLinearClamp;
-rs_sampler gLinearWrap;
-rs_sampler gMipLinearWrap;
-rs_sampler gMipLinearAniso8;
-rs_sampler gMipLinearAniso15;
-rs_sampler gNearestClamp;
-
-rs_program_raster gCullBack;
-rs_program_raster gCullFront;
-rs_program_raster gCullNone;
-
-// Custom vertex shader compunents
-VertexShaderConstants *gVSConstants;
-VertexShaderConstants2 *gVSConstants2;
-FragentShaderConstants *gFSConstants;
-FragentShaderConstants2 *gFSConstants2;
-// Export these out to easily set the inputs to shader
-VertexShaderInputs *gVSInputs;
-// Custom shaders we use for lighting
-rs_program_vertex gProgVertexCustom;
-rs_program_fragment gProgFragmentCustom;
-rs_program_vertex gProgVertexCustom2;
-rs_program_fragment gProgFragmentCustom2;
-rs_program_vertex gProgVertexCube;
-rs_program_fragment gProgFragmentCube;
-rs_program_fragment gProgFragmentMultitex;
-
-float gDt = 0;
-
-void init() {
-}
-
-static void displayFontSamples() {
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- int yPos = 100;
- rsgBindFont(gFontSans);
- rsgDrawText("Sans font sample", 30, yPos);
- yPos += 30;
- rsgFontColor(0.5f, 0.9f, 0.5f, 1.0f);
- rsgBindFont(gFontSerif);
- rsgDrawText("Serif font sample", 30, yPos);
- yPos += 30;
- rsgFontColor(0.7f, 0.7f, 0.7f, 1.0f);
- rsgBindFont(gFontSerifBold);
- rsgDrawText("Serif Bold font sample", 30, yPos);
- yPos += 30;
- rsgFontColor(0.5f, 0.5f, 0.9f, 1.0f);
- rsgBindFont(gFontSerifItalic);
- rsgDrawText("Serif Italic font sample", 30, yPos);
- yPos += 30;
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontSerifBoldItalic);
- rsgDrawText("Serif Bold Italic font sample", 30, yPos);
- yPos += 30;
- rsgBindFont(gFontMono);
- rsgDrawText("Monospace font sample", 30, yPos);
- yPos += 50;
-
- // Now use text metrics to center the text
- uint width = rsgGetWidth();
- uint height = rsgGetHeight();
- int left = 0, right = 0, top = 0, bottom = 0;
-
- rsgFontColor(0.9f, 0.9f, 0.95f, 1.0f);
- rsgBindFont(gFontSerifBoldItalic);
-
- rsgMeasureText(gTextAlloc, &left, &right, &top, &bottom);
- int centeredPos = width / 2 - (right - left) / 2;
- rsgDrawText(gTextAlloc, centeredPos, yPos);
- yPos += 30;
-
- const char* text = "Centered Text Sample";
- rsgMeasureText(text, &left, &right, &top, &bottom);
- centeredPos = width / 2 - (right - left) / 2;
- rsgDrawText(text, centeredPos, yPos);
- yPos += 30;
-
- rsgBindFont(gFontSans);
- text = "More Centered Text Samples";
- rsgMeasureText(text, &left, &right, &top, &bottom);
- centeredPos = width / 2 - (right - left) / 2;
- rsgDrawText(text, centeredPos, yPos);
- yPos += 30;
-
- // Now draw bottom and top right aligned text
- text = "Top-right aligned text";
- rsgMeasureText(text, &left, &right, &top, &bottom);
- rsgDrawText(text, width - right, top);
-
- text = "Top-left";
- rsgMeasureText(text, &left, &right, &top, &bottom);
- rsgDrawText(text, -left, top);
-
- text = "Bottom-right aligned text";
- rsgMeasureText(text, &left, &right, &top, &bottom);
- rsgDrawText(text, width - right, height + bottom);
-
-}
-
-static void bindProgramVertexOrtho() {
- // Default vertex sahder
- rsgBindProgramVertex(gProgVertex);
- // Setup the projectioni matrix
- rs_matrix4x4 proj;
- rsMatrixLoadOrtho(&proj, 0, rsgGetWidth(), rsgGetHeight(), 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-}
-
-static void displayShaderSamples() {
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNone);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
-
- float startX = 0, startY = 0;
- float width = 256, height = 256;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1,
- startX + width, startY + height, 0, 1, 1,
- startX + width, startY, 0, 1, 0);
-
- startX = 200; startY = 0;
- width = 128; height = 128;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1,
- startX + width, startY + height, 0, 1, 1,
- startX + width, startY, 0, 1, 0);
-
- rsgBindProgramStore(gProgStoreBlendAlpha);
- rsgBindTexture(gProgFragmentTexture, 0, gTexTransparent);
- startX = 0; startY = 200;
- width = 128; height = 128;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1,
- startX + width, startY + height, 0, 1, 1,
- startX + width, startY, 0, 1, 0);
-
- // Fragment program with simple color
- rsgBindProgramFragment(gProgFragmentColor);
- rsgProgramFragmentConstantColor(gProgFragmentColor, 0.9, 0.3, 0.3, 1);
- rsgDrawRect(200, 300, 350, 450, 0);
- rsgProgramFragmentConstantColor(gProgFragmentColor, 0.3, 0.9, 0.3, 1);
- rsgDrawRect(50, 400, 400, 600, 0);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Texture shader", 10, 50);
- rsgDrawText("Alpha-blended texture shader", 10, 280);
- rsgDrawText("Flat color shader", 100, 450);
-}
-
-static void displayBlendingSamples() {
- int i;
-
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- rsgBindProgramFragment(gProgFragmentColor);
-
- rsgBindProgramStore(gProgStoreBlendNone);
- for (i = 0; i < 3; i ++) {
- float iPlusOne = (float)(i + 1);
- rsgProgramFragmentConstantColor(gProgFragmentColor,
- 0.1f*iPlusOne, 0.2f*iPlusOne, 0.3f*iPlusOne, 1);
- float yPos = 150 * (float)i;
- rsgDrawRect(0, yPos, 200, yPos + 200, 0);
- }
-
- rsgBindProgramStore(gProgStoreBlendAlpha);
- for (i = 0; i < 3; i ++) {
- float iPlusOne = (float)(i + 1);
- rsgProgramFragmentConstantColor(gProgFragmentColor,
- 0.2f*iPlusOne, 0.3f*iPlusOne, 0.1f*iPlusOne, 0.5);
- float yPos = 150 * (float)i;
- rsgDrawRect(150, yPos, 350, yPos + 200, 0);
- }
-
- rsgBindProgramStore(gProgStoreBlendAdd);
- for (i = 0; i < 3; i ++) {
- float iPlusOne = (float)(i + 1);
- rsgProgramFragmentConstantColor(gProgFragmentColor,
- 0.3f*iPlusOne, 0.1f*iPlusOne, 0.2f*iPlusOne, 0.5);
- float yPos = 150 * (float)i;
- rsgDrawRect(300, yPos, 500, yPos + 200, 0);
- }
-
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("No Blending", 10, 50);
- rsgDrawText("Alpha Blending", 160, 150);
- rsgDrawText("Additive Blending", 320, 250);
-
-}
-
-static void displayMeshSamples() {
-
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadTranslate(&matrix, 128, 128, 0);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNone);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
-
- rsgDrawMesh(gMbyNMesh);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("User gen 10 by 10 grid mesh", 10, 250);
-}
-
-static void displayTextureSamplers() {
-
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNone);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
-
- // Linear clamp
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- float startX = 0, startY = 0;
- float width = 300, height = 300;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1.1,
- startX + width, startY + height, 0, 1.1, 1.1,
- startX + width, startY, 0, 1.1, 0);
-
- // Linear Wrap
- rsgBindSampler(gProgFragmentTexture, 0, gLinearWrap);
- startX = 0; startY = 300;
- width = 300; height = 300;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1.1,
- startX + width, startY + height, 0, 1.1, 1.1,
- startX + width, startY, 0, 1.1, 0);
-
- // Nearest
- rsgBindSampler(gProgFragmentTexture, 0, gNearestClamp);
- startX = 300; startY = 0;
- width = 300; height = 300;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1.1,
- startX + width, startY + height, 0, 1.1, 1.1,
- startX + width, startY, 0, 1.1, 0);
-
- rsgBindSampler(gProgFragmentTexture, 0, gMipLinearWrap);
- startX = 300; startY = 300;
- width = 300; height = 300;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1.5,
- startX + width, startY + height, 0, 1.5, 1.5,
- startX + width, startY, 0, 1.5, 0);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Filtering: linear clamp", 10, 290);
- rsgDrawText("Filtering: linear wrap", 10, 590);
- rsgDrawText("Filtering: nearest clamp", 310, 290);
- rsgDrawText("Filtering: miplinear wrap", 310, 590);
-}
-
-static float gTorusRotation = 0;
-
-static void displayCullingSamples() {
- rsgBindProgramVertex(gProgVertex);
- // Setup the projectioni matrix with 60 degree field of view
- rs_matrix4x4 proj;
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 0.1f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gTexTorus);
-
- // Aplly a rotation to our mesh
- gTorusRotation += 50.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- rs_matrix4x4 matrix;
- // Position our model on the screen
- rsMatrixLoadTranslate(&matrix, -2.0f, 0.0f, -10.0f);
- rsMatrixRotate(&matrix, gTorusRotation, 1.0f, 0.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
- // Use front face culling
- rsgBindProgramRaster(gCullFront);
- rsgDrawMesh(gTorusMesh);
-
- rsMatrixLoadTranslate(&matrix, 2.0f, 0.0f, -10.0f);
- rsMatrixRotate(&matrix, gTorusRotation, 1.0f, 0.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
- // Use back face culling
- rsgBindProgramRaster(gCullBack);
- rsgDrawMesh(gTorusMesh);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Displaying mesh front/back face culling", 10, rsgGetHeight() - 10);
-}
-
-static float gLight0Rotation = 0;
-static float gLight1Rotation = 0;
-
-static void setupCustomShaderLights() {
- float4 light0Pos = {-5.0f, 5.0f, -10.0f, 1.0f};
- float4 light1Pos = {2.0f, 5.0f, 15.0f, 1.0f};
- float4 light0DiffCol = {0.9f, 0.7f, 0.7f, 1.0f};
- float4 light0SpecCol = {0.9f, 0.6f, 0.6f, 1.0f};
- float4 light1DiffCol = {0.5f, 0.5f, 0.9f, 1.0f};
- float4 light1SpecCol = {0.5f, 0.5f, 0.9f, 1.0f};
-
- gLight0Rotation += 50.0f * gDt;
- if (gLight0Rotation > 360.0f) {
- gLight0Rotation -= 360.0f;
- }
- gLight1Rotation -= 50.0f * gDt;
- if (gLight1Rotation > 360.0f) {
- gLight1Rotation -= 360.0f;
- }
-
- rs_matrix4x4 l0Mat;
- rsMatrixLoadRotate(&l0Mat, gLight0Rotation, 1.0f, 0.0f, 0.0f);
- light0Pos = rsMatrixMultiply(&l0Mat, light0Pos);
- rs_matrix4x4 l1Mat;
- rsMatrixLoadRotate(&l1Mat, gLight1Rotation, 0.0f, 0.0f, 1.0f);
- light1Pos = rsMatrixMultiply(&l1Mat, light1Pos);
-
- // Set light 0 properties
- gVSConstants->light0_Posision = light0Pos;
- gVSConstants->light0_Diffuse = 1.0f;
- gVSConstants->light0_Specular = 0.5f;
- gVSConstants->light0_CosinePower = 10.0f;
- // Set light 1 properties
- gVSConstants->light1_Posision = light1Pos;
- gVSConstants->light1_Diffuse = 1.0f;
- gVSConstants->light1_Specular = 0.7f;
- gVSConstants->light1_CosinePower = 25.0f;
- rsgAllocationSyncAll(rsGetAllocation(gVSConstants));
-
- gVSConstants2->light_Posision[0] = light0Pos;
- gVSConstants2->light_Diffuse[0] = 1.0f;
- gVSConstants2->light_Specular[0] = 0.5f;
- gVSConstants2->light_CosinePower[0] = 10.0f;
- gVSConstants2->light_Posision[1] = light1Pos;
- gVSConstants2->light_Diffuse[1] = 1.0f;
- gVSConstants2->light_Specular[1] = 0.7f;
- gVSConstants2->light_CosinePower[1] = 25.0f;
- rsgAllocationSyncAll(rsGetAllocation(gVSConstants2));
-
- // Update fragmetn shader constants
- // Set light 0 colors
- gFSConstants->light0_DiffuseColor = light0DiffCol;
- gFSConstants->light0_SpecularColor = light0SpecCol;
- // Set light 1 colors
- gFSConstants->light1_DiffuseColor = light1DiffCol;
- gFSConstants->light1_SpecularColor = light1SpecCol;
- rsgAllocationSyncAll(rsGetAllocation(gFSConstants));
-
- gFSConstants2->light_DiffuseColor[0] = light0DiffCol;
- gFSConstants2->light_SpecularColor[0] = light0SpecCol;
- // Set light 1 colors
- gFSConstants2->light_DiffuseColor[1] = light1DiffCol;
- gFSConstants2->light_SpecularColor[1] = light1SpecCol;
- rsgAllocationSyncAll(rsGetAllocation(gFSConstants2));
-}
-
-static void displayCustomShaderSamples() {
-
- // Update vertex shader constants
- // Load model matrix
- // Aplly a rotation to our mesh
- gTorusRotation += 50.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- // Position our model on the screen
- rsMatrixLoadTranslate(&gVSConstants->model, 0.0f, 0.0f, -10.0f);
- rsMatrixRotate(&gVSConstants->model, gTorusRotation, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&gVSConstants->model, gTorusRotation, 0.0f, 0.0f, 1.0f);
- // Setup the projectioni matrix
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&gVSConstants->proj, 30.0f, aspect, 0.1f, 100.0f);
- setupCustomShaderLights();
-
- rsgBindProgramVertex(gProgVertexCustom);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- rsgBindProgramFragment(gProgFragmentCustom);
- rsgBindSampler(gProgFragmentCustom, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentCustom, 0, gTexTorus);
-
- // Use back face culling
- rsgBindProgramRaster(gCullBack);
- rsgDrawMesh(gTorusMesh);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Custom shader sample", 10, rsgGetHeight() - 10);
-}
-
-static void displayCustomShaderSamples2() {
-
- // Update vertex shader constants
- // Load model matrix
- // Aplly a rotation to our mesh
- gTorusRotation += 50.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- // Position our model on the screen
- rsMatrixLoadTranslate(&gVSConstants2->model[1], 0.0f, 0.0f, -10.0f);
- rsMatrixLoadIdentity(&gVSConstants2->model[0]);
- rsMatrixRotate(&gVSConstants2->model[0], gTorusRotation, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&gVSConstants2->model[0], gTorusRotation, 0.0f, 0.0f, 1.0f);
- // Setup the projectioni matrix
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&gVSConstants2->proj, 30.0f, aspect, 0.1f, 100.0f);
- setupCustomShaderLights();
-
- rsgBindProgramVertex(gProgVertexCustom2);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- rsgBindProgramFragment(gProgFragmentCustom2);
- rsgBindSampler(gProgFragmentCustom2, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentCustom2, 0, gTexTorus);
-
- // Use back face culling
- rsgBindProgramRaster(gCullBack);
- rsgDrawMesh(gTorusMesh);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Custom shader sample with array uniforms", 10, rsgGetHeight() - 10);
-}
-
-static void displayCubemapShaderSample() {
- // Update vertex shader constants
- // Load model matrix
- // Aplly a rotation to our mesh
- gTorusRotation += 50.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- // Position our model on the screen
- // Position our model on the screen
- rsMatrixLoadTranslate(&gVSConstants->model, 0.0f, 0.0f, -10.0f);
- rsMatrixRotate(&gVSConstants->model, gTorusRotation, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&gVSConstants->model, gTorusRotation, 0.0f, 0.0f, 1.0f);
- // Setup the projectioni matrix
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&gVSConstants->proj, 30.0f, aspect, 0.1f, 100.0f);
- rsgAllocationSyncAll(rsGetAllocation(gFSConstants));
-
- rsgBindProgramVertex(gProgVertexCube);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- rsgBindProgramFragment(gProgFragmentCube);
- rsgBindSampler(gProgFragmentCube, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentCube, 0, gTexCube);
-
- // Use back face culling
- rsgBindProgramRaster(gCullBack);
- rsgDrawMesh(gTorusMesh);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Cubemap shader sample", 10, rsgGetHeight() - 10);
-}
-
-static void displayMultitextureSample() {
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNone);
- rsgBindProgramFragment(gProgFragmentMultitex);
- rsgBindSampler(gProgFragmentMultitex, 0, gLinearClamp);
- rsgBindSampler(gProgFragmentMultitex, 1, gLinearWrap);
- rsgBindSampler(gProgFragmentMultitex, 2, gLinearClamp);
- rsgBindTexture(gProgFragmentMultitex, 0, gTexChecker);
- rsgBindTexture(gProgFragmentMultitex, 1, gTexTorus);
- rsgBindTexture(gProgFragmentMultitex, 2, gTexTransparent);
-
- float startX = 0, startY = 0;
- float width = 256, height = 256;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1,
- startX + width, startY + height, 0, 1, 1,
- startX + width, startY, 0, 1, 0);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- rsgDrawText("Custom shader with multitexturing", 10, 280);
-}
-
-static float gAnisoTime = 0.0f;
-static uint anisoMode = 0;
-static void displayAnisoSample() {
-
- gAnisoTime += gDt;
-
- rsgBindProgramVertex(gProgVertex);
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rs_matrix4x4 proj;
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 0.1f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rs_matrix4x4 matrix;
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNone);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsMatrixLoadTranslate(&matrix, 0.0f, 0.0f, -10.0f);
- rsMatrixRotate(&matrix, -80, 1.0f, 0.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- rsgBindProgramRaster(gCullNone);
-
- rsgBindTexture(gProgFragmentTexture, 0, gTexChecker);
-
- if (gAnisoTime >= 5.0f) {
- gAnisoTime = 0.0f;
- anisoMode ++;
- anisoMode = anisoMode % 3;
- }
-
- if (anisoMode == 0) {
- rsgBindSampler(gProgFragmentTexture, 0, gMipLinearAniso8);
- } else if (anisoMode == 1) {
- rsgBindSampler(gProgFragmentTexture, 0, gMipLinearAniso15);
- } else {
- rsgBindSampler(gProgFragmentTexture, 0, gMipLinearWrap);
- }
-
- float startX = -15;
- float startY = -15;
- float width = 30;
- float height = 30;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 10,
- startX + width, startY + height, 0, 10, 10,
- startX + width, startY, 0, 10, 0);
-
- rsgBindProgramRaster(gCullBack);
-
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgBindFont(gFontMono);
- if (anisoMode == 0) {
- rsgDrawText("Anisotropic filtering 8", 10, 40);
- } else if (anisoMode == 1) {
- rsgDrawText("Anisotropic filtering 15", 10, 40);
- } else {
- rsgDrawText("Miplinear filtering", 10, 40);
- }
-}
-
-int root(void) {
-
- gDt = rsGetDt();
-
- rsgClearColor(0.2f, 0.2f, 0.2f, 0.0f);
- rsgClearDepth(1.0f);
-
- switch (gDisplayMode) {
- case 0:
- displayFontSamples();
- break;
- case 1:
- displayShaderSamples();
- break;
- case 2:
- displayBlendingSamples();
- break;
- case 3:
- displayMeshSamples();
- break;
- case 4:
- displayTextureSamplers();
- break;
- case 5:
- displayCullingSamples();
- break;
- case 6:
- displayCustomShaderSamples();
- break;
- case 7:
- displayMultitextureSample();
- break;
- case 8:
- displayAnisoSample();
- break;
- case 9:
- displayCustomShaderSamples2();
- break;
- case 10:
- displayCubemapShaderSample();
- break;
- }
-
- return 10;
-}
diff --git a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/shader_def.rsh b/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/shader_def.rsh
deleted file mode 100644
index 08cf361..0000000
--- a/tests/RenderScriptTests/MiscSamples/src/com/example/android/rs/miscsamples/shader_def.rsh
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.example.android.rs.miscsamples)
-
-typedef struct VertexShaderConstants_s {
- rs_matrix4x4 model;
- rs_matrix4x4 proj;
- float4 light0_Posision;
- float light0_Diffuse;
- float light0_Specular;
- float light0_CosinePower;
-
- float4 light1_Posision;
- float light1_Diffuse;
- float light1_Specular;
- float light1_CosinePower;
-} VertexShaderConstants;
-
-typedef struct VertexShaderConstants2_s {
- rs_matrix4x4 model[2];
- rs_matrix4x4 proj;
- float4 light_Posision[2];
- float light_Diffuse[2];
- float light_Specular[2];
- float light_CosinePower[2];
-} VertexShaderConstants2;
-
-typedef struct VertexShaderConstants3_s {
- rs_matrix4x4 model;
- rs_matrix4x4 proj;
- float time;
-} VertexShaderConstants3;
-
-
-typedef struct FragentShaderConstants_s {
- float4 light0_DiffuseColor;
- float4 light0_SpecularColor;
-
- float4 light1_DiffuseColor;
- float4 light1_SpecularColor;
-} FragentShaderConstants;
-
-typedef struct FragentShaderConstants2_s {
- float4 light_DiffuseColor[2];
- float4 light_SpecularColor[2];
-} FragentShaderConstants2;
-
-typedef struct FragentShaderConstants3_s {
- float4 light0_DiffuseColor;
- float4 light0_SpecularColor;
- float4 light0_Posision;
- float light0_Diffuse;
- float light0_Specular;
- float light0_CosinePower;
-
- float4 light1_DiffuseColor;
- float4 light1_SpecularColor;
- float4 light1_Posision;
- float light1_Diffuse;
- float light1_Specular;
- float light1_CosinePower;
-} FragentShaderConstants3;
-
-typedef struct VertexShaderInputs_s {
- float4 position;
- float3 normal;
- float2 texture0;
-} VertexShaderInputs;
-
diff --git a/tests/RenderScriptTests/ModelViewer/Android.mk b/tests/RenderScriptTests/ModelViewer/Android.mk
deleted file mode 100644
index 86724cf..0000000
--- a/tests/RenderScriptTests/ModelViewer/Android.mk
+++ /dev/null
@@ -1,29 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
-
-LOCAL_SDK_VERSION := 17
-
-LOCAL_PACKAGE_NAME := ModelViewer
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/ModelViewer/AndroidManifest.xml b/tests/RenderScriptTests/ModelViewer/AndroidManifest.xml
deleted file mode 100644
index 57ec4fe..0000000
--- a/tests/RenderScriptTests/ModelViewer/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.modelviewer">
- <application android:label="ModelViewer">
- <activity android:name="SimpleModel"
- android:label="SimpleModel"
- android:screenOrientation="nosensor">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity android:name="A3DSelector"
- android:label="A3DSelector"
- android:hardwareAccelerated="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
- <activity android:name="SceneGraph"
- android:label="SceneGraph"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/ModelViewer/res/drawable-nodpi/robot.png b/tests/RenderScriptTests/ModelViewer/res/drawable-nodpi/robot.png
deleted file mode 100644
index f7353fd..0000000
--- a/tests/RenderScriptTests/ModelViewer/res/drawable-nodpi/robot.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ModelViewer/res/menu/loader_menu.xml b/tests/RenderScriptTests/ModelViewer/res/menu/loader_menu.xml
deleted file mode 100644
index 2a8759c..0000000
--- a/tests/RenderScriptTests/ModelViewer/res/menu/loader_menu.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2011 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.
-*/
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/load_model"
- android:title="@string/load_model" />
- <item android:id="@+id/display_options"
- android:title="@string/display_options" />
- <item android:id="@+id/sensor"
- android:title="@string/sensor" />
-</menu>
diff --git a/tests/RenderScriptTests/ModelViewer/res/raw/robot.a3d b/tests/RenderScriptTests/ModelViewer/res/raw/robot.a3d
deleted file mode 100644
index f48895c..0000000
--- a/tests/RenderScriptTests/ModelViewer/res/raw/robot.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ModelViewer/res/values/strings.xml b/tests/RenderScriptTests/ModelViewer/res/values/strings.xml
deleted file mode 100644
index a5c8f22..0000000
--- a/tests/RenderScriptTests/ModelViewer/res/values/strings.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2011 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <skip />
- <string name="load_model">Load Model</string>
- <string name="display_options">Display Options</string>
- <string name="sensor">Toggle Sensor</string>
-</resources>
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/A3DSelector.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/A3DSelector.java
deleted file mode 100644
index 0e2004f..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/A3DSelector.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.modelviewer;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-/**
- * A list view where the last item the user clicked is placed in
- * the "activated" state, causing its background to highlight.
- */
-public class A3DSelector extends ListActivity {
-
- File[] mCurrentSubList;
- File mCurrentFile;
-
- class A3DFilter implements FileFilter {
- public boolean accept(File file) {
- if (file.isDirectory()) {
- return true;
- }
- return file.getName().endsWith(".a3d");
- }
- }
-
- private void populateList(File file) {
-
- mCurrentFile = file;
- setTitle(mCurrentFile.getAbsolutePath() + "/*.a3d");
- List<String> names = new ArrayList<String>();
- names.add("..");
-
- mCurrentSubList = mCurrentFile.listFiles(new A3DFilter());
-
- if (mCurrentSubList != null) {
- for (int i = 0; i < mCurrentSubList.length; i ++) {
- String fileName = mCurrentSubList[i].getName();
- if (mCurrentSubList[i].isDirectory()) {
- fileName = "/" + fileName;
- }
- names.add(fileName);
- }
- }
-
- // Use the built-in layout for showing a list item with a single
- // line of text whose background is changes when activated.
- setListAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_activated_1, names));
- getListView().setTextFilterEnabled(true);
-
- // Tell the list view to show one checked/activated item at a time.
- getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- populateList(new File("/sdcard/"));
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- if (position == 0) {
- File parent = mCurrentFile.getParentFile();
- if (parent == null) {
- return;
- }
- populateList(parent);
- return;
- }
-
- // the first thing in list is parent directory
- File selectedFile = mCurrentSubList[position - 1];
- if (selectedFile.isDirectory()) {
- populateList(selectedFile);
- return;
- }
-
- Intent resultIntent = new Intent();
- resultIntent.setData(Uri.fromFile(selectedFile));
- setResult(RESULT_OK, resultIntent);
- finish();
- }
-
-}
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraph.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraph.java
deleted file mode 100644
index c9c4dc1..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraph.java
+++ /dev/null
@@ -1,70 +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.
- */
-
-package com.android.modelviewer;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-
-import java.lang.Runtime;
-
-public class SceneGraph extends Activity {
-
- private SceneGraphView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new SceneGraphView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onPause();
- mView.pause();
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
deleted file mode 100644
index f91f31e..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraphRS.java
+++ /dev/null
@@ -1,217 +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.
- */
-
-package com.android.modelviewer;
-
-import java.io.Writer;
-import java.util.Map;
-import java.util.Vector;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Element.Builder;
-import android.renderscript.Font.Style;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-
-
-public class SceneGraphRS {
-
- private final int STATE_LAST_FOCUS = 1;
-
- int mWidth;
- int mHeight;
- int mRotation;
-
- public SceneGraphRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mRS = rs;
- mRes = res;
- mWidth = width;
- mHeight = height;
- mRotation = 0;
- initRS();
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private Sampler mSampler;
- private ProgramStore mPSBackground;
- private ProgramFragment mPFBackground;
- private ProgramVertex mPVBackground;
- private ProgramVertexFixedFunction.Constants mPVA;
-
- private Allocation mGridImage;
- private Allocation mAllocPV;
-
- private Mesh mMesh;
-
- private Font mItalic;
- private Allocation mTextAlloc;
-
- private ScriptC_scenegraph mScript;
- private ScriptC_transform mTransformScript;
-
- int mLastX;
- int mLastY;
-
- public void touchEvent(int x, int y) {
- int dx = mLastX - x;
- if (Math.abs(dx) > 50 || Math.abs(dx) < 3) {
- dx = 0;
- }
-
- mRotation -= dx;
- if (mRotation > 360) {
- mRotation -= 360;
- }
- if (mRotation < 0) {
- mRotation += 360;
- }
-
- mScript.set_gRotate(-(float)mRotation);
-
- mLastX = x;
- mLastY = y;
- }
-
- private void initPFS() {
- ProgramStore.Builder b = new ProgramStore.Builder(mRS);
-
- b.setDepthFunc(ProgramStore.DepthFunc.LESS);
- b.setDitherEnabled(false);
- b.setDepthMaskEnabled(true);
- mPSBackground = b.create();
-
- mScript.set_gPFSBackground(mPSBackground);
- }
-
- private void initPF() {
- Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMinification(Sampler.Value.LINEAR);
- bs.setMagnification(Sampler.Value.LINEAR);
- bs.setWrapS(Sampler.Value.CLAMP);
- bs.setWrapT(Sampler.Value.CLAMP);
- mSampler = bs.create();
-
- ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
- b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mPFBackground = b.create();
- mPFBackground.bindSampler(mSampler, 0);
-
- mScript.set_gPFBackground(mPFBackground);
- }
-
- private void initPV() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mPVBackground = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mPVBackground).bindConstants(mPVA);
-
- mScript.set_gPVBackground(mPVBackground);
- }
-
- private void loadImage() {
- mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- mScript.set_gTGrid(mGridImage);
- }
-
- private void initTextAllocation() {
- String allocString = "Displaying file: R.raw.robot";
- mTextAlloc = Allocation.createFromString(mRS, allocString, Allocation.USAGE_SCRIPT);
- mScript.set_gTextAlloc(mTextAlloc);
- }
-
- SgTransform mRootTransform;
- SgTransform mGroup1;
-
- SgTransform mRobot1;
- SgTransform mRobot2;
-
- void initTransformHierarchy() {
- mRootTransform = new SgTransform(mRS);
-
- mGroup1 = new SgTransform(mRS);
- mRootTransform.addChild(mGroup1);
-
- mRobot1 = new SgTransform(mRS);
- mRobot2 = new SgTransform(mRS);
-
- mGroup1.addChild(mRobot1);
- mGroup1.addChild(mRobot2);
-
- mGroup1.setTransform(0, new Float4(0.0f, 0.0f, -15.0f, 0.0f), TransformType.TRANSLATE);
- mGroup1.setTransform(1, new Float4(0.0f, 1.0f, 0.0f, 15.0f), TransformType.ROTATE);
-
- mRobot1.setTransform(0, new Float4(-3.0f, -0.5f, 0.0f, 0.0f), TransformType.TRANSLATE);
- mRobot1.setTransform(1, new Float4(0.0f, 1.0f, 0.0f, 20.0f), TransformType.ROTATE);
- mRobot1.setTransform(2, new Float4(0.2f, 0.2f, 0.2f, 0.0f), TransformType.SCALE);
-
- mRobot2.setTransform(0, new Float4(3.0f, 0.0f, 0.0f, 0.0f), TransformType.TRANSLATE);
- mRobot2.setTransform(1, new Float4(0.0f, 1.0f, 0.0f, -20.0f), TransformType.ROTATE);
- mRobot2.setTransform(2, new Float4(0.3f, 0.3f, 0.3f, 0.0f), TransformType.SCALE);
- }
-
- private void initRS() {
-
- mScript = new ScriptC_scenegraph(mRS, mRes, R.raw.scenegraph);
- mTransformScript = new ScriptC_transform(mRS, mRes, R.raw.transform);
- mTransformScript.set_transformScript(mTransformScript);
-
- mScript.set_gTransformRS(mTransformScript);
-
- initPFS();
- initPF();
- initPV();
-
- loadImage();
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
- FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) {
- Log.e("rs", "could not load model");
- } else {
- mMesh = (Mesh)entry.getObject();
- mScript.set_gTestMesh(mMesh);
- }
-
- mItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8);
- mScript.set_gItalic(mItalic);
-
- initTextAllocation();
-
- initTransformHierarchy();
-
- mScript.bind_gRootNode(mRootTransform.getField());
-
- mScript.bind_gGroup(mGroup1.mParent.mChildField);
- mScript.bind_gRobot1(mRobot1.mParent.mChildField);
- mScript.set_gRobot1Index(mRobot1.mIndexInParentGroup);
- mScript.bind_gRobot2(mRobot2.mParent.mChildField);
- mScript.set_gRobot2Index(mRobot2.mIndexInParentGroup);
-
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraphView.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
deleted file mode 100644
index 0b6a3b8..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SceneGraphView.java
+++ /dev/null
@@ -1,96 +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.
- */
-
-package com.android.modelviewer;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class SceneGraphView extends RSSurfaceView {
-
- public SceneGraphView(Context context) {
- super(context);
- //setFocusable(true);
- }
-
- private RenderScriptGL mRS;
- private SceneGraphRS mRender;
-
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new SceneGraphRS();
- mRender.init(mRS, getResources(), w, h);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- // break point at here
- // this method doesn't work when 'extends View' include 'extends ScrollView'.
- return super.onKeyDown(keyCode, event);
- }
-
-
- @Override
- public boolean onTouchEvent(MotionEvent ev)
- {
- boolean ret = true;
- int act = ev.getAction();
- if (act == ev.ACTION_UP) {
- ret = false;
- }
-
- mRender.touchEvent((int)ev.getX(), (int)ev.getY());
- return ret;
- }
-}
-
-
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SgTransform.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SgTransform.java
deleted file mode 100644
index f5484e2..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SgTransform.java
+++ /dev/null
@@ -1,112 +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.
- */
-
-package com.android.modelviewer;
-
-import java.io.Writer;
-import java.util.Map;
-import java.util.Vector;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Element.Builder;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-
-enum TransformType {
-
- NONE(0),
- TRANSLATE(1),
- ROTATE(2),
- SCALE(3);
-
- int mID;
- TransformType(int id) {
- mID = id;
- }
-}
-
-public class SgTransform {
-
-
- ScriptField_SgTransform mTransformField;
- ScriptField_SgTransform mChildField;
- public ScriptField_SgTransform.Item mTransformData;
-
- RenderScript mRS;
-
- Vector mChildren;
- SgTransform mParent;
- int mIndexInParentGroup;
-
- public void setParent(SgTransform parent, int parentIndex) {
- mParent = parent;
- mIndexInParentGroup = parentIndex;
- }
-
- public void addChild(SgTransform child) {
- mChildren.add(child);
- child.setParent(this, mChildren.size() - 1);
- }
-
- public void setTransform(int index, Float4 value, TransformType type) {
- mTransformData.transforms[index] = value;
- mTransformData.transformTypes[index] = type.mID;
- }
-
- void initData() {
- int numElements = mTransformData.transforms.length;
- mTransformData.transformTypes = new int[numElements];
- for (int i = 0; i < numElements; i ++) {
- mTransformData.transforms[i] = new Float4(0, 0, 0, 0);
- mTransformData.transformTypes[i] = TransformType.NONE.mID;
- }
-
- mTransformData.isDirty = 1;
- mTransformData.children = null;
- }
-
- public SgTransform(RenderScript rs) {
- mRS = rs;
- mTransformData = new ScriptField_SgTransform.Item();
- mChildren = new Vector();
- initData();
- }
-
- public ScriptField_SgTransform.Item getData() {
- if (mChildren.size() != 0) {
- mChildField = new ScriptField_SgTransform(mRS, mChildren.size());
- mTransformData.children = mChildField.getAllocation();
-
- for (int i = 0; i < mChildren.size(); i ++) {
- SgTransform child = (SgTransform)mChildren.get(i);
- mChildField.set(child.getData(), i, false);
- }
- mChildField.copyAll();
- }
-
- return mTransformData;
- }
-
- public ScriptField_SgTransform getField() {
- mTransformField = new ScriptField_SgTransform(mRS, 1);
- mTransformField.set(getData(), 0, true);
- return mTransformField;
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModel.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModel.java
deleted file mode 100644
index 2b29ff4..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModel.java
+++ /dev/null
@@ -1,116 +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.
- */
-
-package com.android.modelviewer;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.MenuInflater;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-import android.net.Uri;
-
-import java.lang.Runtime;
-
-public class SimpleModel extends Activity {
-
- private SimpleModelView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new SimpleModelView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onPause();
- mView.pause();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.loader_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.load_model:
- loadModel();
- return true;
- case R.id.display_options:
- return true;
- case R.id.sensor:
- mView.toggleSensor();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- private static final int FIND_A3D_MODEL = 10;
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK) {
- if (requestCode == FIND_A3D_MODEL) {
- Uri selectedImageUri = data.getData();
- Log.e("Selected Path: ", selectedImageUri.getPath());
- mView.loadA3DFile(selectedImageUri.getPath());
- }
- }
- }
-
- public void loadModel() {
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_PICK);
- intent.setClassName("com.android.modelviewer",
- "com.android.modelviewer.A3DSelector");
- startActivityForResult(intent, FIND_A3D_MODEL);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
deleted file mode 100644
index 5fa3a9e..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModelRS.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.modelviewer;
-
-import java.io.Writer;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-
-
-public class SimpleModelRS {
-
- public SimpleModelRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- public void surfaceChanged() {
- mRS.getWidth();
- mRS.getHeight();
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private Sampler mSampler;
- private ProgramStore mPSBackground;
- private ProgramFragment mPFBackground;
- private ProgramVertex mPVBackground;
- private ProgramVertexFixedFunction.Constants mPVA;
-
- private Allocation mGridImage;
- private Allocation mAllocPV;
-
- private Font mItalic;
- private Allocation mTextAlloc;
-
- private ScriptField_MeshInfo mMeshes;
- private ScriptC_simplemodel mScript;
-
-
- public void onActionDown(float x, float y) {
- mScript.invoke_onActionDown(x, y);
- }
-
- public void onActionScale(float scale) {
- mScript.invoke_onActionScale(scale);
- }
-
- public void onActionMove(float x, float y) {
- mScript.invoke_onActionMove(x, y);
- }
-
- public void onPostureChanged(Matrix4f posture) {
- mScript.set_gPostureMatrix(posture);
- }
-
- private void initPFS() {
- ProgramStore.Builder b = new ProgramStore.Builder(mRS);
-
- b.setDepthFunc(ProgramStore.DepthFunc.LESS);
- b.setDitherEnabled(false);
- b.setDepthMaskEnabled(true);
- mPSBackground = b.create();
-
- mScript.set_gPFSBackground(mPSBackground);
- }
-
- private void initPF() {
- Sampler.Builder bs = new Sampler.Builder(mRS);
- bs.setMinification(Sampler.Value.LINEAR);
- bs.setMagnification(Sampler.Value.LINEAR);
- bs.setWrapS(Sampler.Value.CLAMP);
- bs.setWrapT(Sampler.Value.CLAMP);
- mSampler = bs.create();
-
- ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
- b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mPFBackground = b.create();
- mPFBackground.bindSampler(mSampler, 0);
-
- mScript.set_gPFBackground(mPFBackground);
- }
-
- private void initPV() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mPVBackground = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mPVBackground).bindConstants(mPVA);
-
- mScript.set_gPVBackground(mPVBackground);
- }
-
- private void loadImage() {
- mGridImage = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- mScript.set_gTGrid(mGridImage);
- }
-
- private void initTextAllocation(String fileName) {
- String allocString = "Displaying file: " + fileName;
- mTextAlloc = Allocation.createFromString(mRS, allocString, Allocation.USAGE_SCRIPT);
- mScript.set_gTextAlloc(mTextAlloc);
- }
-
- private void initMeshes(FileA3D model) {
- int numEntries = model.getIndexEntryCount();
- int numMeshes = 0;
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- numMeshes ++;
- }
- }
-
- if (numMeshes > 0) {
- mMeshes = new ScriptField_MeshInfo(mRS, numMeshes);
-
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- Mesh mesh = entry.getMesh();
- mMeshes.set_mMesh(i, mesh, false);
- mMeshes.set_mNumIndexSets(i, mesh.getPrimitiveCount(), false);
- }
- }
- mMeshes.copyAll();
- } else {
- throw new RSRuntimeException("No valid meshes in file");
- }
-
- mScript.bind_gMeshes(mMeshes);
- mScript.invoke_updateMeshInfo();
- }
-
- public void loadA3DFile(String path) {
- FileA3D model = FileA3D.createFromFile(mRS, path);
- initMeshes(model);
- initTextAllocation(path);
- }
-
- private void initRS() {
-
- mScript = new ScriptC_simplemodel(mRS, mRes, R.raw.simplemodel);
-
- initPFS();
- initPF();
- initPV();
-
- loadImage();
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
- initMeshes(model);
-
- mItalic = Font.create(mRS, mRes, "serif", Font.Style.ITALIC, 8);
- mScript.set_gItalic(mItalic);
-
- initTextAllocation("R.raw.robot");
-
- mRS.bindRootScript(mScript);
- }
-}
-
-
-
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModelView.java b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
deleted file mode 100644
index 4b7836b..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/SimpleModelView.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.modelviewer;
-
-import android.renderscript.Matrix4f;
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.view.ScaleGestureDetector;
-import android.util.Log;
-
-public class SimpleModelView extends RSSurfaceView implements SensorEventListener {
-
- private RenderScriptGL mRS;
- private SimpleModelRS mRender;
-
- private ScaleGestureDetector mScaleDetector;
-
- private SensorManager mSensorManager;
- private Sensor mRotationVectorSensor;
- private final float[] mRotationMatrix = new float[16];
-
- private static final int INVALID_POINTER_ID = -1;
- private int mActivePointerId = INVALID_POINTER_ID;
- private boolean mUseSensor = false;
- private Matrix4f mIdentityMatrix = new Matrix4f();
-
- public SimpleModelView(Context context) {
- super(context);
- ensureRenderScript();
- mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
- // Get an instance of the SensorManager
- mSensorManager = (SensorManager)getContext().getSystemService(Context.SENSOR_SERVICE);
- // find the rotation-vector sensor
- mRotationVectorSensor = mSensorManager.getDefaultSensor(
- Sensor.TYPE_ROTATION_VECTOR);
- mIdentityMatrix.loadIdentity();
- }
-
- private void ensureRenderScript() {
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRender = new SimpleModelRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- public void resume() {
- mSensorManager.registerListener(this, mRotationVectorSensor, 10000);
- }
-
- @Override
- public void pause() {
- mSensorManager.unregisterListener(this);
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- mRender.surfaceChanged();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- public void loadA3DFile(String path) {
- mRender.loadA3DFile(path);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mScaleDetector.onTouchEvent(ev);
-
- boolean ret = false;
- float x = ev.getX();
- float y = ev.getY();
-
- final int action = ev.getAction();
-
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: {
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(0);
- ret = true;
- break;
- }
- case MotionEvent.ACTION_MOVE: {
- if (!mScaleDetector.isInProgress()) {
- mRender.onActionMove(x, y);
- }
- mRender.onActionDown(x, y);
- ret = true;
- break;
- }
-
- case MotionEvent.ACTION_UP: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_CANCEL: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_POINTER_UP: {
- final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
- final int pointerId = ev.getPointerId(pointerIndex);
- if (pointerId == mActivePointerId) {
- // This was our active pointer going up. Choose a new
- // active pointer and adjust accordingly.
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- x = ev.getX(newPointerIndex);
- y = ev.getY(newPointerIndex);
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(newPointerIndex);
- }
- break;
- }
- }
-
- return ret;
- }
-
- private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- mRender.onActionScale(detector.getScaleFactor());
- return true;
- }
- }
-
- public void onSensorChanged(SensorEvent event) {
- // we received a sensor event. it is a good practice to check
- // that we received the proper event
- if (mUseSensor) {
- if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
- // convert the rotation-vector to a 4x4 matrix. the matrix
- // is interpreted by Open GL as the inverse of the
- // rotation-vector, which is what we want.
- SensorManager.getRotationMatrixFromVector(
- mRotationMatrix , event.values);
-
- if (mRender != null) {
- mRender.onPostureChanged(new Matrix4f(mRotationMatrix));
- }
- }
- }
- }
-
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
-
- public void toggleSensor() {
- mUseSensor = !mUseSensor;
- if (mUseSensor == false) {
- mRender.onPostureChanged(mIdentityMatrix);
- }
- }
-}
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/scenegraph.rs b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/scenegraph.rs
deleted file mode 100644
index 5c5b1c9..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/scenegraph.rs
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.modelviewer)
-
-#include "rs_graphics.rsh"
-#include "transform_def.rsh"
-
-rs_program_vertex gPVBackground;
-rs_program_fragment gPFBackground;
-
-rs_allocation gTGrid;
-rs_mesh gTestMesh;
-
-rs_program_store gPFSBackground;
-
-float gRotate;
-
-rs_font gItalic;
-rs_allocation gTextAlloc;
-
-rs_script gTransformRS;
-
-SgTransform *gGroup;
-SgTransform *gRobot1;
-int gRobot1Index;
-SgTransform *gRobot2;
-int gRobot2Index;
-
-SgTransform *gRootNode;
-
-void init() {
- gRotate = 0.0f;
-}
-
-int root(void) {
-
- gGroup->transforms[1].w += 0.5f;
- gGroup->isDirty = 1;
-
- SgTransform *robot1Ptr = gRobot1 + gRobot1Index;
-
- robot1Ptr->transforms[1].w -= 1.5f;
- robot1Ptr->isDirty = 1;
-
- SgTransform *robot2Ptr = gRobot2 + gRobot2Index;
- robot2Ptr->transforms[1].w += 2.5f;
- robot2Ptr->isDirty = 1;
-
- rsForEach(gTransformRS, gRootNode->children, gRootNode->children);
-
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
-
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 0.1f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gTGrid);
-
- rsgProgramVertexLoadModelMatrix(&robot1Ptr->globalMat);
- rsgDrawMesh(gTestMesh);
-
- rsgProgramVertexLoadModelMatrix(&robot2Ptr->globalMat);
- rsgDrawMesh(gTestMesh);
-
- //color(0.3f, 0.3f, 0.3f, 1.0f);
- rsgDrawText("Renderscript transform test", 30, 695);
-
- rsgBindFont(gItalic);
- rsgDrawText(gTextAlloc, 30, 730);
-
- return 10;
-}
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/simplemodel.rs b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/simplemodel.rs
deleted file mode 100644
index d3dd5b9..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/simplemodel.rs
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.modelviewer)
-
-#include "rs_graphics.rsh"
-
-rs_program_vertex gPVBackground;
-rs_program_fragment gPFBackground;
-
-rs_allocation gTGrid;
-
-rs_program_store gPFSBackground;
-
-rs_font gItalic;
-rs_allocation gTextAlloc;
-
-rs_matrix4x4 gPostureMatrix;
-
-typedef struct MeshInfo {
- rs_mesh mMesh;
- int mNumIndexSets;
- float3 bBoxMin;
- float3 bBoxMax;
-} MeshInfo_t;
-
-MeshInfo_t *gMeshes;
-
-static float3 gLookAt;
-
-static float gRotateX;
-static float gRotateY;
-static float gZoom;
-
-static float gLastX;
-static float gLastY;
-
-static float3 toFloat3(float x, float y, float z) {
- float3 f;
- f.x = x;
- f.y = y;
- f.z = z;
- return f;
-}
-
-void onActionDown(float x, float y) {
- gLastX = x;
- gLastY = y;
-}
-
-void onActionScale(float scale) {
-
- gZoom *= 1.0f / scale;
- gZoom = max(0.1f, min(gZoom, 500.0f));
-}
-
-void onActionMove(float x, float y) {
- float dx = gLastX - x;
- float dy = gLastY - y;
-
- if (fabs(dy) <= 2.0f) {
- dy = 0.0f;
- }
- if (fabs(dx) <= 2.0f) {
- dx = 0.0f;
- }
-
- gRotateY -= dx;
- if (gRotateY > 360) {
- gRotateY -= 360;
- }
- if (gRotateY < 0) {
- gRotateY += 360;
- }
-
- gRotateX -= dy;
- gRotateX = min(gRotateX, 80.0f);
- gRotateX = max(gRotateX, -80.0f);
-
- gLastX = x;
- gLastY = y;
-}
-
-void init() {
- gRotateX = 0.0f;
- gRotateY = 0.0f;
- gZoom = 50.0f;
- gLookAt = 0.0f;
- rsMatrixLoadIdentity(&gPostureMatrix);
-}
-
-void updateMeshInfo() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- float minX, minY, minZ, maxX, maxY, maxZ;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgMeshComputeBoundingBox(info->mMesh,
- &minX, &minY, &minZ,
- &maxX, &maxY, &maxZ);
- info->bBoxMin = toFloat3(minX, minY, minZ);
- info->bBoxMax = toFloat3(maxX, maxY, maxZ);
- gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f;
- }
- gLookAt = gLookAt / (float)size;
-}
-
-static void renderAllMeshes() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgDrawMesh(info->mMesh);
- }
-}
-
-void drawDescription() {
- uint height = rsgGetHeight();
- int left = 0, right = 0, top = 0, bottom = 0;
-
- rsgBindFont(gItalic);
-
- rsgMeasureText(gTextAlloc, &left, &right, &top, &bottom);
- rsgDrawText(gTextAlloc, 2 -left, height - 2 + bottom);
-}
-
-int root(void) {
-
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
-
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gTGrid);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- // Position our models on the screen
- rsMatrixTranslate(&matrix, gLookAt.x, gLookAt.y, gLookAt.z - gZoom);
- rsMatrixMultiply(&matrix, &gPostureMatrix);
- rsMatrixRotate(&matrix, gRotateX, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
-
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- renderAllMeshes();
-
- drawDescription();
-
- return 0;
-}
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/transform.rs b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/transform.rs
deleted file mode 100644
index 85c0630..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/transform.rs
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.modelviewer)
-
-#include "transform_def.rsh"
-
-rs_script transformScript;
-
-typedef struct {
- int changed;
- rs_matrix4x4 *mat;
-} ParentData;
-
-static void appendTransformation(int type, float4 data, rs_matrix4x4 *mat) {
- rs_matrix4x4 temp;
-
- switch (type) {
- case TRANSFORM_TRANSLATE:
- rsMatrixLoadTranslate(&temp, data.x, data.y, data.z);
- break;
- case TRANSFORM_ROTATE:
- rsMatrixLoadRotate(&temp, data.w, data.x, data.y, data.z);
- break;
- case TRANSFORM_SCALE:
- rsMatrixLoadScale(&temp, data.x, data.y, data.z);
- break;
- }
- rsMatrixMultiply(mat, &temp);
-}
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
-
- SgTransform *data = (SgTransform *)v_out;
- const ParentData *parent = (const ParentData *)usrData;
-
- //rsDebug("Transform data", (int)data);
- //rsDebug("Entering parent", (int)parent);
-
- rs_matrix4x4 *localMat = &data->localMat;
- rs_matrix4x4 *globalMat = &data->globalMat;
-
- ParentData toChild;
- toChild.changed = 0;
- toChild.mat = globalMat;
-
- //rsDebug("Transform is dirty", data->isDirty);
-
- // Refresh matrices if dirty
- if (data->isDirty) {
- data->isDirty = 0;
- toChild.changed = 1;
-
- // Reset our local matrix
- rsMatrixLoadIdentity(localMat);
-
- for (int i = 0; i < 16; i ++) {
- if (data->transformTypes[i] == TRANSFORM_NONE) {
- break;
- }
- //rsDebug("Transform adding transformation", transformTypes[i]);
- appendTransformation(data->transformTypes[i], data->transforms[i], localMat);
- }
- }
-
- //rsDebug("Transform checking parent", (int)0);
-
- if (parent) {
- if (parent->changed) {
- toChild.changed = 1;
-
- rsMatrixLoad(globalMat, parent->mat);
- rsMatrixMultiply(globalMat, localMat);
- }
- } else {
- rsMatrixLoad(globalMat, localMat);
- }
-
- //rsDebug("Transform calling self with child ", (int)data->children.p);
- if (data->children.p) {
- rsForEach(transformScript, data->children, data->children, (void*)&toChild, sizeof(toChild));
- }
-}
diff --git a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/transform_def.rsh b/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/transform_def.rsh
deleted file mode 100644
index 24a36c1..0000000
--- a/tests/RenderScriptTests/ModelViewer/src/com/android/modelviewer/transform_def.rsh
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.modelviewer)
-
-#define TRANSFORM_NONE 0
-#define TRANSFORM_TRANSLATE 1
-#define TRANSFORM_ROTATE 2
-#define TRANSFORM_SCALE 3
-
-typedef struct __attribute__((packed, aligned(4))) SgTransform {
- rs_matrix4x4 globalMat;
- rs_matrix4x4 localMat;
-
- float4 transforms[16];
- int transformTypes[16];
-
- int isDirty;
-
- rs_allocation children;
-
-} SgTransform;
diff --git a/tests/RenderScriptTests/PerfTest/Android.mk b/tests/RenderScriptTests/PerfTest/Android.mk
deleted file mode 100644
index e9ee771..0000000
--- a/tests/RenderScriptTests/PerfTest/Android.mk
+++ /dev/null
@@ -1,31 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
-
-LOCAL_SDK_VERSION := 17
-
-LOCAL_PACKAGE_NAME := PerfTest
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/PerfTest/AndroidManifest.xml b/tests/RenderScriptTests/PerfTest/AndroidManifest.xml
deleted file mode 100644
index cc60396..0000000
--- a/tests/RenderScriptTests/PerfTest/AndroidManifest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.perftest">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-
- <uses-sdk android:minSdkVersion="11" />
- <application android:label="PerfTest"
- android:icon="@drawable/test_pattern">
- <uses-library android:name="android.test.runner" />
- <activity android:name="RsBench"
- android:label="RsBenchmark">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
- <instrumentation android:name=".RsPerfTestRunner"
- android:targetPackage="com.android.perftest"
- android:label="Test runner for RsBench tests"
- />
-</manifest>
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/checker.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/checker.png
deleted file mode 100644
index b631e1e..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/checker.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/data.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/data.png
deleted file mode 100644
index 8e34714..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/data.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/flares.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/flares.png
deleted file mode 100644
index 3a5c970..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/flares.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/globe.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/globe.png
deleted file mode 100644
index f9d6172..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/globe.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/leaf.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/leaf.png
deleted file mode 100644
index 3cd3775..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/leaf.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/light1.jpg b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/light1.jpg
deleted file mode 100644
index 2f2f10e..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/light1.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/space.jpg b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/space.jpg
deleted file mode 100644
index b61f6a3..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/space.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/test_pattern.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/torusmap.png b/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/torusmap.png
deleted file mode 100644
index 1e08f3b..0000000
--- a/tests/RenderScriptTests/PerfTest/res/drawable-nodpi/torusmap.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/menu/loader_menu.xml b/tests/RenderScriptTests/PerfTest/res/menu/loader_menu.xml
deleted file mode 100644
index 59a251d..0000000
--- a/tests/RenderScriptTests/PerfTest/res/menu/loader_menu.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2011 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.
-*/
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/benchmark_all"
- android:title="@string/benchmark_all" />
- <item android:id="@+id/benchmark_one"
- android:title="@string/benchmark_one" />
- <item android:id="@+id/debug_mode"
- android:title="@string/debug_mode" />
-</menu>
-
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/multitexf.glsl b/tests/RenderScriptTests/PerfTest/res/raw/multitexf.glsl
deleted file mode 100644
index e492a47..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/multitexf.glsl
+++ /dev/null
@@ -1,13 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- vec2 t0 = varTex0.xy;
- lowp vec4 col0 = texture2D(UNI_Tex0, t0).rgba;
- lowp vec4 col1 = texture2D(UNI_Tex1, t0*4.0).rgba;
- lowp vec4 col2 = texture2D(UNI_Tex2, t0).rgba;
- col0.xyz = col0.xyz*col1.xyz*1.5;
- col0.xyz = mix(col0.xyz, col2.xyz, col2.w);
- col0.w = 0.5;
- gl_FragColor = col0;
-}
-
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/shader2f.glsl b/tests/RenderScriptTests/PerfTest/res/raw/shader2f.glsl
deleted file mode 100644
index 5fc05f1..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/shader2f.glsl
+++ /dev/null
@@ -1,29 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(-varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = normalize(UNI_light0_Posision.xyz - varWorldPos);
- vec3 light0R = -reflect(light0Vec, worldNorm);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light0_Diffuse;
- float light0Spec = clamp(dot(light0R, V), 0.001, 1.0);
- float light0_Specular = pow(light0Spec, UNI_light0_CosinePower) * UNI_light0_Specular;
-
- vec3 light1Vec = normalize(UNI_light1_Posision.xyz - varWorldPos);
- vec3 light1R = reflect(light1Vec, worldNorm);
- float light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light1_Diffuse;
- float light1Spec = clamp(dot(light1R, V), 0.001, 1.0);
- float light1_Specular = pow(light1Spec, UNI_light1_CosinePower) * UNI_light1_Specular;
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_Tex0, t0).rgba;
- col.xyz = col.xyz * (light0_Diffuse * UNI_light0_DiffuseColor.xyz + light1_Diffuse * UNI_light1_DiffuseColor.xyz);
- col.xyz += light0_Specular * UNI_light0_SpecularColor.xyz;
- col.xyz += light1_Specular * UNI_light1_SpecularColor.xyz;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/shader2movev.glsl b/tests/RenderScriptTests/PerfTest/res/raw/shader2movev.glsl
deleted file mode 100644
index a2c807e..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/shader2movev.glsl
+++ /dev/null
@@ -1,21 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 objPos = ATTRIB_position;
- vec3 oldPos = objPos.xyz;
- objPos.xyz += 0.1*sin(objPos.xyz*2.0 + UNI_time);
- objPos.xyz += 0.05*sin(objPos.xyz*4.0 + UNI_time*0.5);
- objPos.xyz += 0.02*sin(objPos.xyz*7.0 + UNI_time*0.75);
- vec4 worldPos = UNI_model * objPos;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * (ATTRIB_normal + oldPos - objPos.xyz);
-
- varWorldPos = worldPos.xyz;
- varWorldNormal = worldNorm;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/shader2v.glsl b/tests/RenderScriptTests/PerfTest/res/raw/shader2v.glsl
deleted file mode 100644
index e6885a3..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/shader2v.glsl
+++ /dev/null
@@ -1,17 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 objPos = ATTRIB_position;
- vec4 worldPos = UNI_model * objPos;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * ATTRIB_normal;
-
- varWorldPos = worldPos.xyz;
- varWorldNormal = worldNorm;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/shaderf.glsl b/tests/RenderScriptTests/PerfTest/res/raw/shaderf.glsl
deleted file mode 100644
index d56e203..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/shaderf.glsl
+++ /dev/null
@@ -1,16 +0,0 @@
-
-varying lowp float light0_Diffuse;
-varying lowp float light0_Specular;
-varying lowp float light1_Diffuse;
-varying lowp float light1_Specular;
-varying vec2 varTex0;
-
-void main() {
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_Tex0, t0).rgba;
- col.xyz = col.xyz * (light0_Diffuse * UNI_light0_DiffuseColor.xyz + light1_Diffuse * UNI_light1_DiffuseColor.xyz);
- col.xyz += light0_Specular * UNI_light0_SpecularColor.xyz;
- col.xyz += light1_Specular * UNI_light1_SpecularColor.xyz;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/shaderv.glsl b/tests/RenderScriptTests/PerfTest/res/raw/shaderv.glsl
deleted file mode 100644
index f7d01de..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/shaderv.glsl
+++ /dev/null
@@ -1,30 +0,0 @@
-varying float light0_Diffuse;
-varying float light0_Specular;
-varying float light1_Diffuse;
-varying float light1_Specular;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 worldPos = UNI_model * ATTRIB_position;
- gl_Position = UNI_proj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * ATTRIB_normal;
- vec3 V = normalize(-worldPos.xyz);
-
- vec3 light0Vec = normalize(UNI_light0_Posision.xyz - worldPos.xyz);
- vec3 light0R = -reflect(light0Vec, worldNorm);
- light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0) * UNI_light0_Diffuse;
- float light0Spec = clamp(dot(light0R, V), 0.001, 1.0);
- light0_Specular = pow(light0Spec, UNI_light0_CosinePower) * UNI_light0_Specular;
-
- vec3 light1Vec = normalize(UNI_light1_Posision.xyz - worldPos.xyz);
- vec3 light1R = reflect(light1Vec, worldNorm);
- light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0) * UNI_light1_Diffuse;
- float light1Spec = clamp(dot(light1R, V), 0.001, 1.0);
- light1_Specular = pow(light1Spec, UNI_light1_CosinePower) * UNI_light1_Specular;
-
- gl_PointSize = 1.0;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/singletexf.glsl b/tests/RenderScriptTests/PerfTest/res/raw/singletexf.glsl
deleted file mode 100644
index 83dfc7f..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/singletexf.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- lowp vec3 col0 = texture2D(UNI_Tex0, varTex0).rgb;
- gl_FragColor.xyz = col0;
- gl_FragColor.w = 0.5;
-}
-
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/singletexfm.glsl b/tests/RenderScriptTests/PerfTest/res/raw/singletexfm.glsl
deleted file mode 100644
index 656961c..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/singletexfm.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- lowp vec3 col0 = texture2D(UNI_Tex0, varTex0).rgb;
- gl_FragColor.xyz = col0 * UNI_modulate.rgb;
- gl_FragColor.w = UNI_modulate.a;
-}
-
diff --git a/tests/RenderScriptTests/PerfTest/res/raw/torus.a3d b/tests/RenderScriptTests/PerfTest/res/raw/torus.a3d
deleted file mode 100644
index 0322b01..0000000
--- a/tests/RenderScriptTests/PerfTest/res/raw/torus.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/PerfTest/res/values/strings.xml b/tests/RenderScriptTests/PerfTest/res/values/strings.xml
deleted file mode 100644
index ce9819e..0000000
--- a/tests/RenderScriptTests/PerfTest/res/values/strings.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2011 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <skip />
- <string name="benchmark_all">Benchmark All</string>
- <string name="benchmark_one">Benchmark One</string>
- <string name="debug_mode">Debug Mode</string>
-</resources>
-
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java
deleted file mode 100644
index 41f664a..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/FillTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import android.os.Environment;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-
-import android.util.Log;
-
-
-public class FillTest implements RsBenchBaseTest{
-
- private static final String TAG = "FillTest";
- private RenderScriptGL mRS;
- private Resources mRes;
-
- // Custom shaders
- private ProgramFragment mProgFragmentMultitex;
- private ProgramFragment mProgFragmentSingletex;
- private ProgramFragment mProgFragmentSingletexModulate;
- private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
- int mBenchmarkDimX;
- int mBenchmarkDimY;
-
- private ScriptC_fill_test mFillScript;
- ScriptField_TestScripts_s.Item[] mTests;
- ScriptField_FillTestFragData_s mFragData;
-
- private final String[] mNames = {
- "Fill screen 10x singletexture",
- "Fill screen 10x 3tex multitexture",
- "Fill screen 10x blended singletexture",
- "Fill screen 10x blended 3tex multitexture",
- "Fill screen 3x modulate blended singletexture",
- "Fill screen 1x modulate blended singletexture",
- };
-
- public FillTest() {
- mOptionsARGB.inScaled = false;
- mOptionsARGB.inPreferredConfig = Bitmap.Config.ARGB_8888;
- mBenchmarkDimX = 1280;
- mBenchmarkDimY = 720;
- }
-
- void addTest(int index, int testId, int blend, int quadCount) {
- mTests[index] = new ScriptField_TestScripts_s.Item();
- mTests[index].testScript = mFillScript;
- mTests[index].testName = Allocation.createFromString(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
- mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
-
- ScriptField_FillTestData_s.Item dataItem = new ScriptField_FillTestData_s.Item();
- dataItem.testId = testId;
- dataItem.blend = blend;
- dataItem.quadCount = quadCount;
- ScriptField_FillTestData_s testData = new ScriptField_FillTestData_s(mRS, 1);
- testData.set(dataItem, 0, true);
- mTests[index].testData = testData.getAllocation();
- }
-
- public boolean init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initCustomShaders();
- initFillScript();
- mTests = new ScriptField_TestScripts_s.Item[mNames.length];
-
- int index = 0;
-
- addTest(index++, 1 /*testId*/, 0 /*blend*/, 10 /*quadCount*/);
- addTest(index++, 0 /*testId*/, 0 /*blend*/, 10 /*quadCount*/);
- addTest(index++, 1 /*testId*/, 1 /*blend*/, 10 /*quadCount*/);
- addTest(index++, 0 /*testId*/, 1 /*blend*/, 10 /*quadCount*/);
- addTest(index++, 2 /*testId*/, 1 /*blend*/, 3 /*quadCount*/);
- addTest(index++, 2 /*testId*/, 1 /*blend*/, 1 /*quadCount*/);
-
- return true;
- }
-
- public ScriptField_TestScripts_s.Item[] getTests() {
- return mTests;
- }
-
- public String[] getTestNames() {
- return mNames;
- }
-
- private void initCustomShaders() {
- ProgramFragment.Builder pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.multitexf);
- for (int texCount = 0; texCount < 3; texCount ++) {
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- }
- mProgFragmentMultitex = pfbCustom.create();
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.singletexf);
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- mProgFragmentSingletex = pfbCustom.create();
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.singletexfm);
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- mFragData = new ScriptField_FillTestFragData_s(mRS, 1);
- pfbCustom.addConstant(mFragData.getType());
- mProgFragmentSingletexModulate = pfbCustom.create();
- mProgFragmentSingletexModulate.bindConstants(mFragData.getAllocation(), 0);
- }
-
- private Allocation loadTextureARGB(int id) {
- Bitmap b = BitmapFactory.decodeResource(mRes, id, mOptionsARGB);
- return Allocation.createFromBitmap(mRS, b,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- private Allocation loadTextureRGB(int id) {
- return Allocation.createFromBitmapResource(mRS, mRes, id,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- void initFillScript() {
- mFillScript = new ScriptC_fill_test(mRS, mRes, R.raw.fill_test);
-
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- ProgramVertexFixedFunction progVertex = pvb.create();
- ProgramVertexFixedFunction.Constants PVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)progVertex).bindConstants(PVA);
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(mBenchmarkDimX, mBenchmarkDimY);
- PVA.setProjection(proj);
- mFillScript.set_gProgVertex(progVertex);
-
- mFillScript.set_gProgFragmentTexture(mProgFragmentSingletex);
- mFillScript.set_gProgFragmentTextureModulate(mProgFragmentSingletexModulate);
- mFillScript.set_gProgFragmentMultitex(mProgFragmentMultitex);
- mFillScript.set_gProgStoreBlendNone(ProgramStore.BLEND_NONE_DEPTH_NONE(mRS));
- mFillScript.set_gProgStoreBlendAlpha(ProgramStore.BLEND_ALPHA_DEPTH_NONE(mRS));
-
- mFillScript.set_gLinearClamp(Sampler.CLAMP_LINEAR(mRS));
- mFillScript.set_gLinearWrap(Sampler.WRAP_LINEAR(mRS));
- mFillScript.set_gTexTorus(loadTextureRGB(R.drawable.torusmap));
- mFillScript.set_gTexOpaque(loadTextureRGB(R.drawable.data));
- mFillScript.set_gTexTransparent(loadTextureARGB(R.drawable.leaf));
- mFillScript.set_gTexChecker(loadTextureRGB(R.drawable.checker));
-
- mFillScript.bind_gFragData(mFragData);
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java
deleted file mode 100644
index cdb4435..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/MeshTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import android.os.Environment;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.renderscript.*;
-import android.renderscript.Element.DataKind;
-import android.renderscript.Element.DataType;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Program.TextureType;
-import android.renderscript.RenderScript.RSMessageHandler;
-import android.renderscript.Mesh.Primitive;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramVertexFixedFunction;
-
-import android.util.Log;
-
-
-public class MeshTest implements RsBenchBaseTest{
-
- private static final String TAG = "MeshTest";
- private RenderScriptGL mRS;
- private Resources mRes;
-
- int mBenchmarkDimX;
- int mBenchmarkDimY;
-
- private Mesh m10by10Mesh;
- private Mesh m100by100Mesh;
- private Mesh mWbyHMesh;
-
- private ScriptC_mesh_test mGeoScript;
-
- private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
-
- ScriptField_TestScripts_s.Item[] mTests;
-
- private final String[] mNames = {
- "Full screen mesh 10 by 10",
- "Full screen mesh 100 by 100",
- "Full screen mesh W / 4 by H / 4"
- };
-
- public MeshTest() {
- mBenchmarkDimX = 1280;
- mBenchmarkDimY = 720;
- }
-
- void addTest(int index, int meshNum) {
- mTests[index] = new ScriptField_TestScripts_s.Item();
- mTests[index].testScript = mGeoScript;
- mTests[index].testName = Allocation.createFromString(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
- mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
-
- ScriptField_MeshTestData_s.Item dataItem = new ScriptField_MeshTestData_s.Item();
- dataItem.meshNum = meshNum;
- ScriptField_MeshTestData_s testData = new ScriptField_MeshTestData_s(mRS, 1);
- testData.set(dataItem, 0, true);
- mTests[index].testData = testData.getAllocation();
- }
-
- public boolean init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initGeoScript();
- mTests = new ScriptField_TestScripts_s.Item[mNames.length];
-
- int index = 0;
- addTest(index++, 0 /*meshNum*/);
- addTest(index++, 1 /*meshNum*/);
- addTest(index++, 2 /*meshNum*/);
-
- return true;
- }
-
- public ScriptField_TestScripts_s.Item[] getTests() {
- return mTests;
- }
-
- public String[] getTestNames() {
- return mNames;
- }
-
- private Mesh getMbyNMesh(float width, float height, int wResolution, int hResolution) {
-
- Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
- 2, Mesh.TriangleMeshBuilder.TEXTURE_0);
-
- for (int y = 0; y <= hResolution; y++) {
- final float normalizedY = (float)y / hResolution;
- final float yOffset = (normalizedY - 0.5f) * height;
- for (int x = 0; x <= wResolution; x++) {
- float normalizedX = (float)x / wResolution;
- float xOffset = (normalizedX - 0.5f) * width;
- tmb.setTexture((float)x % 2, (float)y % 2);
- tmb.addVertex(xOffset, yOffset);
- }
- }
-
- for (int y = 0; y < hResolution; y++) {
- final int curY = y * (wResolution + 1);
- final int belowY = (y + 1) * (wResolution + 1);
- for (int x = 0; x < wResolution; x++) {
- int curV = curY + x;
- int belowV = belowY + x;
- tmb.addTriangle(curV, belowV, curV + 1);
- tmb.addTriangle(belowV, belowV + 1, curV + 1);
- }
- }
-
- return tmb.create(true);
- }
-
- private Allocation loadTextureRGB(int id) {
- return Allocation.createFromBitmapResource(mRS, mRes, id,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- void initGeoScript() {
- mGeoScript = new ScriptC_mesh_test(mRS, mRes, R.raw.mesh_test);
-
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- ProgramVertexFixedFunction progVertex = pvb.create();
- ProgramVertexFixedFunction.Constants PVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)progVertex).bindConstants(PVA);
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(mBenchmarkDimX, mBenchmarkDimY);
- PVA.setProjection(proj);
-
- mGeoScript.set_gProgVertex(progVertex);
- ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mGeoScript.set_gProgFragmentTexture(texBuilder.create());
- mGeoScript.set_gProgStoreBlendNone(ProgramStore.BLEND_NONE_DEPTH_NONE(mRS));
-
- mGeoScript.set_gLinearClamp(Sampler.CLAMP_LINEAR(mRS));
- mGeoScript.set_gTexOpaque(loadTextureRGB(R.drawable.data));
-
- m10by10Mesh = getMbyNMesh(mBenchmarkDimX, mBenchmarkDimY, 10, 10);
- m100by100Mesh = getMbyNMesh(mBenchmarkDimX, mBenchmarkDimY, 100, 100);
- mWbyHMesh= getMbyNMesh(mBenchmarkDimX, mBenchmarkDimY, mBenchmarkDimX/4, mBenchmarkDimY/4);
-
- mGeoScript.set_g10by10Mesh(m10by10Mesh);
- mGeoScript.set_g100by100Mesh(m100by100Mesh);
- mGeoScript.set_gWbyHMesh(mWbyHMesh);
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java
deleted file mode 100644
index 0dceafe..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBench.java
+++ /dev/null
@@ -1,136 +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.
- */
-
-package com.android.perftest;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.MenuInflater;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.widget.Toast;
-
-import java.lang.Runtime;
-
-public class RsBench extends Activity {
- private final String TAG = "RsBench";
- public RsBenchView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- int iterations = 0;
- Intent intent = getIntent();
- Uri uri = intent.getData();
- if (uri != null) {
- // when lauched from instrumentation
- String scheme = uri.getScheme();
- if ("iterations".equals(scheme)) {
- iterations = Integer.parseInt(uri.getSchemeSpecificPart());
- }
- }
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new RsBenchView(this);
- setContentView(mView);
- mView.setLoops(iterations);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.loader_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.benchmark_all:
- mView.setBenchmarkMode(-1);
- mView.suspendRendering(false);
- return true;
- case R.id.benchmark_one:
- mView.suspendRendering(true);
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Pick a Test");
- builder.setItems(mView.getTestNames(),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- Toast.makeText(getApplicationContext(),
- "Starting to benchmark: " + mView.getTestNames()[item],
- Toast.LENGTH_SHORT).show();
- mView.setBenchmarkMode(item);
- mView.suspendRendering(false);
- }
- });
- builder.show();
- return true;
- case R.id.debug_mode:
- mView.suspendRendering(true);
- AlertDialog.Builder debugBuilder = new AlertDialog.Builder(this);
- debugBuilder.setTitle("Pick a Test");
- debugBuilder.setItems(mView.getTestNames(),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- Toast.makeText(getApplicationContext(),
- "Switching to: " + mView.getTestNames()[item],
- Toast.LENGTH_SHORT).show();
- mView.setDebugMode(item);
- mView.suspendRendering(false);
- }
- });
- debugBuilder.show();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchBaseTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchBaseTest.java
deleted file mode 100644
index a9e1777..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchBaseTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-import android.renderscript.*;
-import android.content.res.Resources;
-
-interface RsBenchBaseTest {
- boolean init(RenderScriptGL rs, Resources res);
-
- ScriptField_TestScripts_s.Item[] getTests();
- String[] getTestNames();
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
deleted file mode 100644
index 4ac7dd5..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchRS.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 2010-2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import java.io.Writer;
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-
-import android.os.Environment;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.Element.DataKind;
-import android.renderscript.Element.DataType;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Program.TextureType;
-import android.renderscript.RenderScript.RSMessageHandler;
-import android.renderscript.Sampler.Value;
-import android.renderscript.Mesh.Primitive;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramVertexFixedFunction;
-
-import android.util.Log;
-
-
-public class RsBenchRS {
-
- private static final String TAG = "RsBenchRS";
- int mWidth;
- int mHeight;
- int mLoops;
- int mCurrentLoop;
-
- int mBenchmarkDimX;
- int mBenchmarkDimY;
-
- public RsBenchRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res, int width, int height, int loops) {
- mRS = rs;
- mRes = res;
- mWidth = width;
- mHeight = height;
- mMode = 0;
- mLoops = loops;
- mCurrentLoop = 0;
- mBenchmarkDimX = 1280;
- mBenchmarkDimY = 720;
- initRS();
- }
-
- private boolean stopTest = false;
-
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private ProgramStore mProgStoreBlendNone;
- private ProgramStore mProgStoreBlendAlpha;
-
- private ProgramFragment mProgFragmentTexture;
- private ProgramFragment mProgFragmentColor;
-
- private ProgramVertex mProgVertex;
- private ProgramVertexFixedFunction.Constants mPVA;
- private ProgramVertexFixedFunction.Constants mPvProjectionAlloc;
-
- private ScriptC_rsbench mScript;
-
- ScriptField_TestScripts_s.Item[] mIndividualTests;
-
- int mMode;
-
- String[] mTestNames;
- float[] mLocalTestResults;
-
- static Allocation createZeroTerminatedAlloc(RenderScript rs,
- String str,
- int usage) {
- byte[] allocArray = null;
- try {
- allocArray = str.getBytes("UTF-8");
- byte[] allocArrayZero = new byte[allocArray.length + 1];
- System.arraycopy(allocArray, 0, allocArrayZero, 0, allocArray.length);
- allocArrayZero[allocArrayZero.length - 1] = '\0';
- Allocation alloc = Allocation.createSized(rs, Element.U8(rs),
- allocArrayZero.length, usage);
- alloc.copyFrom(allocArrayZero);
- return alloc;
- }
- catch (Exception e) {
- throw new RSRuntimeException("Could not convert string to utf-8.");
- }
-
- }
-
- void appendTests(RsBenchBaseTest testSet) {
- ScriptField_TestScripts_s.Item[] newTests = testSet.getTests();
- if (mIndividualTests != null) {
- ScriptField_TestScripts_s.Item[] combined;
- combined = new ScriptField_TestScripts_s.Item[newTests.length + mIndividualTests.length];
- System.arraycopy(mIndividualTests, 0, combined, 0, mIndividualTests.length);
- System.arraycopy(newTests, 0, combined, mIndividualTests.length, newTests.length);
- mIndividualTests = combined;
- } else {
- mIndividualTests = newTests;
- }
-
- String[] newNames = testSet.getTestNames();
- if (mTestNames != null) {
- String[] combinedNames;
- combinedNames = new String[newNames.length + mTestNames.length];
- System.arraycopy(mTestNames, 0, combinedNames, 0, mTestNames.length);
- System.arraycopy(newNames, 0, combinedNames, mTestNames.length, newNames.length);
- mTestNames = combinedNames;
- } else {
- mTestNames = newNames;
- }
- }
-
- void createTestAllocation() {
- int numTests = mIndividualTests.length;
- mLocalTestResults = new float[numTests];
- ScriptField_TestScripts_s allTests;
- allTests = new ScriptField_TestScripts_s(mRS, numTests);
- for (int i = 0; i < numTests; i ++) {
- allTests.set(mIndividualTests[i], i, false);
- }
- allTests.copyAll();
- mScript.bind_gTestScripts(allTests);
- }
-
- private void saveTestResults() {
- String state = Environment.getExternalStorageState();
- if (!Environment.MEDIA_MOUNTED.equals(state)) {
- Log.v(TAG, "sdcard is read only");
- return;
- }
- File sdCard = Environment.getExternalStorageDirectory();
- if (!sdCard.canWrite()) {
- Log.v(TAG, "ssdcard is read only");
- return;
- }
-
- File resultFile = new File(sdCard, "rsbench_result" + mCurrentLoop + ".csv");
- resultFile.setWritable(true, false);
-
- try {
- BufferedWriter results = new BufferedWriter(new FileWriter(resultFile));
- for (int i = 0; i < mLocalTestResults.length; i ++) {
- results.write(mTestNames[i] + ", " + mLocalTestResults[i] + ",\n");
- }
- results.close();
- Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
- } catch (IOException e) {
- Log.v(TAG, "Unable to write result file " + e.getMessage());
- }
- }
-
- /**
- * Create a message handler to handle message sent from the script
- */
- protected RSMessageHandler mRsMessage = new RSMessageHandler() {
- public void run() {
- if (mID == mScript.get_RS_MSG_RESULTS_READY()) {
- for (int i = 0; i < mLocalTestResults.length; i ++) {
- mLocalTestResults[i] = Float.intBitsToFloat(mData[i]);
- }
- saveTestResults();
- if (mLoops > 0) {
- mCurrentLoop ++;
- mCurrentLoop = mCurrentLoop % mLoops;
- }
- return;
-
- } else if (mID == mScript.get_RS_MSG_TEST_DONE()) {
- synchronized(this) {
- stopTest = true;
- this.notifyAll();
- }
- return;
- } else {
- Log.v(TAG, "Perf test got unexpected message");
- return;
- }
- }
- };
-
- /**
- * Wait for message from the script
- */
- public boolean testIsFinished() {
- synchronized(this) {
- while (true) {
- if (stopTest) {
- return true;
- } else {
- try {
- this.wait(60*1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
-
- private void initProgramFragment() {
-
- ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mProgFragmentTexture = texBuilder.create();
- mProgFragmentTexture.bindSampler(Sampler.CLAMP_LINEAR(mRS), 0);
-
- ProgramFragmentFixedFunction.Builder colBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- colBuilder.setVaryingColor(false);
- mProgFragmentColor = colBuilder.create();
-
- mScript.set_gProgFragmentTexture(mProgFragmentTexture);
- }
-
- private void initProgramVertex() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mProgVertex = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mProgVertex).bindConstants(mPVA);
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(mBenchmarkDimX, mBenchmarkDimY);
- mPVA.setProjection(proj);
-
- mScript.set_gProgVertex(mProgVertex);
- }
-
- private int strlen(byte[] array) {
- int count = 0;
- while(count < array.length && array[count] != 0) {
- count ++;
- }
- return count;
- }
-
- public void setDebugMode(int num) {
- mScript.invoke_setDebugMode(num);
- }
-
- public void setBenchmarkMode(int benchNum) {
- mScript.invoke_setBenchmarkMode(benchNum);
- }
-
- public void pause(boolean pause) {
- mScript.set_gPauseRendering(pause);
- }
-
- private void initRS() {
-
- mScript = new ScriptC_rsbench(mRS, mRes, R.raw.rsbench);
- mRS.bindRootScript(mScript);
-
- mRS.setMessageHandler(mRsMessage);
-
- mScript.set_gMaxLoops(mLoops);
-
- initProgramVertex();
- initProgramFragment();
- mScript.set_gFontSerif(Font.create(mRS, mRes, "serif", Font.Style.NORMAL, 8));
-
- Type.Builder b = new Type.Builder(mRS, Element.RGBA_8888(mRS));
- b.setX(mBenchmarkDimX).setY(mBenchmarkDimY);
- Allocation offscreen = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_GRAPHICS_TEXTURE |
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gRenderBufferColor(offscreen);
-
- b = new Type.Builder(mRS,
- Element.createPixel(mRS, DataType.UNSIGNED_16,
- DataKind.PIXEL_DEPTH));
- b.setX(mBenchmarkDimX).setY(mBenchmarkDimY);
- offscreen = Allocation.createTyped(mRS,
- b.create(),
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gRenderBufferDepth(offscreen);
- mScript.set_gLinearClamp(Sampler.CLAMP_LINEAR(mRS));
-
- RsBenchBaseTest test = new TextTest();
- if (test.init(mRS, mRes)) {
- appendTests(test);
- }
- test = new FillTest();
- if (test.init(mRS, mRes)) {
- appendTests(test);
- }
- test = new MeshTest();
- if (test.init(mRS, mRes)) {
- appendTests(test);
- }
- test = new TorusTest();
- if (test.init(mRS, mRes)) {
- appendTests(test);
- }
- test = new UiTest();
- if (test.init(mRS, mRes)) {
- appendTests(test);
- }
- createTestAllocation();
-
- mScript.set_gLoadComplete(true);
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchTest.java
deleted file mode 100644
index 199200b..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.TouchUtils;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-
-/**
- * To run the test, please use command
- *
- * adb shell am instrument -w com.android.perftest/.RsPerfTestRunner
- *
- */
-public class RsBenchTest extends ActivityInstrumentationTestCase2<RsBench> {
- private String TAG = "RsBenchTest";
- private int iterations = 0;
- private RsBench mAct;
-
- public RsBenchTest() {
- super(RsBench.class);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- Instrumentation mInst = getInstrumentation();
- RsPerfTestRunner mRunner = (RsPerfTestRunner) getInstrumentation();
- iterations = mRunner.iterations;
- Log.v(TAG, "Run benchmark for " + iterations + " iterations.");
-
- Uri data = Uri.fromParts("iterations", Integer.toString(iterations), null);
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName("com.android.perftest", "com.android.perftest.RsBench");
- intent.setData(data);
- mAct = (RsBench) mInst.startActivitySync(intent);
- mInst.waitForIdleSync();
-
- }
-
- @Override
- public void tearDown() throws Exception {
- mAct.finish();
- super.tearDown();
- }
-
- /**
- * Run tests and wait until the test has been run for iterations.
- */
- @LargeTest
- public void testRsBench() {
- if (mAct.mView.testIsFinished()) {
- return;
- } else {
- fail("test didn't stop correctly");
- }
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java
deleted file mode 100644
index 124071e..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsBenchView.java
+++ /dev/null
@@ -1,106 +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.
- */
-
-package com.android.perftest;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-import android.renderscript.RenderScript.RSMessageHandler;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class RsBenchView extends RSSurfaceView {
-
- public RsBenchView(Context context) {
- super(context);
- }
-
- private RenderScriptGL mRS;
- private RsBenchRS mRender;
- private int mLoops = 0;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new RsBenchRS();
- Log.v("RsBenchView", "mLoops = " + mLoops);
- mRender.init(mRS, getResources(), w, h, mLoops);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- /**
- * Set the total number of loops the benchmark tests will run
- * before the test results are collected.
- */
- public void setLoops(int iterations) {
- if (iterations > 0) {
- mLoops = iterations;
- }
- }
-
- /**
- * Wait for message from the script
- */
- public boolean testIsFinished() {
- return mRender.testIsFinished();
- }
-
- void setBenchmarkMode(int benchNum) {
- mRender.setBenchmarkMode(benchNum);
- }
-
- void suspendRendering(boolean pause) {
- mRender.pause(pause);
- }
-
- void setDebugMode(int num) {
- mRender.setDebugMode(num);
- }
-
- String[] getTestNames() {
- return mRender.mTestNames;
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsPerfTestRunner.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsPerfTestRunner.java
deleted file mode 100644
index 031af6a..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/RsPerfTestRunner.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-//import com.android.perftest.RsBenchTest;
-
-import android.os.Bundle;
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-
-import junit.framework.TestSuite;
-
-/**
- * Run the RenderScript Performance Test
- * adb shell am instrument -w com.android.perftest/.RsPerfTestRunner
- *
- * with specified iterations:
- * adb shell am instrument -e iterations <n> -w com.android.perftest/.RsPerfTestRunner
- *
- */
-public class RsPerfTestRunner extends InstrumentationTestRunner {
- public int iterations = 10;
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(RsBenchTest.class);
- return suite;
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- String strValue = (String)icicle.get("iterations");
- if (strValue != null) {
- int intValue = Integer.parseInt(strValue);
- if (iterations > 0) {
- iterations = intValue;
- }
- }
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java
deleted file mode 100644
index 3ca2792..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TextTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import android.os.Environment;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.DisplayMetrics;
-
-import android.util.Log;
-
-
-public class TextTest implements RsBenchBaseTest{
-
- private static final String TAG = "TextTest";
- private RenderScriptGL mRS;
- private Resources mRes;
-
- private ScriptC_text_test mTextScript;
- ScriptField_TestScripts_s.Item[] mTests;
-
- private final String[] mNames = {
- "Fill screen with text 1 time",
- "Fill screen with text 3 times",
- "Fill screen with text 5 times"
- };
-
- public TextTest() {
- }
-
- void addTest(int index, int fillNum) {
- mTests[index] = new ScriptField_TestScripts_s.Item();
- mTests[index].testScript = mTextScript;
- mTests[index].testName = Allocation.createFromString(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
- mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
-
- ScriptField_TextTestData_s.Item dataItem = new ScriptField_TextTestData_s.Item();
- dataItem.fillNum = fillNum;
- ScriptField_TextTestData_s testData = new ScriptField_TextTestData_s(mRS, 1);
- testData.set(dataItem, 0, true);
- mTests[index].testData = testData.getAllocation();
- }
-
- public boolean init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initTextScript();
- mTests = new ScriptField_TestScripts_s.Item[mNames.length];
-
- int index = 0;
- addTest(index++, 1 /*fillNum*/);
- addTest(index++, 3 /*fillNum*/);
- addTest(index++, 5 /*fillNum*/);
-
- return true;
- }
-
- public ScriptField_TestScripts_s.Item[] getTests() {
- return mTests;
- }
-
- public String[] getTestNames() {
- return mNames;
- }
-
- void initTextScript() {
- DisplayMetrics metrics = mRes.getDisplayMetrics();
-
- mTextScript = new ScriptC_text_test(mRS, mRes, R.raw.text_test);
- mTextScript.set_gFontSans(Font.create(mRS, mRes, "sans-serif",
- Font.Style.NORMAL, 8.0f / metrics.density));
- mTextScript.set_gFontSerif(Font.create(mRS, mRes, "serif",
- Font.Style.NORMAL, 8.0f / metrics.density));
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java
deleted file mode 100644
index 5c9ecd5..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/TorusTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import android.os.Environment;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.renderscript.*;
-import android.renderscript.Element.DataKind;
-import android.renderscript.Element.DataType;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Program.TextureType;
-import android.renderscript.RenderScript.RSMessageHandler;
-import android.renderscript.Mesh.Primitive;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramVertexFixedFunction;
-
-import android.util.Log;
-
-
-public class TorusTest implements RsBenchBaseTest{
-
- private static final String TAG = "TorusTest";
- private RenderScriptGL mRS;
- private Resources mRes;
-
- private ProgramStore mProgStoreBlendNoneDepth;
- private ProgramStore mProgStoreBlendNone;
- private ProgramStore mProgStoreBlendAlpha;
-
- private ProgramFragment mProgFragmentTexture;
- private ProgramFragment mProgFragmentColor;
-
- private ProgramVertex mProgVertex;
- private ProgramVertexFixedFunction.Constants mPVA;
- private ProgramVertexFixedFunction.Constants mPvProjectionAlloc;
-
- // Custom shaders
- private ProgramVertex mProgVertexCustom;
- private ProgramFragment mProgFragmentCustom;
- private ProgramFragment mProgFragmentMultitex;
- private ProgramVertex mProgVertexPixelLight;
- private ProgramVertex mProgVertexPixelLightMove;
- private ProgramFragment mProgFragmentPixelLight;
- private ScriptField_VertexShaderConstants_s mVSConst;
- private ScriptField_FragentShaderConstants_s mFSConst;
- private ScriptField_VertexShaderConstants3_s mVSConstPixel;
- private ScriptField_FragentShaderConstants3_s mFSConstPixel;
-
- private Allocation mTexTorus;
- private Mesh mTorus;
-
- private ScriptC_torus_test mTorusScript;
-
- private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
-
- ScriptField_TestScripts_s.Item[] mTests;
-
- private final String[] mNames = {
- "Geo test 25.6k flat color",
- "Geo test 51.2k flat color",
- "Geo test 204.8k small tries flat color",
- "Geo test 25.6k single texture",
- "Geo test 51.2k single texture",
- "Geo test 204.8k small tries single texture",
- "Geo test 25.6k geo heavy vertex",
- "Geo test 51.2k geo heavy vertex",
- "Geo test 204.8k geo raster load heavy vertex",
- "Geo test 25.6k heavy fragment",
- "Geo test 51.2k heavy fragment",
- "Geo test 204.8k small tries heavy fragment",
- "Geo test 25.6k heavy fragment heavy vertex",
- "Geo test 51.2k heavy fragment heavy vertex",
- "Geo test 204.8k small tries heavy fragment heavy vertex"
- };
-
- public TorusTest() {
- }
-
- void addTest(int index, int testId, int user1, int user2) {
- mTests[index] = new ScriptField_TestScripts_s.Item();
- mTests[index].testScript = mTorusScript;
- mTests[index].testName = Allocation.createFromString(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
- mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
-
- ScriptField_TorusTestData_s.Item dataItem = new ScriptField_TorusTestData_s.Item();
- dataItem.testId = testId;
- dataItem.user1 = user1;
- dataItem.user2 = user2;
- ScriptField_TorusTestData_s testData = new ScriptField_TorusTestData_s(mRS, 1);
- testData.set(dataItem, 0, true);
- mTests[index].testData = testData.getAllocation();
- }
-
- public boolean init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initCustomShaders();
- loadImages();
- initMesh();
- initTorusScript();
- mTests = new ScriptField_TestScripts_s.Item[mNames.length];
-
- int index = 0;
- addTest(index++, 0, 0 /*useTexture*/, 1 /*numMeshes*/);
- addTest(index++, 0, 0 /*useTexture*/, 2 /*numMeshes*/);
- addTest(index++, 0, 0 /*useTexture*/, 8 /*numMeshes*/);
- addTest(index++, 0, 1 /*useTexture*/, 1 /*numMeshes*/);
- addTest(index++, 0, 1 /*useTexture*/, 2 /*numMeshes*/);
- addTest(index++, 0, 1 /*useTexture*/, 8 /*numMeshes*/);
-
- // Secont test
- addTest(index++, 1, 1 /*numMeshes*/, 0 /*unused*/);
- addTest(index++, 1, 2 /*numMeshes*/, 0 /*unused*/);
- addTest(index++, 1, 8 /*numMeshes*/, 0 /*unused*/);
-
- // Third test
- addTest(index++, 2, 1 /*numMeshes*/, 0 /*heavyVertex*/);
- addTest(index++, 2, 2 /*numMeshes*/, 0 /*heavyVertex*/);
- addTest(index++, 2, 8 /*numMeshes*/, 0 /*heavyVertex*/);
- addTest(index++, 2, 1 /*numMeshes*/, 1 /*heavyVertex*/);
- addTest(index++, 2, 2 /*numMeshes*/, 1 /*heavyVertex*/);
- addTest(index++, 2, 8 /*numMeshes*/, 1 /*heavyVertex*/);
-
- return true;
- }
-
- public ScriptField_TestScripts_s.Item[] getTests() {
- return mTests;
- }
-
- public String[] getTestNames() {
- return mNames;
- }
-
- private void initCustomShaders() {
- mVSConst = new ScriptField_VertexShaderConstants_s(mRS, 1);
- mFSConst = new ScriptField_FragentShaderConstants_s(mRS, 1);
-
- mVSConstPixel = new ScriptField_VertexShaderConstants3_s(mRS, 1);
- mFSConstPixel = new ScriptField_FragentShaderConstants3_s(mRS, 1);
-
- // Initialize the shader builder
- ProgramVertex.Builder pvbCustom = new ProgramVertex.Builder(mRS);
- // Specify the resource that contains the shader string
- pvbCustom.setShader(mRes, R.raw.shaderv);
- // Use a script field to specify the input layout
- pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
- // Define the constant input layout
- pvbCustom.addConstant(mVSConst.getAllocation().getType());
- mProgVertexCustom = pvbCustom.create();
- // Bind the source of constant data
- mProgVertexCustom.bindConstants(mVSConst.getAllocation(), 0);
-
- ProgramFragment.Builder pfbCustom = new ProgramFragment.Builder(mRS);
- // Specify the resource that contains the shader string
- pfbCustom.setShader(mRes, R.raw.shaderf);
- // Tell the builder how many textures we have
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- // Define the constant input layout
- pfbCustom.addConstant(mFSConst.getAllocation().getType());
- mProgFragmentCustom = pfbCustom.create();
- // Bind the source of constant data
- mProgFragmentCustom.bindConstants(mFSConst.getAllocation(), 0);
-
- pvbCustom = new ProgramVertex.Builder(mRS);
- pvbCustom.setShader(mRes, R.raw.shader2v);
- pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
- pvbCustom.addConstant(mVSConstPixel.getAllocation().getType());
- mProgVertexPixelLight = pvbCustom.create();
- mProgVertexPixelLight.bindConstants(mVSConstPixel.getAllocation(), 0);
-
- pvbCustom = new ProgramVertex.Builder(mRS);
- pvbCustom.setShader(mRes, R.raw.shader2movev);
- pvbCustom.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
- pvbCustom.addConstant(mVSConstPixel.getAllocation().getType());
- mProgVertexPixelLightMove = pvbCustom.create();
- mProgVertexPixelLightMove.bindConstants(mVSConstPixel.getAllocation(), 0);
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.shader2f);
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- pfbCustom.addConstant(mFSConstPixel.getAllocation().getType());
- mProgFragmentPixelLight = pfbCustom.create();
- mProgFragmentPixelLight.bindConstants(mFSConstPixel.getAllocation(), 0);
-
- pfbCustom = new ProgramFragment.Builder(mRS);
- pfbCustom.setShader(mRes, R.raw.multitexf);
- for (int texCount = 0; texCount < 3; texCount ++) {
- pfbCustom.addTexture(Program.TextureType.TEXTURE_2D);
- }
- mProgFragmentMultitex = pfbCustom.create();
-
- ProgramFragmentFixedFunction.Builder colBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- colBuilder.setVaryingColor(false);
- mProgFragmentColor = colBuilder.create();
-
- ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mProgFragmentTexture = texBuilder.create();
-
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mProgVertex = pvb.create();
- ProgramVertexFixedFunction.Constants PVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)mProgVertex).bindConstants(PVA);
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(1280, 720);
- PVA.setProjection(proj);
- }
-
- private Allocation loadTextureRGB(int id) {
- return Allocation.createFromBitmapResource(mRS, mRes, id,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- private void loadImages() {
- mTexTorus = loadTextureRGB(R.drawable.torusmap);
- }
-
- private void initMesh() {
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.torus);
- FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if (entry == null || entry.getEntryType() != FileA3D.EntryType.MESH) {
- Log.e("rs", "could not load model");
- } else {
- mTorus = (Mesh)entry.getObject();
- }
- }
-
- void initTorusScript() {
- mTorusScript = new ScriptC_torus_test(mRS, mRes, R.raw.torus_test);
- mTorusScript.set_gCullFront(ProgramRaster.CULL_FRONT(mRS));
- mTorusScript.set_gCullBack(ProgramRaster.CULL_BACK(mRS));
- mTorusScript.set_gLinearClamp(Sampler.CLAMP_LINEAR(mRS));
- mTorusScript.set_gTorusMesh(mTorus);
- mTorusScript.set_gTexTorus(mTexTorus);
- mTorusScript.set_gProgVertexCustom(mProgVertexCustom);
- mTorusScript.set_gProgFragmentCustom(mProgFragmentCustom);
- mTorusScript.set_gProgVertexPixelLight(mProgVertexPixelLight);
- mTorusScript.set_gProgVertexPixelLightMove(mProgVertexPixelLightMove);
- mTorusScript.set_gProgFragmentPixelLight(mProgFragmentPixelLight);
- mTorusScript.bind_gVSConstPixel(mVSConstPixel);
- mTorusScript.bind_gFSConstPixel(mFSConstPixel);
- mTorusScript.bind_gVSConstants(mVSConst);
- mTorusScript.bind_gFSConstants(mFSConst);
- mTorusScript.set_gProgVertex(mProgVertex);
- mTorusScript.set_gProgFragmentTexture(mProgFragmentTexture);
- mTorusScript.set_gProgFragmentColor(mProgFragmentColor);
- mTorusScript.set_gProgStoreBlendNoneDepth(mProgStoreBlendNoneDepth);
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java
deleted file mode 100644
index c8b58b2..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/UiTest.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.perftest;
-
-import android.os.Environment;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.renderscript.*;
-import android.renderscript.Element.DataKind;
-import android.renderscript.Element.DataType;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Program.TextureType;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.renderscript.ProgramStore.BlendSrcFunc;
-import android.renderscript.ProgramStore.BlendDstFunc;
-import android.renderscript.RenderScript.RSMessageHandler;
-import android.renderscript.Mesh.Primitive;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramVertexFixedFunction;
-
-import android.util.Log;
-
-
-public class UiTest implements RsBenchBaseTest{
-
- private static final String TAG = "UiTest";
- private static final String SAMPLE_TEXT = "Bench Test";
- private static final String LIST_TEXT =
- "This is a sample list of text to show in the list view";
- private static int PARTICLES_COUNT = 12000;
-
- private RenderScriptGL mRS;
- private Resources mRes;
-
- Font mFontSans;
-
- private ScriptField_ListAllocs_s mTextureAllocs;
- private ScriptField_ListAllocs_s mSampleTextAllocs;
- private ScriptField_ListAllocs_s mSampleListViewAllocs;
- private ScriptField_VpConsts mPvStarAlloc;
- private ProgramVertexFixedFunction.Constants mPvProjectionAlloc;
-
- private Mesh mSingleMesh;
- private Mesh mParticlesMesh;
-
- private ScriptC_ui_test mUiScript;
-
- private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
-
- ScriptField_TestScripts_s.Item[] mTests;
-
- private final String[] mNames = {
- "UI test with icon display 10 by 10",
- "UI test with icon display 100 by 100",
- "UI test with image and text display 3 pages",
- "UI test with image and text display 5 pages",
- "UI test with list view",
- "UI test with live wallpaper"
- };
-
- public UiTest() {
- }
-
- void addTest(int index, int testId, int user1, int user2, int user3) {
- mTests[index] = new ScriptField_TestScripts_s.Item();
- mTests[index].testScript = mUiScript;
- mTests[index].testName = Allocation.createFromString(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
- mTests[index].debugName = RsBenchRS.createZeroTerminatedAlloc(mRS,
- mNames[index],
- Allocation.USAGE_SCRIPT);
-
- ScriptField_UiTestData_s.Item dataItem = new ScriptField_UiTestData_s.Item();
- dataItem.testId = testId;
- dataItem.user1 = user1;
- dataItem.user2 = user2;
- dataItem.user3 = user3;
- ScriptField_UiTestData_s testData = new ScriptField_UiTestData_s(mRS, 1);
- testData.set(dataItem, 0, true);
- mTests[index].testData = testData.getAllocation();
- }
-
- public boolean init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- mFontSans = Font.create(mRS, mRes, "sans-serif", Font.Style.NORMAL, 8);
- mSingleMesh = getSingleMesh(1, 1); // a unit size mesh
-
- initUiScript();
- mTests = new ScriptField_TestScripts_s.Item[mNames.length];
-
- int index = 0;
-
- addTest(index++, 0, 0 /*meshMode*/, 0 /*unused*/, 0 /*unused*/);
- addTest(index++, 0, 1 /*meshMode*/, 0 /*unused*/, 0 /*unused*/);
- addTest(index++, 1, 7 /*wResolution*/, 5 /*hResolution*/, 0 /*meshMode*/);
- addTest(index++, 1, 7 /*wResolution*/, 5 /*hResolution*/, 1 /*meshMode*/);
- addTest(index++, 2, 0 /*unused*/, 0 /*unused*/, 0 /*unused*/);
- addTest(index++, 3, 7 /*wResolution*/, 5 /*hResolution*/, 0 /*unused*/);
-
- return true;
- }
-
- public ScriptField_TestScripts_s.Item[] getTests() {
- return mTests;
- }
-
- public String[] getTestNames() {
- return mNames;
- }
-
- private Allocation loadTextureRGB(int id) {
- return Allocation.createFromBitmapResource(mRS, mRes, id,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- private Allocation loadTextureARGB(int id) {
- Bitmap b = BitmapFactory.decodeResource(mRes, id, mOptionsARGB);
- return Allocation.createFromBitmap(mRS, b,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- }
-
- private void createParticlesMesh() {
- ScriptField_Particle p = new ScriptField_Particle(mRS, PARTICLES_COUNT);
-
- final Mesh.AllocationBuilder meshBuilder = new Mesh.AllocationBuilder(mRS);
- meshBuilder.addVertexAllocation(p.getAllocation());
- final int vertexSlot = meshBuilder.getCurrentVertexTypeIndex();
- meshBuilder.addIndexSetType(Primitive.POINT);
- mParticlesMesh = meshBuilder.create();
-
- mUiScript.set_gParticlesMesh(mParticlesMesh);
- mUiScript.bind_Particles(p);
- }
-
- /**
- * Create a mesh with a single quad for the given width and height.
- */
- private Mesh getSingleMesh(float width, float height) {
- Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
- 2, Mesh.TriangleMeshBuilder.TEXTURE_0);
- float xOffset = width/2;
- float yOffset = height/2;
- tmb.setTexture(0, 0);
- tmb.addVertex(-1.0f * xOffset, -1.0f * yOffset);
- tmb.setTexture(1, 0);
- tmb.addVertex(xOffset, -1.0f * yOffset);
- tmb.setTexture(1, 1);
- tmb.addVertex(xOffset, yOffset);
- tmb.setTexture(0, 1);
- tmb.addVertex(-1.0f * xOffset, yOffset);
- tmb.addTriangle(0, 3, 1);
- tmb.addTriangle(1, 3, 2);
- return tmb.create(true);
- }
-
- private Matrix4f getProjectionNormalized(int w, int h) {
- // range -1,1 in the narrow axis at z = 0.
- Matrix4f m1 = new Matrix4f();
- Matrix4f m2 = new Matrix4f();
-
- if(w > h) {
- float aspect = ((float)w) / h;
- m1.loadFrustum(-aspect,aspect, -1,1, 1,100);
- } else {
- float aspect = ((float)h) / w;
- m1.loadFrustum(-1,1, -aspect,aspect, 1,100);
- }
-
- m2.loadRotate(180, 0, 1, 0);
- m1.loadMultiply(m1, m2);
-
- m2.loadScale(-2, 2, 1);
- m1.loadMultiply(m1, m2);
-
- m2.loadTranslate(0, 0, 2);
- m1.loadMultiply(m1, m2);
- return m1;
- }
-
- private void updateProjectionMatrices() {
- Matrix4f projNorm = getProjectionNormalized(1280, 720);
- ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
- i.Proj = projNorm;
- i.MVP = projNorm;
- mPvStarAlloc.set(i, 0, true);
- mPvProjectionAlloc.setProjection(projNorm);
- }
-
- void initUiScript() {
- mUiScript = new ScriptC_ui_test(mRS, mRes, R.raw.ui_test);
-
- ProgramFragmentFixedFunction.Builder colBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- colBuilder.setVaryingColor(false);
- ProgramFragmentFixedFunction.Builder texBuilder = new ProgramFragmentFixedFunction.Builder(mRS);
- texBuilder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
-
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- ProgramVertexFixedFunction progVertex = pvb.create();
- ProgramVertexFixedFunction.Constants PVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)progVertex).bindConstants(PVA);
- Matrix4f proj = new Matrix4f();
- proj.loadOrthoWindow(1280, 720);
- PVA.setProjection(proj);
-
- mUiScript.set_gProgVertex(progVertex);
- mUiScript.set_gProgFragmentColor(colBuilder.create());
- mUiScript.set_gProgFragmentTexture(texBuilder.create());
- mUiScript.set_gProgStoreBlendAlpha(ProgramStore.BLEND_ALPHA_DEPTH_NONE(mRS));
-
- mUiScript.set_gLinearClamp(Sampler.CLAMP_LINEAR(mRS));
-
- mUiScript.set_gTexTorus(loadTextureRGB(R.drawable.torusmap));
- mUiScript.set_gTexOpaque(loadTextureRGB(R.drawable.data));
- mUiScript.set_gTexGlobe(loadTextureRGB(R.drawable.globe));
- mUiScript.set_gSingleMesh(mSingleMesh);
-
- // For GALAXY
- ProgramStore.Builder psb = new ProgramStore.Builder(mRS);
- psb.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
- mRS.bindProgramStore(psb.create());
-
- psb.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE);
- mUiScript.set_gPSLights(psb.create());
-
- // For Galaxy live wallpaper drawing
- ProgramFragmentFixedFunction.Builder builder = new ProgramFragmentFixedFunction.Builder(mRS);
- builder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGB, 0);
- ProgramFragment pfb = builder.create();
- pfb.bindSampler(Sampler.WRAP_NEAREST(mRS), 0);
- mUiScript.set_gPFBackground(pfb);
-
- builder = new ProgramFragmentFixedFunction.Builder(mRS);
- builder.setPointSpriteTexCoordinateReplacement(true);
- builder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.MODULATE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- builder.setVaryingColor(true);
- ProgramFragment pfs = builder.create();
- pfs.bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(mRS), 0);
- mUiScript.set_gPFStars(pfs);
-
- mTextureAllocs = new ScriptField_ListAllocs_s(mRS, 100);
- for (int i = 0; i < 100; i++) {
- ScriptField_ListAllocs_s.Item texElem = new ScriptField_ListAllocs_s.Item();
- texElem.item = loadTextureRGB(R.drawable.globe);
- mTextureAllocs.set(texElem, i, false);
- }
- mTextureAllocs.copyAll();
- mUiScript.bind_gTexList100(mTextureAllocs);
-
- mSampleTextAllocs = new ScriptField_ListAllocs_s(mRS, 100);
- for (int i = 0; i < 100; i++) {
- ScriptField_ListAllocs_s.Item textElem = new ScriptField_ListAllocs_s.Item();
- textElem.item = Allocation.createFromString(mRS, SAMPLE_TEXT, Allocation.USAGE_SCRIPT);
- mSampleTextAllocs.set(textElem, i, false);
- }
- mSampleTextAllocs.copyAll();
- mUiScript.bind_gSampleTextList100(mSampleTextAllocs);
-
- mSampleListViewAllocs = new ScriptField_ListAllocs_s(mRS, 1000);
- for (int i = 0; i < 1000; i++) {
- ScriptField_ListAllocs_s.Item textElem = new ScriptField_ListAllocs_s.Item();
- textElem.item = Allocation.createFromString(mRS, LIST_TEXT, Allocation.USAGE_SCRIPT);
- mSampleListViewAllocs.set(textElem, i, false);
- }
- mSampleListViewAllocs.copyAll();
- mUiScript.bind_gListViewText(mSampleListViewAllocs);
-
- // For galaxy live wallpaper
- mPvStarAlloc = new ScriptField_VpConsts(mRS, 1);
- mUiScript.bind_vpConstants(mPvStarAlloc);
- mPvProjectionAlloc = new ProgramVertexFixedFunction.Constants(mRS);
- updateProjectionMatrices();
-
- pvb = new ProgramVertexFixedFunction.Builder(mRS);
- ProgramVertex pvbp = pvb.create();
- ((ProgramVertexFixedFunction)pvbp).bindConstants(mPvProjectionAlloc);
- mUiScript.set_gPVBkProj(pvbp);
-
- createParticlesMesh();
-
- ProgramVertex.Builder sb = new ProgramVertex.Builder(mRS);
- String t = "varying vec4 varColor;\n" +
- "varying vec2 varTex0;\n" +
- "void main() {\n" +
- " float dist = ATTRIB_position.y;\n" +
- " float angle = ATTRIB_position.x;\n" +
- " float x = dist * sin(angle);\n" +
- " float y = dist * cos(angle) * 0.892;\n" +
- " float p = dist * 5.5;\n" +
- " float s = cos(p);\n" +
- " float t = sin(p);\n" +
- " vec4 pos;\n" +
- " pos.x = t * x + s * y;\n" +
- " pos.y = s * x - t * y;\n" +
- " pos.z = ATTRIB_position.z;\n" +
- " pos.w = 1.0;\n" +
- " gl_Position = UNI_MVP * pos;\n" +
- " gl_PointSize = ATTRIB_color.a * 10.0;\n" +
- " varColor.rgb = ATTRIB_color.rgb;\n" +
- " varColor.a = 1.0;\n" +
- "}\n";
- sb.setShader(t);
- sb.addInput(mParticlesMesh.getVertexAllocation(0).getType().getElement());
- sb.addConstant(mPvStarAlloc.getType());
- ProgramVertex pvs = sb.create();
- pvs.bindConstants(mPvStarAlloc.getAllocation(), 0);
- mUiScript.set_gPVStars(pvs);
-
- // For Galaxy live wallpaper
- mUiScript.set_gTSpace(loadTextureRGB(R.drawable.space));
- mUiScript.set_gTLight1(loadTextureRGB(R.drawable.light1));
- mUiScript.set_gTFlares(loadTextureARGB(R.drawable.flares));
-
- mUiScript.set_gFontSans(mFontSans);
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/fill_test.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/fill_test.rs
deleted file mode 100644
index 281f830..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/fill_test.rs
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-#include "rs_graphics.rsh"
-#include "subtest_def.rsh"
-
-rs_program_vertex gProgVertex;
-rs_program_fragment gProgFragmentTexture;
-rs_program_fragment gProgFragmentTextureModulate;
-rs_program_fragment gProgFragmentMultitex;
-
-rs_program_store gProgStoreBlendNone;
-rs_program_store gProgStoreBlendAlpha;
-
-rs_allocation gTexOpaque;
-rs_allocation gTexTorus;
-rs_allocation gTexTransparent;
-rs_allocation gTexChecker;
-
-rs_sampler gLinearClamp;
-rs_sampler gLinearWrap;
-
-typedef struct FillTestData_s {
- int testId;
- int blend;
- int quadCount;
-} FillTestData;
-FillTestData *gData;
-
-typedef struct FillTestFragData_s {
- float4 modulate;
-} FillTestFragData;
-FillTestFragData *gFragData;
-
-static float gDt = 0.0f;
-
-void init() {
-}
-
-static int gRenderSurfaceW = 1280;
-static int gRenderSurfaceH = 720;
-
-static void bindProgramVertexOrtho() {
- // Default vertex shader
- rsgBindProgramVertex(gProgVertex);
- // Setup the projection matrix
- rs_matrix4x4 proj;
- rsMatrixLoadOrtho(&proj, 0, gRenderSurfaceW, gRenderSurfaceH, 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-}
-
-static void displaySingletexFill(bool blend, int quadCount, bool modulate) {
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- if (!blend) {
- rsgBindProgramStore(gProgStoreBlendNone);
- } else {
- rsgBindProgramStore(gProgStoreBlendAlpha);
- }
- if (modulate) {
- rsgBindProgramFragment(gProgFragmentTextureModulate);
- rsgBindSampler(gProgFragmentTextureModulate, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTextureModulate, 0, gTexOpaque);
-
- gFragData->modulate.r = 0.8f;
- gFragData->modulate.g = 0.7f;
- gFragData->modulate.b = 0.8f;
- gFragData->modulate.a = 0.5f;
- rsgAllocationSyncAll(rsGetAllocation(gFragData));
- } else {
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
- }
-
- for (int i = 0; i < quadCount; i ++) {
- float startX = 5 * i, startY = 5 * i;
- float width = gRenderSurfaceW - startX, height = gRenderSurfaceH - startY;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1,
- startX + width, startY + height, 0, 1, 1,
- startX + width, startY, 0, 1, 0);
- }
-}
-
-static void displayMultitextureSample(bool blend, int quadCount) {
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- if (!blend) {
- rsgBindProgramStore(gProgStoreBlendNone);
- } else {
- rsgBindProgramStore(gProgStoreBlendAlpha);
- }
- rsgBindProgramFragment(gProgFragmentMultitex);
- rsgBindSampler(gProgFragmentMultitex, 0, gLinearClamp);
- rsgBindSampler(gProgFragmentMultitex, 1, gLinearWrap);
- rsgBindSampler(gProgFragmentMultitex, 2, gLinearClamp);
- rsgBindTexture(gProgFragmentMultitex, 0, gTexChecker);
- rsgBindTexture(gProgFragmentMultitex, 1, gTexTorus);
- rsgBindTexture(gProgFragmentMultitex, 2, gTexTransparent);
-
- for (int i = 0; i < quadCount; i ++) {
- float startX = 10 * i, startY = 10 * i;
- float width = gRenderSurfaceW - startX, height = gRenderSurfaceH - startY;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
- startX, startY + height, 0, 0, 1,
- startX + width, startY + height, 0, 1, 1,
- startX + width, startY, 0, 1, 0);
- }
-}
-
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- TestData *testData = (TestData*)usrData;
- gRenderSurfaceW = testData->renderSurfaceW;
- gRenderSurfaceH = testData->renderSurfaceH;
- gDt = testData->dt;
-
- gData = (FillTestData*)v_in;
-
- switch(gData->testId) {
- case 0:
- displayMultitextureSample(gData->blend == 1 ? true : false, gData->quadCount);
- break;
- case 1:
- displaySingletexFill(gData->blend == 1 ? true : false, gData->quadCount, false);
- break;
- case 2:
- displaySingletexFill(gData->blend == 1 ? true : false, gData->quadCount, true);
- break;
- default:
- rsDebug("Wrong test number", 0);
- break;
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/mesh_test.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/mesh_test.rs
deleted file mode 100644
index d7e4857..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/mesh_test.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-#include "rs_graphics.rsh"
-#include "shader_def.rsh"
-#include "subtest_def.rsh"
-
-rs_program_vertex gProgVertex;
-rs_program_fragment gProgFragmentTexture;
-
-rs_program_store gProgStoreBlendNone;
-
-rs_allocation gTexOpaque;
-
-rs_mesh g10by10Mesh;
-rs_mesh g100by100Mesh;
-rs_mesh gWbyHMesh;
-
-rs_sampler gLinearClamp;
-static int gRenderSurfaceW;
-static int gRenderSurfaceH;
-
-static float gDt = 0;
-
-typedef struct MeshTestData_s {
- int meshNum;
-} MeshTestData;
-MeshTestData *gData;
-
-void init() {
-}
-
-static void bindProgramVertexOrtho() {
- // Default vertex shader
- rsgBindProgramVertex(gProgVertex);
- // Setup the projection matrix
- rs_matrix4x4 proj;
- rsMatrixLoadOrtho(&proj, 0, gRenderSurfaceW, gRenderSurfaceH, 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-}
-
-static void displayMeshSamples(int meshNum) {
-
- bindProgramVertexOrtho();
- rs_matrix4x4 matrix;
- rsMatrixLoadTranslate(&matrix, gRenderSurfaceW/2, gRenderSurfaceH/2, 0);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNone);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
-
- rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
-
- if (meshNum == 0) {
- rsgDrawMesh(g10by10Mesh);
- } else if (meshNum == 1) {
- rsgDrawMesh(g100by100Mesh);
- } else if (meshNum == 2) {
- rsgDrawMesh(gWbyHMesh);
- }
-}
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- TestData *testData = (TestData*)usrData;
- gRenderSurfaceW = testData->renderSurfaceW;
- gRenderSurfaceH = testData->renderSurfaceH;
- gDt = testData->dt;
-
- gData = (MeshTestData*)v_in;
-
- displayMeshSamples(gData->meshNum);
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs
deleted file mode 100644
index 43cf4e0..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/rsbench.rs
+++ /dev/null
@@ -1,270 +0,0 @@
-// Copyright (C) 2010-2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-#include "rs_graphics.rsh"
-#include "shader_def.rsh"
-#include "subtest_def.rsh"
-
-/* Message sent from script to renderscript */
-const int RS_MSG_TEST_DONE = 100;
-const int RS_MSG_RESULTS_READY = 101;
-
-static const int gMaxModes = 64;
-int gMaxLoops = 1;
-int gDisplayMode = 1;
-
-// Allocation to write the results into
-static float gResultBuffer[gMaxModes];
-
-rs_font gFontSerif;
-rs_sampler gLinearClamp;
-
-rs_program_vertex gProgVertex;
-rs_program_fragment gProgFragmentTexture;
-
-rs_allocation gRenderBufferColor;
-rs_allocation gRenderBufferDepth;
-
-VertexShaderInputs *gVSInputs;
-
-typedef struct TestScripts_s {
- rs_allocation testData;
- rs_allocation testName;
- rs_allocation debugName;
- rs_script testScript;
-} TestScripts;
-TestScripts *gTestScripts;
-
-bool gLoadComplete = false;
-bool gPauseRendering = false;
-
-static float gDt = 0;
-
-void init() {
-}
-
-static int gRenderSurfaceW;
-static int gRenderSurfaceH;
-
-static void fillSurfaceParams(TestData *testData) {
- testData->renderSurfaceW = gRenderSurfaceW;
- testData->renderSurfaceH = gRenderSurfaceH;
- testData->dt = gDt;
-}
-
-static void setupOffscreenTarget() {
- rsgBindColorTarget(gRenderBufferColor, 0);
- rsgBindDepthTarget(gRenderBufferDepth);
-}
-
-static void bindProgramVertexOrtho() {
- // Default vertex shader
- rsgBindProgramVertex(gProgVertex);
- // Setup the projection matrix
- rs_matrix4x4 proj;
- rsMatrixLoadOrtho(&proj, 0, gRenderSurfaceW, gRenderSurfaceH, 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-}
-
-static void runSubTest(int index) {
- TestData testData;
- fillSurfaceParams(&testData);
-
- rs_allocation null_alloc = {0};
- rsForEach(gTestScripts[index].testScript,
- gTestScripts[index].testData,
- null_alloc,
- &testData,
- sizeof(testData));
-}
-
-
-static bool checkInit() {
-
- static int countdown = 3;
-
- // Perform all the uploads so we only measure rendered time
- if(countdown > 1) {
- int testCount = rsAllocationGetDimX(rsGetAllocation(gTestScripts));
- for(int i = 0; i < testCount; i ++) {
- rsgClearColor(0.2f, 0.2f, 0.2f, 0.0f);
- runSubTest(i);
- rsgFinish();
- }
- countdown --;
- rsgClearColor(0.2f, 0.2f, 0.2f, 0.0f);
-
- rsgFontColor(0.9f, 0.9f, 0.95f, 1.0f);
- rsgBindFont(gFontSerif);
- if (countdown == 1) {
- rsgDrawText("Rendering", 50, 50);
- } else {
- rsgDrawText("Initializing", 50, 50);
- }
-
- return false;
- }
-
- return true;
-}
-
-static int benchMode = 0;
-static bool benchmarkSingleTest = false;
-static int runningLoops = 0;
-static bool sendMsgFlag = false;
-
-static bool gIsDebugMode = false;
-void setDebugMode(int testNumber) {
- gIsDebugMode = true;
- benchMode = testNumber;
- rsgClearAllRenderTargets();
-}
-
-void setBenchmarkMode(int testNumber) {
- gIsDebugMode = false;
- if (testNumber == -1) {
- benchmarkSingleTest = false;
- benchMode = 0;
- } else {
- benchmarkSingleTest = true;
- benchMode = testNumber;
- }
-
- runningLoops = 0;
-}
-
-static void drawOffscreenResult(int posX, int posY, int width, int height) {
- bindProgramVertexOrtho();
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- rsgBindProgramFragment(gProgFragmentTexture);
-
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gRenderBufferColor);
-
- float startX = posX, startY = posY;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 1,
- startX, startY + height, 0, 0, 0,
- startX + width, startY + height, 0, 1, 0,
- startX + width, startY, 0, 1, 1);
-}
-
-static void benchmark() {
-
- gDt = 1.0f / 60.0f;
-
- rsgFinish();
- int64_t start = rsUptimeMillis();
-
- int drawPos = 0;
- int frameCount = 100;
- for(int i = 0; i < frameCount; i ++) {
- setupOffscreenTarget();
- gRenderSurfaceW = rsAllocationGetDimX(gRenderBufferColor);
- gRenderSurfaceH = rsAllocationGetDimY(gRenderBufferColor);
- rsgClearColor(0.1f, 0.1f, 0.1f, 1.0f);
- rsgClearDepth(1.0f);
-
- runSubTest(benchMode);
- rsgClearAllRenderTargets();
- gRenderSurfaceW = rsgGetWidth();
- gRenderSurfaceH = rsgGetHeight();
- int size = 8;
- // draw each frame at (8, 3/4 gRenderSurfaceH) with size
- drawOffscreenResult((drawPos+=size)%gRenderSurfaceW, (gRenderSurfaceH * 3) / 4, size, size);
- }
-
- rsgFinish();
-
- int64_t end = rsUptimeMillis();
- float fps = (float)(frameCount) / ((float)(end - start)*0.001f);
- const char *testName = rsGetElementAt(gTestScripts[benchMode].debugName, 0);
- rsDebug(testName, fps);
-
- gResultBuffer[benchMode] = fps;
- int bufferW = rsAllocationGetDimX(gRenderBufferColor);
- int bufferH = rsAllocationGetDimY(gRenderBufferColor);
-
- int quadW = gRenderSurfaceW / 2;
- int quadH = (quadW * bufferH) / bufferW;
- drawOffscreenResult(0, 0, quadW, quadH);
-
- int left = 0, right = 0, top = 0, bottom = 0;
- uint height = rsgGetHeight();
- rsgFontColor(0.9f, 0.9f, 0.95f, 1.0f);
- rsgBindFont(gFontSerif);
- rsgMeasureText(gTestScripts[benchMode].testName, &left, &right, &top, &bottom);
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgDrawText(gTestScripts[benchMode].testName, 2 -left, height - 2 + bottom);
-
- if (benchmarkSingleTest) {
- return;
- }
-
- benchMode ++;
- int testCount = rsAllocationGetDimX(rsGetAllocation(gTestScripts));
- if (benchMode == testCount) {
- rsSendToClientBlocking(RS_MSG_RESULTS_READY, gResultBuffer, testCount*sizeof(float));
- benchMode = 0;
- runningLoops++;
- if ((gMaxLoops > 0) && (runningLoops > gMaxLoops) && !sendMsgFlag) {
- //Notifiy the test to stop and get results
- rsDebug("gMaxLoops and runningLoops: ", gMaxLoops, runningLoops);
- rsSendToClientBlocking(RS_MSG_TEST_DONE);
- sendMsgFlag = true;
- }
- }
-}
-
-static void debug() {
- gDt = rsGetDt();
- runSubTest(benchMode);
-}
-
-int root(void) {
- gRenderSurfaceW = rsgGetWidth();
- gRenderSurfaceH = rsgGetHeight();
- rsgClearColor(0.2f, 0.2f, 0.2f, 1.0f);
- rsgClearDepth(1.0f);
-
- if (!gLoadComplete) {
- rsgFontColor(0.9f, 0.9f, 0.95f, 1.0f);
- rsgBindFont(gFontSerif);
- rsgDrawText("Loading", 50, 50);
- return 0;
- }
-
- if(!checkInit()) {
- return 1;
- }
-
- if (gPauseRendering) {
- rsgDrawText("Paused", 50, 50);
- return 30;
- }
- if (gIsDebugMode) {
- debug();
- } else {
- benchmark();
- }
-
- return 1;
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/shader_def.rsh b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/shader_def.rsh
deleted file mode 100644
index 648359c..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/shader_def.rsh
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-typedef struct VertexShaderConstants_s {
- rs_matrix4x4 model;
- rs_matrix4x4 proj;
- float4 light0_Posision;
- float light0_Diffuse;
- float light0_Specular;
- float light0_CosinePower;
-
- float4 light1_Posision;
- float light1_Diffuse;
- float light1_Specular;
- float light1_CosinePower;
-} VertexShaderConstants;
-
-typedef struct VertexShaderConstants3_s {
- rs_matrix4x4 model;
- rs_matrix4x4 proj;
- float time;
-} VertexShaderConstants3;
-
-
-typedef struct FragentShaderConstants_s {
- float4 light0_DiffuseColor;
- float4 light0_SpecularColor;
-
- float4 light1_DiffuseColor;
- float4 light1_SpecularColor;
-} FragentShaderConstants;
-
-typedef struct FragentShaderConstants2_s {
- float4 light_DiffuseColor[2];
- float4 light_SpecularColor[2];
-} FragentShaderConstants2;
-
-typedef struct FragentShaderConstants3_s {
- float4 light0_DiffuseColor;
- float4 light0_SpecularColor;
- float4 light0_Posision;
- float light0_Diffuse;
- float light0_Specular;
- float light0_CosinePower;
-
- float4 light1_DiffuseColor;
- float4 light1_SpecularColor;
- float4 light1_Posision;
- float light1_Diffuse;
- float light1_Specular;
- float light1_CosinePower;
-} FragentShaderConstants3;
-
-typedef struct VertexShaderInputs_s {
- float4 position;
- float3 normal;
- float2 texture0;
-} VertexShaderInputs;
-
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/subtest_def.rsh b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/subtest_def.rsh
deleted file mode 100644
index 43658b1..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/subtest_def.rsh
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-typedef struct TestData_s {
- int renderSurfaceW;
- int renderSurfaceH;
- float dt;
-} TestData;
-
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/text_test.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/text_test.rs
deleted file mode 100644
index 0f50828..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/text_test.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-#include "rs_graphics.rsh"
-#include "subtest_def.rsh"
-
-rs_font gFontSans;
-rs_font gFontSerif;
-
-typedef struct TextTestData_s {
- int fillNum;
-} TextTestData;
-TextTestData *gData;
-
-void init() {
-}
-
-static int gRenderSurfaceW = 1280;
-static int gRenderSurfaceH = 720;
-
-static const char *sampleText = "This is a sample of small text for performace";
-// Offsets for multiple layer of text
-static int textOffsets[] = { 0, 0, -5, -5, 5, 5, -8, -8, 8, 8};
-static float textColors[] = {1.0f, 1.0f, 1.0f, 1.0f,
- 0.5f, 0.7f, 0.5f, 1.0f,
- 0.7f, 0.5f, 0.5f, 1.0f,
- 0.5f, 0.5f, 0.7f, 1.0f,
- 0.5f, 0.6f, 0.7f, 1.0f,
-};
-
-static void displayFontSamples(int fillNum) {
-
- rs_font fonts[5];
- fonts[0] = gFontSans;
- fonts[1] = gFontSerif;
- fonts[2] = gFontSans;
- fonts[3] = gFontSerif;
- fonts[4] = gFontSans;
-
- uint height = gRenderSurfaceH;
- int left = 0, right = 0, top = 0, bottom = 0;
- rsgMeasureText(sampleText, &left, &right, &top, &bottom);
-
- int textHeight = top - bottom;
- int textWidth = right - left;
- int numVerticalLines = height / textHeight;
- int yPos = top;
-
- int xOffset = 0, yOffset = 0;
- for(int fillI = 0; fillI < fillNum; fillI ++) {
- rsgBindFont(fonts[fillI]);
- xOffset = textOffsets[fillI * 2];
- yOffset = textOffsets[fillI * 2 + 1];
- float *colPtr = textColors + fillI * 4;
- rsgFontColor(colPtr[0], colPtr[1], colPtr[2], colPtr[3]);
- for (int h = 0; h < 4; h ++) {
- yPos = top + yOffset;
- for (int v = 0; v < numVerticalLines; v ++) {
- rsgDrawText(sampleText, xOffset + textWidth * h, yPos);
- yPos += textHeight;
- }
- }
- }
-}
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- TestData *testData = (TestData*)usrData;
- gRenderSurfaceW = testData->renderSurfaceW;
- gRenderSurfaceH = testData->renderSurfaceH;
-
- gData = (TextTestData*)v_in;
-
- displayFontSamples(gData->fillNum);
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/torus_test.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/torus_test.rs
deleted file mode 100644
index 853a05d..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/torus_test.rs
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-#include "rs_graphics.rsh"
-#include "subtest_def.rsh"
-#include "shader_def.rsh"
-
-rs_program_vertex gProgVertex;
-rs_program_fragment gProgFragmentColor;
-rs_program_fragment gProgFragmentTexture;
-
-rs_program_store gProgStoreBlendNoneDepth;
-rs_mesh gTorusMesh;
-
-rs_program_raster gCullBack;
-rs_program_raster gCullFront;
-
-// Custom vertex shader compunents
-VertexShaderConstants *gVSConstants;
-FragentShaderConstants *gFSConstants;
-VertexShaderConstants3 *gVSConstPixel;
-FragentShaderConstants3 *gFSConstPixel;
-
-// Custom shaders we use for lighting
-rs_program_vertex gProgVertexCustom;
-rs_program_fragment gProgFragmentCustom;
-
-rs_sampler gLinearClamp;
-rs_allocation gTexTorus;
-
-rs_program_vertex gProgVertexPixelLight;
-rs_program_vertex gProgVertexPixelLightMove;
-rs_program_fragment gProgFragmentPixelLight;
-
-typedef struct TorusTestData_s {
- int testId;
- int user1;
- int user2;
-} TorusTestData;
-TorusTestData *gData;
-
-static float gDt = 0.0f;
-
-static int gRenderSurfaceW;
-static int gRenderSurfaceH;
-
-
-static float gTorusRotation = 0;
-static void updateModelMatrix(rs_matrix4x4 *matrix, void *buffer) {
- if (buffer == 0) {
- rsgProgramVertexLoadModelMatrix(matrix);
- } else {
- rsgAllocationSyncAll(rsGetAllocation(buffer));
- }
-}
-
-static void drawToruses(int numMeshes, rs_matrix4x4 *matrix, void *buffer) {
-
- if (numMeshes == 1) {
- rsMatrixLoadTranslate(matrix, 0.0f, 0.0f, -7.5f);
- rsMatrixRotate(matrix, gTorusRotation, 1.0f, 0.0f, 0.0f);
- updateModelMatrix(matrix, buffer);
- rsgDrawMesh(gTorusMesh);
- return;
- }
-
- if (numMeshes == 2) {
- rsMatrixLoadTranslate(matrix, -1.6f, 0.0f, -7.5f);
- rsMatrixRotate(matrix, gTorusRotation, 1.0f, 0.0f, 0.0f);
- updateModelMatrix(matrix, buffer);
- rsgDrawMesh(gTorusMesh);
-
- rsMatrixLoadTranslate(matrix, 1.6f, 0.0f, -7.5f);
- rsMatrixRotate(matrix, gTorusRotation, 1.0f, 0.0f, 0.0f);
- updateModelMatrix(matrix, buffer);
- rsgDrawMesh(gTorusMesh);
- return;
- }
-
- float startX = -5.0f;
- float startY = -1.5f;
- float startZ = -15.0f;
- float dist = 3.2f;
-
- for (int h = 0; h < 4; h ++) {
- for (int v = 0; v < 2; v ++) {
- // Position our model on the screen
- rsMatrixLoadTranslate(matrix, startX + dist * h, startY + dist * v, startZ);
- rsMatrixRotate(matrix, gTorusRotation, 1.0f, 0.0f, 0.0f);
- updateModelMatrix(matrix, buffer);
- rsgDrawMesh(gTorusMesh);
- }
- }
-}
-
-
-// Quick hack to get some geometry numbers
-static void displaySimpleGeoSamples(bool useTexture, int numMeshes) {
- rsgBindProgramVertex(gProgVertex);
- rsgBindProgramRaster(gCullBack);
- // Setup the projection matrix with 30 degree field of view
- rs_matrix4x4 proj;
- float aspect = (float)gRenderSurfaceW / (float)gRenderSurfaceH;
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 0.1f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- if (useTexture) {
- rsgBindProgramFragment(gProgFragmentTexture);
- } else {
- rsgBindProgramFragment(gProgFragmentColor);
- rsgProgramFragmentConstantColor(gProgFragmentColor, 0.1, 0.7, 0.1, 1);
- }
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gTexTorus);
-
- // Apply a rotation to our mesh
- gTorusRotation += 50.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- rs_matrix4x4 matrix;
- drawToruses(numMeshes, &matrix, 0);
-}
-
-float gLight0Rotation = 0;
-float gLight1Rotation = 0;
-
-static void setupCustomShaderLights() {
- float4 light0Pos = {-5.0f, 5.0f, -10.0f, 1.0f};
- float4 light1Pos = {2.0f, 5.0f, 15.0f, 1.0f};
- float4 light0DiffCol = {0.9f, 0.7f, 0.7f, 1.0f};
- float4 light0SpecCol = {0.9f, 0.6f, 0.6f, 1.0f};
- float4 light1DiffCol = {0.5f, 0.5f, 0.9f, 1.0f};
- float4 light1SpecCol = {0.5f, 0.5f, 0.9f, 1.0f};
-
- gLight0Rotation += 50.0f * gDt;
- if (gLight0Rotation > 360.0f) {
- gLight0Rotation -= 360.0f;
- }
- gLight1Rotation -= 50.0f * gDt;
- if (gLight1Rotation > 360.0f) {
- gLight1Rotation -= 360.0f;
- }
-
- rs_matrix4x4 l0Mat;
- rsMatrixLoadRotate(&l0Mat, gLight0Rotation, 1.0f, 0.0f, 0.0f);
- light0Pos = rsMatrixMultiply(&l0Mat, light0Pos);
- rs_matrix4x4 l1Mat;
- rsMatrixLoadRotate(&l1Mat, gLight1Rotation, 0.0f, 0.0f, 1.0f);
- light1Pos = rsMatrixMultiply(&l1Mat, light1Pos);
-
- // Set light 0 properties
- gVSConstants->light0_Posision = light0Pos;
- gVSConstants->light0_Diffuse = 1.0f;
- gVSConstants->light0_Specular = 0.5f;
- gVSConstants->light0_CosinePower = 10.0f;
- // Set light 1 properties
- gVSConstants->light1_Posision = light1Pos;
- gVSConstants->light1_Diffuse = 1.0f;
- gVSConstants->light1_Specular = 0.7f;
- gVSConstants->light1_CosinePower = 25.0f;
- rsgAllocationSyncAll(rsGetAllocation(gVSConstants));
-
- // Update fragment shader constants
- // Set light 0 colors
- gFSConstants->light0_DiffuseColor = light0DiffCol;
- gFSConstants->light0_SpecularColor = light0SpecCol;
- // Set light 1 colors
- gFSConstants->light1_DiffuseColor = light1DiffCol;
- gFSConstants->light1_SpecularColor = light1SpecCol;
- rsgAllocationSyncAll(rsGetAllocation(gFSConstants));
-
- // Set light 0 properties for per pixel lighting
- gFSConstPixel->light0_Posision = light0Pos;
- gFSConstPixel->light0_Diffuse = 1.0f;
- gFSConstPixel->light0_Specular = 0.5f;
- gFSConstPixel->light0_CosinePower = 10.0f;
- gFSConstPixel->light0_DiffuseColor = light0DiffCol;
- gFSConstPixel->light0_SpecularColor = light0SpecCol;
- // Set light 1 properties
- gFSConstPixel->light1_Posision = light1Pos;
- gFSConstPixel->light1_Diffuse = 1.0f;
- gFSConstPixel->light1_Specular = 0.7f;
- gFSConstPixel->light1_CosinePower = 25.0f;
- gFSConstPixel->light1_DiffuseColor = light1DiffCol;
- gFSConstPixel->light1_SpecularColor = light1SpecCol;
- rsgAllocationSyncAll(rsGetAllocation(gFSConstPixel));
-}
-
-static void displayCustomShaderSamples(int numMeshes) {
-
- // Update vertex shader constants
- // Load model matrix
- // Apply a rotation to our mesh
- gTorusRotation += 50.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- // Setup the projection matrix
- float aspect = (float)gRenderSurfaceW / (float)gRenderSurfaceH;
- rsMatrixLoadPerspective(&gVSConstants->proj, 30.0f, aspect, 0.1f, 100.0f);
- setupCustomShaderLights();
-
- rsgBindProgramVertex(gProgVertexCustom);
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- rsgBindProgramFragment(gProgFragmentCustom);
- rsgBindSampler(gProgFragmentCustom, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentCustom, 0, gTexTorus);
-
- // Use back face culling
- rsgBindProgramRaster(gCullBack);
-
- drawToruses(numMeshes, &gVSConstants->model, gVSConstants);
-}
-
-static void displayPixelLightSamples(int numMeshes, bool heavyVertex) {
-
- // Update vertex shader constants
- // Load model matrix
- // Apply a rotation to our mesh
- gTorusRotation += 30.0f * gDt;
- if (gTorusRotation > 360.0f) {
- gTorusRotation -= 360.0f;
- }
-
- gVSConstPixel->time = rsUptimeMillis()*0.005;
-
- // Setup the projection matrix
- float aspect = (float)gRenderSurfaceW / (float)gRenderSurfaceH;
- rsMatrixLoadPerspective(&gVSConstPixel->proj, 30.0f, aspect, 0.1f, 100.0f);
- setupCustomShaderLights();
-
- if (heavyVertex) {
- rsgBindProgramVertex(gProgVertexPixelLightMove);
- } else {
- rsgBindProgramVertex(gProgVertexPixelLight);
- }
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendNoneDepth);
- rsgBindProgramFragment(gProgFragmentPixelLight);
- rsgBindSampler(gProgFragmentPixelLight, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentPixelLight, 0, gTexTorus);
-
- // Use back face culling
- rsgBindProgramRaster(gCullBack);
-
- drawToruses(numMeshes, &gVSConstPixel->model, gVSConstPixel);
-}
-
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- TestData *testData = (TestData*)usrData;
- gRenderSurfaceW = testData->renderSurfaceW;
- gRenderSurfaceH = testData->renderSurfaceH;
- gDt = testData->dt;
-
- gData = (TorusTestData*)v_in;
-
- switch(gData->testId) {
- case 0:
- displaySimpleGeoSamples(gData->user1 == 1 ? true : false, gData->user2);
- break;
- case 1:
- displayCustomShaderSamples(gData->user1);
- break;
- case 2:
- displayPixelLightSamples(gData->user1, gData->user2 == 1 ? true : false);
- break;
- default:
- rsDebug("Wrong test number", gData->testId);
- break;
- }
-}
diff --git a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/ui_test.rs b/tests/RenderScriptTests/PerfTest/src/com/android/perftest/ui_test.rs
deleted file mode 100644
index e87db39..0000000
--- a/tests/RenderScriptTests/PerfTest/src/com/android/perftest/ui_test.rs
+++ /dev/null
@@ -1,442 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.perftest)
-
-#include "rs_graphics.rsh"
-#include "shader_def.rsh"
-#include "subtest_def.rsh"
-
-// Parameters for galaxy live wallpaper
-rs_allocation gTSpace;
-rs_allocation gTLight1;
-rs_allocation gTFlares;
-rs_mesh gParticlesMesh;
-
-rs_program_fragment gPFBackground;
-rs_program_fragment gPFStars;
-rs_program_vertex gPVStars;
-rs_program_vertex gPVBkProj;
-rs_program_store gPSLights;
-
-float gXOffset = 0.5f;
-
-#define ELLIPSE_RATIO 0.892f
-#define PI 3.1415f
-#define TWO_PI 6.283f
-#define ELLIPSE_TWIST 0.023333333f
-
-static float angle = 50.f;
-static int gOldWidth;
-static int gOldHeight;
-static int gWidth;
-static int gHeight;
-static float gSpeed[12000];
-static int gGalaxyRadius = 300;
-static rs_allocation gParticlesBuffer;
-
-typedef struct __attribute__((packed, aligned(4))) Particle {
- uchar4 color;
- float3 position;
-} Particle_t;
-Particle_t *Particles;
-
-typedef struct VpConsts {
- rs_matrix4x4 Proj;
- rs_matrix4x4 MVP;
-} VpConsts_t;
-VpConsts_t *vpConstants;
-// End of parameters for galaxy live wallpaper
-
-rs_program_vertex gProgVertex;
-rs_program_fragment gProgFragmentColor;
-rs_program_fragment gProgFragmentTexture;
-
-rs_program_store gProgStoreBlendAlpha;
-
-rs_allocation gTexOpaque;
-rs_allocation gTexTorus;
-rs_allocation gTexGlobe;
-
-typedef struct ListAllocs_s {
- rs_allocation item;
-} ListAllocs;
-
-ListAllocs *gTexList100;
-ListAllocs *gSampleTextList100;
-ListAllocs *gListViewText;
-
-rs_mesh gSingleMesh;
-
-rs_font gFontSans;
-
-rs_sampler gLinearClamp;
-
-typedef struct UiTestData_s {
- int testId;
- int user1;
- int user2;
- int user3;
-} UiTestData;
-UiTestData *gData;
-
-static float gDt = 0;
-
-
-void init() {
-}
-
-static int gRenderSurfaceW;
-static int gRenderSurfaceH;
-
-static void bindProgramVertexOrtho() {
- // Default vertex shader
- rsgBindProgramVertex(gProgVertex);
- // Setup the projection matrix
- rs_matrix4x4 proj;
- rsMatrixLoadOrtho(&proj, 0, gRenderSurfaceW, gRenderSurfaceH, 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-}
-
-/**
- * Methods to draw the galaxy live wall paper
- */
-static float mapf(float minStart, float minStop, float maxStart, float maxStop, float value) {
- return maxStart + (maxStart - maxStop) * ((value - minStart) / (minStop - minStart));
-}
-
-/**
- * Helper function to generate the stars.
- */
-static float randomGauss() {
- float x1;
- float x2;
- float w = 2.f;
-
- while (w >= 1.0f) {
- x1 = rsRand(2.0f) - 1.0f;
- x2 = rsRand(2.0f) - 1.0f;
- w = x1 * x1 + x2 * x2;
- }
-
- w = sqrt(-2.0f * log(w) / w);
- return x1 * w;
-}
-
-/**
- * Generates the properties for a given star.
- */
-static void createParticle(Particle_t *part, int idx, float scale) {
- float d = fabs(randomGauss()) * gGalaxyRadius * 0.5f + rsRand(64.0f);
- float id = d / gGalaxyRadius;
- float z = randomGauss() * 0.4f * (1.0f - id);
-
- if (d < gGalaxyRadius * 0.33f) {
- part->color.x = (uchar) (220 + id * 35);
- part->color.y = 220;
- part->color.z = 220;
- } else {
- part->color.x = 180;
- part->color.y = 180;
- part->color.z = (uchar) clamp(140.f + id * 115.f, 140.f, 255.f);
- }
- // Stash point size * 10 in Alpha
- part->color.w = (uchar) (rsRand(1.2f, 2.1f) * 60);
-
- if (d > gGalaxyRadius * 0.15f) {
- z *= 0.6f * (1.0f - id);
- } else {
- z *= 0.72f;
- }
-
- // Map to the projection coordinates (viewport.x = -1.0 -> 1.0)
- d = mapf(-4.0f, gGalaxyRadius + 4.0f, 0.0f, scale, d);
-
- part->position.x = rsRand(TWO_PI);
- part->position.y = d;
- gSpeed[idx] = rsRand(0.0015f, 0.0025f) * (0.5f + (scale / d)) * 0.8f;
-
- part->position.z = z / 5.0f;
-}
-
-/**
- * Initialize all the starts, called from Java
- */
-void initParticles() {
- Particle_t *part = Particles;
- float scale = gGalaxyRadius / (gWidth * 0.5f);
- int count = rsAllocationGetDimX(gParticlesBuffer);
- for (int i = 0; i < count; i ++) {
- createParticle(part, i, scale);
- part++;
- }
-}
-
-static void drawSpace() {
- rsgBindProgramFragment(gPFBackground);
- rsgBindTexture(gPFBackground, 0, gTSpace);
- rsgDrawQuadTexCoords(
- 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
- gWidth, 0.0f, 0.0f, 2.0f, 1.0f,
- gWidth, gHeight, 0.0f, 2.0f, 0.0f,
- 0.0f, gHeight, 0.0f, 0.0f, 0.0f);
-}
-
-static void drawLights() {
- rsgBindProgramVertex(gPVBkProj);
- rsgBindProgramFragment(gPFBackground);
- rsgBindTexture(gPFBackground, 0, gTLight1);
-
- float scale = 512.0f / gWidth;
- float x = -scale - scale * 0.05f;
- float y = -scale;
-
- scale *= 2.0f;
-
- rsgDrawQuad(x, y, 0.0f,
- x + scale * 1.1f, y, 0.0f,
- x + scale * 1.1f, y + scale, 0.0f,
- x, y + scale, 0.0f);
-}
-
-static void drawParticles(float offset) {
- float a = offset * angle;
- float absoluteAngle = fabs(a);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadTranslate(&matrix, 0.0f, 0.0f, 10.0f - 6.0f * absoluteAngle / 50.0f);
- if (gHeight > gWidth) {
- rsMatrixScale(&matrix, 6.6f, 6.0f, 1.0f);
- } else {
- rsMatrixScale(&matrix, 12.6f, 12.0f, 1.0f);
- }
- rsMatrixRotate(&matrix, absoluteAngle, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, a, 0.0f, 0.4f, 0.1f);
- rsMatrixLoad(&vpConstants->MVP, &vpConstants->Proj);
- rsMatrixMultiply(&vpConstants->MVP, &matrix);
- rsgAllocationSyncAll(rsGetAllocation(vpConstants));
-
- rsgBindProgramVertex(gPVStars);
- rsgBindProgramFragment(gPFStars);
- rsgBindProgramStore(gPSLights);
- rsgBindTexture(gPFStars, 0, gTFlares);
-
- Particle_t *vtx = Particles;
- int count = rsAllocationGetDimX(gParticlesBuffer);
- for (int i = 0; i < count; i++) {
- vtx->position.x = vtx->position.x + gSpeed[i];
- vtx++;
- }
-
- rsgDrawMesh(gParticlesMesh);
-}
-/* end of methods for drawing galaxy */
-
-// Display sample images in a mesh with different texture
-static void displayIcons(int meshMode) {
- bindProgramVertexOrtho();
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendAlpha);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
- rsgBindTexture(gProgFragmentTexture, 0, gTexTorus);
- rsgDrawQuadTexCoords(
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, gRenderSurfaceH, 0.0f, 0.0f, 1.0f,
- gRenderSurfaceW, gRenderSurfaceH, 0.0f, 1.0f, 1.0f,
- gRenderSurfaceW, 0.0f, 0.0f, 1.0f, 0.0f);
-
- int meshCount = (int)pow(10.0f, (float)(meshMode + 1));
-
- float wSize = gRenderSurfaceW/(float)meshCount;
- float hSize = gRenderSurfaceH/(float)meshCount;
- rs_matrix4x4 matrix;
- rsMatrixLoadScale(&matrix, wSize, hSize, 1.0);
-
- float yPos = 0;
- float yPad = hSize / 2;
- float xPad = wSize / 2;
- for (int y = 0; y < meshCount; y++) {
- yPos = y * hSize + yPad;
- float xPos = 0;
- for (int x = 0; x < meshCount; x++) {
- xPos = x * wSize + xPad;
- rs_matrix4x4 transMatrix;
- rsMatrixLoadTranslate(&transMatrix, xPos, yPos, 0);
- rsMatrixMultiply(&transMatrix, &matrix);
- rsgProgramVertexLoadModelMatrix(&transMatrix);
- int i = (x + y * meshCount) % 100;
- rsgBindTexture(gProgFragmentTexture, 0, gTexList100[i].item);
- rsgDrawMesh(gSingleMesh);
- }
- }
-}
-
-// Draw meshes in a single page with top left corner coordinates (xStart, yStart)
-static void drawMeshInPage(float xStart, float yStart, int wResolution, int hResolution) {
- // Draw wResolution * hResolution meshes in one page
- float wMargin = 100.0f;
- float hMargin = 100.0f;
- float xPad = 50.0f;
- float yPad = 20.0f;
- float size = 100.0f; // size of images
-
- // font info
- rs_font font = gFontSans;
- rsgBindFont(font);
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
-
- // Measure text size
- int left = 0, right = 0, top = 0, bottom = 0;
- rsgMeasureText(gSampleTextList100[0].item, &left, &right, &top, &bottom);
- float textHeight = (float)(top - bottom);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadScale(&matrix, size, size, 1.0);
-
- for (int y = 0; y < hResolution; y++) {
- float yPos = yStart + hMargin + y * size + y * yPad;
- for (int x = 0; x < wResolution; x++) {
- float xPos = xStart + wMargin + x * size + x * xPad;
-
- rs_matrix4x4 transMatrix;
- rsMatrixLoadTranslate(&transMatrix, xPos + size/2, yPos + size/2, 0);
- rsMatrixMultiply(&transMatrix, &matrix); // scale the mesh
- rsgProgramVertexLoadModelMatrix(&transMatrix);
-
- int i = (y * wResolution + x) % 100;
- rsgBindTexture(gProgFragmentTexture, 0, gTexList100[i].item);
- rsgDrawMesh(gSingleMesh);
- rsgDrawText(gSampleTextList100[i].item, xPos, yPos + size + yPad/2 + textHeight);
- }
- }
-}
-
-// Display both images and text as shown in launcher and homepage
-// meshMode will decide how many pages we draw
-// meshMode = 0: draw 3 pages of meshes
-// meshMode = 1: draw 5 pages of meshes
-static void displayImageWithText(int wResolution, int hResolution, int meshMode) {
- bindProgramVertexOrtho();
-
- // Fragment shader with texture
- rsgBindProgramStore(gProgStoreBlendAlpha);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
-
- drawMeshInPage(0, 0, wResolution, hResolution);
- drawMeshInPage(-1.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- drawMeshInPage(1.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- if (meshMode == 1) {
- // draw another two pages of meshes
- drawMeshInPage(-2.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- drawMeshInPage(2.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- }
-}
-
-// Display a list of text as the list view
-static void displayListView() {
- // set text color
- rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f);
- rsgBindFont(gFontSans);
-
- // get the size of the list
- rs_allocation textAlloc;
- textAlloc = rsGetAllocation(gListViewText);
- int allocSize = rsAllocationGetDimX(textAlloc);
-
- int listItemHeight = 80;
- int yOffset = listItemHeight;
-
- // set the color for the list divider
- rsgBindProgramFragment(gProgFragmentColor);
- rsgProgramFragmentConstantColor(gProgFragmentColor, 1.0, 1.0, 1.0, 1);
-
- // draw the list with divider
- for (int i = 0; i < allocSize; i++) {
- if (yOffset - listItemHeight > gRenderSurfaceH) {
- break;
- }
- rsgDrawRect(0, yOffset - 1, gRenderSurfaceW, yOffset, 0);
- rsgDrawText(gListViewText[i].item, 20, yOffset - 10);
- yOffset += listItemHeight;
- }
-}
-
-static void drawGalaxy() {
- rsgClearColor(0.f, 0.f, 0.f, 1.f);
- gParticlesBuffer = rsGetAllocation(Particles);
- rsgBindProgramFragment(gPFBackground);
-
- gWidth = rsgGetWidth();
- gHeight = rsgGetHeight();
- if ((gWidth != gOldWidth) || (gHeight != gOldHeight)) {
- initParticles();
- gOldWidth = gWidth;
- gOldHeight = gHeight;
- }
-
- float offset = mix(-1.0f, 1.0f, gXOffset);
- drawSpace();
- drawParticles(offset);
- drawLights();
-}
-
-// Display images and text with live wallpaper in the background
-static void displayLiveWallPaper(int wResolution, int hResolution) {
- bindProgramVertexOrtho();
-
- drawGalaxy();
-
- rsgBindProgramVertex(gProgVertex);
- rsgBindProgramStore(gProgStoreBlendAlpha);
- rsgBindProgramFragment(gProgFragmentTexture);
- rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
-
- drawMeshInPage(0, 0, wResolution, hResolution);
- drawMeshInPage(-1.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- drawMeshInPage(1.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- drawMeshInPage(-2.0f*gRenderSurfaceW, 0, wResolution, hResolution);
- drawMeshInPage(2.0f*gRenderSurfaceW, 0, wResolution, hResolution);
-}
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- TestData *testData = (TestData*)usrData;
- gRenderSurfaceW = testData->renderSurfaceW;
- gRenderSurfaceH = testData->renderSurfaceH;
- gDt = testData->dt;
-
- gData = (UiTestData*)v_in;
-
- switch(gData->testId) {
- case 0:
- displayIcons(gData->user1);
- break;
- case 1:
- displayImageWithText(gData->user1, gData->user2, gData->user3);
- break;
- case 2:
- displayListView();
- break;
- case 3:
- displayLiveWallPaper(gData->user1, gData->user2);
- break;
- default:
- rsDebug("Wrong test number", 0);
- break;
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/Android.mk b/tests/RenderScriptTests/SceneGraph/Android.mk
deleted file mode 100644
index 6047305..0000000
--- a/tests/RenderScriptTests/SceneGraph/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_SDK_VERSION := 17
-
-LOCAL_PACKAGE_NAME := SceneGraphTest
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/SceneGraph/AndroidManifest.xml b/tests/RenderScriptTests/SceneGraph/AndroidManifest.xml
deleted file mode 100644
index 67af0fa..0000000
--- a/tests/RenderScriptTests/SceneGraph/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.testapp">
- <uses-permission
- android:name="android.permission.INTERNET" />
- <application android:label="SceneGraphTest">
- <activity android:name="TestApp"
- android:label="SceneGraphTest">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity android:name="SimpleApp"
- android:label="SimpleSceneGraph">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity android:name="FileSelector"
- android:label="FileSelector"
- android:hardwareAccelerated="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/SceneGraph/assets/blue.jpg b/tests/RenderScriptTests/SceneGraph/assets/blue.jpg
deleted file mode 100644
index 494e77a..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/blue.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/carbonfiber.jpg b/tests/RenderScriptTests/SceneGraph/assets/carbonfiber.jpg
deleted file mode 100644
index 2fcecb0..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/carbonfiber.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/green.jpg b/tests/RenderScriptTests/SceneGraph/assets/green.jpg
deleted file mode 100644
index a86a754..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/green.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/grey.jpg b/tests/RenderScriptTests/SceneGraph/assets/grey.jpg
deleted file mode 100644
index 5870b1a..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/grey.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/orange.jpg b/tests/RenderScriptTests/SceneGraph/assets/orange.jpg
deleted file mode 100644
index 7dbe942..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/orange.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/orientation_test.a3d b/tests/RenderScriptTests/SceneGraph/assets/orientation_test.a3d
deleted file mode 100644
index 07318ae..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/orientation_test.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/orientation_test.dae b/tests/RenderScriptTests/SceneGraph/assets/orientation_test.dae
deleted file mode 100644
index 7eef443f..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/orientation_test.dae
+++ /dev/null
@@ -1,1102 +0,0 @@
-<?xml version="1.0" ?>
-<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
- <asset>
- <contributor>
- <author>alexst</author>
- <authoring_tool>OpenCOLLADA2010</authoring_tool>
- <comments>ColladaMaya export options: bakeTransforms=0;relativePaths=0;copyTextures=0;exportTriangles=1;exportCgfxFileReferences=0; isSampling=0;curveConstrainSampling=0;removeStaticCurves=1;exportPolygonMeshes=1;exportLights=1; exportCameras=1;exportJointsAndSkin=1;exportAnimations=0;exportInvisibleNodes=0;exportDefaultCameras=0; exportTexCoords=1;exportNormals=1;exportNormalsPerVertex=1;exportVertexColors=0;exportVertexColorsPerVertex=0; exportTexTangents=0;exportTangents=0;exportReferencedMaterials=1;exportMaterialsOnly=0; exportXRefs=1;dereferenceXRefs=1;exportCameraAsLookat=0;cameraXFov=0;cameraYFov=1;doublePrecision=0</comments>
- <source_data>file:///Volumes/Android/art/orientation_test.mb</source_data>
- </contributor>
- <created>2011-09-30T15:31:38</created>
- <modified>2011-09-30T15:31:38</modified>
- <unit meter="0.01" name="centimeter" />
- <up_axis>Y_UP</up_axis>
- </asset>
- <library_cameras>
- <camera id="cameraShape1" name="cameraShape1">
- <optics>
- <technique_common>
- <perspective>
- <yfov>37.8493</yfov>
- <aspect_ratio>1.5</aspect_ratio>
- <znear>1</znear>
- <zfar>400</zfar>
- </perspective>
- </technique_common>
- </optics>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <film_fit>0</film_fit>
- <film_fit_offset>0</film_fit_offset>
- <film_offsetX>0</film_offsetX>
- <film_offsetY>0</film_offsetY>
- <horizontal_aperture>3.599993</horizontal_aperture>
- <lens_squeeze>1</lens_squeeze>
- <originalMayaNodeId>cameraShape1</originalMayaNodeId>
- <vertical_aperture>2.399995</vertical_aperture>
- </technique>
- </extra>
- </camera>
- <camera id="CameraDistShape" name="CameraDistShape">
- <optics>
- <technique_common>
- <perspective>
- <yfov>37.8493</yfov>
- <aspect_ratio>1.5</aspect_ratio>
- <znear>1</znear>
- <zfar>1000</zfar>
- </perspective>
- </technique_common>
- </optics>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <film_fit>0</film_fit>
- <film_fit_offset>0</film_fit_offset>
- <film_offsetX>0</film_offsetX>
- <film_offsetY>0</film_offsetY>
- <horizontal_aperture>3.599993</horizontal_aperture>
- <lens_squeeze>1</lens_squeeze>
- <originalMayaNodeId>CameraDistShape</originalMayaNodeId>
- <vertical_aperture>2.399995</vertical_aperture>
- </technique>
- </extra>
- </camera>
- </library_cameras>
- <library_materials>
- <material id="Paint1" name="Paint1">
- <instance_effect url="#Paint1-fx" />
- </material>
- <material id="lambert2" name="lambert2">
- <instance_effect url="#lambert2-fx" />
- </material>
- <material id="Plastic" name="Plastic">
- <instance_effect url="#Plastic-fx" />
- </material>
- <material id="Metal" name="Metal">
- <instance_effect url="#Metal-fx" />
- </material>
- <material id="PlasticCenter" name="PlasticCenter">
- <instance_effect url="#PlasticCenter-fx" />
- </material>
- <material id="PlasticRed" name="PlasticRed">
- <instance_effect url="#PlasticRed-fx" />
- </material>
- <material id="lambert10" name="lambert10">
- <instance_effect url="#lambert10-fx" />
- </material>
- <material id="lambert11" name="lambert11">
- <instance_effect url="#lambert11-fx" />
- </material>
- </library_materials>
- <library_effects>
- <effect id="Metal-fx">
- <profile_COMMON>
- <newparam sid="file23-surface">
- <surface type="2D">
- <init_from>file23</init_from>
- </surface>
- </newparam>
- <newparam sid="file23-sampler">
- <sampler2D>
- <source>file23-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file23-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="Paint1-fx">
- <profile_COMMON>
- <newparam sid="file25-surface">
- <surface type="2D">
- <init_from>file25</init_from>
- </surface>
- </newparam>
- <newparam sid="file25-sampler">
- <sampler2D>
- <source>file25-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file25-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="Plastic-fx">
- <profile_COMMON>
- <newparam sid="file24-surface">
- <surface type="2D">
- <init_from>file24</init_from>
- </surface>
- </newparam>
- <newparam sid="file24-sampler">
- <sampler2D>
- <source>file24-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file24-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="PlasticCenter-fx">
- <profile_COMMON>
- <newparam sid="file24-surface">
- <surface type="2D">
- <init_from>file24</init_from>
- </surface>
- </newparam>
- <newparam sid="file24-sampler">
- <sampler2D>
- <source>file24-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file24-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="PlasticRed-fx">
- <profile_COMMON>
- <newparam sid="file23-surface">
- <surface type="2D">
- <init_from>file23</init_from>
- </surface>
- </newparam>
- <newparam sid="file23-sampler">
- <sampler2D>
- <source>file23-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file23-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="lambert10-fx">
- <profile_COMMON>
- <newparam sid="file28-surface">
- <surface type="2D">
- <init_from>file28</init_from>
- </surface>
- </newparam>
- <newparam sid="file28-sampler">
- <sampler2D>
- <source>file28-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file28-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="lambert11-fx">
- <profile_COMMON>
- <newparam sid="file29-surface">
- <surface type="2D">
- <init_from>file29</init_from>
- </surface>
- </newparam>
- <newparam sid="file29-sampler">
- <sampler2D>
- <source>file29-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file29-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- <effect id="lambert2-fx">
- <profile_COMMON>
- <newparam sid="file22-surface">
- <surface type="2D">
- <init_from>file22</init_from>
- </surface>
- </newparam>
- <newparam sid="file22-sampler">
- <sampler2D>
- <source>file22-surface</source>
- </sampler2D>
- </newparam>
- <technique sid="common">
- <lambert>
- <emission>
- <color>0 0 0 1</color>
- </emission>
- <ambient>
- <color>0 0 0 1</color>
- </ambient>
- <diffuse>
- <texture texture="file22-sampler" texcoord="TEX0">
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <blend_mode>NONE</blend_mode>
- <coverageU>1</coverageU>
- <coverageV>1</coverageV>
- <fast>0</fast>
- <mirrorU>0</mirrorU>
- <mirrorV>0</mirrorV>
- <noiseU>0</noiseU>
- <noiseV>0</noiseV>
- <offsetU>0</offsetU>
- <offsetV>0</offsetV>
- <repeatU>1</repeatU>
- <repeatV>1</repeatV>
- <rotateFrame>0</rotateFrame>
- <rotateUV>0</rotateUV>
- <stagger>0</stagger>
- <translateFrameU>0</translateFrameU>
- <translateFrameV>0</translateFrameV>
- <wrapU>1</wrapU>
- <wrapV>1</wrapV>
- </technique>
- </extra>
- </texture>
- </diffuse>
- <transparent opaque="RGB_ZERO">
- <color>0 0 0 1</color>
- </transparent>
- <transparency>
- <float>1</float>
- </transparency>
- </lambert>
- </technique>
- </profile_COMMON>
- </effect>
- </library_effects>
- <library_images>
- <image id="file29" name="file29" height="0" width="0">
- <init_from>file:///Volumes/Android/Sanity/SceneGraph/assets/blue.jpg</init_from>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <dgnode_type>kFile</dgnode_type>
- <image_sequence>0</image_sequence>
- <originalMayaNodeId>file29</originalMayaNodeId>
- </technique>
- </extra>
- </image>
- <image id="file25" name="file25" height="0" width="0">
- <init_from>file:///Volumes/Android/Sanity/SceneGraph/assets/carbonfiber.jpg</init_from>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <dgnode_type>kFile</dgnode_type>
- <image_sequence>0</image_sequence>
- <originalMayaNodeId>file25</originalMayaNodeId>
- </technique>
- </extra>
- </image>
- <image id="file28" name="file28" height="0" width="0">
- <init_from>file:///Volumes/Android/Sanity/SceneGraph/assets/green.jpg</init_from>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <dgnode_type>kFile</dgnode_type>
- <image_sequence>0</image_sequence>
- <originalMayaNodeId>file28</originalMayaNodeId>
- </technique>
- </extra>
- </image>
- <image id="file22" name="file22" height="0" width="0">
- <init_from>file:///Volumes/Android/Sanity/SceneGraph/assets/grey.jpg</init_from>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <dgnode_type>kFile</dgnode_type>
- <image_sequence>0</image_sequence>
- <originalMayaNodeId>file22</originalMayaNodeId>
- </technique>
- </extra>
- </image>
- <image id="file24" name="file24" height="0" width="0">
- <init_from>file:///Volumes/Android/Sanity/SceneGraph/assets/orange.jpg</init_from>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <dgnode_type>kFile</dgnode_type>
- <image_sequence>0</image_sequence>
- <originalMayaNodeId>file24</originalMayaNodeId>
- </technique>
- </extra>
- </image>
- <image id="file23" name="file23" height="0" width="0">
- <init_from>file:///Volumes/Android/Sanity/SceneGraph/assets/red.jpg</init_from>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <dgnode_type>kFile</dgnode_type>
- <image_sequence>0</image_sequence>
- <originalMayaNodeId>file23</originalMayaNodeId>
- </technique>
- </extra>
- </image>
- </library_images>
- <library_visual_scenes>
- <visual_scene id="VisualSceneNode" name="orientation_test">
- <node id="camera1" name="camera1">
- <translate sid="translate">24.5791 14.1321 31.4654</translate>
- <rotate sid="rotateZ">0 0 1 0</rotate>
- <rotate sid="rotateY">0 1 0 42</rotate>
- <rotate sid="rotateX">1 0 0 -16.2</rotate>
- <scale sid="scale">1 1 1</scale>
- <instance_camera url="#cameraShape1" />
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>camera1</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="CameraAim" name="CameraAim">
- <translate sid="translate">0.0209301 3.68542 2.06912</translate>
- <rotate sid="rotateY">0 1 0 43.2561</rotate>
- <rotate sid="rotateX">1 0 0 -20</rotate>
- <scale sid="scale">1 1 1</scale>
- <node id="CameraDist" name="CameraDist">
- <translate sid="translate">0 0 45</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_camera url="#CameraDistShape" />
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>CameraDist</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>CameraAim</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere4" name="pSphere4">
- <translate sid="translate">-9.69237 0 7.70498</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape4">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert7SG" target="#Paint1">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere4</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere1" name="pSphere1">
- <translate sid="translate">13.0966 0 5.76254</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape1">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert7SG" target="#Paint1">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere1</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere2" name="pSphere2">
- <translate sid="translate">21.7661 0 -13.6375</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape2">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert7SG" target="#Paint1">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere2</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere3" name="pSphere3">
- <translate sid="translate">-13.862 0 -13.6154</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape3">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert7SG" target="#Paint1">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere3</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere5" name="pSphere5">
- <translate sid="translate">31.0862 0 18.5992</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape5">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert7SG" target="#Paint1">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere5</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pCube1" name="pCube1">
- <translate sid="translate">0 0 0</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pCubeShape1">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert4SG" target="#lambert2">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pCube1</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="group1" name="group1">
- <translate sid="translate">0 0 0</translate>
- <rotate sid="rotateZ">0 0 1 -162.693</rotate>
- <rotate sid="rotateY">0 1 0 21.3345</rotate>
- <rotate sid="rotateX">1 0 0 -100.567</rotate>
- <scale sid="scale">1 1 1</scale>
- <node id="pSphere6" name="pSphere6">
- <translate sid="translate">-13.862 0 -13.6154</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape6">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert6SG" target="#Plastic">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere6</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere7" name="pSphere7">
- <translate sid="translate">-9.69237 0 7.70498</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape7">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert6SG" target="#Plastic">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere7</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere8" name="pSphere8">
- <translate sid="translate">21.7661 0 -13.6375</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape8">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert6SG" target="#Plastic">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere8</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere9" name="pSphere9">
- <translate sid="translate">13.0966 0 5.76254</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape9">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert6SG" target="#Plastic">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere9</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>group1</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="group2" name="group2">
- <translate sid="translate">0 0 0</translate>
- <rotate sid="rotateZ">0 0 1 45.4017</rotate>
- <rotate sid="rotateY">0 1 0 79.393</rotate>
- <rotate sid="rotateX">1 0 0 5.10889</rotate>
- <scale sid="scale">1 1 1</scale>
- <node id="pSphere10" name="pSphere10">
- <translate sid="translate">31.0862 0 18.5992</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape10">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere10</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere11" name="pSphere11">
- <translate sid="translate">13.0966 0 5.76254</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape11">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere11</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere12" name="pSphere12">
- <translate sid="translate">7.4784 16.3496 7.36882</translate>
- <rotate sid="rotateZ">0 0 1 17.3073</rotate>
- <rotate sid="rotateY">0 1 0 158.666</rotate>
- <rotate sid="rotateX">1 0 0 79.4335</rotate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape12">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere12</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere13" name="pSphere13">
- <translate sid="translate">-9.69237 0 7.70498</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape13">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere13</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere14" name="pSphere14">
- <translate sid="translate">11.3635 -4.3926 2.21012</translate>
- <rotate sid="rotateZ">0 0 1 17.3073</rotate>
- <rotate sid="rotateY">0 1 0 158.666</rotate>
- <rotate sid="rotateX">1 0 0 79.4335</rotate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape14">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere14</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere15" name="pSphere15">
- <translate sid="translate">21.7661 0 -13.6375</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape15">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere15</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere16" name="pSphere16">
- <translate sid="translate">-9.5945 -8.92317 -5.74901</translate>
- <rotate sid="rotateZ">0 0 1 17.3073</rotate>
- <rotate sid="rotateY">0 1 0 158.666</rotate>
- <rotate sid="rotateX">1 0 0 79.4335</rotate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape16">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere16</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere17" name="pSphere17">
- <translate sid="translate">-13.862 0 -13.6154</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape17">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere17</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pSphere18" name="pSphere18">
- <translate sid="translate">-24.2135 6.497 -5.58935</translate>
- <rotate sid="rotateZ">0 0 1 17.3073</rotate>
- <rotate sid="rotateY">0 1 0 158.666</rotate>
- <rotate sid="rotateX">1 0 0 79.4335</rotate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pSphereShape18">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert5SG" target="#Metal">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pSphere18</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>group2</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pCube2" name="pCube2">
- <translate sid="translate">0 0 0</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pCubeShape2">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert8SG" target="#PlasticCenter">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pCube2</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pCube3" name="pCube3">
- <translate sid="translate">15 0 0</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pCubeShape3">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert9SG" target="#PlasticRed">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pCube3</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pCube4" name="pCube4">
- <translate sid="translate">0 15 0</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pCubeShape4">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert10SG" target="#lambert10">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pCube4</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- <node id="pCube5" name="pCube5">
- <translate sid="translate">0 0 15</translate>
- <scale sid="scale">1 1 1</scale>
- <instance_geometry url="#pCubeShape5">
- <bind_material>
- <technique_common>
- <instance_material symbol="lambert11SG" target="#lambert11">
- <bind_vertex_input semantic="TEX0" input_semantic="TEXCOORD" input_set="0" />
- </instance_material>
- </technique_common>
- </bind_material>
- </instance_geometry>
- <extra>
- <technique profile="OpenCOLLADAMaya">
- <originalMayaNodeId>pCube5</originalMayaNodeId>
- </technique>
- </extra>
- </node>
- </visual_scene>
- </library_visual_scenes>
- <scene>
- <instance_visual_scene url="#VisualSceneNode" />
- </scene>
-</COLLADA>
diff --git a/tests/RenderScriptTests/SceneGraph/assets/paint.jpg b/tests/RenderScriptTests/SceneGraph/assets/paint.jpg
deleted file mode 100644
index 0791045..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/paint.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/assets/red.jpg b/tests/RenderScriptTests/SceneGraph/assets/red.jpg
deleted file mode 100644
index 320a2a6..0000000
--- a/tests/RenderScriptTests/SceneGraph/assets/red.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/res/drawable-nodpi/icon.png b/tests/RenderScriptTests/SceneGraph/res/drawable-nodpi/icon.png
deleted file mode 100644
index ff34a7f..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/drawable-nodpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/res/drawable-nodpi/robot.png b/tests/RenderScriptTests/SceneGraph/res/drawable-nodpi/robot.png
deleted file mode 100644
index f7353fd..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/drawable-nodpi/robot.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/res/menu/loader_menu.xml b/tests/RenderScriptTests/SceneGraph/res/menu/loader_menu.xml
deleted file mode 100644
index 9ea30107..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/menu/loader_menu.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2011 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.
-*/
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/load_model"
- android:title="@string/load_model" />
- <item android:id="@+id/use_blur"
- android:title="@string/use_blur" />
-</menu>
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl
deleted file mode 100644
index c34adc9..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/blur_h.glsl
+++ /dev/null
@@ -1,15 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- vec2 blurCoord = varTex0;
- blurCoord.x = varTex0.x + UNI_blurOffset0;
- vec3 col = texture2D(UNI_color, blurCoord).rgb;
- blurCoord.x = varTex0.x + UNI_blurOffset1;
- col += texture2D(UNI_color, blurCoord).rgb;
- blurCoord.x = varTex0.x + UNI_blurOffset2;
- col += texture2D(UNI_color, blurCoord).rgb;
- blurCoord.x = varTex0.x + UNI_blurOffset3;
- col += texture2D(UNI_color, blurCoord).rgb;
-
- gl_FragColor = vec4(col * 0.25, 0.0);
-}
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl
deleted file mode 100644
index ade05a2..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/blur_v.glsl
+++ /dev/null
@@ -1,17 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- vec2 blurCoord = varTex0;
- blurCoord.y = varTex0.y + UNI_blurOffset0;
- vec3 col = texture2D(UNI_color, blurCoord).rgb;
- blurCoord.y = varTex0.y + UNI_blurOffset1;
- col += texture2D(UNI_color, blurCoord).rgb;
- blurCoord.y = varTex0.y + UNI_blurOffset2;
- col += texture2D(UNI_color, blurCoord).rgb;
- blurCoord.y = varTex0.y + UNI_blurOffset3;
- col += texture2D(UNI_color, blurCoord).rgb;
-
- col = col * 0.25;
-
- gl_FragColor = vec4(col, 0.0);
-}
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/blur_vertex.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/blur_vertex.glsl
deleted file mode 100644
index bc824b6..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/blur_vertex.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- gl_Position = ATTRIB_position;
- varTex0 = ATTRIB_texture0;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl
deleted file mode 100644
index 2eb1028..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse.glsl
+++ /dev/null
@@ -1,19 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
- vec3 worldNorm = (varWorldNormal);
-
- vec3 light0Vec = V;
- vec3 light0R = reflect(light0Vec, worldNorm);
- float light0_Diffuse = dot(worldNorm, light0Vec);
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_diffuse, t0).rgba;
- col.xyz = col.xyz * light0_Diffuse * 1.2;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse_lights.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/diffuse_lights.glsl
deleted file mode 100644
index ef93e1c..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/diffuse_lights.glsl
+++ /dev/null
@@ -1,22 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = normalize(UNI_lightPos_0.xyz - varWorldPos.xyz);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0);
-
- vec3 light1Vec = normalize(UNI_lightPos_1.xyz - varWorldPos.xyz);
- float light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0);
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = UNI_diffuse;
- col.xyz = col.xyz * (light0_Diffuse * UNI_lightColor_0.xyz +
- light1_Diffuse * UNI_lightColor_1.xyz);
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl
deleted file mode 100644
index b90a7b2..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/metal.glsl
+++ /dev/null
@@ -1,23 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = V;
- vec3 light0R = reflect(light0Vec, worldNorm);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0);
- float light0Spec = clamp(dot(-light0R, V), 0.001, 1.0);
- float light0_Specular = pow(light0Spec, 15.0) * 0.5;
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_diffuse, t0).rgba;
- col.xyz = col.xyz * (textureCube(UNI_reflection, worldNorm).rgb * 0.5 + vec3(light0_Diffuse));
- col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0);
-
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl
deleted file mode 100644
index f3b89ed..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/paintf.glsl
+++ /dev/null
@@ -1,26 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = V;
- vec3 light0R = reflect(light0Vec, worldNorm);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.01, 0.99);
- float light0Spec = clamp(dot(-light0R, V), 0.001, 1.0);
- float light0_Specular = pow(light0Spec, 150.0) * 0.5;
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_diffuse, t0).rgba;
- col.xyz = col.xyz * light0_Diffuse * 1.1;
- col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0);
-
- float fresnel = mix(pow(1.0 - light0_Diffuse, 15.0), 1.0, 0.1);
- col.xyz = mix(col.xyz, textureCube(UNI_reflection, -light0R).rgb * 2.4, fresnel);
- col.w = 0.8;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl
deleted file mode 100644
index 56f7151f..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/plastic.glsl
+++ /dev/null
@@ -1,22 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = V;
- vec3 light0R = reflect(light0Vec, worldNorm);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0);
- float light0Spec = clamp(dot(-light0R, V), 0.001, 1.0);
- float light0_Specular = pow(light0Spec, 10.0) * 0.5;
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = texture2D(UNI_diffuse, t0).rgba;
- col.xyz = col.xyz * light0_Diffuse * 1.2;
- col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0);
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/plastic_lights.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/plastic_lights.glsl
deleted file mode 100644
index b253622..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/plastic_lights.glsl
+++ /dev/null
@@ -1,29 +0,0 @@
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-void main() {
-
- vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
- vec3 worldNorm = normalize(varWorldNormal);
-
- vec3 light0Vec = normalize(UNI_lightPos_0.xyz - varWorldPos.xyz);
- vec3 light0R = reflect(light0Vec, worldNorm);
- float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0);
- float light0Spec = clamp(dot(-light0R, V), 0.001, 1.0);
- float light0_Specular = pow(light0Spec, 10.0) * 0.7;
-
- vec3 light1Vec = normalize(UNI_lightPos_1.xyz - varWorldPos.xyz);
- vec3 light1R = reflect(light1Vec, worldNorm);
- float light1_Diffuse = clamp(dot(worldNorm, light1Vec), 0.0, 1.0);
- float light1Spec = clamp(dot(-light1R, V), 0.001, 1.0);
- float light1_Specular = pow(light1Spec, 10.0) * 0.7;
-
- vec2 t0 = varTex0.xy;
- lowp vec4 col = UNI_diffuse;
- col.xyz = col.xyz * (light0_Diffuse * UNI_lightColor_0.xyz +
- light1_Diffuse * UNI_lightColor_1.xyz);
- col.xyz += (light0_Specular + light1_Specular);
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/robot.a3d b/tests/RenderScriptTests/SceneGraph/res/raw/robot.a3d
deleted file mode 100644
index f48895c..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/robot.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl
deleted file mode 100644
index 1a927ca..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/select_color.glsl
+++ /dev/null
@@ -1,13 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- vec3 col = texture2D(UNI_color, varTex0).rgb;
-
- vec3 desat = vec3(0.299, 0.587, 0.114);
- float lum = dot(desat, col);
- float stepVal = step(lum, 0.8);
- col = mix(col, vec3(0.0), stepVal)*0.5;
-
- gl_FragColor = vec4(col, 0.0);
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl
deleted file mode 100644
index 7910a54..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/shader2v.glsl
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- rs_matrix4x4 model;
- rs_matrix4x4 viewProj;
-*/
-
-varying vec3 varWorldPos;
-varying vec3 varWorldNormal;
-varying vec2 varTex0;
-
-// This is where actual shader code begins
-void main() {
- vec4 objPos = ATTRIB_position;
- vec4 worldPos = UNI_model * objPos;
- gl_Position = UNI_viewProj * worldPos;
-
- mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);
- vec3 worldNorm = model3 * ATTRIB_normal;
-
- varWorldPos = worldPos.xyz;
- varWorldNormal = worldNorm;
- varTex0 = ATTRIB_texture0;
-}
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl b/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl
deleted file mode 100644
index 662ecd8..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/texture.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-varying vec2 varTex0;
-
-void main() {
- lowp vec4 col = texture2D(UNI_color, varTex0).rgba;
- gl_FragColor = col;
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/res/raw/unit_obj.a3d b/tests/RenderScriptTests/SceneGraph/res/raw/unit_obj.a3d
deleted file mode 100644
index 56eff04..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/raw/unit_obj.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SceneGraph/res/values/strings.xml b/tests/RenderScriptTests/SceneGraph/res/values/strings.xml
deleted file mode 100644
index c916d79..0000000
--- a/tests/RenderScriptTests/SceneGraph/res/values/strings.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2011 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.
-*/
--->
-
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <skip />
- <string name="load_model">Load Model</string>
- <string name="use_blur">Use Blur</string>
-</resources>
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Camera.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Camera.java
deleted file mode 100644
index 42f2be5..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Camera.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import com.android.scenegraph.SceneManager;
-
-import android.renderscript.*;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class Camera extends SceneGraphBase {
-
- Transform mTransform;
-
- ScriptField_Camera_s.Item mData;
- ScriptField_Camera_s mField;
-
- public Camera() {
- mData = new ScriptField_Camera_s.Item();
- mData.near = 0.1f;
- mData.far = 1000.0f;
- mData.horizontalFOV = 60.0f;
- mData.aspect = 0;
- }
-
- public void setTransform(Transform t) {
- mTransform = t;
- if (mField != null) {
- mField.set_transformMatrix(0, mTransform.getRSData().getAllocation(), true);
- mField.set_isDirty(0, 1, true);
- }
- }
- public void setFOV(float fov) {
- mData.horizontalFOV = fov;
- if (mField != null) {
- mField.set_horizontalFOV(0, fov, true);
- mField.set_isDirty(0, 1, true);
- }
- }
-
- public void setNear(float n) {
- mData.near = n;
- if (mField != null) {
- mField.set_near(0, n, true);
- mField.set_isDirty(0, 1, true);
- }
- }
-
- public void setFar(float f) {
- mData.far = f;
- if (mField != null) {
- mField.set_far(0, f, true);
- mField.set_isDirty(0, 1, true);
- }
- }
-
- public void setName(String n) {
- super.setName(n);
- if (mField != null) {
- RenderScriptGL rs = SceneManager.getRS();
- mData.name = getNameAlloc(rs);
- mField.set_name(0, mData.name, true);
- mField.set_isDirty(0, 1, true);
- }
- }
-
- ScriptField_Camera_s getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- if (rs == null) {
- return null;
- }
-
- if (mTransform == null) {
- throw new RuntimeException("Cameras without transforms are invalid");
- }
-
- mField = new ScriptField_Camera_s(rs, 1);
-
- mData.transformMatrix = mTransform.getRSData().getAllocation();
- mData.transformTimestamp = 1;
- mData.timestamp = 1;
- mData.isDirty = 1;
- mData.name = getNameAlloc(rs);
- mField.set(mData, 0, true);
-
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaParser.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaParser.java
deleted file mode 100644
index b4b6fb9..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaParser.java
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-import com.android.scenegraph.CompoundTransform.TranslateComponent;
-import com.android.scenegraph.CompoundTransform.RotateComponent;
-import com.android.scenegraph.CompoundTransform.ScaleComponent;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.HashMap;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import android.renderscript.*;
-import android.util.Log;
-
-public class ColladaParser {
- static final String TAG = "ColladaParser";
- Document mDom;
-
- HashMap<String, LightBase> mLights;
- HashMap<String, Camera> mCameras;
- HashMap<String, ArrayList<ShaderParam> > mEffectsParams;
- HashMap<String, Texture2D> mImages;
- HashMap<String, Texture2D> mSamplerImageMap;
- HashMap<String, String> mMeshIdNameMap;
- Scene mScene;
-
- String mRootDir;
-
- String toString(Float3 v) {
- String valueStr = v.x + " " + v.y + " " + v.z;
- return valueStr;
- }
-
- String toString(Float4 v) {
- String valueStr = v.x + " " + v.y + " " + v.z + " " + v.w;
- return valueStr;
- }
-
- public ColladaParser(){
- mLights = new HashMap<String, LightBase>();
- mCameras = new HashMap<String, Camera>();
- mEffectsParams = new HashMap<String, ArrayList<ShaderParam> >();
- mImages = new HashMap<String, Texture2D>();
- mMeshIdNameMap = new HashMap<String, String>();
- }
-
- public void init(InputStream is, String rootDir) {
- mLights.clear();
- mCameras.clear();
- mEffectsParams.clear();
-
- mRootDir = rootDir;
-
- long start = System.currentTimeMillis();
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder db = dbf.newDocumentBuilder();
- mDom = db.parse(is);
- } catch(ParserConfigurationException e) {
- e.printStackTrace();
- } catch(SAXException e) {
- e.printStackTrace();
- } catch(IOException e) {
- e.printStackTrace();
- }
- long end = System.currentTimeMillis();
- Log.v("TIMER", " Parse time: " + (end - start));
- exportSceneData();
- }
-
- Scene getScene() {
- return mScene;
- }
-
- private void exportSceneData(){
- mScene = new Scene();
-
- Element docEle = mDom.getDocumentElement();
- NodeList nl = docEle.getElementsByTagName("light");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element l = (Element)nl.item(i);
- convertLight(l);
- }
- }
-
- nl = docEle.getElementsByTagName("camera");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element c = (Element)nl.item(i);
- convertCamera(c);
- }
- }
-
- nl = docEle.getElementsByTagName("image");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element img = (Element)nl.item(i);
- convertImage(img);
- }
- }
-
- nl = docEle.getElementsByTagName("effect");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element e = (Element)nl.item(i);
- convertEffects(e);
- }
- }
-
- // Material is just a link to the effect
- nl = docEle.getElementsByTagName("material");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element m = (Element)nl.item(i);
- convertMaterials(m);
- }
- }
-
- // Look through the geometry list and build up a correlation between id's and names
- nl = docEle.getElementsByTagName("geometry");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element m = (Element)nl.item(i);
- convertGeometries(m);
- }
- }
-
-
- nl = docEle.getElementsByTagName("visual_scene");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element s = (Element)nl.item(i);
- getScene(s);
- }
- }
- }
-
- private void getRenderable(Element shape, Transform t) {
- String geoURL = shape.getAttribute("url").substring(1);
- String geoName = mMeshIdNameMap.get(geoURL);
- if (geoName != null) {
- geoURL = geoName;
- }
- //RenderableGroup group = new RenderableGroup();
- //group.setName(geoURL.substring(1));
- //mScene.appendRenderable(group);
- NodeList nl = shape.getElementsByTagName("instance_material");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element materialRef = (Element)nl.item(i);
- String meshIndexName = materialRef.getAttribute("symbol");
- String materialName = materialRef.getAttribute("target");
-
- Renderable d = new Renderable();
- d.setMesh(geoURL, meshIndexName);
- d.setMaterialName(materialName.substring(1));
- d.setName(geoURL);
-
- //Log.v(TAG, "Created drawable geo " + geoURL + " index " + meshIndexName + " material " + materialName);
-
- d.setTransform(t);
- //Log.v(TAG, "Set source param " + t.getName());
-
- // Now find all the parameters that exist on the material
- ArrayList<ShaderParam> materialParams;
- materialParams = mEffectsParams.get(materialName.substring(1));
- for (int pI = 0; pI < materialParams.size(); pI ++) {
- d.appendSourceParams(materialParams.get(pI));
- //Log.v(TAG, "Set source param i: " + pI + " name " + materialParams.get(pI).getParamName());
- }
- mScene.appendRenderable(d);
- //group.appendChildren(d);
- }
- }
- }
-
- private void updateLight(Element shape, Transform t) {
- String lightURL = shape.getAttribute("url");
- // collada uses a uri structure to link things,
- // but we ignore it for now and do a simple search
- LightBase light = mLights.get(lightURL.substring(1));
- if (light != null) {
- light.setTransform(t);
- //Log.v(TAG, "Set Light " + light.getName() + " " + t.getName());
- }
- }
-
- private void updateCamera(Element shape, Transform t) {
- String camURL = shape.getAttribute("url");
- // collada uses a uri structure to link things,
- // but we ignore it for now and do a simple search
- Camera cam = mCameras.get(camURL.substring(1));
- if (cam != null) {
- cam.setTransform(t);
- //Log.v(TAG, "Set Camera " + cam.getName() + " " + t.getName());
- }
- }
-
- private void getNode(Element node, Transform parent, String indent) {
- String name = node.getAttribute("name");
- String id = node.getAttribute("id");
- CompoundTransform current = new CompoundTransform();
- current.setName(name);
- if (parent != null) {
- parent.appendChild(current);
- } else {
- mScene.appendTransform(current);
- }
-
- mScene.addToTransformMap(current);
-
- //Log.v(TAG, indent + "|");
- //Log.v(TAG, indent + "[" + name + "]");
-
- Node childNode = node.getFirstChild();
- while (childNode != null) {
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- Element field = (Element)childNode;
- String fieldName = field.getTagName();
- String description = field.getAttribute("sid");
- if (fieldName.equals("translate")) {
- Float3 value = getFloat3(field);
- current.addTranslate(description, value);
- //Log.v(TAG, indent + " translate " + description + toString(value));
- } else if (fieldName.equals("rotate")) {
- Float4 value = getFloat4(field);
- //Log.v(TAG, indent + " rotate " + description + toString(value));
- Float3 axis = new Float3(value.x, value.y, value.z);
- current.addRotate(description, axis, value.w);
- } else if (fieldName.equals("scale")) {
- Float3 value = getFloat3(field);
- //Log.v(TAG, indent + " scale " + description + toString(value));
- current.addScale(description, value);
- } else if (fieldName.equals("instance_geometry")) {
- getRenderable(field, current);
- } else if (fieldName.equals("instance_light")) {
- updateLight(field, current);
- } else if (fieldName.equals("instance_camera")) {
- updateCamera(field, current);
- } else if (fieldName.equals("node")) {
- getNode(field, current, indent + " ");
- }
- }
- childNode = childNode.getNextSibling();
- }
- }
-
- // This will find the actual texture node, which is sometimes hidden behind a sampler
- // and sometimes referenced directly
- Texture2D getTexture(String samplerName) {
- String texName = samplerName;
-
- // Check to see if the image file is hidden by a sampler surface link combo
- Element sampler = mDom.getElementById(samplerName);
- if (sampler != null) {
- NodeList nl = sampler.getElementsByTagName("source");
- if (nl != null && nl.getLength() == 1) {
- Element ref = (Element)nl.item(0);
- String surfaceName = getString(ref);
- if (surfaceName == null) {
- return null;
- }
-
- Element surface = mDom.getElementById(surfaceName);
- if (surface == null) {
- return null;
- }
- nl = surface.getElementsByTagName("init_from");
- if (nl != null && nl.getLength() == 1) {
- ref = (Element)nl.item(0);
- texName = getString(ref);
- }
- }
- }
-
- //Log.v(TAG, "Extracted texture name " + texName);
- return mImages.get(texName);
- }
-
- void extractParams(Element fx, ArrayList<ShaderParam> params) {
- Node paramNode = fx.getFirstChild();
- while (paramNode != null) {
- if (paramNode.getNodeType() == Node.ELEMENT_NODE) {
- String name = paramNode.getNodeName();
- // Now find what type it is
- Node typeNode = paramNode.getFirstChild();
- while (typeNode != null && typeNode.getNodeType() != Node.ELEMENT_NODE) {
- typeNode = typeNode.getNextSibling();
- }
- String paramType = typeNode.getNodeName();
- Element typeElem = (Element)typeNode;
- ShaderParam sceneParam = null;
- if (paramType.equals("color")) {
- Float4Param f4p = new Float4Param(name);
- Float4 value = getFloat4(typeElem);
- f4p.setValue(value);
- sceneParam = f4p;
- //Log.v(TAG, "Extracted " + sceneParam.getParamName() + " value " + toString(value));
- } else if (paramType.equals("float")) {
- Float4Param f4p = new Float4Param(name);
- float value = getFloat(typeElem);
- f4p.setValue(new Float4(value, value, value, value));
- sceneParam = f4p;
- //Log.v(TAG, "Extracted " + sceneParam.getParamName() + " value " + value);
- } else if (paramType.equals("texture")) {
- String samplerName = typeElem.getAttribute("texture");
- Texture2D tex = getTexture(samplerName);
- TextureParam texP = new TextureParam(name);
- texP.setTexture(tex);
- sceneParam = texP;
- //Log.v(TAG, "Extracted texture " + tex);
- }
- if (sceneParam != null) {
- params.add(sceneParam);
- }
- }
- paramNode = paramNode.getNextSibling();
- }
- }
-
- private void convertMaterials(Element mat) {
- String id = mat.getAttribute("id");
- NodeList nl = mat.getElementsByTagName("instance_effect");
- if (nl != null && nl.getLength() == 1) {
- Element ref = (Element)nl.item(0);
- String url = ref.getAttribute("url");
- ArrayList<ShaderParam> params = mEffectsParams.get(url.substring(1));
- mEffectsParams.put(id, params);
- }
- }
-
- private void convertGeometries(Element geo) {
- String id = geo.getAttribute("id");
- String name = geo.getAttribute("name");
- if (!id.equals(name)) {
- mMeshIdNameMap.put(id, name);
- }
- }
-
- private void convertEffects(Element fx) {
- String id = fx.getAttribute("id");
- ArrayList<ShaderParam> params = new ArrayList<ShaderParam>();
-
- NodeList nl = fx.getElementsByTagName("newparam");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element field = (Element)nl.item(i);
- field.setIdAttribute("sid", true);
- }
- }
-
- nl = fx.getElementsByTagName("blinn");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element field = (Element)nl.item(i);
- //Log.v(TAG, "blinn");
- extractParams(field, params);
- }
- }
- nl = fx.getElementsByTagName("lambert");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element field = (Element)nl.item(i);
- //Log.v(TAG, "lambert");
- extractParams(field, params);
- }
- }
- nl = fx.getElementsByTagName("phong");
- if (nl != null) {
- for(int i = 0; i < nl.getLength(); i++) {
- Element field = (Element)nl.item(i);
- //Log.v(TAG, "phong");
- extractParams(field, params);
- }
- }
- mEffectsParams.put(id, params);
- }
-
- private void convertLight(Element light) {
- String name = light.getAttribute("name");
- String id = light.getAttribute("id");
-
- // Determine type
- String[] knownTypes = { "point", "spot", "directional" };
- final int POINT_LIGHT = 0;
- final int SPOT_LIGHT = 1;
- final int DIR_LIGHT = 2;
- int type = -1;
- for (int i = 0; i < knownTypes.length; i ++) {
- NodeList nl = light.getElementsByTagName(knownTypes[i]);
- if (nl != null && nl.getLength() != 0) {
- type = i;
- break;
- }
- }
-
- //Log.v(TAG, "Found Light Type " + type);
-
- LightBase sceneLight = null;
- switch (type) {
- case POINT_LIGHT:
- sceneLight = new PointLight();
- break;
- case SPOT_LIGHT: // TODO: finish light types
- break;
- case DIR_LIGHT: // TODO: finish light types
- break;
- }
-
- if (sceneLight == null) {
- return;
- }
-
- Float3 color = getFloat3(light, "color");
- sceneLight.setColor(color.x, color.y, color.z);
- sceneLight.setName(name);
- mScene.appendLight(sceneLight);
- mLights.put(id, sceneLight);
-
- //Log.v(TAG, "Light " + name + " color " + toString(color));
- }
-
- private void convertCamera(Element camera) {
- String name = camera.getAttribute("name");
- String id = camera.getAttribute("id");
- float fov = 30.0f;
- if (getString(camera, "yfov") != null) {
- fov = getFloat(camera, "yfov");
- } else if(getString(camera, "xfov") != null) {
- float aspect = getFloat(camera, "aspect_ratio");
- fov = getFloat(camera, "xfov") / aspect;
- }
-
- float near = getFloat(camera, "znear");
- float far = getFloat(camera, "zfar");
-
- Camera sceneCamera = new Camera();
- sceneCamera.setFOV(fov);
- sceneCamera.setNear(near);
- sceneCamera.setFar(far);
- sceneCamera.setName(name);
- mScene.appendCamera(sceneCamera);
- mCameras.put(id, sceneCamera);
- }
-
- private void convertImage(Element img) {
- String name = img.getAttribute("name");
- String id = img.getAttribute("id");
- String file = getString(img, "init_from");
-
- Texture2D tex = new Texture2D();
- tex.setFileName(file);
- tex.setFileDir(mRootDir);
- mScene.appendTextures(tex);
- mImages.put(id, tex);
- }
-
- private void getScene(Element scene) {
- String name = scene.getAttribute("name");
- String id = scene.getAttribute("id");
-
- Node childNode = scene.getFirstChild();
- while (childNode != null) {
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- String indent = "";
- getNode((Element)childNode, null, indent);
- }
- childNode = childNode.getNextSibling();
- }
- }
-
- private String getString(Element elem, String name) {
- String text = null;
- NodeList nl = elem.getElementsByTagName(name);
- if (nl != null && nl.getLength() != 0) {
- text = ((Element)nl.item(0)).getFirstChild().getNodeValue();
- }
- return text;
- }
-
- private String getString(Element elem) {
- String text = null;
- text = elem.getFirstChild().getNodeValue();
- return text;
- }
-
- private int getInt(Element elem, String name) {
- return Integer.parseInt(getString(elem, name));
- }
-
- private float getFloat(Element elem, String name) {
- return Float.parseFloat(getString(elem, name));
- }
-
- private float getFloat(Element elem) {
- return Float.parseFloat(getString(elem));
- }
-
- private Float3 parseFloat3(String valueString) {
- StringTokenizer st = new StringTokenizer(valueString);
- float x = Float.parseFloat(st.nextToken());
- float y = Float.parseFloat(st.nextToken());
- float z = Float.parseFloat(st.nextToken());
- return new Float3(x, y, z);
- }
-
- private Float4 parseFloat4(String valueString) {
- StringTokenizer st = new StringTokenizer(valueString);
- float x = Float.parseFloat(st.nextToken());
- float y = Float.parseFloat(st.nextToken());
- float z = Float.parseFloat(st.nextToken());
- float w = Float.parseFloat(st.nextToken());
- return new Float4(x, y, z, w);
- }
-
- private Float3 getFloat3(Element elem, String name) {
- String valueString = getString(elem, name);
- return parseFloat3(valueString);
- }
-
- private Float4 getFloat4(Element elem, String name) {
- String valueString = getString(elem, name);
- return parseFloat4(valueString);
- }
-
- private Float3 getFloat3(Element elem) {
- String valueString = getString(elem);
- return parseFloat3(valueString);
- }
-
- private Float4 getFloat4(Element elem) {
- String valueString = getString(elem);
- return parseFloat4(valueString);
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java
deleted file mode 100644
index 301075e..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ColladaScene.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Element.Builder;
-import android.renderscript.Font.Style;
-import android.renderscript.Program.TextureType;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-import com.android.scenegraph.SceneManager.SceneLoadedCallback;
-
-
-public class ColladaScene {
-
- private String modelName;
- private static String TAG = "ColladaScene";
- private final int STATE_LAST_FOCUS = 1;
- boolean mLoadFromSD = false;
-
- SceneLoadedCallback mCallback;
-
- public ColladaScene(String name, SceneLoadedCallback cb) {
- modelName = name;
- mCallback = cb;
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
-
- mLoadFromSD = SceneManager.isSDCardPath(modelName);
-
- new ColladaLoaderTask().execute(modelName);
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- Scene mActiveScene;
-
- private class ColladaLoaderTask extends AsyncTask<String, Void, Boolean> {
- ColladaParser sceneSource;
- protected Boolean doInBackground(String... names) {
- String rootDir = names[0].substring(0, names[0].lastIndexOf('/') + 1);
- long start = System.currentTimeMillis();
- sceneSource = new ColladaParser();
- InputStream is = null;
- try {
- if (!mLoadFromSD) {
- is = mRes.getAssets().open(names[0]);
- } else {
- File f = new File(names[0]);
- is = new BufferedInputStream(new FileInputStream(f));
- }
- } catch (IOException e) {
- Log.e(TAG, "Could not open collada file");
- return new Boolean(false);
- }
- long end = System.currentTimeMillis();
- Log.v("TIMER", "Stream load time: " + (end - start));
-
- start = System.currentTimeMillis();
- sceneSource.init(is, rootDir);
- end = System.currentTimeMillis();
- Log.v("TIMER", "Collada parse time: " + (end - start));
- return new Boolean(true);
- }
-
- protected void onPostExecute(Boolean result) {
- mActiveScene = sceneSource.getScene();
- if (mCallback != null) {
- mCallback.mLoadedScene = mActiveScene;
- mCallback.run();
- }
-
- String shortName = modelName.substring(0, modelName.lastIndexOf('.'));
- new A3DLoaderTask().execute(shortName + ".a3d");
- }
- }
-
- private class A3DLoaderTask extends AsyncTask<String, Void, Boolean> {
- protected Boolean doInBackground(String... names) {
- long start = System.currentTimeMillis();
- FileA3D model;
- if (!mLoadFromSD) {
- model = FileA3D.createFromAsset(mRS, mRes.getAssets(), names[0]);
- } else {
- model = FileA3D.createFromFile(mRS, names[0]);
- }
- int numModels = model.getIndexEntryCount();
- for (int i = 0; i < numModels; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- mActiveScene.meshLoaded(entry.getMesh());
- }
- }
- long end = System.currentTimeMillis();
- Log.v("TIMER", "A3D load time: " + (end - start));
- return new Boolean(true);
- }
-
- protected void onPostExecute(Boolean result) {
- }
- }
-
-}
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/CompoundTransform.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/CompoundTransform.java
deleted file mode 100644
index 9274b17..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/CompoundTransform.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import com.android.scenegraph.SceneManager;
-
-import android.renderscript.*;
-import android.renderscript.Float3;
-import android.renderscript.Matrix4f;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class CompoundTransform extends Transform {
-
- public static abstract class Component {
- String mName;
- CompoundTransform mParent;
- int mParentIndex;
- protected ScriptField_TransformComponent_s.Item mData;
-
- Component(int type, String name) {
- mData = new ScriptField_TransformComponent_s.Item();
- mData.type = type;
- mName = name;
- }
-
- void setNameAlloc() {
- RenderScriptGL rs = SceneManager.getRS();
- if (mData.name != null) {
- return;
- }
- mData.name = SceneManager.getCachedAlloc(getName());
- if (mData.name == null) {
- mData.name = SceneManager.getStringAsAllocation(rs, getName());
- SceneManager.cacheAlloc(getName(), mData.name);
- }
- }
-
- ScriptField_TransformComponent_s.Item getRSData() {
- setNameAlloc();
- return mData;
- }
-
- protected void update() {
- if (mParent != null) {
- mParent.updateRSComponent(this);
- }
- }
-
- public String getName() {
- return mName;
- }
- }
-
- public static class TranslateComponent extends Component {
- public TranslateComponent(String name, Float3 translate) {
- super(ScriptC_export.const_Transform_TRANSLATE, name);
- setValue(translate);
- }
- public Float3 getValue() {
- return new Float3(mData.value.x, mData.value.y, mData.value.z);
- }
- public void setValue(Float3 val) {
- mData.value.x = val.x;
- mData.value.y = val.y;
- mData.value.z = val.z;
- update();
- }
- }
-
- public static class RotateComponent extends Component {
- public RotateComponent(String name, Float3 axis, float angle) {
- super(ScriptC_export.const_Transform_ROTATE, name);
- setAxis(axis);
- setAngle(angle);
- }
- public Float3 getAxis() {
- return new Float3(mData.value.x, mData.value.y, mData.value.z);
- }
- public float getAngle() {
- return mData.value.w;
- }
- public void setAxis(Float3 val) {
- mData.value.x = val.x;
- mData.value.y = val.y;
- mData.value.z = val.z;
- update();
- }
- public void setAngle(float val) {
- mData.value.w = val;
- update();
- }
- }
-
- public static class ScaleComponent extends Component {
- public ScaleComponent(String name, Float3 scale) {
- super(ScriptC_export.const_Transform_SCALE, name);
- setValue(scale);
- }
- public Float3 getValue() {
- return new Float3(mData.value.x, mData.value.y, mData.value.z);
- }
- public void setValue(Float3 val) {
- mData.value.x = val.x;
- mData.value.y = val.y;
- mData.value.z = val.z;
- update();
- }
- }
-
- ScriptField_TransformComponent_s mComponentField;
- public ArrayList<Component> mTransformComponents;
-
- public CompoundTransform() {
- mTransformComponents = new ArrayList<Component>();
- }
-
- public TranslateComponent addTranslate(String name, Float3 translate) {
- TranslateComponent c = new TranslateComponent(name, translate);
- addComponent(c);
- return c;
- }
-
- public RotateComponent addRotate(String name, Float3 axis, float angle) {
- RotateComponent c = new RotateComponent(name, axis, angle);
- addComponent(c);
- return c;
- }
-
- public ScaleComponent addScale(String name, Float3 scale) {
- ScaleComponent c = new ScaleComponent(name, scale);
- addComponent(c);
- return c;
- }
-
- public void addComponent(Component c) {
- if (c.mParent != null) {
- throw new IllegalArgumentException("Transform components may not be shared");
- }
- c.mParent = this;
- c.mParentIndex = mTransformComponents.size();
- mTransformComponents.add(c);
- updateRSComponentAllocation();
- }
-
- public void setComponent(int index, Component c) {
- if (c.mParent != null) {
- throw new IllegalArgumentException("Transform components may not be shared");
- }
- if (index >= mTransformComponents.size()) {
- throw new IllegalArgumentException("Invalid component index");
- }
- c.mParent = this;
- c.mParentIndex = index;
- mTransformComponents.set(index, c);
- updateRSComponent(c);
- }
-
- void updateRSComponent(Component c) {
- if (mField == null || mComponentField == null) {
- return;
- }
- mComponentField.set(c.getRSData(), c.mParentIndex, true);
- mField.set_isDirty(0, 1, true);
- }
-
- void updateRSComponentAllocation() {
- if (mField == null) {
- return;
- }
- initLocalData();
-
- mField.set_components(0, mTransformData.components, false);
- mField.set_isDirty(0, 1, true);
- }
-
- void initLocalData() {
- RenderScriptGL rs = SceneManager.getRS();
- int numComponenets = mTransformComponents.size();
- if (numComponenets > 0) {
- mComponentField = new ScriptField_TransformComponent_s(rs, numComponenets);
- for (int i = 0; i < numComponenets; i ++) {
- Component ith = mTransformComponents.get(i);
- mComponentField.set(ith.getRSData(), i, false);
- }
- mComponentField.copyAll();
-
- mTransformData.components = mComponentField.getAllocation();
- }
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Float4Param.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Float4Param.java
deleted file mode 100644
index 1502458..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Float4Param.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import com.android.scenegraph.Scene;
-import com.android.scenegraph.SceneManager;
-
-import android.renderscript.Element;
-import android.renderscript.Float4;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class Float4Param extends ShaderParam {
- private static String TAG = "Float4Param";
-
- LightBase mLight;
-
- public Float4Param(String name) {
- super(name);
- }
-
- public Float4Param(String name, float x) {
- super(name);
- set(x, 0, 0, 0);
- }
-
- public Float4Param(String name, float x, float y) {
- super(name);
- set(x, y, 0, 0);
- }
-
- public Float4Param(String name, float x, float y, float z) {
- super(name);
- set(x, y, z, 0);
- }
-
- public Float4Param(String name, float x, float y, float z, float w) {
- super(name);
- set(x, y, z, w);
- }
-
- void set(float x, float y, float z, float w) {
- mData.float_value.x = x;
- mData.float_value.y = y;
- mData.float_value.z = z;
- mData.float_value.w = w;
- if (mField != null) {
- mField.set_float_value(0, mData.float_value, true);
- }
- incTimestamp();
- }
-
- public void setValue(Float4 v) {
- set(v.x, v.y, v.z, v.w);
- }
-
- public Float4 getValue() {
- return mData.float_value;
- }
-
- public void setLight(LightBase l) {
- mLight = l;
- if (mField != null) {
- mData.light = mLight.getRSData().getAllocation();
- mField.set_light(0, mData.light, true);
- }
- incTimestamp();
- }
-
- boolean findLight(String property) {
- String indexStr = mParamName.substring(property.length() + 1);
- if (indexStr == null) {
- Log.e(TAG, "Invalid light index.");
- return false;
- }
- int index = Integer.parseInt(indexStr);
- if (index == -1) {
- return false;
- }
- Scene parentScene = SceneManager.getInstance().getActiveScene();
- ArrayList<LightBase> allLights = parentScene.getLights();
- if (index >= allLights.size()) {
- return false;
- }
- mLight = allLights.get(index);
- if (mLight == null) {
- return false;
- }
- return true;
- }
-
- int getTypeFromName() {
- int paramType = ScriptC_export.const_ShaderParam_FLOAT4_DATA;
- if (mParamName.equalsIgnoreCase(cameraPos)) {
- paramType = ScriptC_export.const_ShaderParam_FLOAT4_CAMERA_POS;
- } else if(mParamName.equalsIgnoreCase(cameraDir)) {
- paramType = ScriptC_export.const_ShaderParam_FLOAT4_CAMERA_DIR;
- } else if(mParamName.startsWith(lightColor) && findLight(lightColor)) {
- paramType = ScriptC_export.const_ShaderParam_FLOAT4_LIGHT_COLOR;
- } else if(mParamName.startsWith(lightPos) && findLight(lightPos)) {
- paramType = ScriptC_export.const_ShaderParam_FLOAT4_LIGHT_POS;
- } else if(mParamName.startsWith(lightDir) && findLight(lightDir)) {
- paramType = ScriptC_export.const_ShaderParam_FLOAT4_LIGHT_DIR;
- }
- return paramType;
- }
-
- void initLocalData() {
- mData.type = getTypeFromName();
- if (mCamera != null) {
- mData.camera = mCamera.getRSData().getAllocation();
- }
- if (mLight != null) {
- mData.light = mLight.getRSData().getAllocation();
- }
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java
deleted file mode 100644
index 8a468db..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/FragmentShader.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import com.android.scenegraph.TextureBase;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.renderscript.ProgramFragment.Builder;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class FragmentShader extends Shader {
- ProgramFragment mProgram;
- ScriptField_FragmentShader_s mField;
-
- public static class Builder {
-
- FragmentShader mShader;
- ProgramFragment.Builder mBuilder;
-
- public Builder(RenderScriptGL rs) {
- mShader = new FragmentShader();
- mBuilder = new ProgramFragment.Builder(rs);
- }
-
- public Builder setShader(Resources resources, int resourceID) {
- mBuilder.setShader(resources, resourceID);
- return this;
- }
-
- public Builder setShader(String code) {
- mBuilder.setShader(code);
- return this;
- }
-
- public Builder setObjectConst(Type type) {
- mShader.mPerObjConstants = type;
- return this;
- }
-
- public Builder setShaderConst(Type type) {
- mShader.mPerShaderConstants = type;
- return this;
- }
-
- public Builder addShaderTexture(Program.TextureType texType, String name) {
- mShader.mShaderTextureNames.add(name);
- mShader.mShaderTextureTypes.add(texType);
- return this;
- }
-
- public Builder addTexture(Program.TextureType texType, String name) {
- mShader.mTextureNames.add(name);
- mShader.mTextureTypes.add(texType);
- return this;
- }
-
- public FragmentShader create() {
- if (mShader.mPerShaderConstants != null) {
- mBuilder.addConstant(mShader.mPerShaderConstants);
- }
- if (mShader.mPerObjConstants != null) {
- mBuilder.addConstant(mShader.mPerObjConstants);
- }
- for (int i = 0; i < mShader.mTextureTypes.size(); i ++) {
- mBuilder.addTexture(mShader.mTextureTypes.get(i),
- mShader.mTextureNames.get(i));
- }
- for (int i = 0; i < mShader.mShaderTextureTypes.size(); i ++) {
- mBuilder.addTexture(mShader.mShaderTextureTypes.get(i),
- mShader.mShaderTextureNames.get(i));
- }
-
- mShader.mProgram = mBuilder.create();
- return mShader;
- }
- }
-
- public ProgramFragment getProgram() {
- return mProgram;
- }
-
- ScriptField_ShaderParam_s getTextureParams() {
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (rs == null || res == null) {
- return null;
- }
-
- ArrayList<ScriptField_ShaderParam_s.Item> paramList;
- paramList = new ArrayList<ScriptField_ShaderParam_s.Item>();
-
- int shaderTextureStart = mTextureTypes.size();
- for (int i = 0; i < mShaderTextureNames.size(); i ++) {
- ShaderParam sp = mSourceParams.get(mShaderTextureNames.get(i));
- if (sp != null && sp instanceof TextureParam) {
- TextureParam p = (TextureParam)sp;
- ScriptField_ShaderParam_s.Item paramRS = new ScriptField_ShaderParam_s.Item();
- paramRS.bufferOffset = shaderTextureStart + i;
- paramRS.transformTimestamp = 0;
- paramRS.dataTimestamp = 0;
- paramRS.data = p.getRSData().getAllocation();
- paramList.add(paramRS);
- }
- }
-
- ScriptField_ShaderParam_s rsParams = null;
- int paramCount = paramList.size();
- if (paramCount != 0) {
- rsParams = new ScriptField_ShaderParam_s(rs, paramCount);
- for (int i = 0; i < paramCount; i++) {
- rsParams.set(paramList.get(i), i, false);
- }
- rsParams.copyAll();
- }
- return rsParams;
- }
-
- ScriptField_FragmentShader_s getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (rs == null || res == null) {
- return null;
- }
-
- ScriptField_FragmentShader_s.Item item = new ScriptField_FragmentShader_s.Item();
- item.program = mProgram;
-
- ScriptField_ShaderParam_s texParams = getTextureParams();
- if (texParams != null) {
- item.shaderTextureParams = texParams.getAllocation();
- }
-
- linkConstants(rs);
- if (mPerShaderConstants != null) {
- item.shaderConst = mConstantBuffer;
- item.shaderConstParams = mConstantBufferParams.getAllocation();
- mProgram.bindConstants(item.shaderConst, 0);
- }
-
- item.objectConstIndex = -1;
- if (mPerObjConstants != null) {
- item.objectConstIndex = mPerShaderConstants != null ? 1 : 0;
- }
-
- mField = new ScriptField_FragmentShader_s(rs, 1);
- mField.set(item, 0, true);
- return mField;
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/LightBase.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/LightBase.java
deleted file mode 100644
index 8f5e2e7..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/LightBase.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.Float3;
-import android.renderscript.Float4;
-import android.renderscript.Matrix4f;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class LightBase extends SceneGraphBase {
- static final int RS_LIGHT_POINT = 0;
- static final int RS_LIGHT_DIRECTIONAL = 1;
-
- ScriptField_Light_s mField;
- ScriptField_Light_s.Item mFieldData;
- Transform mTransform;
- Float4 mColor;
- float mIntensity;
- public LightBase() {
- mColor = new Float4(0.0f, 0.0f, 0.0f, 0.0f);
- mIntensity = 1.0f;
- }
-
- public void setTransform(Transform t) {
- mTransform = t;
- updateRSData();
- }
-
- public void setColor(float r, float g, float b) {
- mColor.x = r;
- mColor.y = g;
- mColor.z = b;
- updateRSData();
- }
-
- public void setColor(Float3 c) {
- setColor(c.x, c.y, c.z);
- }
-
- public void setIntensity(float i) {
- mIntensity = i;
- updateRSData();
- }
-
- public void setName(String n) {
- super.setName(n);
- updateRSData();
- }
-
- protected void updateRSData() {
- if (mField == null) {
- return;
- }
- RenderScriptGL rs = SceneManager.getRS();
- mFieldData.transformMatrix = mTransform.getRSData().getAllocation();
- mFieldData.name = getNameAlloc(rs);
- mFieldData.color = mColor;
- mFieldData.intensity = mIntensity;
-
- initLocalData();
-
- mField.set(mFieldData, 0, true);
- }
-
- abstract void initLocalData();
-
- ScriptField_Light_s getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- if (rs == null) {
- return null;
- }
- if (mField == null) {
- mField = new ScriptField_Light_s(rs, 1);
- mFieldData = new ScriptField_Light_s.Item();
- }
-
- updateRSData();
-
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/MatrixTransform.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/MatrixTransform.java
deleted file mode 100644
index 6d70bc9..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/MatrixTransform.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.Matrix4f;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class MatrixTransform extends Transform {
-
- Matrix4f mLocalMatrix;
- public MatrixTransform() {
- mLocalMatrix = new Matrix4f();
- }
-
- public void setMatrix(Matrix4f matrix) {
- mLocalMatrix = matrix;
- updateRSData();
- }
-
- public Matrix4f getMatrix() {
- return new Matrix4f(mLocalMatrix.getArray());
- }
-
- void initLocalData() {
- mTransformData.localMat = mLocalMatrix;
- }
-
- void updateRSData() {
- if (mField == null) {
- return;
- }
- mField.set_localMat(0, mLocalMatrix, false);
- mField.set_isDirty(0, 1, true);
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/PointLight.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/PointLight.java
deleted file mode 100644
index 574bafc..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/PointLight.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class PointLight extends LightBase {
- public PointLight() {
- }
-
- void initLocalData() {
- mFieldData.type = RS_LIGHT_POINT;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderPass.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderPass.java
deleted file mode 100644
index 02fd69d..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderPass.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.util.Log;
-
-import android.renderscript.*;
-import android.content.res.Resources;
-
-/**
- * @hide
- */
-public class RenderPass extends SceneGraphBase {
-
- TextureRenderTarget mColorTarget;
- Float4 mClearColor;
- boolean mShouldClearColor;
-
- TextureRenderTarget mDepthTarget;
- float mClearDepth;
- boolean mShouldClearDepth;
-
- ArrayList<RenderableBase> mObjectsToDraw;
-
- Camera mCamera;
-
- ScriptField_RenderPass_s.Item mRsField;
-
- public RenderPass() {
- mObjectsToDraw = new ArrayList<RenderableBase>();
- mClearColor = new Float4(0.0f, 0.0f, 0.0f, 0.0f);
- mShouldClearColor = true;
- mClearDepth = 1.0f;
- mShouldClearDepth = true;
- }
-
- public void appendRenderable(Renderable d) {
- mObjectsToDraw.add(d);
- }
-
- public void setCamera(Camera c) {
- mCamera = c;
- }
-
- public void setColorTarget(TextureRenderTarget colorTarget) {
- mColorTarget = colorTarget;
- }
- public void setClearColor(Float4 clearColor) {
- mClearColor = clearColor;
- }
- public void setShouldClearColor(boolean shouldClearColor) {
- mShouldClearColor = shouldClearColor;
- }
-
- public void setDepthTarget(TextureRenderTarget depthTarget) {
- mDepthTarget = depthTarget;
- }
- public void setClearDepth(float clearDepth) {
- mClearDepth = clearDepth;
- }
- public void setShouldClearDepth(boolean shouldClearDepth) {
- mShouldClearDepth = shouldClearDepth;
- }
-
- public ArrayList<RenderableBase> getRenderables() {
- return mObjectsToDraw;
- }
-
- ScriptField_RenderPass_s.Item getRsField(RenderScriptGL rs, Resources res) {
- if (mRsField != null) {
- return mRsField;
- }
-
- mRsField = new ScriptField_RenderPass_s.Item();
- if (mColorTarget != null) {
- mRsField.color_target = mColorTarget.getRsData(true).get_texture(0);
- }
- if (mColorTarget != null) {
- mRsField.depth_target = mDepthTarget.getRsData(true).get_texture(0);
- }
- mRsField.camera = mCamera != null ? mCamera.getRSData().getAllocation() : null;
-
- if (mObjectsToDraw.size() != 0) {
- Allocation drawableData = Allocation.createSized(rs,
- Element.ALLOCATION(rs),
- mObjectsToDraw.size());
- Allocation[] drawableAllocs = new Allocation[mObjectsToDraw.size()];
- for (int i = 0; i < mObjectsToDraw.size(); i ++) {
- Renderable dI = (Renderable)mObjectsToDraw.get(i);
- drawableAllocs[i] = dI.getRsField(rs, res).getAllocation();
- }
- drawableData.copyFrom(drawableAllocs);
- mRsField.objects = drawableData;
- }
-
- mRsField.clear_color = mClearColor;
- mRsField.clear_depth = mClearDepth;
- mRsField.should_clear_color = mShouldClearColor;
- mRsField.should_clear_depth = mShouldClearDepth;
- return mRsField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderState.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderState.java
deleted file mode 100644
index c08a722..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderState.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-import android.content.res.Resources;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramRaster;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.RSRuntimeException;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class RenderState extends SceneGraphBase {
- VertexShader mVertex;
- FragmentShader mFragment;
- ProgramStore mStore;
- ProgramRaster mRaster;
-
- ScriptField_RenderState_s mField;
-
- public RenderState(VertexShader pv,
- FragmentShader pf,
- ProgramStore ps,
- ProgramRaster pr) {
- mVertex = pv;
- mFragment = pf;
- mStore = ps;
- mRaster = pr;
- }
-
- public RenderState(RenderState r) {
- mVertex = r.mVertex;
- mFragment = r.mFragment;
- mStore = r.mStore;
- mRaster = r.mRaster;
- }
-
- public void setProgramVertex(VertexShader pv) {
- mVertex = pv;
- updateRSData();
- }
-
- public void setProgramFragment(FragmentShader pf) {
- mFragment = pf;
- updateRSData();
- }
-
- public void setProgramStore(ProgramStore ps) {
- mStore = ps;
- updateRSData();
- }
-
- public void setProgramRaster(ProgramRaster pr) {
- mRaster = pr;
- updateRSData();
- }
-
- void updateRSData() {
- if (mField == null) {
- return;
- }
- ScriptField_RenderState_s.Item item = new ScriptField_RenderState_s.Item();
- item.pv = mVertex.getRSData().getAllocation();
- item.pf = mFragment.getRSData().getAllocation();
- item.ps = mStore;
- item.pr = mRaster;
-
- mField.set(item, 0, true);
- }
-
- public ScriptField_RenderState_s getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- if (rs == null) {
- return null;
- }
-
- mField = new ScriptField_RenderState_s(rs, 1);
- updateRSData();
-
- return mField;
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java
deleted file mode 100644
index 9266f30..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Renderable.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import com.android.scenegraph.Float4Param;
-import com.android.scenegraph.MatrixTransform;
-import com.android.scenegraph.SceneManager;
-import com.android.scenegraph.ShaderParam;
-import com.android.scenegraph.TransformParam;
-
-import android.content.res.Resources;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Element.DataType;
-import android.renderscript.Matrix4f;
-import android.renderscript.Mesh;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class Renderable extends RenderableBase {
- HashMap<String, ShaderParam> mSourceParams;
-
- RenderState mRenderState;
- Transform mTransform;
-
- String mMeshName;
- String mMeshIndexName;
-
- public String mMaterialName;
-
- ScriptField_Renderable_s mField;
- ScriptField_Renderable_s.Item mData;
-
- public Renderable() {
- mSourceParams = new HashMap<String, ShaderParam>();
- mData = new ScriptField_Renderable_s.Item();
- }
-
- public void setCullType(int cull) {
- mData.cullType = cull;
- }
-
- public void setRenderState(RenderState renderState) {
- mRenderState = renderState;
- if (mField != null) {
- RenderScriptGL rs = SceneManager.getRS();
- updateFieldItem(rs);
- mField.set(mData, 0, true);
- }
- }
-
- public void setMesh(Mesh mesh) {
- mData.mesh = mesh;
- if (mField != null) {
- mField.set_mesh(0, mData.mesh, true);
- }
- }
-
- public void setMesh(String mesh, String indexName) {
- mMeshName = mesh;
- mMeshIndexName = indexName;
- }
-
- public void setMaterialName(String name) {
- mMaterialName = name;
- }
-
- public Transform getTransform() {
- return mTransform;
- }
-
- public void setTransform(Transform t) {
- mTransform = t;
- if (mField != null) {
- RenderScriptGL rs = SceneManager.getRS();
- updateFieldItem(rs);
- mField.set(mData, 0, true);
- }
- }
-
- public void appendSourceParams(ShaderParam p) {
- mSourceParams.put(p.getParamName(), p);
- // Possibly lift this restriction later
- if (mField != null) {
- throw new RuntimeException("Can't add source params to objects that are rendering");
- }
- }
-
- public void resolveMeshData(Mesh mesh) {
- mData.mesh = mesh;
- if (mData.mesh == null) {
- Log.v("DRAWABLE: ", "*** NO MESH *** " + mMeshName);
- return;
- }
- int subIndexCount = mData.mesh.getPrimitiveCount();
- if (subIndexCount == 1 || mMeshIndexName == null) {
- mData.meshIndex = 0;
- } else {
- for (int i = 0; i < subIndexCount; i ++) {
- if (mData.mesh.getIndexSetAllocation(i).getName().equals(mMeshIndexName)) {
- mData.meshIndex = i;
- break;
- }
- }
- }
- if (mField != null) {
- mField.set(mData, 0, true);
- }
- }
-
- void updateTextures(RenderScriptGL rs) {
- Iterator<ShaderParam> allParamsIter = mSourceParams.values().iterator();
- int paramIndex = 0;
- while (allParamsIter.hasNext()) {
- ShaderParam sp = allParamsIter.next();
- if (sp instanceof TextureParam) {
- TextureParam p = (TextureParam)sp;
- TextureBase tex = p.getTexture();
- if (tex != null) {
- mData.pf_textures[paramIndex++] = tex.getRsData(false).getAllocation();
- }
- }
- }
- ProgramFragment pf = mRenderState.mFragment.mProgram;
- mData.pf_num_textures = pf != null ? Math.min(pf.getTextureCount(), paramIndex) : 0;
- if (mField != null) {
- mField.set_pf_textures(0, mData.pf_textures, true);
- mField.set_pf_num_textures(0, mData.pf_num_textures, true);
- }
- }
-
- public void setVisible(boolean vis) {
- mData.cullType = vis ? 0 : 2;
- if (mField != null) {
- mField.set_cullType(0, mData.cullType, true);
- }
- }
-
- ScriptField_Renderable_s getRsField(RenderScriptGL rs, Resources res) {
- if (mField != null) {
- return mField;
- }
- updateFieldItem(rs);
- updateTextures(rs);
-
- mField = new ScriptField_Renderable_s(rs, 1);
- mField.set(mData, 0, true);
-
- return mField;
- }
-
- void updateVertexConstants(RenderScriptGL rs) {
- Allocation pvParams = null, vertexConstants = null;
- VertexShader pv = mRenderState.mVertex;
- if (pv != null && pv.getObjectConstants() != null) {
- vertexConstants = Allocation.createTyped(rs, pv.getObjectConstants());
- Element vertexConst = vertexConstants.getType().getElement();
- pvParams = ShaderParam.fillInParams(vertexConst, mSourceParams,
- mTransform).getAllocation();
- }
- mData.pv_const = vertexConstants;
- mData.pv_constParams = pvParams;
- }
-
- void updateFragmentConstants(RenderScriptGL rs) {
- Allocation pfParams = null, fragmentConstants = null;
- FragmentShader pf = mRenderState.mFragment;
- if (pf != null && pf.getObjectConstants() != null) {
- fragmentConstants = Allocation.createTyped(rs, pf.getObjectConstants());
- Element fragmentConst = fragmentConstants.getType().getElement();
- pfParams = ShaderParam.fillInParams(fragmentConst, mSourceParams,
- mTransform).getAllocation();
- }
- mData.pf_const = fragmentConstants;
- mData.pf_constParams = pfParams;
- }
-
- void updateFieldItem(RenderScriptGL rs) {
- if (mRenderState == null) {
- mRenderState = SceneManager.getDefaultState();
- }
- if (mTransform == null) {
- mTransform = SceneManager.getDefaultTransform();
- }
- updateVertexConstants(rs);
- updateFragmentConstants(rs);
-
- mData.transformMatrix = mTransform.getRSData().getAllocation();
-
- mData.name = getNameAlloc(rs);
- mData.render_state = mRenderState.getRSData().getAllocation();
- mData.bVolInitialized = 0;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderableBase.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderableBase.java
deleted file mode 100644
index 74535dd..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderableBase.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class RenderableBase extends SceneGraphBase {
- public RenderableBase() {
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderableGroup.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderableGroup.java
deleted file mode 100644
index 590bbab..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/RenderableGroup.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class RenderableGroup extends RenderableBase {
-
- ArrayList<RenderableBase> mChildren;
-
- public RenderableGroup() {
- mChildren = new ArrayList<RenderableBase>();
- }
-
- public void appendChildren(RenderableBase d) {
- mChildren.add(d);
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java
deleted file mode 100644
index 27336ab..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Scene.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.android.scenegraph.Camera;
-import com.android.scenegraph.CompoundTransform;
-import com.android.scenegraph.RenderPass;
-import com.android.scenegraph.Renderable;
-import com.android.scenegraph.SceneManager;
-import com.android.scenegraph.TextureBase;
-
-import android.content.res.Resources;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Mesh;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class Scene extends SceneGraphBase {
- private static String TIMER_TAG = "TIMER";
-
- CompoundTransform mRootTransforms;
- HashMap<String, Transform> mTransformMap;
- ArrayList<RenderPass> mRenderPasses;
- ArrayList<LightBase> mLights;
- ArrayList<Camera> mCameras;
- ArrayList<FragmentShader> mFragmentShaders;
- ArrayList<VertexShader> mVertexShaders;
- ArrayList<RenderableBase> mRenderables;
- HashMap<String, RenderableBase> mRenderableMap;
- ArrayList<Texture2D> mTextures;
-
- HashMap<String, ArrayList<Renderable> > mRenderableMeshMap;
-
- // RS Specific stuff
- ScriptField_SgTransform mTransformRSData;
-
- RenderScriptGL mRS;
- Resources mRes;
-
- ScriptField_RenderPass_s mRenderPassAlloc;
-
- public Scene() {
- mRenderPasses = new ArrayList<RenderPass>();
- mLights = new ArrayList<LightBase>();
- mCameras = new ArrayList<Camera>();
- mFragmentShaders = new ArrayList<FragmentShader>();
- mVertexShaders = new ArrayList<VertexShader>();
- mRenderables = new ArrayList<RenderableBase>();
- mRenderableMap = new HashMap<String, RenderableBase>();
- mRenderableMeshMap = new HashMap<String, ArrayList<Renderable> >();
- mTextures = new ArrayList<Texture2D>();
- mRootTransforms = new CompoundTransform();
- mRootTransforms.setName("_scene_root_");
- mTransformMap = new HashMap<String, Transform>();
- }
-
- public void appendTransform(Transform t) {
- if (t == null) {
- throw new RuntimeException("Adding null object");
- }
- mRootTransforms.appendChild(t);
- }
-
- public CompoundTransform appendNewCompoundTransform() {
- CompoundTransform t = new CompoundTransform();
- appendTransform(t);
- return t;
- }
-
- public MatrixTransform appendNewMatrixTransform() {
- MatrixTransform t = new MatrixTransform();
- appendTransform(t);
- return t;
- }
-
- // temporary
- public void addToTransformMap(Transform t) {
- mTransformMap.put(t.getName(), t);
- }
-
- public Transform getTransformByName(String name) {
- return mTransformMap.get(name);
- }
-
- public void appendRenderPass(RenderPass p) {
- if (p == null) {
- throw new RuntimeException("Adding null object");
- }
- mRenderPasses.add(p);
- }
-
- public RenderPass appendNewRenderPass() {
- RenderPass p = new RenderPass();
- appendRenderPass(p);
- return p;
- }
-
- public void clearRenderPasses() {
- mRenderPasses.clear();
- }
-
- public void appendLight(LightBase l) {
- if (l == null) {
- throw new RuntimeException("Adding null object");
- }
- mLights.add(l);
- }
-
- public void appendCamera(Camera c) {
- if (c == null) {
- throw new RuntimeException("Adding null object");
- }
- mCameras.add(c);
- }
-
- public Camera appendNewCamera() {
- Camera c = new Camera();
- appendCamera(c);
- return c;
- }
-
- public void appendShader(FragmentShader f) {
- if (f == null) {
- throw new RuntimeException("Adding null object");
- }
- mFragmentShaders.add(f);
- }
-
- public void appendShader(VertexShader v) {
- if (v == null) {
- throw new RuntimeException("Adding null object");
- }
- mVertexShaders.add(v);
- }
-
- public ArrayList<Camera> getCameras() {
- return mCameras;
- }
-
- public ArrayList<LightBase> getLights() {
- return mLights;
- }
-
- public void appendRenderable(RenderableBase d) {
- if (d == null) {
- throw new RuntimeException("Adding null object");
- }
- mRenderables.add(d);
- if (d.getName() != null) {
- mRenderableMap.put(d.getName(), d);
- }
- }
-
- public Renderable appendNewRenderable() {
- Renderable r = new Renderable();
- appendRenderable(r);
- return r;
- }
-
- public ArrayList<RenderableBase> getRenderables() {
- return mRenderables;
- }
-
- public RenderableBase getRenderableByName(String name) {
- return mRenderableMap.get(name);
- }
-
- public void appendTextures(Texture2D tex) {
- if (tex == null) {
- throw new RuntimeException("Adding null object");
- }
- mTextures.add(tex);
- }
-
- public void assignRenderStateToMaterial(RenderState renderState, String regex) {
- Pattern pattern = Pattern.compile(regex);
- int numRenderables = mRenderables.size();
- for (int i = 0; i < numRenderables; i ++) {
- Renderable shape = (Renderable)mRenderables.get(i);
- Matcher m = pattern.matcher(shape.mMaterialName);
- if (m.find()) {
- shape.setRenderState(renderState);
- }
- }
- }
-
- public void assignRenderState(RenderState renderState) {
- int numRenderables = mRenderables.size();
- for (int i = 0; i < numRenderables; i ++) {
- Renderable shape = (Renderable)mRenderables.get(i);
- shape.setRenderState(renderState);
- }
- }
-
- public void meshLoaded(Mesh m) {
- ArrayList<Renderable> entries = mRenderableMeshMap.get(m.getName());
- int numEntries = entries.size();
- for (int i = 0; i < numEntries; i++) {
- Renderable d = entries.get(i);
- d.resolveMeshData(m);
- }
- }
-
- void addToMeshMap(Renderable d) {
- ArrayList<Renderable> entries = mRenderableMeshMap.get(d.mMeshName);
- if (entries == null) {
- entries = new ArrayList<Renderable>();
- mRenderableMeshMap.put(d.mMeshName, entries);
- }
- entries.add(d);
- }
-
- public void destroyRS() {
- SceneManager sceneManager = SceneManager.getInstance();
- mTransformRSData = null;
- sceneManager.mRenderLoop.bind_gRootNode(mTransformRSData);
- sceneManager.mRenderLoop.set_gRenderableObjects(null);
- mRenderPassAlloc = null;
- sceneManager.mRenderLoop.set_gRenderPasses(null);
- sceneManager.mRenderLoop.bind_gFrontToBack(null);
- sceneManager.mRenderLoop.bind_gBackToFront(null);
- sceneManager.mRenderLoop.set_gCameras(null);
-
- mTransformMap = null;
- mRenderPasses = null;
- mLights = null;
- mCameras = null;
- mRenderables = null;
- mRenderableMap = null;
- mTextures = null;
- mRenderableMeshMap = null;
- mRootTransforms = null;
- }
-
- public void initRenderPassRS(RenderScriptGL rs, SceneManager sceneManager) {
- if (mRenderPasses.size() != 0) {
- mRenderPassAlloc = new ScriptField_RenderPass_s(mRS, mRenderPasses.size());
- for (int i = 0; i < mRenderPasses.size(); i ++) {
- mRenderPassAlloc.set(mRenderPasses.get(i).getRsField(mRS, mRes), i, false);
- }
- mRenderPassAlloc.copyAll();
- sceneManager.mRenderLoop.set_gRenderPasses(mRenderPassAlloc.getAllocation());
- }
- }
-
- private void addDrawables(RenderScriptGL rs, Resources res, SceneManager sceneManager) {
- Allocation drawableData = Allocation.createSized(rs,
- Element.ALLOCATION(rs),
- mRenderables.size());
- Allocation[] drawableAllocs = new Allocation[mRenderables.size()];
- for (int i = 0; i < mRenderables.size(); i ++) {
- Renderable dI = (Renderable)mRenderables.get(i);
- addToMeshMap(dI);
- drawableAllocs[i] = dI.getRsField(rs, res).getAllocation();
- }
- drawableData.copyFrom(drawableAllocs);
- sceneManager.mRenderLoop.set_gRenderableObjects(drawableData);
-
- initRenderPassRS(rs, sceneManager);
- }
-
- private void addShaders(RenderScriptGL rs, Resources res, SceneManager sceneManager) {
- if (mVertexShaders.size() > 0) {
- Allocation shaderData = Allocation.createSized(rs, Element.ALLOCATION(rs),
- mVertexShaders.size());
- Allocation[] shaderAllocs = new Allocation[mVertexShaders.size()];
- for (int i = 0; i < mVertexShaders.size(); i ++) {
- VertexShader sI = mVertexShaders.get(i);
- shaderAllocs[i] = sI.getRSData().getAllocation();
- }
- shaderData.copyFrom(shaderAllocs);
- sceneManager.mRenderLoop.set_gVertexShaders(shaderData);
- }
-
- if (mFragmentShaders.size() > 0) {
- Allocation shaderData = Allocation.createSized(rs, Element.ALLOCATION(rs),
- mFragmentShaders.size());
- Allocation[] shaderAllocs = new Allocation[mFragmentShaders.size()];
- for (int i = 0; i < mFragmentShaders.size(); i ++) {
- FragmentShader sI = mFragmentShaders.get(i);
- shaderAllocs[i] = sI.getRSData().getAllocation();
- }
- shaderData.copyFrom(shaderAllocs);
- sceneManager.mRenderLoop.set_gFragmentShaders(shaderData);
- }
- }
-
- public void initRS() {
- SceneManager sceneManager = SceneManager.getInstance();
- mRS = SceneManager.getRS();
- mRes = SceneManager.getRes();
- long start = System.currentTimeMillis();
- mTransformRSData = mRootTransforms.getRSData();
- long end = System.currentTimeMillis();
- Log.v(TIMER_TAG, "Transform init time: " + (end - start));
-
- start = System.currentTimeMillis();
-
- sceneManager.mRenderLoop.bind_gRootNode(mTransformRSData);
- end = System.currentTimeMillis();
- Log.v(TIMER_TAG, "Script init time: " + (end - start));
-
- start = System.currentTimeMillis();
- addDrawables(mRS, mRes, sceneManager);
- end = System.currentTimeMillis();
- Log.v(TIMER_TAG, "Renderable init time: " + (end - start));
-
- addShaders(mRS, mRes, sceneManager);
-
- Allocation opaqueBuffer = null;
- if (mRenderables.size() > 0) {
- opaqueBuffer = Allocation.createSized(mRS, Element.U32(mRS), mRenderables.size());
- }
- Allocation transparentBuffer = null;
- if (mRenderables.size() > 0) {
- transparentBuffer = Allocation.createSized(mRS, Element.U32(mRS), mRenderables.size());
- }
-
- sceneManager.mRenderLoop.bind_gFrontToBack(opaqueBuffer);
- sceneManager.mRenderLoop.bind_gBackToFront(transparentBuffer);
-
- if (mCameras.size() > 0) {
- Allocation cameraData;
- cameraData = Allocation.createSized(mRS, Element.ALLOCATION(mRS), mCameras.size());
- Allocation[] cameraAllocs = new Allocation[mCameras.size()];
- for (int i = 0; i < mCameras.size(); i ++) {
- cameraAllocs[i] = mCameras.get(i).getRSData().getAllocation();
- }
- cameraData.copyFrom(cameraAllocs);
- sceneManager.mRenderLoop.set_gCameras(cameraData);
- }
-
- if (mLights.size() > 0) {
- Allocation lightData = Allocation.createSized(mRS,
- Element.ALLOCATION(mRS),
- mLights.size());
- Allocation[] lightAllocs = new Allocation[mLights.size()];
- for (int i = 0; i < mLights.size(); i ++) {
- lightAllocs[i] = mLights.get(i).getRSData().getAllocation();
- }
- lightData.copyFrom(lightAllocs);
- sceneManager.mRenderLoop.set_gLights(lightData);
- }
- }
-}
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneGraphBase.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneGraphBase.java
deleted file mode 100644
index 412ffbf..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneGraphBase.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import com.android.scenegraph.SceneManager;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.RSRuntimeException;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class SceneGraphBase {
- String mName;
- Allocation mNameAlloc;
- public void setName(String n) {
- mName = n;
- mNameAlloc = null;
- }
-
- public String getName() {
- return mName;
- }
-
- Allocation getNameAlloc(RenderScriptGL rs) {
- if (mNameAlloc == null) {
- mNameAlloc = SceneManager.getStringAsAllocation(rs, getName());
- }
- return mNameAlloc;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java
deleted file mode 100644
index 4ff2c8b..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/SceneManager.java
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.lang.Math;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.android.scenegraph.Camera;
-import com.android.scenegraph.FragmentShader;
-import com.android.scenegraph.MatrixTransform;
-import com.android.scenegraph.Scene;
-import com.android.scenegraph.VertexShader;
-import com.android.testapp.R;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Mesh;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-import android.view.SurfaceHolder;
-
-/**
- * @hide
- */
-public class SceneManager extends SceneGraphBase {
-
- HashMap<String, Allocation> mAllocationMap;
-
- ScriptC_render mRenderLoop;
- ScriptC mCameraScript;
- ScriptC mLightScript;
- ScriptC mObjectParamsScript;
- ScriptC mFragmentParamsScript;
- ScriptC mVertexParamsScript;
- ScriptC mCullScript;
- ScriptC_transform mTransformScript;
- ScriptC_export mExportScript;
-
- RenderScriptGL mRS;
- Resources mRes;
- Mesh mQuad;
- int mWidth;
- int mHeight;
-
- Scene mActiveScene;
- private static SceneManager sSceneManager;
-
- private Allocation mDefault2D;
- private Allocation mDefaultCube;
-
- private FragmentShader mColor;
- private FragmentShader mTexture;
- private VertexShader mDefaultVertex;
-
- private RenderState mDefaultState;
- private Transform mDefaultTransform;
-
- private static Allocation getDefault(boolean isCube) {
- final int dimension = 4;
- final int bytesPerPixel = 4;
- int arraySize = dimension * dimension * bytesPerPixel;
-
- RenderScriptGL rs = sSceneManager.mRS;
- Type.Builder b = new Type.Builder(rs, Element.RGBA_8888(rs));
- b.setX(dimension).setY(dimension);
- if (isCube) {
- b.setFaces(true);
- arraySize *= 6;
- }
- Type bitmapType = b.create();
-
- Allocation.MipmapControl mip = Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE;
- int usage = Allocation.USAGE_GRAPHICS_TEXTURE;
- Allocation defaultImage = Allocation.createTyped(rs, bitmapType, mip, usage);
-
- byte imageData[] = new byte[arraySize];
- defaultImage.copyFrom(imageData);
- return defaultImage;
- }
-
- static Allocation getDefaultTex2D() {
- if (sSceneManager == null) {
- return null;
- }
- if (sSceneManager.mDefault2D == null) {
- sSceneManager.mDefault2D = getDefault(false);
- }
- return sSceneManager.mDefault2D;
- }
-
- static Allocation getDefaultTexCube() {
- if (sSceneManager == null) {
- return null;
- }
- if (sSceneManager.mDefaultCube == null) {
- sSceneManager.mDefaultCube = getDefault(true);
- }
- return sSceneManager.mDefaultCube;
- }
-
- public static boolean isSDCardPath(String path) {
- int sdCardIndex = path.indexOf("sdcard/");
- // We are looking for /sdcard/ or sdcard/
- if (sdCardIndex == 0 || sdCardIndex == 1) {
- return true;
- }
- sdCardIndex = path.indexOf("mnt/sdcard/");
- if (sdCardIndex == 0 || sdCardIndex == 1) {
- return true;
- }
- return false;
- }
-
- static Bitmap loadBitmap(String name, Resources res) {
- InputStream is = null;
- boolean loadFromSD = isSDCardPath(name);
- try {
- if (!loadFromSD) {
- is = res.getAssets().open(name);
- } else {
- File f = new File(name);
- is = new BufferedInputStream(new FileInputStream(f));
- }
- } catch (IOException e) {
- Log.e("ImageLoaderTask", " Message: " + e.getMessage());
- return null;
- }
-
- Bitmap b = BitmapFactory.decodeStream(is);
- try {
- is.close();
- } catch (IOException e) {
- Log.e("ImageLoaderTask", " Message: " + e.getMessage());
- }
- return b;
- }
-
- static Allocation createFromBitmap(Bitmap b, RenderScriptGL rs, boolean isCube) {
- if (b == null) {
- return null;
- }
- MipmapControl mip = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE;
- int usage = Allocation.USAGE_GRAPHICS_TEXTURE;
- if (isCube) {
- return Allocation.createCubemapFromBitmap(rs, b, mip, usage);
- }
- return Allocation.createFromBitmap(rs, b, mip, usage);
- }
-
- public static Allocation loadCubemap(String name, RenderScriptGL rs, Resources res) {
- return createFromBitmap(loadBitmap(name, res), rs, true);
- }
-
- public static Allocation loadCubemap(int id, RenderScriptGL rs, Resources res) {
- return createFromBitmap(BitmapFactory.decodeResource(res, id), rs, true);
- }
-
- public static Allocation loadTexture2D(String name, RenderScriptGL rs, Resources res) {
- return createFromBitmap(loadBitmap(name, res), rs, false);
- }
-
- public static Allocation loadTexture2D(int id, RenderScriptGL rs, Resources res) {
- return createFromBitmap(BitmapFactory.decodeResource(res, id), rs, false);
- }
-
- public static ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) {
- ProgramStore.Builder builder = new ProgramStore.Builder(rs);
- builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
- builder.setBlendFunc(ProgramStore.BlendSrcFunc.ONE, ProgramStore.BlendDstFunc.ONE);
- builder.setDitherEnabled(false);
- builder.setDepthMaskEnabled(false);
- return builder.create();
- }
-
- static Allocation getStringAsAllocation(RenderScript rs, String str) {
- if (str == null) {
- return null;
- }
- if (str.length() == 0) {
- return null;
- }
- byte[] allocArray = null;
- byte[] nullChar = new byte[1];
- nullChar[0] = 0;
- try {
- allocArray = str.getBytes("UTF-8");
- Allocation alloc = Allocation.createSized(rs, Element.U8(rs),
- allocArray.length + 1,
- Allocation.USAGE_SCRIPT);
- alloc.copy1DRangeFrom(0, allocArray.length, allocArray);
- alloc.copy1DRangeFrom(allocArray.length, 1, nullChar);
- return alloc;
- }
- catch (Exception e) {
- throw new RSRuntimeException("Could not convert string to utf-8.");
- }
- }
-
- static Allocation getCachedAlloc(String str) {
- if (sSceneManager == null) {
- throw new RuntimeException("Scene manager not initialized");
- }
- return sSceneManager.mAllocationMap.get(str);
- }
-
- static void cacheAlloc(String str, Allocation alloc) {
- if (sSceneManager == null) {
- throw new RuntimeException("Scene manager not initialized");
- }
- sSceneManager.mAllocationMap.put(str, alloc);
- }
-
- public static class SceneLoadedCallback implements Runnable {
- public Scene mLoadedScene;
- public String mName;
- public void run() {
- }
- }
-
- public Scene getActiveScene() {
- return mActiveScene;
- }
-
- public void setActiveScene(Scene s) {
- mActiveScene = s;
-
- if (mActiveScene == null) {
- return;
- }
-
- // Do some sanity checking
- if (mActiveScene.getCameras().size() == 0) {
- Matrix4f camPos = new Matrix4f();
- camPos.translate(0, 0, 10);
- MatrixTransform cameraTransform = new MatrixTransform();
- cameraTransform.setName("_DefaultCameraTransform");
- cameraTransform.setMatrix(camPos);
- mActiveScene.appendTransform(cameraTransform);
- Camera cam = new Camera();
- cam.setName("_DefaultCamera");
- cam.setTransform(cameraTransform);
- mActiveScene.appendCamera(cam);
- }
-
- mActiveScene.appendShader(getDefaultVS());
- mActiveScene.appendTransform(getDefaultTransform());
- }
-
- static RenderScriptGL getRS() {
- if (sSceneManager == null) {
- return null;
- }
- return sSceneManager.mRS;
- }
-
- static Resources getRes() {
- if (sSceneManager == null) {
- return null;
- }
- return sSceneManager.mRes;
- }
-
- // Provides the folowing inputs to fragment shader
- // Assigned by default if nothing is present
- // vec3 varWorldPos;
- // vec3 varWorldNormal;
- // vec2 varTex0;
- public static VertexShader getDefaultVS() {
- if (sSceneManager == null) {
- return null;
- }
-
- if (sSceneManager.mDefaultVertex == null) {
- RenderScriptGL rs = getRS();
- Element.Builder b = new Element.Builder(rs);
- b.add(Element.MATRIX_4X4(rs), "model");
- Type.Builder objConstBuilder = new Type.Builder(rs, b.create());
-
- b = new Element.Builder(rs);
- b.add(Element.MATRIX_4X4(rs), "viewProj");
- Type.Builder shaderConstBuilder = new Type.Builder(rs, b.create());
-
- b = new Element.Builder(rs);
- b.add(Element.F32_4(rs), "position");
- b.add(Element.F32_2(rs), "texture0");
- b.add(Element.F32_3(rs), "normal");
- Element defaultIn = b.create();
-
- final String code = "\n" +
- "varying vec3 varWorldPos;\n" +
- "varying vec3 varWorldNormal;\n" +
- "varying vec2 varTex0;\n" +
- "void main() {" +
- " vec4 objPos = ATTRIB_position;\n" +
- " vec4 worldPos = UNI_model * objPos;\n" +
- " gl_Position = UNI_viewProj * worldPos;\n" +
- " mat3 model3 = mat3(UNI_model[0].xyz, UNI_model[1].xyz, UNI_model[2].xyz);\n" +
- " vec3 worldNorm = model3 * ATTRIB_normal;\n" +
- " varWorldPos = worldPos.xyz;\n" +
- " varWorldNormal = worldNorm;\n" +
- " varTex0 = ATTRIB_texture0;\n" +
- "}\n";
-
- VertexShader.Builder sb = new VertexShader.Builder(rs);
- sb.addInput(defaultIn);
- sb.setObjectConst(objConstBuilder.setX(1).create());
- sb.setShaderConst(shaderConstBuilder.setX(1).create());
- sb.setShader(code);
- sSceneManager.mDefaultVertex = sb.create();
- }
-
- return sSceneManager.mDefaultVertex;
- }
-
- public static FragmentShader getColorFS() {
- if (sSceneManager == null) {
- return null;
- }
- if (sSceneManager.mColor == null) {
- RenderScriptGL rs = getRS();
- Element.Builder b = new Element.Builder(rs);
- b.add(Element.F32_4(rs), "color");
- Type.Builder objConstBuilder = new Type.Builder(rs, b.create());
-
- final String code = "\n" +
- "varying vec2 varTex0;\n" +
- "void main() {\n" +
- " lowp vec4 col = UNI_color;\n" +
- " gl_FragColor = col;\n" +
- "}\n";
- FragmentShader.Builder fb = new FragmentShader.Builder(rs);
- fb.setShader(code);
- fb.setObjectConst(objConstBuilder.create());
- sSceneManager.mColor = fb.create();
- }
-
- return sSceneManager.mColor;
- }
-
- public static FragmentShader getTextureFS() {
- if (sSceneManager == null) {
- return null;
- }
- if (sSceneManager.mTexture == null) {
- RenderScriptGL rs = getRS();
-
- final String code = "\n" +
- "varying vec2 varTex0;\n" +
- "void main() {\n" +
- " lowp vec4 col = texture2D(UNI_color, varTex0).rgba;\n" +
- " gl_FragColor = col;\n" +
- "}\n";
-
- FragmentShader.Builder fb = new FragmentShader.Builder(rs);
- fb.setShader(code);
- fb.addTexture(Program.TextureType.TEXTURE_2D, "color");
- sSceneManager.mTexture = fb.create();
- sSceneManager.mTexture.mProgram.bindSampler(Sampler.CLAMP_LINEAR_MIP_LINEAR(rs), 0);
- }
-
- return sSceneManager.mTexture;
- }
-
- static RenderState getDefaultState() {
- if (sSceneManager == null) {
- return null;
- }
- if (sSceneManager.mDefaultState == null) {
- sSceneManager.mDefaultState = new RenderState(getDefaultVS(), getColorFS(), null, null);
- sSceneManager.mDefaultState.setName("__DefaultState");
- }
- return sSceneManager.mDefaultState;
- }
-
- static Transform getDefaultTransform() {
- if (sSceneManager == null) {
- return null;
- }
- if (sSceneManager.mDefaultTransform == null) {
- sSceneManager.mDefaultTransform = new MatrixTransform();
- sSceneManager.mDefaultTransform.setName("__DefaultTransform");
- }
- return sSceneManager.mDefaultTransform;
- }
-
- public static SceneManager getInstance() {
- if (sSceneManager == null) {
- sSceneManager = new SceneManager();
- }
- return sSceneManager;
- }
-
- protected SceneManager() {
- }
-
- public void loadModel(String name, SceneLoadedCallback cb) {
- ColladaScene scene = new ColladaScene(name, cb);
- scene.init(mRS, mRes);
- }
-
- public Mesh getScreenAlignedQuad() {
- if (mQuad != null) {
- return mQuad;
- }
-
- Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS,
- 3, Mesh.TriangleMeshBuilder.TEXTURE_0);
-
- tmb.setTexture(0.0f, 1.0f).addVertex(-1.0f, 1.0f, 1.0f);
- tmb.setTexture(0.0f, 0.0f).addVertex(-1.0f, -1.0f, 1.0f);
- tmb.setTexture(1.0f, 0.0f).addVertex(1.0f, -1.0f, 1.0f);
- tmb.setTexture(1.0f, 1.0f).addVertex(1.0f, 1.0f, 1.0f);
-
- tmb.addTriangle(0, 1, 2);
- tmb.addTriangle(2, 3, 0);
-
- mQuad = tmb.create(true);
- return mQuad;
- }
-
- public Renderable getRenderableQuad(String name, RenderState state) {
- Renderable quad = new Renderable();
- quad.setTransform(new MatrixTransform());
- quad.setMesh(getScreenAlignedQuad());
- quad.setName(name);
- quad.setRenderState(state);
- quad.setCullType(1);
- return quad;
- }
-
- public void initRS(RenderScriptGL rs, Resources res, int w, int h) {
- mRS = rs;
- mRes = res;
- mAllocationMap = new HashMap<String, Allocation>();
-
- mQuad = null;
- mDefault2D = null;
- mDefaultCube = null;
- mDefaultVertex = null;
- mColor = null;
- mTexture = null;
- mDefaultState = null;
- mDefaultTransform = null;
-
- mExportScript = new ScriptC_export(rs, res, R.raw.export);
-
- mTransformScript = new ScriptC_transform(rs, res, R.raw.transform);
- mTransformScript.set_gTransformScript(mTransformScript);
-
- mCameraScript = new ScriptC_camera(rs, res, R.raw.camera);
- mLightScript = new ScriptC_light(rs, res, R.raw.light);
- mObjectParamsScript = new ScriptC_object_params(rs, res, R.raw.object_params);
- mFragmentParamsScript = new ScriptC_object_params(rs, res, R.raw.fragment_params);
- mVertexParamsScript = new ScriptC_object_params(rs, res, R.raw.vertex_params);
- mCullScript = new ScriptC_cull(rs, res, R.raw.cull);
-
- mRenderLoop = new ScriptC_render(rs, res, R.raw.render);
- mRenderLoop.set_gTransformScript(mTransformScript);
- mRenderLoop.set_gCameraScript(mCameraScript);
- mRenderLoop.set_gLightScript(mLightScript);
- mRenderLoop.set_gObjectParamsScript(mObjectParamsScript);
- mRenderLoop.set_gFragmentParamsScript(mFragmentParamsScript);
- mRenderLoop.set_gVertexParamsScript(mVertexParamsScript);
- mRenderLoop.set_gCullScript(mCullScript);
-
- mRenderLoop.set_gPFSBackground(ProgramStore.BLEND_NONE_DEPTH_TEST(mRS));
- }
-
- public ScriptC getRenderLoop() {
- return mRenderLoop;
- }
-}
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Shader.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Shader.java
deleted file mode 100644
index 4975114..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Shader.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.android.scenegraph.SceneGraphBase;
-import com.android.scenegraph.ShaderParam;
-
-import android.renderscript.*;
-import android.renderscript.ProgramFragment.Builder;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class Shader extends SceneGraphBase {
- protected Type mPerObjConstants;
- protected Type mPerShaderConstants;
-
- protected HashMap<String, ShaderParam> mSourceParams;
- protected ArrayList<String> mShaderTextureNames;
- protected ArrayList<Program.TextureType > mShaderTextureTypes;
- protected ArrayList<String> mTextureNames;
- protected ArrayList<Program.TextureType > mTextureTypes;
-
- protected Allocation mConstantBuffer;
- protected ScriptField_ShaderParam_s mConstantBufferParams;
-
- public Shader() {
- mSourceParams = new HashMap<String, ShaderParam>();
- mShaderTextureNames = new ArrayList<String>();
- mShaderTextureTypes = new ArrayList<Program.TextureType>();
- mTextureNames = new ArrayList<String>();
- mTextureTypes = new ArrayList<Program.TextureType>();
- }
-
- public void appendSourceParams(ShaderParam p) {
- mSourceParams.put(p.getParamName(), p);
- }
-
- public Type getObjectConstants() {
- return mPerObjConstants;
- }
-
- public Type getShaderConstants() {
- return mPerObjConstants;
- }
-
- void linkConstants(RenderScriptGL rs) {
- if (mPerShaderConstants == null) {
- return;
- }
-
- Element constElem = mPerShaderConstants.getElement();
- mConstantBufferParams = ShaderParam.fillInParams(constElem, mSourceParams, null);
-
- mConstantBuffer = Allocation.createTyped(rs, mPerShaderConstants);
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
deleted file mode 100644
index 3dd41ca..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.android.scenegraph.SceneManager;
-import com.android.scenegraph.Transform;
-
-import android.renderscript.Element;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.RenderScriptGL;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class ShaderParam extends SceneGraphBase {
-
- static final String cameraPos = "cameraPos";
- static final String cameraDir = "cameraDir";
-
- static final String lightColor = "lightColor";
- static final String lightPos = "lightPos";
- static final String lightDir = "lightDir";
-
- static final String view = "view";
- static final String proj = "proj";
- static final String viewProj = "viewProj";
- static final String model = "model";
- static final String modelView = "modelView";
- static final String modelViewProj = "modelViewProj";
-
- static final long sMaxTimeStamp = 0xffffffffL;
-
- ScriptField_ShaderParamData_s.Item mData;
- ScriptField_ShaderParamData_s mField;
-
- String mParamName;
- Camera mCamera;
-
- static ScriptField_ShaderParam_s fillInParams(Element constantElem,
- HashMap<String, ShaderParam> sourceParams,
- Transform transform) {
- RenderScriptGL rs = SceneManager.getRS();
- ArrayList<ScriptField_ShaderParam_s.Item> paramList;
- paramList = new ArrayList<ScriptField_ShaderParam_s.Item>();
-
- int subElemCount = constantElem.getSubElementCount();
- for (int i = 0; i < subElemCount; i ++) {
- String inputName = constantElem.getSubElementName(i);
- int offset = constantElem.getSubElementOffsetBytes(i);
-
- ShaderParam matchingParam = sourceParams.get(inputName);
- Element subElem = constantElem.getSubElement(i);
- // Make one if it's not there
- if (matchingParam == null) {
- if (subElem.getDataType() == Element.DataType.FLOAT_32) {
- matchingParam = new Float4Param(inputName, 0.5f, 0.5f, 0.5f, 0.5f);
- } else if (subElem.getDataType() == Element.DataType.MATRIX_4X4) {
- TransformParam trParam = new TransformParam(inputName);
- trParam.setTransform(transform);
- matchingParam = trParam;
- }
- }
- ScriptField_ShaderParam_s.Item paramRS = new ScriptField_ShaderParam_s.Item();
- paramRS.bufferOffset = offset;
- paramRS.transformTimestamp = 0;
- paramRS.dataTimestamp = 0;
- paramRS.data = matchingParam.getRSData().getAllocation();
- if (subElem.getDataType() == Element.DataType.FLOAT_32) {
- paramRS.float_vecSize = subElem.getVectorSize();
- }
-
- paramList.add(paramRS);
- }
-
- ScriptField_ShaderParam_s rsParams = null;
- int paramCount = paramList.size();
- if (paramCount != 0) {
- rsParams = new ScriptField_ShaderParam_s(rs, paramCount);
- for (int i = 0; i < paramCount; i++) {
- rsParams.set(paramList.get(i), i, false);
- }
- rsParams.copyAll();
- }
- return rsParams;
- }
-
- public ShaderParam(String name) {
- mParamName = name;
- mData = new ScriptField_ShaderParamData_s.Item();
- }
-
- public String getParamName() {
- return mParamName;
- }
-
- public void setCamera(Camera c) {
- mCamera = c;
- if (mField != null) {
- mData.camera = mCamera.getRSData().getAllocation();
- mField.set_camera(0, mData.camera, true);
- }
- }
-
- protected void incTimestamp() {
- if (mField != null) {
- mData.timestamp ++;
- mData.timestamp %= sMaxTimeStamp;
- mField.set_timestamp(0, mData.timestamp, true);
- }
- }
-
- abstract void initLocalData();
-
- public ScriptField_ShaderParamData_s getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- mField = new ScriptField_ShaderParamData_s(rs, 1);
-
- if (mParamName != null) {
- mData.paramName = SceneManager.getCachedAlloc(mParamName);
- if (mData.paramName == null) {
- mData.paramName = SceneManager.getStringAsAllocation(rs, mParamName);
- SceneManager.cacheAlloc(mParamName, mData.paramName);
- }
- }
- initLocalData();
- mData.timestamp = 1;
-
- mField.set(mData, 0, true);
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java
deleted file mode 100644
index b53ab88..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Texture2D.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-
-import com.android.scenegraph.SceneManager;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class Texture2D extends TextureBase {
- String mFileName;
- String mFileDir;
- int mResourceID;
-
- public Texture2D() {
- super(ScriptC_export.const_TextureType_TEXTURE_2D);
- }
-
- public Texture2D(Allocation tex) {
- super(ScriptC_export.const_TextureType_TEXTURE_2D);
- setTexture(tex);
- }
-
- public Texture2D(String dir, String file) {
- super(ScriptC_export.const_TextureType_TEXTURE_CUBE);
- setFileDir(dir);
- setFileName(file);
- }
-
- public Texture2D(int resourceID) {
- super(ScriptC_export.const_TextureType_TEXTURE_2D);
- mResourceID = resourceID;
- }
-
- public void setFileDir(String dir) {
- mFileDir = dir;
- }
-
- public void setFileName(String file) {
- mFileName = file;
- }
-
- public String getFileName() {
- return mFileName;
- }
-
- public void setTexture(Allocation tex) {
- mData.texture = tex != null ? tex : SceneManager.getDefaultTex2D();
- if (mField != null) {
- mField.set_texture(0, mData.texture, true);
- }
- }
-
- void load() {
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (mFileName != null && mFileName.length() > 0) {
- String shortName = mFileName.substring(mFileName.lastIndexOf('/') + 1);
- setTexture(SceneManager.loadTexture2D(mFileDir + shortName, rs, res));
- } else if (mResourceID != 0) {
- setTexture(SceneManager.loadTexture2D(mResourceID, rs, res));
- }
- }
-
- ScriptField_Texture_s getRsData(boolean loadNow) {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (rs == null || res == null) {
- return null;
- }
-
- mField = new ScriptField_Texture_s(rs, 1);
-
- if (loadNow) {
- load();
- } else {
- mData.texture = SceneManager.getDefaultTex2D();
- new SingleImageLoaderTask().execute(this);
- }
-
- mField.set(mData, 0, true);
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureBase.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureBase.java
deleted file mode 100644
index ba49d4e..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureBase.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-
-import com.android.scenegraph.SceneManager;
-import android.os.AsyncTask;
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class TextureBase extends SceneGraphBase {
-
- class SingleImageLoaderTask extends AsyncTask<TextureBase, Void, Boolean> {
- protected Boolean doInBackground(TextureBase... objects) {
- TextureBase tex = objects[0];
- tex.load();
- return new Boolean(true);
- }
- protected void onPostExecute(Boolean result) {
- }
- }
-
- ScriptField_Texture_s.Item mData;
- ScriptField_Texture_s mField;
- TextureBase(int type) {
- mData = new ScriptField_Texture_s.Item();
- mData.type = type;
- }
-
- protected Allocation mRsTexture;
- abstract ScriptField_Texture_s getRsData(boolean loadNow);
- abstract void load();
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureCube.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureCube.java
deleted file mode 100644
index 1269e3c..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureCube.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-
-import com.android.scenegraph.SceneManager;
-import com.android.scenegraph.TextureBase;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class TextureCube extends TextureBase {
- String mFileName;
- String mFileDir;
- int mResourceID;
-
- public TextureCube() {
- super(ScriptC_export.const_TextureType_TEXTURE_CUBE);
- }
-
- public TextureCube(Allocation tex) {
- super(ScriptC_export.const_TextureType_TEXTURE_CUBE);
- setTexture(tex);
- }
-
- public TextureCube(String dir, String file) {
- super(ScriptC_export.const_TextureType_TEXTURE_CUBE);
- setFileDir(dir);
- setFileName(file);
- }
-
- public TextureCube(int resourceID) {
- super(ScriptC_export.const_TextureType_TEXTURE_2D);
- mResourceID = resourceID;
- }
-
- public void setFileDir(String dir) {
- mFileDir = dir;
- }
-
- public void setFileName(String file) {
- mFileName = file;
- }
-
- public String getFileName() {
- return mFileName;
- }
-
- public void setTexture(Allocation tex) {
- mData.texture = tex != null ? tex : SceneManager.getDefaultTexCube();
- if (mField != null) {
- mField.set_texture(0, mData.texture, true);
- }
- }
-
- void load() {
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (mFileName != null && mFileName.length() > 0) {
- String shortName = mFileName.substring(mFileName.lastIndexOf('/') + 1);
- setTexture(SceneManager.loadCubemap(mFileDir + shortName, rs, res));
- } else if (mResourceID != 0) {
- setTexture(SceneManager.loadCubemap(mResourceID , rs, res));
- }
- }
-
- ScriptField_Texture_s getRsData(boolean loadNow) {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (rs == null || res == null) {
- return null;
- }
-
- mField = new ScriptField_Texture_s(rs, 1);
-
- if (loadNow) {
- load();
- } else {
- mData.texture = SceneManager.getDefaultTexCube();
- new SingleImageLoaderTask().execute(this);
- }
-
- mField.set(mData, 0, true);
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureParam.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureParam.java
deleted file mode 100644
index e656ed2..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureParam.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.graphics.Camera;
-import android.renderscript.RenderScriptGL;
-import android.renderscript.Float4;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.Element;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class TextureParam extends ShaderParam {
-
- TextureBase mTexture;
-
- public TextureParam(String name) {
- super(name);
- }
-
- public TextureParam(String name, TextureBase t) {
- super(name);
- setTexture(t);
- }
-
- public void setTexture(TextureBase t) {
- mTexture = t;
- }
-
- public TextureBase getTexture() {
- return mTexture;
- }
-
- void initLocalData() {
- mData.type = ScriptC_export.const_ShaderParam_TEXTURE;
- if (mTexture != null) {
- mData.texture = mTexture.getRsData(false).getAllocation();
- }
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureRenderTarget.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureRenderTarget.java
deleted file mode 100644
index 6aa29a5..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TextureRenderTarget.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-
-import com.android.scenegraph.SceneManager;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class TextureRenderTarget extends TextureBase {
- public TextureRenderTarget() {
- super(ScriptC_export.const_TextureType_TEXTURE_RENDER_TARGET);
- }
-
- public TextureRenderTarget(Allocation tex) {
- super(ScriptC_export.const_TextureType_TEXTURE_RENDER_TARGET);
- setTexture(tex);
- }
-
- public void setTexture(Allocation tex) {
- mData.texture = tex;
- if (mField != null) {
- mField.set_texture(0, mData.texture, true);
- }
- }
-
- void load() {
- }
-
- ScriptField_Texture_s getRsData(boolean loadNow) {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- if (rs == null) {
- return null;
- }
-
- mField = new ScriptField_Texture_s(rs, 1);
- mField.set(mData, 0, true);
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Transform.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Transform.java
deleted file mode 100644
index 8180bd0..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/Transform.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.*;
-import android.renderscript.Matrix4f;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class Transform extends SceneGraphBase {
- Transform mParent;
- ArrayList<Transform> mChildren;
-
- ScriptField_SgTransform mField;
- ScriptField_SgTransform.Item mTransformData;
-
- public Transform() {
- mChildren = new ArrayList<Transform>();
- mParent = null;
- }
-
- public void appendChild(Transform t) {
- mChildren.add(t);
- t.mParent = this;
- updateRSChildData(true);
- }
-
- abstract void initLocalData();
-
- void updateRSChildData(boolean copyData) {
- if (mField == null) {
- return;
- }
- RenderScriptGL rs = SceneManager.getRS();
- if (mChildren.size() != 0) {
- Allocation childRSData = Allocation.createSized(rs, Element.ALLOCATION(rs),
- mChildren.size());
- mTransformData.children = childRSData;
-
- Allocation[] childrenAllocs = new Allocation[mChildren.size()];
- for (int i = 0; i < mChildren.size(); i ++) {
- Transform child = mChildren.get(i);
- childrenAllocs[i] = child.getRSData().getAllocation();
- }
- childRSData.copyFrom(childrenAllocs);
- }
- if (copyData) {
- mField.set(mTransformData, 0, true);
- }
- }
-
- ScriptField_SgTransform getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- if (rs == null) {
- return null;
- }
- mField = new ScriptField_SgTransform(rs, 1);
-
- mTransformData = new ScriptField_SgTransform.Item();
- mTransformData.name = getNameAlloc(rs);
- mTransformData.isDirty = 1;
- mTransformData.timestamp = 1;
-
- initLocalData();
- updateRSChildData(false);
-
- mField.set(mTransformData, 0, true);
- return mField;
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TransformParam.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TransformParam.java
deleted file mode 100644
index d120d5d..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TransformParam.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.renderscript.RenderScriptGL;
-import android.renderscript.Matrix4f;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.Element;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class TransformParam extends ShaderParam {
-
- Transform mTransform;
- LightBase mLight;
-
- public TransformParam(String name) {
- super(name);
- }
-
- public void setTransform(Transform t) {
- mTransform = t;
- if (mField != null && mTransform != null) {
- mData.transform = mTransform.getRSData().getAllocation();
- }
- incTimestamp();
- }
-
- int getTypeFromName() {
- int paramType = ScriptC_export.const_ShaderParam_TRANSFORM_DATA;
- if (mParamName.equalsIgnoreCase(view)) {
- paramType = ScriptC_export.const_ShaderParam_TRANSFORM_VIEW;
- } else if(mParamName.equalsIgnoreCase(proj)) {
- paramType = ScriptC_export.const_ShaderParam_TRANSFORM_PROJ;
- } else if(mParamName.equalsIgnoreCase(viewProj)) {
- paramType = ScriptC_export.const_ShaderParam_TRANSFORM_VIEW_PROJ;
- } else if(mParamName.equalsIgnoreCase(model)) {
- paramType = ScriptC_export.const_ShaderParam_TRANSFORM_MODEL;
- } else if(mParamName.equalsIgnoreCase(modelView)) {
- paramType = ScriptC_export.const_ShaderParam_TRANSFORM_MODEL_VIEW;
- } else if(mParamName.equalsIgnoreCase(modelViewProj)) {
- paramType = ScriptC_export.const_ShaderParam_TRANSFORM_MODEL_VIEW_PROJ;
- }
- return paramType;
- }
-
- void initLocalData() {
- mData.type = getTypeFromName();
- if (mTransform != null) {
- mData.transform = mTransform.getRSData().getAllocation();
- }
- if (mCamera != null) {
- mData.camera = mCamera.getRSData().getAllocation();
- }
- if (mLight != null) {
- mData.light = mLight.getRSData().getAllocation();
- }
- }
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java
deleted file mode 100644
index 4efaff7..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/VertexShader.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.scenegraph;
-
-import java.lang.Math;
-import java.util.ArrayList;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class VertexShader extends Shader {
- ProgramVertex mProgram;
- ScriptField_VertexShader_s mField;
-
- public static class Builder {
- VertexShader mShader;
- ProgramVertex.Builder mBuilder;
-
- public Builder(RenderScriptGL rs) {
- mShader = new VertexShader();
- mBuilder = new ProgramVertex.Builder(rs);
- }
-
- public Builder setShader(Resources resources, int resourceID) {
- mBuilder.setShader(resources, resourceID);
- return this;
- }
-
- public Builder setShader(String code) {
- mBuilder.setShader(code);
- return this;
- }
-
- public Builder setObjectConst(Type type) {
- mShader.mPerObjConstants = type;
- return this;
- }
-
- public Builder setShaderConst(Type type) {
- mShader.mPerShaderConstants = type;
- return this;
- }
-
- public Builder addInput(Element e) {
- mBuilder.addInput(e);
- return this;
- }
-
- public VertexShader create() {
- if (mShader.mPerShaderConstants != null) {
- mBuilder.addConstant(mShader.mPerShaderConstants);
- }
- if (mShader.mPerObjConstants != null) {
- mBuilder.addConstant(mShader.mPerObjConstants);
- }
- mShader.mProgram = mBuilder.create();
- return mShader;
- }
- }
-
- public ProgramVertex getProgram() {
- return mProgram;
- }
-
- ScriptField_VertexShader_s getRSData() {
- if (mField != null) {
- return mField;
- }
-
- RenderScriptGL rs = SceneManager.getRS();
- Resources res = SceneManager.getRes();
- if (rs == null || res == null) {
- return null;
- }
-
- ScriptField_VertexShader_s.Item item = new ScriptField_VertexShader_s.Item();
- item.program = mProgram;
-
- linkConstants(rs);
- if (mPerShaderConstants != null) {
- item.shaderConst = mConstantBuffer;
- item.shaderConstParams = mConstantBufferParams.getAllocation();
- mProgram.bindConstants(item.shaderConst, 0);
- }
-
- item.objectConstIndex = -1;
- if (mPerObjConstants != null) {
- item.objectConstIndex = mPerShaderConstants != null ? 1 : 0;
- }
-
- mField = new ScriptField_VertexShader_s(rs, 1);
- mField.set(item, 0, true);
- return mField;
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs
deleted file mode 100644
index dc0a885..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/camera.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-//#define DEBUG_CAMERA
-#include "scenegraph_objects.rsh"
-
-void root(const rs_allocation *v_in, rs_allocation *v_out, const float *usrData) {
-
- SgCamera *cam = (SgCamera *)rsGetElementAt(*v_in, 0);
- float aspect = *usrData;
- if (cam->aspect != aspect) {
- cam->isDirty = 1;
- cam->aspect = aspect;
- }
- if (cam->isDirty) {
- rsMatrixLoadPerspective(&cam->proj, cam->horizontalFOV, cam->aspect, cam->near, cam->far);
- }
-
- const SgTransform *camTransform = (const SgTransform *)rsGetElementAt(cam->transformMatrix, 0);
- //rsDebug("Camera stamp", cam->transformTimestamp);
- //rsDebug("Transform stamp", camTransform->timestamp);
- if (camTransform->timestamp != cam->transformTimestamp || cam->isDirty) {
- cam->isDirty = 1;
- rs_matrix4x4 camPosMatrix;
- rsMatrixLoad(&camPosMatrix, &camTransform->globalMat);
- float4 zero = {0.0f, 0.0f, 0.0f, 1.0f};
- cam->position = rsMatrixMultiply(&camPosMatrix, zero);
-
- rsMatrixInverse(&camPosMatrix);
- rsMatrixLoad(&cam->view, &camPosMatrix);
-
- rsMatrixLoad(&cam->viewProj, &cam->proj);
- rsMatrixMultiply(&cam->viewProj, &cam->view);
-
- rsExtractFrustumPlanes(&cam->viewProj,
- &cam->frustumPlanes[0], &cam->frustumPlanes[1],
- &cam->frustumPlanes[2], &cam->frustumPlanes[3],
- &cam->frustumPlanes[3], &cam->frustumPlanes[4]);
- }
-
- if (cam->isDirty) {
- cam->timestamp ++;
- }
-
- cam->isDirty = 0;
- cam->transformTimestamp = camTransform->timestamp;
-
-#ifdef DEBUG_CAMERA
- printCameraInfo(cam);
-#endif //DEBUG_CAMERA
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs
deleted file mode 100644
index 024e026..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/cull.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#include "scenegraph_objects.rsh"
-
-static void getTransformedSphere(SgRenderable *obj) {
- obj->worldBoundingSphere = obj->boundingSphere;
- obj->worldBoundingSphere.w = 1.0f;
- const SgTransform *objTransform = (const SgTransform *)rsGetElementAt(obj->transformMatrix, 0);
- obj->worldBoundingSphere = rsMatrixMultiply(&objTransform->globalMat, obj->worldBoundingSphere);
-
- const float4 unitVec = {0.57735f, 0.57735f, 0.57735f, 0.0f};
- float4 scaledVec = rsMatrixMultiply(&objTransform->globalMat, unitVec);
- scaledVec.w = 0.0f;
- obj->worldBoundingSphere.w = obj->boundingSphere.w * length(scaledVec);
-}
-
-static bool frustumCulled(SgRenderable *obj, SgCamera *cam) {
- if (!obj->bVolInitialized) {
- float minX, minY, minZ, maxX, maxY, maxZ;
- rsgMeshComputeBoundingBox(obj->mesh,
- &minX, &minY, &minZ,
- &maxX, &maxY, &maxZ);
- //rsDebug("min", minX, minY, minZ);
- //rsDebug("max", maxX, maxY, maxZ);
- float4 sphere;
- sphere.x = (maxX + minX) * 0.5f;
- sphere.y = (maxY + minY) * 0.5f;
- sphere.z = (maxZ + minZ) * 0.5f;
- float3 radius;
- radius.x = (maxX - sphere.x);
- radius.y = (maxY - sphere.y);
- radius.z = (maxZ - sphere.z);
-
- sphere.w = length(radius);
- obj->boundingSphere = sphere;
- obj->bVolInitialized = 1;
- //rsDebug("Sphere", sphere);
- }
-
- getTransformedSphere(obj);
-
- return !rsIsSphereInFrustum(&obj->worldBoundingSphere,
- &cam->frustumPlanes[0], &cam->frustumPlanes[1],
- &cam->frustumPlanes[2], &cam->frustumPlanes[3],
- &cam->frustumPlanes[4], &cam->frustumPlanes[5]);
-}
-
-
-void root(rs_allocation *v_out, const void *usrData) {
-
- SgRenderable *drawable = (SgRenderable *)rsGetElementAt(*v_out, 0);
- const SgCamera *camera = (const SgCamera*)usrData;
-
- drawable->isVisible = 0;
- // Not loaded yet
- if (!rsIsObject(drawable->mesh) || drawable->cullType == CULL_ALWAYS) {
- return;
- }
-
- // check to see if we are culling this object and if it's
- // outside the frustum
- if (drawable->cullType == CULL_FRUSTUM && frustumCulled(drawable, (SgCamera*)camera)) {
-#ifdef DEBUG_RENDERABLES
- rsDebug("Culled", drawable);
- printName(drawable->name);
-#endif // DEBUG_RENDERABLES
- return;
- }
- drawable->isVisible = 1;
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs
deleted file mode 100644
index b438a43..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-// The sole purpose of this script is to have various structs exposed
-// so that java reflected classes are generated
-#include "scenegraph_objects.rsh"
-
-// Export our native constants to java so that we don't have parallel definitions
-const int ShaderParam_FLOAT4_DATA = SHADER_PARAM_FLOAT4_DATA;
-const int ShaderParam_TRANSFORM_DATA = SHADER_PARAM_TRANSFORM_DATA;
-const int ShaderParam_TRANSFORM_MODEL = SHADER_PARAM_TRANSFORM_MODEL;
-
-const int ShaderParam_FLOAT4_CAMERA_POS = SHADER_PARAM_FLOAT4_CAMERA_POS;
-const int ShaderParam_FLOAT4_CAMERA_DIR = SHADER_PARAM_FLOAT4_CAMERA_DIR;
-const int ShaderParam_TRANSFORM_VIEW = SHADER_PARAM_TRANSFORM_VIEW;
-const int ShaderParam_TRANSFORM_PROJ = SHADER_PARAM_TRANSFORM_PROJ;
-const int ShaderParam_TRANSFORM_VIEW_PROJ = SHADER_PARAM_TRANSFORM_VIEW_PROJ;
-const int ShaderParam_TRANSFORM_MODEL_VIEW = SHADER_PARAM_TRANSFORM_MODEL_VIEW;
-const int ShaderParam_TRANSFORM_MODEL_VIEW_PROJ = SHADER_PARAM_TRANSFORM_MODEL_VIEW_PROJ;
-
-const int ShaderParam_FLOAT4_LIGHT_COLOR = SHADER_PARAM_FLOAT4_LIGHT_COLOR;
-const int ShaderParam_FLOAT4_LIGHT_POS = SHADER_PARAM_FLOAT4_LIGHT_POS;
-const int ShaderParam_FLOAT4_LIGHT_DIR = SHADER_PARAM_FLOAT4_LIGHT_DIR;
-
-const int ShaderParam_TEXTURE = SHADER_PARAM_TEXTURE;
-
-const int Transform_TRANSLATE = TRANSFORM_TRANSLATE;
-const int Transform_ROTATE = TRANSFORM_ROTATE;
-const int Transform_SCALE = TRANSFORM_SCALE;
-
-const int TextureType_TEXTURE_2D = TEXTURE_2D;
-const int TextureType_TEXTURE_CUBE = TEXTURE_CUBE;
-const int TextureType_TEXTURE_RENDER_TARGET = TEXTURE_RENDER_TARGET;
-
-SgTransform *exportPtr;
-SgTransformComponent *componentPtr;
-SgRenderState *sExport;
-SgRenderable *drExport;
-SgRenderPass *pExport;
-SgCamera *exportPtrCam;
-SgLight *exportPtrLight;
-SgShaderParam *spExport;
-SgShaderParamData *spDataExport;
-SgVertexShader *pvExport;
-SgFragmentShader *pfExport;
-SgTexture *texExport;
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs
deleted file mode 100644
index 7202285..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/fragment_params.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#include "scenegraph_objects.rsh"
-
-//#define DEBUG_PARAMS
-
-#include "params.rsh"
-
-void root(rs_allocation *v_out, const void *usrData) {
- SgFragmentShader *shader = (SgFragmentShader *)rsGetElementAt(*v_out, 0);
- const SgCamera *camera = (const SgCamera*)usrData;
- processAllParams(shader->shaderConst, shader->shaderConstParams, camera);
- processTextureParams(shader);
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs
deleted file mode 100644
index e11979f..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/light.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-//#define DEBUG_LIGHT
-#include "scenegraph_objects.rsh"
-
-void root(const rs_allocation *v_in, rs_allocation *v_out) {
-
- SgLight *light = (SgLight *)rsGetElementAt(*v_in, 0);
- const SgTransform *lTransform = (const SgTransform *)rsGetElementAt(light->transformMatrix, 0);
-
- float4 zero = {0.0f, 0.0f, 0.0f, 1.0f};
- light->position = rsMatrixMultiply(&lTransform->globalMat, zero);
-
-#ifdef DEBUG_LIGHT
- printLightInfo(light);
-#endif //DEBUG_LIGHT
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs
deleted file mode 100644
index 0d524a6..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/object_params.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#include "scenegraph_objects.rsh"
-
-//#define DEBUG_PARAMS
-
-#include "params.rsh"
-
-void root(rs_allocation *v_out, const void *usrData) {
-
- SgRenderable *drawable = (SgRenderable *)rsGetElementAt(*v_out, 0);
- // Visibility flag was set earlier in the cull stage
- if (!drawable->isVisible) {
- return;
- }
-
- const SgCamera *camera = (const SgCamera*)usrData;
- processAllParams(drawable->pf_const, drawable->pf_constParams, camera);
- processAllParams(drawable->pv_const, drawable->pv_constParams, camera);
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh
deleted file mode 100644
index 00793c0..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rsh
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#include "scenegraph_objects.rsh"
-
-//#define DEBUG_PARAMS
-static inline void debugParam(SgShaderParam *p, SgShaderParamData *pData) {
- rsDebug("____________ Param ____________", p);
- printName(pData->paramName);
- rsDebug("bufferOffset", p->bufferOffset);
- rsDebug("type ", pData->type);
- rsDebug("data timestamp ", pData->timestamp);
- rsDebug("param timestamp", p->dataTimestamp);
-
- const SgTransform *pTransform = NULL;
- if (rsIsObject(pData->transform)) {
- pTransform = (const SgTransform *)rsGetElementAt(pData->transform, 0);
-
- rsDebug("transform", pTransform);
- printName(pTransform->name);
- rsDebug("timestamp", pTransform->timestamp);
- rsDebug("param timestamp", p->transformTimestamp);
- }
-
- const SgLight *pLight = NULL;
- if (rsIsObject(pData->light)) {
- pLight = (const SgLight *)rsGetElementAt(pData->light, 0);
- printLightInfo(pLight);
- }
-}
-
-static inline void writeFloatData(float *ptr, const float4 *input, uint32_t vecSize) {
-#ifdef DEBUG_PARAMS
- rsDebug("Writing value ", *input);
- rsDebug("Writing vec size ", vecSize);
-#endif // DEBUG_PARAMS
-
- switch (vecSize) {
- case 1:
- *ptr = input->x;
- break;
- case 2:
- *((float2*)ptr) = (*input).xy;
- break;
- case 3:
- *((float3*)ptr) = (*input).xyz;
- break;
- case 4:
- *((float4*)ptr) = *input;
- break;
- }
-}
-
-static inline bool processParam(SgShaderParam *p, SgShaderParamData *pData,
- uint8_t *constantBuffer,
- const SgCamera *currentCam,
- SgFragmentShader *shader) {
- bool isDataOnly = (pData->type > SHADER_PARAM_DATA_ONLY);
- const SgTransform *pTransform = NULL;
- if (rsIsObject(pData->transform)) {
- pTransform = (const SgTransform *)rsGetElementAt(pData->transform, 0);
- }
-
- if (isDataOnly) {
- // If we are a transform param and our transform is unchanged, nothing to do
- if (pTransform) {
- if (p->transformTimestamp == pTransform->timestamp) {
- return false;
- }
- p->transformTimestamp = pTransform->timestamp;
- } else {
- if (p->dataTimestamp == pData->timestamp) {
- return false;
- }
- p->dataTimestamp = pData->timestamp;
- }
- }
-
- const SgLight *pLight = NULL;
- if (rsIsObject(pData->light)) {
- pLight = (const SgLight *)rsGetElementAt(pData->light, 0);
- }
-
- uint8_t *dataPtr = NULL;
- const SgTexture *tex = NULL;
- if (pData->type == SHADER_PARAM_TEXTURE) {
- tex = rsGetElementAt(pData->texture, 0);
- } else {
- dataPtr = constantBuffer + p->bufferOffset;
- }
-
- switch (pData->type) {
- case SHADER_PARAM_TEXTURE:
- rsgBindTexture(shader->program, p->bufferOffset, tex->texture);
- break;
- case SHADER_PARAM_FLOAT4_DATA:
- writeFloatData((float*)dataPtr, &pData->float_value, p->float_vecSize);
- break;
- case SHADER_PARAM_FLOAT4_CAMERA_POS:
- writeFloatData((float*)dataPtr, ¤tCam->position, p->float_vecSize);
- break;
- case SHADER_PARAM_FLOAT4_CAMERA_DIR: break;
- case SHADER_PARAM_FLOAT4_LIGHT_COLOR:
- writeFloatData((float*)dataPtr, &pLight->color, p->float_vecSize);
- break;
- case SHADER_PARAM_FLOAT4_LIGHT_POS:
- writeFloatData((float*)dataPtr, &pLight->position, p->float_vecSize);
- break;
- case SHADER_PARAM_FLOAT4_LIGHT_DIR: break;
-
- case SHADER_PARAM_TRANSFORM_DATA:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &pTransform->globalMat);
- break;
- case SHADER_PARAM_TRANSFORM_VIEW:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, ¤tCam->view);
- break;
- case SHADER_PARAM_TRANSFORM_PROJ:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, ¤tCam->proj);
- break;
- case SHADER_PARAM_TRANSFORM_VIEW_PROJ:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, ¤tCam->viewProj);
- break;
- case SHADER_PARAM_TRANSFORM_MODEL:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &pTransform->globalMat);
- break;
- case SHADER_PARAM_TRANSFORM_MODEL_VIEW:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, ¤tCam->view);
- rsMatrixLoadMultiply((rs_matrix4x4*)dataPtr,
- (rs_matrix4x4*)dataPtr,
- &pTransform->globalMat);
- break;
- case SHADER_PARAM_TRANSFORM_MODEL_VIEW_PROJ:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, ¤tCam->viewProj);
- rsMatrixLoadMultiply((rs_matrix4x4*)dataPtr,
- (rs_matrix4x4*)dataPtr,
- &pTransform->globalMat);
- break;
- }
- return true;
-}
-
-static inline void processAllParams(rs_allocation shaderConst,
- rs_allocation allParams,
- const SgCamera *camera) {
- if (rsIsObject(shaderConst)) {
- uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(shaderConst, 0);
-
- int numParams = 0;
- if (rsIsObject(allParams)) {
- numParams = rsAllocationGetDimX(allParams);
- }
- bool updated = false;
- for (int i = 0; i < numParams; i ++) {
- SgShaderParam *current = (SgShaderParam*)rsGetElementAt(allParams, i);
- SgShaderParamData *currentData = (SgShaderParamData*)rsGetElementAt(current->data, 0);
-#ifdef DEBUG_PARAMS
- debugParam(current, currentData);
-#endif // DEBUG_PARAMS
- updated = processParam(current, currentData, constantBuffer, camera, NULL) || updated;
- }
- }
-}
-
-static inline void processTextureParams(SgFragmentShader *shader) {
- int numParams = 0;
- if (rsIsObject(shader->shaderTextureParams)) {
- numParams = rsAllocationGetDimX(shader->shaderTextureParams);
- }
- for (int i = 0; i < numParams; i ++) {
- SgShaderParam *current = (SgShaderParam*)rsGetElementAt(shader->shaderTextureParams, i);
- SgShaderParamData *currentData = (SgShaderParamData*)rsGetElementAt(current->data, 0);
-#ifdef DEBUG_PARAMS
- debugParam(current, currentData);
-#endif // DEBUG_PARAMS
- processParam(current, currentData, NULL, NULL, shader);
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs
deleted file mode 100644
index 205b2cb..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright (C) 2011-2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#include "rs_graphics.rsh"
-#include "scenegraph_objects.rsh"
-
-rs_script gTransformScript;
-rs_script gCameraScript;
-rs_script gLightScript;
-rs_script gObjectParamsScript;
-rs_script gFragmentParamsScript;
-rs_script gVertexParamsScript;
-rs_script gCullScript;
-
-SgTransform *gRootNode;
-rs_allocation gCameras;
-rs_allocation gLights;
-rs_allocation gFragmentShaders;
-rs_allocation gVertexShaders;
-rs_allocation gRenderableObjects;
-
-rs_allocation gRenderPasses;
-
-// Temporary shaders
-rs_program_store gPFSBackground;
-
-uint32_t *gFrontToBack;
-static uint32_t gFrontToBackCount = 0;
-uint32_t *gBackToFront;
-static uint32_t gBackToFrontCount = 0;
-
-static SgCamera *gActiveCamera = NULL;
-
-static rs_allocation nullAlloc;
-
-// #define DEBUG_RENDERABLES
-static void draw(SgRenderable *obj) {
-#ifdef DEBUG_RENDERABLES
- const SgTransform *objTransform = (const SgTransform *)rsGetElementAt(obj->transformMatrix, 0);
- rsDebug("**** Drawing object with transform", obj);
- printName(objTransform->name);
- rsDebug("Model matrix: ", &objTransform->globalMat);
- printName(obj->name);
-#endif //DEBUG_RENDERABLES
-
- const SgRenderState *renderState = (const SgRenderState *)rsGetElementAt(obj->render_state, 0);
- const SgVertexShader *pv = (const SgVertexShader *)rsGetElementAt(renderState->pv, 0);
- const SgFragmentShader *pf = (const SgFragmentShader *)rsGetElementAt(renderState->pf, 0);
-
- if (pv->objectConstIndex != -1) {
- rsgBindConstant(pv->program, pv->objectConstIndex, obj->pv_const);
- }
- if (pf->objectConstIndex != -1) {
- rsgBindConstant(pf->program, pf->objectConstIndex, obj->pf_const);
- }
-
- if (rsIsObject(renderState->ps)) {
- rsgBindProgramStore(renderState->ps);
- } else {
- rsgBindProgramStore(gPFSBackground);
- }
-
- if (rsIsObject(renderState->pr)) {
- rsgBindProgramRaster(renderState->pr);
- } else {
- rs_program_raster pr = {0};
- rsgBindProgramRaster(pr);
- }
-
- rsgBindProgramVertex(pv->program);
- rsgBindProgramFragment(pf->program);
-
- for (uint32_t i = 0; i < obj->pf_num_textures; i ++) {
- const SgTexture *tex = rsGetElementAt(obj->pf_textures[i], 0);
- rsgBindTexture(pf->program, i, tex->texture);
- }
-
- rsgDrawMesh(obj->mesh, obj->meshIndex);
-}
-
-static void sortToBucket(SgRenderable *obj) {
- const SgRenderState *renderState = (const SgRenderState *)rsGetElementAt(obj->render_state, 0);
- if (rsIsObject(renderState->ps)) {
- bool isOpaque = false;
- if (isOpaque) {
- gFrontToBack[gFrontToBackCount++] = (uint32_t)obj;
- } else {
- gBackToFront[gBackToFrontCount++] = (uint32_t)obj;
- }
- } else {
- gFrontToBack[gFrontToBackCount++] = (uint32_t)obj;
- }
-}
-
-static void updateActiveCamera(rs_allocation cam) {
- gActiveCamera = (SgCamera *)rsGetElementAt(cam, 0);
-}
-
-static void prepareCameras() {
- // now compute all the camera matrices
- if (rsIsObject(gCameras)) {
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsForEach(gCameraScript, gCameras, nullAlloc, &aspect, sizeof(aspect));
- }
-}
-
-static void prepareLights() {
- if (rsIsObject(gLights)) {
- rsForEach(gLightScript, gLights, nullAlloc);
- }
-}
-
-static void drawSorted() {
- for (int i = 0; i < gFrontToBackCount; i ++) {
- SgRenderable *current = (SgRenderable*)gFrontToBack[i];
- draw(current);
- }
-
- for (int i = 0; i < gBackToFrontCount; i ++) {
- SgRenderable *current = (SgRenderable*)gBackToFront[i];
- draw(current);
- }
-}
-
-static void drawAllObjects(rs_allocation allObj) {
- if (!rsIsObject(allObj)) {
- return;
- }
-
- if (rsIsObject(gVertexShaders)) {
- rsForEach(gVertexParamsScript, nullAlloc, gVertexShaders,
- gActiveCamera, sizeof(gActiveCamera));
- }
- if (rsIsObject(gFragmentShaders)) {
- rsForEach(gFragmentParamsScript, nullAlloc, gFragmentShaders,
- gActiveCamera, sizeof(gActiveCamera));
- }
-
- // Run the params and cull script
- rsForEach(gCullScript, nullAlloc, allObj, gActiveCamera, sizeof(gActiveCamera));
- rsForEach(gObjectParamsScript, nullAlloc, allObj, gActiveCamera, sizeof(gActiveCamera));
-
- int numRenderables = rsAllocationGetDimX(allObj);
- for (int i = 0; i < numRenderables; i ++) {
- rs_allocation *drawAlloc = (rs_allocation*)rsGetElementAt(allObj, i);
- SgRenderable *current = (SgRenderable*)rsGetElementAt(*drawAlloc, 0);
- if (current->isVisible) {
- sortToBucket(current);
- }
- }
- drawSorted();
-}
-
-int root(void) {
-#ifdef DEBUG_RENDERABLES
- rsDebug("=============================================================================", 0);
-#endif // DEBUG_RENDERABLES
-
- // first step is to update the transform hierachy
- if (gRootNode && rsIsObject(gRootNode->children)) {
- rsForEach(gTransformScript, gRootNode->children, nullAlloc, 0, 0);
- }
-
- prepareCameras();
- prepareLights();
-
- if (rsIsObject(gRenderPasses)) {
- rsgClearDepth(1.0f);
- int numPasses = rsAllocationGetDimX(gRenderPasses);
- for (uint i = 0; i < numPasses; i ++) {
- gFrontToBackCount = 0;
- gBackToFrontCount = 0;
- SgRenderPass *pass = (SgRenderPass*)rsGetElementAt(gRenderPasses, i);
- if (rsIsObject(pass->color_target)) {
- rsgBindColorTarget(pass->color_target, 0);
- }
- if (rsIsObject(pass->depth_target)) {
- rsgBindDepthTarget(pass->depth_target);
- }
- if (!rsIsObject(pass->color_target) &&
- !rsIsObject(pass->depth_target)) {
- rsgClearAllRenderTargets();
- }
- updateActiveCamera(pass->camera);
- if (pass->should_clear_color) {
- rsgClearColor(pass->clear_color.x, pass->clear_color.y,
- pass->clear_color.z, pass->clear_color.w);
- }
- if (pass->should_clear_depth) {
- rsgClearDepth(pass->clear_depth);
- }
- drawAllObjects(pass->objects);
- }
- } else {
- gFrontToBackCount = 0;
- gBackToFrontCount = 0;
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
-
- if (rsIsObject(gCameras)) {
- rs_allocation *camAlloc = (rs_allocation*)rsGetElementAt(gCameras, 0);
- updateActiveCamera(*camAlloc);
- }
- drawAllObjects(gRenderableObjects);
- }
- return 10;
-}
-
-// Search through sorted and culled objects
-void pick(int screenX, int screenY) {
- float3 pnt, vec;
- getCameraRay(gActiveCamera, screenX, screenY, &pnt, &vec);
-
- for (int i = 0; i < gFrontToBackCount; i ++) {
- SgRenderable *current = (SgRenderable*)gFrontToBack[i];
- bool isPicked = intersect(current, pnt, vec);
- if (isPicked) {
- current->cullType = CULL_ALWAYS;
- }
- }
-
- for (int i = 0; i < gBackToFrontCount; i ++) {
- SgRenderable *current = (SgRenderable*)gBackToFront[i];
- bool isPicked = intersect(current, pnt, vec);
- if (isPicked) {
- current->cullType = CULL_ALWAYS;
- }
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph_objects.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph_objects.rsh
deleted file mode 100644
index 90ae212..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/scenegraph_objects.rsh
+++ /dev/null
@@ -1,323 +0,0 @@
-// Copyright (C) 2011-2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#ifndef _TRANSFORM_DEF_
-#define _TRANSFORM_DEF_
-
-#include "rs_graphics.rsh"
-
-#define TRANSFORM_NONE 0
-#define TRANSFORM_TRANSLATE 1
-#define TRANSFORM_ROTATE 2
-#define TRANSFORM_SCALE 3
-
-#define CULL_FRUSTUM 0
-#define CULL_ALWAYS 2
-
-#define LIGHT_POINT 0
-#define LIGHT_DIRECTIONAL 1
-
-// Shader params that involve only data
-#define SHADER_PARAM_DATA_ONLY 10000
-#define SHADER_PARAM_FLOAT4_DATA 10001
-#define SHADER_PARAM_TRANSFORM_DATA 10002
-#define SHADER_PARAM_TRANSFORM_MODEL 10003
-
-// Shader params that involve camera
-#define SHADER_PARAM_CAMERA 1000
-#define SHADER_PARAM_FLOAT4_CAMERA_POS 1001
-#define SHADER_PARAM_FLOAT4_CAMERA_DIR 1002
-#define SHADER_PARAM_TRANSFORM_VIEW 1003
-#define SHADER_PARAM_TRANSFORM_PROJ 1004
-#define SHADER_PARAM_TRANSFORM_VIEW_PROJ 1005
-#define SHADER_PARAM_TRANSFORM_MODEL_VIEW 1006
-#define SHADER_PARAM_TRANSFORM_MODEL_VIEW_PROJ 1007
-
-// Shader Params that only involve lights
-#define SHADER_PARAM_LIGHT 100
-#define SHADER_PARAM_FLOAT4_LIGHT_COLOR 103
-#define SHADER_PARAM_FLOAT4_LIGHT_POS 104
-#define SHADER_PARAM_FLOAT4_LIGHT_DIR 105
-
-#define SHADER_PARAM_TEXTURE 10
-
-#define TEXTURE_NONE 0
-#define TEXTURE_2D 1
-#define TEXTURE_CUBE 2
-#define TEXTURE_RENDER_TARGET 3
-
-typedef struct TransformComponent_s {
- float4 value;
- int type;
- rs_allocation name;
-} SgTransformComponent;
-
-typedef struct __attribute__((packed, aligned(4))) SgTransform {
- rs_matrix4x4 globalMat;
- rs_matrix4x4 localMat;
-
- rs_allocation components;
- int isDirty;
-
- rs_allocation children;
- rs_allocation name;
-
- // Used to check whether transform params need to be updated
- uint32_t timestamp;
-} SgTransform;
-
-typedef struct VertexShader_s {
- rs_program_vertex program;
- // Buffer with vertex constant data
- rs_allocation shaderConst;
- // ShaderParam's that populate data
- rs_allocation shaderConstParams;
- // location of the per object constants on the buffer
- int objectConstIndex;
-} SgVertexShader;
-
-typedef struct FragmentShader_s {
- rs_program_fragment program;
- // Buffer with vertex constant data
- rs_allocation shaderConst;
- // ShaderParam's that populate data
- rs_allocation shaderConstParams;
- // ShaderParam's that set textures
- rs_allocation shaderTextureParams;
- // location of the per object constants on the buffer
- int objectConstIndex;
-} SgFragmentShader;
-
-typedef struct RenderState_s {
- rs_allocation pv; // VertexShader struct
- rs_allocation pf; // FragmentShader struct
- rs_program_store ps;
- rs_program_raster pr;
-} SgRenderState;
-
-typedef struct Renderable_s {
- rs_allocation render_state;
- // Buffer with vertex constant data
- rs_allocation pv_const;
- // ShaderParam's that populate data
- rs_allocation pv_constParams;
- // Buffer with fragment constant data
- rs_allocation pf_const;
- // ShaderParam's that populate data
- rs_allocation pf_constParams;
- rs_allocation pf_textures[8];
- int pf_num_textures;
- rs_mesh mesh;
- int meshIndex;
- rs_allocation transformMatrix;
- rs_allocation name;
- float4 boundingSphere;
- float4 worldBoundingSphere;
- int bVolInitialized;
- int cullType; // specifies whether to frustum cull
- int isVisible;
-} SgRenderable;
-
-typedef struct RenderPass_s {
- rs_allocation color_target;
- rs_allocation depth_target;
- rs_allocation camera;
- rs_allocation objects;
-
- float4 clear_color;
- float clear_depth;
- bool should_clear_color;
- bool should_clear_depth;
-} SgRenderPass;
-
-typedef struct Camera_s {
- rs_matrix4x4 proj;
- rs_matrix4x4 view;
- rs_matrix4x4 viewProj;
- float4 position;
- float near;
- float far;
- float horizontalFOV;
- float aspect;
- rs_allocation name;
- rs_allocation transformMatrix;
- float4 frustumPlanes[6];
-
- int isDirty;
- // Timestamp of the camera itself to signal params if anything changes
- uint32_t timestamp;
- // Timestamp of our transform
- uint32_t transformTimestamp;
-} SgCamera;
-
-typedef struct Light_s {
- float4 position;
- float4 color;
- float intensity;
- int type;
- rs_allocation name;
- rs_allocation transformMatrix;
-} SgLight;
-
-// This represents the shader parameter data needed to set a float or transform data
-typedef struct ShaderParamData_s {
- int type;
- float4 float_value;
- uint32_t timestamp;
- rs_allocation paramName;
- rs_allocation camera;
- rs_allocation light;
- rs_allocation transform;
- rs_allocation texture;
-} SgShaderParamData;
-
-// This represents a shader parameter that knows how to update itself for a given
-// renderable or shader and contains a timestamp for the last time this buffer was updated
-typedef struct ShaderParam_s {
- // Used to check whether transform params need to be updated
- uint32_t transformTimestamp;
- // Used to check whether data params need to be updated
- // These are used when somebody set the matrix of float value directly in java
- uint32_t dataTimestamp;
- // Specifies where in the constant buffer data gets written to
- int bufferOffset;
- // An instance of SgShaderParamData that could be shared by multiple objects
- rs_allocation data;
- // How many components of the vector we need to write
- int float_vecSize;
-} SgShaderParam;
-
-// This represents a texture object
-typedef struct Texture_s {
- uint32_t type;
- rs_allocation texture;
-} SgTexture;
-
-static inline void printName(rs_allocation name) {
- if (!rsIsObject(name)) {
- rsDebug("no name", 0);
- return;
- }
-
- rsDebug((const char*)rsGetElementAt(name, 0), 0);
-}
-
-static inline void printCameraInfo(const SgCamera *cam) {
- rsDebug("***** Camera information. ptr:", cam);
- printName(cam->name);
- const SgTransform *camTransform = (const SgTransform *)rsGetElementAt(cam->transformMatrix, 0);
- rsDebug("Transform name:", camTransform);
- printName(camTransform->name);
-
- rsDebug("Aspect: ", cam->aspect);
- rsDebug("Near: ", cam->near);
- rsDebug("Far: ", cam->far);
- rsDebug("Fov: ", cam->horizontalFOV);
- rsDebug("Position: ", cam->position);
- rsDebug("Proj: ", &cam->proj);
- rsDebug("View: ", &cam->view);
-}
-
-static inline void printLightInfo(const SgLight *light) {
- rsDebug("***** Light information. ptr:", light);
- printName(light->name);
- const SgTransform *lTransform = (const SgTransform *)rsGetElementAt(light->transformMatrix, 0);
- rsDebug("Transform name:", lTransform);
- printName(lTransform->name);
-
- rsDebug("Position: ", light->position);
- rsDebug("Color : ", light->color);
- rsDebug("Intensity: ", light->intensity);
- rsDebug("Type: ", light->type);
-}
-
-static inline void getCameraRay(const SgCamera *cam, int screenX, int screenY, float3 *pnt, float3 *vec) {
- rsDebug("=================================", screenX);
- rsDebug("Point X", screenX);
- rsDebug("Point Y", screenY);
-
- rs_matrix4x4 mvpInv;
- rsMatrixLoad(&mvpInv, &cam->viewProj);
- rsMatrixInverse(&mvpInv);
-
- float width = (float)rsgGetWidth();
- float height = (float)rsgGetHeight();
-
- float4 pos = {(float)screenX, height - (float)screenY, 0.0f, 1.0f};
-
- pos.x /= width;
- pos.y /= height;
-
- rsDebug("Pre Norm X", pos.x);
- rsDebug("Pre Norm Y", pos.y);
-
- pos.xy = pos.xy * 2.0f - 1.0f;
-
- rsDebug("Norm X", pos.x);
- rsDebug("Norm Y", pos.y);
-
- pos = rsMatrixMultiply(&mvpInv, pos);
- float oneOverW = 1.0f / pos.w;
- pos.xyz *= oneOverW;
-
- rsDebug("World X", pos.x);
- rsDebug("World Y", pos.y);
- rsDebug("World Z", pos.z);
-
- rsDebug("Cam X", cam->position.x);
- rsDebug("Cam Y", cam->position.y);
- rsDebug("Cam Z", cam->position.z);
-
- *vec = normalize(pos.xyz - cam->position.xyz);
- rsDebug("Vec X", vec->x);
- rsDebug("Vec Y", vec->y);
- rsDebug("Vec Z", vec->z);
- *pnt = cam->position.xyz;
-}
-
-static inline bool intersect(const SgRenderable *obj, float3 pnt, float3 vec) {
- // Solving for t^2 + Bt + C = 0
- float3 originMinusCenter = pnt - obj->worldBoundingSphere.xyz;
- float B = dot(originMinusCenter, vec) * 2.0f;
- float C = dot(originMinusCenter, originMinusCenter) -
- obj->worldBoundingSphere.w * obj->worldBoundingSphere.w;
-
- float discriminant = B * B - 4.0f * C;
- if (discriminant < 0.0f) {
- return false;
- }
- discriminant = sqrt(discriminant);
-
- float t0 = (-B - discriminant) * 0.5f;
- float t1 = (-B + discriminant) * 0.5f;
-
- if (t0 > t1) {
- float temp = t0;
- t0 = t1;
- t1 = temp;
- }
-
- // The sphere is behind us
- if (t1 < 0.0f) {
- return false;
- }
- return true;
-}
-
-
-#endif // _TRANSFORM_DEF_
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs
deleted file mode 100644
index 1d0b5be..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/transform.rs
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.modelviewer)
-
-#include "scenegraph_objects.rsh"
-
-rs_script gTransformScript;
-
-typedef struct {
- int changed;
- rs_matrix4x4 *mat;
-} ParentData;
-
-//#define DEBUG_TRANSFORMS
-/* Unused function:
-static void debugTransform(SgTransform *data, const ParentData *parent) {
- rsDebug("****** <Transform> ******", (int)data);
- printName(data->name);
- rsDebug("isDirty", data->isDirty);
- rsDebug("parent", (int)parent);
- rsDebug("child ", rsIsObject(data->children));
-
- // Refresh matrices if dirty
- if (data->isDirty && rsIsObject(data->components)) {
- uint32_t numComponenets = rsAllocationGetDimX(data->components);
- for (int i = 0; i < numComponenets; i ++) {
- const SgTransformComponent *comp = NULL;
- comp = (const SgTransformComponent *)rsGetElementAt(data->components, i);
-
- if (rsIsObject(comp->name)) {
- rsDebug((const char*)rsGetElementAt(comp->name, 0), comp->value);
- rsDebug("Type", comp->type);
- } else {
- rsDebug("no name", comp->value);
- rsDebug("Type", comp->type);
- }
- }
- }
-
- rsDebug("timestamp", data->timestamp);
- rsDebug("****** </Transform> ******", (int)data);
-}
-*/
-
-static void appendTransformation(int type, float4 data, rs_matrix4x4 *mat) {
- rs_matrix4x4 temp;
-
- switch (type) {
- case TRANSFORM_TRANSLATE:
- rsMatrixLoadTranslate(&temp, data.x, data.y, data.z);
- break;
- case TRANSFORM_ROTATE:
- rsMatrixLoadRotate(&temp, data.w, data.x, data.y, data.z);
- break;
- case TRANSFORM_SCALE:
- rsMatrixLoadScale(&temp, data.x, data.y, data.z);
- break;
- }
- rsMatrixMultiply(mat, &temp);
-}
-
-void root(const rs_allocation *v_in, rs_allocation *v_out, const void *usrData) {
-
- SgTransform *data = (SgTransform *)rsGetElementAt(*v_in, 0);
- const ParentData *parent = (const ParentData *)usrData;
-
-#ifdef DEBUG_TRANSFORMS
- debugTransform(data, parent);
-#endif //DEBUG_TRANSFORMS
-
- rs_matrix4x4 *localMat = &data->localMat;
- rs_matrix4x4 *globalMat = &data->globalMat;
-
- // Refresh matrices if dirty
- if (data->isDirty && rsIsObject(data->components)) {
- bool resetLocal = false;
- uint32_t numComponenets = rsAllocationGetDimX(data->components);
- for (int i = 0; i < numComponenets; i ++) {
- if (!resetLocal) {
- // Reset our local matrix only for component transforms
- rsMatrixLoadIdentity(localMat);
- resetLocal = true;
- }
- const SgTransformComponent *comp = NULL;
- comp = (const SgTransformComponent *)rsGetElementAt(data->components, i);
- appendTransformation(comp->type, comp->value, localMat);
- }
- }
-
- if (parent) {
- data->isDirty = (parent->changed || data->isDirty) ? 1 : 0;
- if (data->isDirty) {
- rsMatrixLoad(globalMat, parent->mat);
- rsMatrixMultiply(globalMat, localMat);
- }
- } else if (data->isDirty) {
- rsMatrixLoad(globalMat, localMat);
- }
-
- ParentData toChild;
- toChild.changed = 0;
- toChild.mat = globalMat;
-
- if (data->isDirty) {
- toChild.changed = 1;
- data->timestamp ++;
- }
-
- if (rsIsObject(data->children)) {
- rs_allocation nullAlloc = {0};
- rsForEach(gTransformScript, data->children, nullAlloc, &toChild, sizeof(toChild));
- }
-
- data->isDirty = 0;
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs
deleted file mode 100644
index 88955a8..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/vertex_params.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.scenegraph)
-
-#include "scenegraph_objects.rsh"
-
-//#define DEBUG_PARAMS
-
-#include "params.rsh"
-
-void root(rs_allocation *v_out, const void *usrData) {
- SgVertexShader *shader = (SgVertexShader *)rsGetElementAt(*v_out, 0);
- const SgCamera *camera = (const SgCamera*)usrData;
- processAllParams(shader->shaderConst, shader->shaderConstParams, camera);
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FileSelector.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FileSelector.java
deleted file mode 100644
index 420e133..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FileSelector.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-/**
- * A list view where the last item the user clicked is placed in
- * the "activated" state, causing its background to highlight.
- */
-public class FileSelector extends ListActivity {
-
- File[] mCurrentSubList;
- File mCurrentFile;
-
- class DAEFilter implements FileFilter {
- public boolean accept(File file) {
- if (file.isDirectory()) {
- return true;
- }
- return file.getName().endsWith(".dae");
- }
- }
-
- private void populateList(File file) {
-
- mCurrentFile = file;
- setTitle(mCurrentFile.getAbsolutePath() + "/*.dae");
- List<String> names = new ArrayList<String>();
- names.add("..");
-
- mCurrentSubList = mCurrentFile.listFiles(new DAEFilter());
-
- if (mCurrentSubList != null) {
- for (int i = 0; i < mCurrentSubList.length; i ++) {
- String fileName = mCurrentSubList[i].getName();
- if (mCurrentSubList[i].isDirectory()) {
- fileName = "/" + fileName;
- }
- names.add(fileName);
- }
- }
-
- // Use the built-in layout for showing a list item with a single
- // line of text whose background is changes when activated.
- setListAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_activated_1, names));
- getListView().setTextFilterEnabled(true);
-
- // Tell the list view to show one checked/activated item at a time.
- getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- populateList(new File("/sdcard/"));
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- if (position == 0) {
- File parent = mCurrentFile.getParentFile();
- if (parent == null) {
- return;
- }
- populateList(parent);
- return;
- }
-
- // the first thing in list is parent directory
- File selectedFile = mCurrentSubList[position - 1];
- if (selectedFile.isDirectory()) {
- populateList(selectedFile);
- return;
- }
-
- Intent resultIntent = new Intent();
- resultIntent.setData(Uri.fromFile(selectedFile));
- setResult(RESULT_OK, resultIntent);
- finish();
- }
-
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FullscreenBlur.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FullscreenBlur.java
deleted file mode 100644
index 28f916c..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/FullscreenBlur.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package com.android.testapp;
-
-import java.util.ArrayList;
-
-import com.android.scenegraph.*;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Element.Builder;
-import android.renderscript.Font.Style;
-import android.renderscript.Program.TextureType;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-
-class FullscreenBlur {
-
- static TextureRenderTarget sRenderTargetBlur0Color;
- static TextureRenderTarget sRenderTargetBlur0Depth;
- static TextureRenderTarget sRenderTargetBlur1Color;
- static TextureRenderTarget sRenderTargetBlur1Depth;
- static TextureRenderTarget sRenderTargetBlur2Color;
- static TextureRenderTarget sRenderTargetBlur2Depth;
-
- static FragmentShader mPF_BlurH;
- static FragmentShader mPF_BlurV;
- static FragmentShader mPF_SelectColor;
- static FragmentShader mPF_Texture;
- static VertexShader mPV_Paint;
- static VertexShader mPV_Blur;
-
- static int targetWidth;
- static int targetHeight;
-
- // This is only used when full screen blur is enabled
- // Basically, it's the offscreen render targets
- static void createRenderTargets(RenderScriptGL rs, int w, int h) {
- targetWidth = w/8;
- targetHeight = h/8;
- Type.Builder b = new Type.Builder(rs, Element.RGBA_8888(rs));
- Type renderType = b.setX(targetWidth).setY(targetHeight).create();
- int usage = Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_GRAPHICS_RENDER_TARGET;
- sRenderTargetBlur0Color = new TextureRenderTarget(Allocation.createTyped(rs, renderType, usage));
- sRenderTargetBlur1Color = new TextureRenderTarget(Allocation.createTyped(rs, renderType, usage));
- sRenderTargetBlur2Color = new TextureRenderTarget(Allocation.createTyped(rs, renderType, usage));
-
- b = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_16,
- Element.DataKind.PIXEL_DEPTH));
- renderType = b.setX(targetWidth).setY(targetHeight).create();
- usage = Allocation.USAGE_GRAPHICS_RENDER_TARGET;
- sRenderTargetBlur0Depth = new TextureRenderTarget(Allocation.createTyped(rs, renderType, usage));
- sRenderTargetBlur1Depth = new TextureRenderTarget(Allocation.createTyped(rs, renderType, usage));
- sRenderTargetBlur2Depth = new TextureRenderTarget(Allocation.createTyped(rs, renderType, usage));
- }
-
- static void addOffsets(Renderable quad, float advance) {
- quad.appendSourceParams(new Float4Param("blurOffset0", - advance * 2.5f));
- quad.appendSourceParams(new Float4Param("blurOffset1", - advance * 0.5f));
- quad.appendSourceParams(new Float4Param("blurOffset2", advance * 1.5f));
- quad.appendSourceParams(new Float4Param("blurOffset3", advance * 3.5f));
- }
-
- static RenderPass addPass(Scene scene, Camera cam, TextureRenderTarget color, TextureRenderTarget depth) {
- RenderPass pass = new RenderPass();
- pass.setColorTarget(color);
- pass.setDepthTarget(depth);
- pass.setShouldClearColor(false);
- pass.setShouldClearDepth(false);
- pass.setCamera(cam);
- scene.appendRenderPass(pass);
- return pass;
- }
-
- static void addBlurPasses(Scene scene, RenderScriptGL rs, Camera cam) {
- SceneManager sceneManager = SceneManager.getInstance();
- ArrayList<RenderableBase> allDraw = scene.getRenderables();
- int numDraw = allDraw.size();
-
- ProgramRaster cullNone = ProgramRaster.CULL_NONE(rs);
- ProgramStore blendAdd = SceneManager.BLEND_ADD_DEPTH_NONE(rs);
- ProgramStore blendNone = ProgramStore.BLEND_NONE_DEPTH_NONE(rs);
-
- RenderState drawTex = new RenderState(mPV_Blur, mPF_Texture, blendAdd, cullNone);
- RenderState selectCol = new RenderState(mPV_Blur, mPF_SelectColor, blendNone, cullNone);
- RenderState hBlur = new RenderState(mPV_Blur, mPF_BlurH, blendNone, cullNone);
- RenderState vBlur = new RenderState(mPV_Blur, mPF_BlurV, blendNone, cullNone);
-
- // Renders the scene off screen
- RenderPass blurSourcePass = addPass(scene, cam,
- sRenderTargetBlur0Color,
- sRenderTargetBlur0Depth);
- blurSourcePass.setClearColor(new Float4(1.0f, 1.0f, 1.0f, 1.0f));
- blurSourcePass.setShouldClearColor(true);
- blurSourcePass.setClearDepth(1.0f);
- blurSourcePass.setShouldClearDepth(true);
- for (int i = 0; i < numDraw; i ++) {
- blurSourcePass.appendRenderable((Renderable)allDraw.get(i));
- }
-
- // Pass for selecting bright colors
- RenderPass selectColorPass = addPass(scene, cam,
- sRenderTargetBlur2Color,
- sRenderTargetBlur2Depth);
- Renderable quad = sceneManager.getRenderableQuad("ScreenAlignedQuadS", selectCol);
- quad.appendSourceParams(new TextureParam("color", sRenderTargetBlur0Color));
- selectColorPass.appendRenderable(quad);
-
- // Horizontal blur
- RenderPass horizontalBlurPass = addPass(scene, cam,
- sRenderTargetBlur1Color,
- sRenderTargetBlur1Depth);
- quad = sceneManager.getRenderableQuad("ScreenAlignedQuadH", hBlur);
- quad.appendSourceParams(new TextureParam("color", sRenderTargetBlur2Color));
- addOffsets(quad, 1.0f / (float)targetWidth);
- horizontalBlurPass.appendRenderable(quad);
-
- // Vertical Blur
- RenderPass verticalBlurPass = addPass(scene, cam,
- sRenderTargetBlur2Color,
- sRenderTargetBlur2Depth);
- quad = sceneManager.getRenderableQuad("ScreenAlignedQuadV", vBlur);
- quad.appendSourceParams(new TextureParam("color", sRenderTargetBlur1Color));
- addOffsets(quad, 1.0f / (float)targetHeight);
- verticalBlurPass.appendRenderable(quad);
- }
-
- // Additively renders the blurred colors on top of the scene
- static void addCompositePass(Scene scene, RenderScriptGL rs, Camera cam) {
- SceneManager sceneManager = SceneManager.getInstance();
- RenderState drawTex = new RenderState(mPV_Blur, mPF_Texture,
- SceneManager.BLEND_ADD_DEPTH_NONE(rs),
- ProgramRaster.CULL_NONE(rs));
-
- RenderPass compositePass = addPass(scene, cam, null, null);
- Renderable quad = sceneManager.getRenderableQuad("ScreenAlignedQuadComposite", drawTex);
- quad.appendSourceParams(new TextureParam("color", sRenderTargetBlur2Color));
- compositePass.appendRenderable(quad);
- }
-
- static private FragmentShader getShader(Resources res, RenderScriptGL rs,
- int resID, Type constants) {
- FragmentShader.Builder fb = new FragmentShader.Builder(rs);
- fb.setShader(res, resID);
- fb.addTexture(TextureType.TEXTURE_2D, "color");
- if (constants != null) {
- fb.setObjectConst(constants);
- }
- FragmentShader prog = fb.create();
- prog.getProgram().bindSampler(Sampler.CLAMP_LINEAR(rs), 0);
- return prog;
- }
-
- static void initShaders(Resources res, RenderScriptGL rs) {
- ScriptField_BlurOffsets blurConst = new ScriptField_BlurOffsets(rs, 1);
- VertexShader.Builder vb = new VertexShader.Builder(rs);
- vb.addInput(ScriptField_VertexShaderInputs.createElement(rs));
- vb.setShader(res, R.raw.blur_vertex);
- mPV_Blur = vb.create();
-
- mPF_Texture = getShader(res, rs, R.raw.texture, null);
- mPF_Texture.getProgram().bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(rs), 0);
- mPF_BlurH = getShader(res, rs, R.raw.blur_h, blurConst.getAllocation().getType());
- mPF_BlurV = getShader(res, rs, R.raw.blur_v, blurConst.getAllocation().getType());
- mPF_SelectColor = getShader(res, rs, R.raw.select_color, null);
- }
-
-}
-
-
-
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleApp.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleApp.java
deleted file mode 100644
index 314db80..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleApp.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.Window;
-import android.view.Window;
-import android.net.Uri;
-
-import java.lang.Runtime;
-
-public class SimpleApp extends Activity {
-
- private SimpleAppView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new SimpleAppView(this);
- setContentView(mView);
- }
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppRS.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppRS.java
deleted file mode 100644
index fff6f34..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppRS.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-import com.android.scenegraph.*;
-import com.android.scenegraph.SceneManager.SceneLoadedCallback;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Program.TextureType;
-import android.util.Log;
-
-// This is where the scenegraph and the rendered objects are initialized and used
-public class SimpleAppRS {
- SceneManager mSceneManager;
-
- RenderScriptGL mRS;
- Resources mRes;
-
- Scene mScene;
- Mesh mSimpleMesh;
- Mesh mSphereMesh;
- Mesh mCubeMesh;
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mRS = rs;
- mRes = res;
- mSceneManager = SceneManager.getInstance();
- mSceneManager.initRS(mRS, mRes, width, height);
-
- mScene = new Scene();
-
- setupGeometry();
- setupColoredQuad();
- setupTexturedQuad();
- setupShadedGeometry();
- setupCamera();
- setupRenderPass();
-
- mSceneManager.setActiveScene(mScene);
-
- mScene.initRS();
- mRS.bindRootScript(mSceneManager.getRenderLoop());
- }
-
- private void setupGeometry() {
- Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS, 3,
- Mesh.TriangleMeshBuilder.TEXTURE_0);
-
- // Create four vertices with texture coordinates
- tmb.setTexture(0.0f, 1.0f).addVertex(-1.0f, 1.0f, 0.0f);
- tmb.setTexture(0.0f, 0.0f).addVertex(-1.0f, -1.0f, 0.0f);
- tmb.setTexture(1.0f, 0.0f).addVertex(1.0f, -1.0f, 0.0f);
- tmb.setTexture(1.0f, 1.0f).addVertex(1.0f, 1.0f, 0.0f);
-
- tmb.addTriangle(0, 1, 2);
- tmb.addTriangle(2, 3, 0);
- mSimpleMesh = tmb.create(true);
-
- // Load a file that constains two pieces of geometry, a sphere and a cube
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.unit_obj);
- for (int i = 0; i < model.getIndexEntryCount(); i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getName().equals("CubeMesh")) {
- mCubeMesh = entry.getMesh();
- } else if (entry != null && entry.getName().equals("SphereMesh")) {
- mSphereMesh = entry.getMesh();
- }
- }
- }
-
- private void setupColoredQuad() {
- // Built-in shader that provides position, texcoord and normal
- VertexShader genericV = SceneManager.getDefaultVS();
- // Built-in shader that displays a color
- FragmentShader colorF = SceneManager.getColorFS();
- RenderState colorRS = new RenderState(genericV, colorF, null, null);
-
- // Draw a simple colored quad
- Renderable quad = mScene.appendNewRenderable();
- quad.setMesh(mSimpleMesh);
- // Our shader has a constant input called "color"
- // This tells the scenegraph to assign the following float3 to that input
- quad.appendSourceParams(new Float4Param("color", 0.2f, 0.3f, 0.4f));
- quad.setRenderState(colorRS);
- }
-
- private void setupTexturedQuad() {
- // Built-in shader that provides position, texcoord and normal
- VertexShader genericV = SceneManager.getDefaultVS();
- // Built-in shader that displays a texture
- FragmentShader textureF = SceneManager.getTextureFS();
- // We want to use transparency based on the alpha channel of the texture
- ProgramStore alphaBlend = ProgramStore.BLEND_ALPHA_DEPTH_TEST(mRS);
- RenderState texRS = new RenderState(genericV, textureF, alphaBlend, null);
-
- // Draw a textured quad
- Renderable quad = mScene.appendNewRenderable();
- quad.setMesh(mSimpleMesh);
- // Make a transform to position the quad
- CompoundTransform t = mScene.appendNewCompoundTransform();
- t.addTranslate("position", new Float3(2, 2, 0));
- quad.setTransform(t);
- // Our fragment shader has a constant texture input called "color"
- // This will assign an icon from drawables to that input
- quad.appendSourceParams(new TextureParam("color", new Texture2D(R.drawable.icon)));
- quad.setRenderState(texRS);
- }
-
- private FragmentShader createLambertShader() {
- // Describe what constant inputs our shader wants
- Element.Builder b = new Element.Builder(mRS);
- b.add(Element.F32_4(mRS), "cameraPos");
-
- // Create a shader from a text file in resources
- FragmentShader.Builder fb = new FragmentShader.Builder(mRS);
- // Tell the shader what constants we want
- fb.setShaderConst(new Type.Builder(mRS, b.create()).setX(1).create());
- // Shader code location
- fb.setShader(mRes, R.raw.diffuse);
- // We want a texture called diffuse on our shader
- fb.addTexture(TextureType.TEXTURE_2D, "diffuse");
- FragmentShader shader = fb.create();
- mScene.appendShader(shader);
- return shader;
- }
-
- private void setupShadedGeometry() {
- // Built-in shader that provides position, texcoord and normal
- VertexShader genericV = SceneManager.getDefaultVS();
- // Custom shader
- FragmentShader diffuseF = createLambertShader();
- RenderState diffuseRS = new RenderState(genericV, diffuseF, null, null);
-
- // Draw a sphere
- Renderable sphere = mScene.appendNewRenderable();
- // Use the sphere geometry loaded earlier
- sphere.setMesh(mSphereMesh);
- // Make a transform to position the sphere
- CompoundTransform t = mScene.appendNewCompoundTransform();
- t.addTranslate("position", new Float3(-1, 2, 3));
- t.addScale("scale", new Float3(1.4f, 1.4f, 1.4f));
- sphere.setTransform(t);
- // Tell the renderable which texture to use when we draw
- // This will mean a texture param in the shader called "diffuse"
- // will be assigned a texture called red.jpg
- sphere.appendSourceParams(new TextureParam("diffuse", new Texture2D("", "red.jpg")));
- sphere.setRenderState(diffuseRS);
-
- // Draw a cube
- Renderable cube = mScene.appendNewRenderable();
- cube.setMesh(mCubeMesh);
- t = mScene.appendNewCompoundTransform();
- t.addTranslate("position", new Float3(-2, -2.1f, 0));
- t.addRotate("rotateX", new Float3(1, 0, 0), 30);
- t.addRotate("rotateY", new Float3(0, 1, 0), 30);
- t.addScale("scale", new Float3(2, 2, 2));
- cube.setTransform(t);
- cube.appendSourceParams(new TextureParam("diffuse", new Texture2D("", "orange.jpg")));
- cube.setRenderState(diffuseRS);
- }
-
- private void setupCamera() {
- Camera camera = mScene.appendNewCamera();
- camera.setFar(200);
- camera.setNear(0.1f);
- camera.setFOV(60);
- CompoundTransform cameraTransform = mScene.appendNewCompoundTransform();
- cameraTransform.addTranslate("camera", new Float3(0, 0, 10));
- camera.setTransform(cameraTransform);
- }
-
- private void setupRenderPass() {
- RenderPass mainPass = mScene.appendNewRenderPass();
- mainPass.setClearColor(new Float4(1.0f, 1.0f, 1.0f, 1.0f));
- mainPass.setShouldClearColor(true);
- mainPass.setClearDepth(1.0f);
- mainPass.setShouldClearDepth(true);
- mainPass.setCamera(mScene.getCameras().get(0));
- ArrayList<RenderableBase> allRender = mScene.getRenderables();
- for (RenderableBase renderable : allRender) {
- mainPass.appendRenderable((Renderable)renderable);
- }
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java
deleted file mode 100644
index 2112181..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/SimpleAppView.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-public class SimpleAppView extends RSSurfaceView {
-
- public SimpleAppView(Context context) {
- super(context);
- }
-
- private RenderScriptGL mRS;
- SimpleAppRS mRender;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- sc.setSamples(1, 2, 1);
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new SimpleAppRS();
- mRender.init(mRS, getResources(), w, h);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if (mRS != null) {
- mRender = null;
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-}
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestApp.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestApp.java
deleted file mode 100644
index 385a7ab..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestApp.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.ListView;
-import android.view.MenuInflater;
-import android.view.Window;
-import android.net.Uri;
-
-import java.lang.Runtime;
-
-public class TestApp extends Activity {
-
- private TestAppView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our Preview view and set it as the content of our
- // Activity
- mView = new TestAppView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally a game should implement onResume() and onPause()
- // to take appropriate action when the activity looses focus
- super.onPause();
- mView.pause();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.loader_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.load_model:
- loadModel();
- return true;
- case R.id.use_blur:
- mView.mRender.toggleBlur();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- private static final int FIND_DAE_MODEL = 10;
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK) {
- if (requestCode == FIND_DAE_MODEL) {
- Uri selectedImageUri = data.getData();
- Log.e("Selected Path: ", selectedImageUri.getPath());
- mView.mRender.loadModel(selectedImageUri.getPath());
- }
- }
- }
-
- public void loadModel() {
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_PICK);
- intent.setClassName("com.android.testapp",
- "com.android.testapp.FileSelector");
- startActivityForResult(intent, FIND_DAE_MODEL);
- }
-
-}
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppLoadingScreen.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppLoadingScreen.java
deleted file mode 100644
index 5bd8f0b..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppLoadingScreen.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-import com.android.scenegraph.SceneManager;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Allocation.MipmapControl;
-import android.renderscript.Element.Builder;
-import android.renderscript.Font.Style;
-import android.renderscript.Program.TextureType;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.util.Log;
-
-// This is where the scenegraph and the rendered objects are initialized and used
-public class TestAppLoadingScreen {
-
- private static String TAG = "TestAppLoadingScreen";
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private ScriptC_test_app mScript;
-
- public TestAppLoadingScreen(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- // Shows the loading screen with some text
- renderLoading();
- // Adds a little 3D bugdroid model to the laoding screen asynchronously.
- new LoadingScreenLoaderTask().execute();
- }
-
- public void showLoadingScreen(boolean show) {
- if (show) {
- mRS.bindRootScript(mScript);
- } else {
- mRS.bindRootScript(SceneManager.getInstance().getRenderLoop());
- }
- }
-
- // The loading screen has some elements that shouldn't be loaded on the UI thread
- private class LoadingScreenLoaderTask extends AsyncTask<String, Void, Boolean> {
- Allocation robotTex;
- Mesh robotMesh;
- protected Boolean doInBackground(String... names) {
- long start = System.currentTimeMillis();
- robotTex = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
- MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
- FileA3D.IndexEntry entry = model.getIndexEntry(0);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- robotMesh = entry.getMesh();
- }
-
- mScript.set_gPFSBackground(ProgramStore.BLEND_NONE_DEPTH_TEST(mRS));
-
- ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
- b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- ProgramFragment pfDefault = b.create();
- pfDefault.bindSampler(Sampler.CLAMP_LINEAR(mRS), 0);
- mScript.set_gPFBackground(pfDefault);
-
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- ProgramVertexFixedFunction pvDefault = pvb.create();
- ProgramVertexFixedFunction.Constants va = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction)pvDefault).bindConstants(va);
- mScript.set_gPVBackground(pvDefault);
-
- long end = System.currentTimeMillis();
- Log.v("TIMER", "Loading load time: " + (end - start));
- return new Boolean(true);
- }
-
- protected void onPostExecute(Boolean result) {
- mScript.set_gRobotTex(robotTex);
- mScript.set_gRobotMesh(robotMesh);
- }
- }
-
- // Creates a simple script to show a loding screen until everything is initialized
- // Could also be used to do some custom renderscript work before handing things over
- // to the scenegraph
- void renderLoading() {
- mScript = new ScriptC_test_app(mRS, mRes, R.raw.test_app);
- mRS.bindRootScript(mScript);
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java
deleted file mode 100644
index 3aa80f4..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppRS.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (C) 2011-2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-import com.android.scenegraph.*;
-import com.android.scenegraph.SceneManager.SceneLoadedCallback;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.AsyncTask;
-import android.renderscript.*;
-import android.renderscript.Program.TextureType;
-import android.util.Log;
-
-// This is where the scenegraph and the rendered objects are initialized and used
-public class TestAppRS {
-
- private static String modelName = "orientation_test.dae";
- private static String TAG = "TestAppRS";
- private static String mFilePath = "";
-
- int mWidth;
- int mHeight;
-
- boolean mUseBlur;
-
- TestAppLoadingScreen mLoadingScreen;
-
- // Used to asynchronously load scene elements like meshes and transform hierarchies
- SceneLoadedCallback mLoadedCallback = new SceneLoadedCallback() {
- public void run() {
- prepareToRender(mLoadedScene);
- }
- };
-
- // Top level class that initializes all the elements needed to use the scene graph
- SceneManager mSceneManager;
-
- // Used to move the camera around in the 3D world
- TouchHandler mTouchHandler;
-
- private Resources mRes;
- private RenderScriptGL mRS;
-
- // Shaders
- private FragmentShader mPaintF;
- private FragmentShader mLightsF;
- private FragmentShader mLightsDiffF;
- private FragmentShader mAluminumF;
- private FragmentShader mPlasticF;
- private FragmentShader mDiffuseF;
- private FragmentShader mTextureF;
- private VertexShader mGenericV;
-
- Scene mActiveScene;
-
- // This is a part of the test app, it's used to tests multiple render passes and is toggled
- // on and off in the menu, off by default
- void toggleBlur() {
- mUseBlur = !mUseBlur;
-
- mActiveScene.clearRenderPasses();
- initRenderPasses();
- mActiveScene.initRenderPassRS(mRS, mSceneManager);
-
- // This is just a hardcoded object in the scene that gets turned on and off for the demo
- // to make things look a bit better. This could be deleted in the cleanup
- Renderable plane = (Renderable)mActiveScene.getRenderableByName("pPlaneShape1");
- if (plane != null) {
- plane.setVisible(!mUseBlur);
- }
- }
-
- public void init(RenderScriptGL rs, Resources res, int width, int height) {
- mUseBlur = false;
- mRS = rs;
- mRes = res;
- mWidth = width;
- mHeight = height;
-
- mTouchHandler = new TouchHandler();
-
- mSceneManager = SceneManager.getInstance();
- // Initializes all the RS specific scenegraph elements
- mSceneManager.initRS(mRS, mRes, mWidth, mHeight);
-
- mLoadingScreen = new TestAppLoadingScreen(mRS, mRes);
-
- // Initi renderscript stuff specific to the app. This will need to be abstracted out later.
- FullscreenBlur.createRenderTargets(mRS, mWidth, mHeight);
- initPaintShaders();
-
- // Load a scene to render
- mSceneManager.loadModel(mFilePath + modelName, mLoadedCallback);
- }
-
- // When a new model file is selected from the UI, this function gets called to init everything
- void loadModel(String path) {
- mLoadingScreen.showLoadingScreen(true);
- mActiveScene.destroyRS();
- mSceneManager.loadModel(path, mLoadedCallback);
- }
-
- public void onActionDown(float x, float y) {
- mTouchHandler.onActionDown(x, y);
- }
-
- public void onActionScale(float scale) {
- mTouchHandler.onActionScale(scale);
- }
-
- public void onActionMove(float x, float y) {
- mTouchHandler.onActionMove(x, y);
- }
-
- FragmentShader createFromResource(int id, boolean addCubemap, Type constType) {
- FragmentShader.Builder fb = new FragmentShader.Builder(mRS);
- fb.setShaderConst(constType);
- fb.setShader(mRes, id);
- fb.addTexture(TextureType.TEXTURE_2D, "diffuse");
- if (addCubemap) {
- fb.addShaderTexture(TextureType.TEXTURE_CUBE, "reflection");
- }
- FragmentShader pf = fb.create();
- pf.getProgram().bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(mRS), 0);
- if (addCubemap) {
- pf.getProgram().bindSampler(Sampler.CLAMP_LINEAR_MIP_LINEAR(mRS), 1);
- }
- return pf;
- }
-
- private void initPaintShaders() {
- mGenericV = SceneManager.getDefaultVS();
-
- ScriptField_CameraParams camParams = new ScriptField_CameraParams(mRS, 1);
- Type camParamType = camParams.getAllocation().getType();
- ScriptField_LightParams lightParams = new ScriptField_LightParams(mRS, 1);
-
- mPaintF = createFromResource(R.raw.paintf, true, camParamType);
- // Assign a reflection map
- TextureCube envCube = new TextureCube("sdcard/scenegraph/", "cube_env.png");
- mPaintF.appendSourceParams(new TextureParam("reflection", envCube));
-
- mAluminumF = createFromResource(R.raw.metal, true, camParamType);
- TextureCube diffCube = new TextureCube("sdcard/scenegraph/", "cube_spec.png");
- mAluminumF.appendSourceParams(new TextureParam("reflection", diffCube));
-
- mPlasticF = createFromResource(R.raw.plastic, false, camParamType);
- mDiffuseF = createFromResource(R.raw.diffuse, false, camParamType);
- mTextureF = SceneManager.getTextureFS();
-
- FragmentShader.Builder fb = new FragmentShader.Builder(mRS);
- fb.setObjectConst(lightParams.getAllocation().getType());
- fb.setShader(mRes, R.raw.plastic_lights);
- mLightsF = fb.create();
-
- fb = new FragmentShader.Builder(mRS);
- fb.setObjectConst(lightParams.getAllocation().getType());
- fb.setShader(mRes, R.raw.diffuse_lights);
- mLightsDiffF = fb.create();
-
- FullscreenBlur.initShaders(mRes, mRS);
- }
-
- void initRenderPasses() {
- ArrayList<RenderableBase> allDraw = mActiveScene.getRenderables();
- int numDraw = allDraw.size();
-
- if (mUseBlur) {
- FullscreenBlur.addBlurPasses(mActiveScene, mRS, mTouchHandler.getCamera());
- }
-
- RenderPass mainPass = new RenderPass();
- mainPass.setClearColor(new Float4(1.0f, 1.0f, 1.0f, 1.0f));
- mainPass.setShouldClearColor(true);
- mainPass.setClearDepth(1.0f);
- mainPass.setShouldClearDepth(true);
- mainPass.setCamera(mTouchHandler.getCamera());
- for (int i = 0; i < numDraw; i ++) {
- mainPass.appendRenderable((Renderable)allDraw.get(i));
- }
- mActiveScene.appendRenderPass(mainPass);
-
- if (mUseBlur) {
- FullscreenBlur.addCompositePass(mActiveScene, mRS, mTouchHandler.getCamera());
- }
- }
-
- private void addShadersToScene() {
- mActiveScene.appendShader(mPaintF);
- mActiveScene.appendShader(mLightsF);
- mActiveScene.appendShader(mLightsDiffF);
- mActiveScene.appendShader(mAluminumF);
- mActiveScene.appendShader(mPlasticF);
- mActiveScene.appendShader(mDiffuseF);
- mActiveScene.appendShader(mTextureF);
- }
-
- public void prepareToRender(Scene s) {
- mSceneManager.setActiveScene(s);
- mActiveScene = s;
- mTouchHandler.init(mActiveScene);
- addShadersToScene();
- RenderState plastic = new RenderState(mGenericV, mPlasticF, null, null);
- RenderState diffuse = new RenderState(mGenericV, mDiffuseF, null, null);
- RenderState paint = new RenderState(mGenericV, mPaintF, null, null);
- RenderState aluminum = new RenderState(mGenericV, mAluminumF, null, null);
- RenderState lights = new RenderState(mGenericV, mLightsF, null, null);
- RenderState diff_lights = new RenderState(mGenericV, mLightsDiffF, null, null);
- RenderState diff_lights_no_cull = new RenderState(mGenericV, mLightsDiffF, null,
- ProgramRaster.CULL_NONE(mRS));
- RenderState glassTransp = new RenderState(mGenericV, mPaintF,
- ProgramStore.BLEND_ALPHA_DEPTH_TEST(mRS), null);
- RenderState texState = new RenderState(mGenericV, mTextureF, null, null);
-
- initRenderPasses();
-
- mActiveScene.assignRenderState(plastic);
-
- mActiveScene.assignRenderStateToMaterial(diffuse, "lambert2$");
-
- mActiveScene.assignRenderStateToMaterial(paint, "^Paint");
- mActiveScene.assignRenderStateToMaterial(paint, "^Carbon");
- mActiveScene.assignRenderStateToMaterial(paint, "^Glass");
- mActiveScene.assignRenderStateToMaterial(paint, "^MainGlass");
-
- mActiveScene.assignRenderStateToMaterial(aluminum, "^Metal");
- mActiveScene.assignRenderStateToMaterial(aluminum, "^Brake");
-
- mActiveScene.assignRenderStateToMaterial(glassTransp, "^GlassLight");
-
- mActiveScene.assignRenderStateToMaterial(lights, "^LightBlinn");
- mActiveScene.assignRenderStateToMaterial(diff_lights, "^LightLambert");
- mActiveScene.assignRenderStateToMaterial(diff_lights_no_cull, "^LightLambertNoCull");
- mActiveScene.assignRenderStateToMaterial(texState, "^TextureOnly");
-
- Renderable plane = (Renderable)mActiveScene.getRenderableByName("pPlaneShape1");
- if (plane != null) {
- plane.setRenderState(texState);
- plane.setVisible(!mUseBlur);
- }
-
- long start = System.currentTimeMillis();
- mActiveScene.initRS();
- long end = System.currentTimeMillis();
- Log.v("TIMER", "Scene init time: " + (end - start));
-
- mLoadingScreen.showLoadingScreen(false);
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java
deleted file mode 100644
index 33ca1b8..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TestAppView.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.concurrent.Semaphore;
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScript;
-import android.renderscript.RenderScriptGL;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.ScaleGestureDetector;
-
-public class TestAppView extends RSSurfaceView {
-
- public TestAppView(Context context) {
- super(context);
- mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
- }
-
- private RenderScriptGL mRS;
- TestAppRS mRender;
-
- private ScaleGestureDetector mScaleDetector;
- private static final int INVALID_POINTER_ID = -1;
- private int mActivePointerId = INVALID_POINTER_ID;
-
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- sc.setSamples(1, 2, 1);
- mRS = createRenderScriptGL(sc);
- mRS.setSurface(holder, w, h);
- mRender = new TestAppRS();
- mRender.init(mRS, getResources(), w, h);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if (mRS != null) {
- mRender = null;
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- // break point at here
- // this method doesn't work when 'extends View' include 'extends ScrollView'.
- return super.onKeyDown(keyCode, event);
- }
-
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mScaleDetector.onTouchEvent(ev);
-
- boolean ret = false;
- float x = ev.getX();
- float y = ev.getY();
-
- final int action = ev.getAction();
-
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: {
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(0);
- ret = true;
- break;
- }
- case MotionEvent.ACTION_MOVE: {
- if (!mScaleDetector.isInProgress()) {
- mRender.onActionMove(x, y);
- }
- mRender.onActionDown(x, y);
- ret = true;
- break;
- }
-
- case MotionEvent.ACTION_UP: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_CANCEL: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_POINTER_UP: {
- final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
- final int pointerId = ev.getPointerId(pointerIndex);
- if (pointerId == mActivePointerId) {
- // This was our active pointer going up. Choose a new
- // active pointer and adjust accordingly.
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- x = ev.getX(newPointerIndex);
- y = ev.getY(newPointerIndex);
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(newPointerIndex);
- }
- break;
- }
- }
-
- return ret;
- }
-
- private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- mRender.onActionScale(detector.getScaleFactor());
- return true;
- }
- }
-}
-
-
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java
deleted file mode 100644
index d0f9797..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/TouchHandler.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testapp;
-
-import android.util.Log;
-import android.renderscript.Float3;
-import com.android.scenegraph.*;
-import com.android.scenegraph.CompoundTransform.RotateComponent;
-import com.android.scenegraph.CompoundTransform.TranslateComponent;
-
-public class TouchHandler {
- private static String TAG = "TouchHandler";
-
- float mLastX;
- float mLastY;
-
- float mRotateXValue;
- float mRotateYValue;
- Float3 mDistValue;
- Float3 mPosValue;
-
- CompoundTransform mCameraRig;
- RotateComponent mRotateX;
- RotateComponent mRotateY;
- TranslateComponent mDist;
- TranslateComponent mPosition;
- Camera mCamera;
-
- public void init(Scene scene) {
- // Some initial values for camera position
- mRotateXValue = -20;
- mRotateYValue = 0;
- mDistValue = new Float3(0, 0, 45);
- mPosValue = new Float3(0, 4, 0);
-
- // Make a camera transform we can manipulate
- mCameraRig = scene.appendNewCompoundTransform();
- mCameraRig.setName("CameraRig");
-
- mPosition = mCameraRig.addTranslate("Position", mPosValue);
- mRotateY = mCameraRig.addRotate("RotateY", new Float3(0, 1, 0), mRotateYValue);
- mRotateX = mCameraRig.addRotate("RotateX", new Float3(1, 0, 0), mRotateXValue);
- mDist = mCameraRig.addTranslate("Distance", mDistValue);
-
- mCamera = scene.appendNewCamera();
- mCamera.setTransform(mCameraRig);
- }
-
- public Camera getCamera() {
- return mCamera;
- }
-
- public void onActionDown(float x, float y) {
- mLastX = x;
- mLastY = y;
- }
-
- public void onActionScale(float scale) {
- if (mDist == null) {
- return;
- }
- mDistValue.z *= 1.0f / scale;
- mDistValue.z = Math.max(10.0f, Math.min(mDistValue.z, 150.0f));
- mDist.setValue(mDistValue);
- }
-
- public void onActionMove(float x, float y) {
- if (mRotateX == null) {
- return;
- }
-
- float dx = mLastX - x;
- float dy = mLastY - y;
-
- if (Math.abs(dy) <= 2.0f) {
- dy = 0.0f;
- }
- if (Math.abs(dx) <= 2.0f) {
- dx = 0.0f;
- }
-
- mRotateYValue += dx * 0.25f;
- mRotateYValue %= 360.0f;
-
- mRotateXValue += dy * 0.25f;
- mRotateXValue = Math.max(mRotateXValue , -80.0f);
- mRotateXValue = Math.min(mRotateXValue , 0.0f);
-
- mRotateX.setAngle(mRotateXValue);
- mRotateY.setAngle(mRotateYValue);
-
- mLastX = x;
- mLastY = y;
- }
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rs
deleted file mode 100644
index d94da52..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.testapp)
-
-#include "rs_graphics.rsh"
-#include "test_app.rsh"
-
-// Making sure these get reflected
-FBlurOffsets *blurExport;
-VShaderInputs *iExport;
-FShaderParams *fConst;
-FShaderLightParams *fConts2;
-VSParams *vConst2;
-VObjectParams *vConst3;
-
-rs_program_vertex gPVBackground;
-rs_program_fragment gPFBackground;
-
-rs_allocation gRobotTex;
-rs_mesh gRobotMesh;
-
-rs_program_store gPFSBackground;
-
-float gRotate;
-
-void init() {
- gRotate = 0.0f;
-}
-
-static float gRotateY = 120.0f;
-static float gZoom = 50.0f;
-static void displayLoading() {
- if (rsIsObject(gRobotTex) && rsIsObject(gRobotMesh)) {
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float)rsgGetWidth() / (float)rsgGetHeight();
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 100.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindProgramStore(gPFSBackground);
- rsgBindTexture(gPFBackground, 0, gRobotTex);
-
- rs_matrix4x4 matrix;
- rsMatrixLoadIdentity(&matrix);
- // Position our models on the screen
- gRotateY += rsGetDt()*100;
- rsMatrixTranslate(&matrix, 0, 0, -gZoom);
- rsMatrixRotate(&matrix, 20.0f, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
- rsMatrixScale(&matrix, 0.2f, 0.2f, 0.2f);
- rsgProgramVertexLoadModelMatrix(&matrix);
- rsgDrawMesh(gRobotMesh);
- }
-
- uint width = rsgGetWidth();
- uint height = rsgGetHeight();
- int left = 0, right = 0, top = 0, bottom = 0;
- const char* text = "Initializing...";
- rsgMeasureText(text, &left, &right, &top, &bottom);
- int centeredPos = width / 2 - (right - left) / 2;
- rsgDrawText(text, centeredPos, height / 2 + height / 10);
-}
-
-int root(void) {
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
- displayLoading();
- return 30;
-}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rsh b/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rsh
deleted file mode 100644
index 5fbcbb2..0000000
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/testapp/test_app.rsh
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (C) 2012 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.testapp)
-
-// Helpers
-typedef struct ViewProjParams {
- rs_matrix4x4 viewProj;
-} VSParams;
-
-typedef struct ModelParams {
- rs_matrix4x4 model;
-} VObjectParams;
-
-typedef struct CameraParams {
- float4 cameraPos;
-} FShaderParams;
-
-typedef struct LightParams {
- float4 lightPos_0;
- float4 lightColor_0;
- float4 lightPos_1;
- float4 lightColor_1;
- float4 cameraPos;
- float4 diffuse;
-} FShaderLightParams;
-
-typedef struct BlurOffsets {
- float blurOffset0;
- float blurOffset1;
- float blurOffset2;
- float blurOffset3;
-} FBlurOffsets;
-
-typedef struct VertexShaderInputs {
- float4 position;
- float3 normal;
- float2 texture0;
-} VShaderInputs;
diff --git a/tests/RenderScriptTests/ShadersTest/Android.mk b/tests/RenderScriptTests/ShadersTest/Android.mk
deleted file mode 100644
index fb6356e..0000000
--- a/tests/RenderScriptTests/ShadersTest/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-LOCAL_SDK_VERSION := 17
-
-LOCAL_PACKAGE_NAME := ShadersTest
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/ShadersTest/AndroidManifest.xml b/tests/RenderScriptTests/ShadersTest/AndroidManifest.xml
deleted file mode 100644
index 871200d..0000000
--- a/tests/RenderScriptTests/ShadersTest/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.shaderstest">
-
- <uses-permission android:name="android.permission.INTERNET" />
-
- <application android:label="_ShadersTest">
- <activity android:name="ShadersTest"
- android:label="_ShadersTest"
- android:theme="@android:style/Theme.Black.NoTitleBar">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/ShadersTest/res/drawable-nodpi/robot.png b/tests/RenderScriptTests/ShadersTest/res/drawable-nodpi/robot.png
deleted file mode 100644
index f7353fd..0000000
--- a/tests/RenderScriptTests/ShadersTest/res/drawable-nodpi/robot.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ShadersTest/res/raw/depth_fs.glsl b/tests/RenderScriptTests/ShadersTest/res/raw/depth_fs.glsl
deleted file mode 100644
index 096843b..0000000
--- a/tests/RenderScriptTests/ShadersTest/res/raw/depth_fs.glsl
+++ /dev/null
@@ -1,13 +0,0 @@
-void main() {
- // Non-linear depth value
- float z = gl_FragCoord.z;
- // Near and far planes from the projection
- // In practice, these values can be used to tweak
- // the focus range
- float n = UNI_near;
- float f = UNI_far;
- // Linear depth value
- z = (2.0 * n) / (f + n - z * (f - n));
-
- gl_FragColor = vec4(z, z, z, 1.0);
-}
diff --git a/tests/RenderScriptTests/ShadersTest/res/raw/robot.a3d b/tests/RenderScriptTests/ShadersTest/res/raw/robot.a3d
deleted file mode 100644
index f48895c..0000000
--- a/tests/RenderScriptTests/ShadersTest/res/raw/robot.a3d
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ShadersTest/res/raw/vignette_fs.glsl b/tests/RenderScriptTests/ShadersTest/res/raw/vignette_fs.glsl
deleted file mode 100644
index 2dc1ea3..0000000
--- a/tests/RenderScriptTests/ShadersTest/res/raw/vignette_fs.glsl
+++ /dev/null
@@ -1,31 +0,0 @@
-#define CRT_MASK
-
-varying vec2 varTex0;
-
-void main() {
- lowp vec4 color = texture2D(UNI_Tex0, varTex0);
-
- vec2 powers = pow(abs((gl_FragCoord.xy / vec2(UNI_width, UNI_height)) - 0.5), vec2(2.0));
- float gradient = smoothstep(UNI_size - UNI_feather, UNI_size + UNI_feather,
- powers.x + powers.y);
-
- color = vec4(mix(color.rgb, vec3(0.0), gradient), 1.0);
-
-#ifdef CRT_MASK
- float vShift = gl_FragCoord.y;
- if (mod(gl_FragCoord.x, 6.0) >= 3.0) {
- vShift += 2.0;
- }
-
- lowp vec3 r = vec3(0.95, 0.0, 0.2);
- lowp vec3 g = vec3(0.2, 0.95, 0.0);
- lowp vec3 b = vec3(0.0, 0.2, 0.95);
- int channel = int(floor(mod(gl_FragCoord.x, 3.0)));
- lowp vec4 crt = vec4(r[channel], g[channel], b[channel], 1.0);
- crt *= clamp(floor(mod(vShift, 4.0)), 0.0, 1.0);
-
- color = (crt * color * 1.25) + 0.05;
-#endif
-
- gl_FragColor = color;
-}
diff --git a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTest.java b/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTest.java
deleted file mode 100644
index 6803fbb..0000000
--- a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.shaderstest;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-@SuppressWarnings({"UnusedDeclaration"})
-public class ShadersTest extends Activity {
-
- private ShadersTestView mView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- mView = new ShadersTestView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mView.pause();
- }
-}
diff --git a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTestRS.java b/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTestRS.java
deleted file mode 100644
index dad97e2..0000000
--- a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTestRS.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.shaderstest;
-
-import android.content.res.Resources;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.Element.DataKind;
-import android.renderscript.Element.DataType;
-import android.renderscript.FileA3D;
-import android.renderscript.Mesh;
-import android.renderscript.Program;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramFragmentFixedFunction;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramStore.DepthFunc;
-import android.renderscript.ProgramVertex;
-import android.renderscript.ProgramVertexFixedFunction;
-import android.renderscript.RSRuntimeException;
-import android.renderscript.RenderScriptGL;
-import android.renderscript.Sampler;
-import android.renderscript.Type.Builder;
-
-@SuppressWarnings({"FieldCanBeLocal"})
-public class ShadersTestRS {
- public ShadersTestRS() {
- }
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- public void surfaceChanged() {
- initBuffers(mRS.getWidth(), mRS.getHeight());
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private Sampler mLinearClamp;
- private Sampler mNearestClamp;
- private ProgramStore mPSBackground;
- private ProgramFragment mPFBackground;
- private ProgramVertex mPVBackground;
- private ProgramVertexFixedFunction.Constants mPVA;
-
- private ProgramFragment mPFVignette;
- private ScriptField_VignetteConstants_s mFSVignetteConst;
-
- private Allocation mMeshTexture;
- private Allocation mScreen;
- private Allocation mScreenDepth;
-
- private ScriptField_MeshInfo mMeshes;
- private ScriptC_shaderstest mScript;
-
-
- public void onActionDown(float x, float y) {
- mScript.invoke_onActionDown(x, y);
- }
-
- public void onActionScale(float scale) {
- mScript.invoke_onActionScale(scale);
- }
-
- public void onActionMove(float x, float y) {
- mScript.invoke_onActionMove(x, y);
- }
-
- private void initPFS() {
- ProgramStore.Builder b = new ProgramStore.Builder(mRS);
-
- b.setDepthFunc(DepthFunc.LESS);
- b.setDitherEnabled(false);
- b.setDepthMaskEnabled(true);
- mPSBackground = b.create();
-
- mScript.set_gPFSBackground(mPSBackground);
- }
-
- private void initPF() {
- mLinearClamp = Sampler.CLAMP_LINEAR(mRS);
- mScript.set_gLinear(mLinearClamp);
-
- mNearestClamp = Sampler.CLAMP_NEAREST(mRS);
- mScript.set_gNearest(mNearestClamp);
-
- ProgramFragmentFixedFunction.Builder b = new ProgramFragmentFixedFunction.Builder(mRS);
- b.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mPFBackground = b.create();
- mPFBackground.bindSampler(mLinearClamp, 0);
- mScript.set_gPFBackground(mPFBackground);
-
- mFSVignetteConst = new ScriptField_VignetteConstants_s(mRS, 1);
- mScript.bind_gFSVignetteConstants(mFSVignetteConst);
-
- ProgramFragment.Builder fs;
-
- fs = new ProgramFragment.Builder(mRS);
- fs.setShader(mRes, R.raw.vignette_fs);
- fs.addConstant(mFSVignetteConst.getAllocation().getType());
- fs.addTexture(Program.TextureType.TEXTURE_2D);
- mPFVignette = fs.create();
- mPFVignette.bindConstants(mFSVignetteConst.getAllocation(), 0);
- mScript.set_gPFVignette(mPFVignette);
- }
-
- private void initPV() {
- ProgramVertexFixedFunction.Builder pvb = new ProgramVertexFixedFunction.Builder(mRS);
- mPVBackground = pvb.create();
-
- mPVA = new ProgramVertexFixedFunction.Constants(mRS);
- ((ProgramVertexFixedFunction) mPVBackground).bindConstants(mPVA);
-
- mScript.set_gPVBackground(mPVBackground);
- }
-
- private void loadImage() {
- mMeshTexture = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.robot,
- Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
- Allocation.USAGE_GRAPHICS_TEXTURE);
- mScript.set_gTMesh(mMeshTexture);
- }
-
- private void initMeshes(FileA3D model) {
- int numEntries = model.getIndexEntryCount();
- int numMeshes = 0;
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- numMeshes ++;
- }
- }
-
- if (numMeshes > 0) {
- mMeshes = new ScriptField_MeshInfo(mRS, numMeshes);
-
- for (int i = 0; i < numEntries; i ++) {
- FileA3D.IndexEntry entry = model.getIndexEntry(i);
- if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
- Mesh mesh = entry.getMesh();
- mMeshes.set_mMesh(i, mesh, false);
- mMeshes.set_mNumIndexSets(i, mesh.getPrimitiveCount(), false);
- }
- }
- mMeshes.copyAll();
- } else {
- throw new RSRuntimeException("No valid meshes in file");
- }
-
- mScript.bind_gMeshes(mMeshes);
- mScript.invoke_updateMeshInfo();
- }
-
- private void initRS() {
- mScript = new ScriptC_shaderstest(mRS, mRes, R.raw.shaderstest);
-
- initPFS();
- initPF();
- initPV();
-
- loadImage();
-
- initBuffers(1, 1);
-
- FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.robot);
- initMeshes(model);
-
- mRS.bindRootScript(mScript);
- }
-
- private void initBuffers(int width, int height) {
- Builder b;
- b = new Builder(mRS, Element.RGBA_8888(mRS));
- b.setX(width).setY(height);
- mScreen = Allocation.createTyped(mRS, b.create(),
- Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gScreen(mScreen);
-
- b = new Builder(mRS, Element.createPixel(mRS, DataType.UNSIGNED_16, DataKind.PIXEL_DEPTH));
- b.setX(width).setY(height);
- mScreenDepth = Allocation.createTyped(mRS, b.create(),
- Allocation.USAGE_GRAPHICS_RENDER_TARGET);
- mScript.set_gScreenDepth(mScreenDepth);
- }
-}
diff --git a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTestView.java b/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTestView.java
deleted file mode 100644
index e0a540f..0000000
--- a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/ShadersTestView.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.shaderstest;
-
-import android.content.Context;
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-import android.view.MotionEvent;
-import android.view.ScaleGestureDetector;
-import android.view.SurfaceHolder;
-
-public class ShadersTestView extends RSSurfaceView {
-
- private RenderScriptGL mRS;
- private ShadersTestRS mRender;
-
- private ScaleGestureDetector mScaleDetector;
-
- private static final int INVALID_POINTER_ID = -1;
- private int mActivePointerId = INVALID_POINTER_ID;
-
- public ShadersTestView(Context context) {
- super(context);
- ensureRenderScript();
- mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
- }
-
- private void ensureRenderScript() {
- if (mRS == null) {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- sc.setDepth(16, 24);
- mRS = createRenderScriptGL(sc);
- mRender = new ShadersTestRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- super.surfaceChanged(holder, format, w, h);
- mRender.surfaceChanged();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- mScaleDetector.onTouchEvent(ev);
-
- boolean ret = false;
- float x = ev.getX();
- float y = ev.getY();
-
- final int action = ev.getAction();
-
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN: {
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(0);
- ret = true;
- break;
- }
- case MotionEvent.ACTION_MOVE: {
- if (!mScaleDetector.isInProgress()) {
- mRender.onActionMove(x, y);
- }
- mRender.onActionDown(x, y);
- ret = true;
- break;
- }
-
- case MotionEvent.ACTION_UP: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_CANCEL: {
- mActivePointerId = INVALID_POINTER_ID;
- break;
- }
-
- case MotionEvent.ACTION_POINTER_UP: {
- final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
- final int pointerId = ev.getPointerId(pointerIndex);
- if (pointerId == mActivePointerId) {
- // This was our active pointer going up. Choose a new
- // active pointer and adjust accordingly.
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- x = ev.getX(newPointerIndex);
- y = ev.getY(newPointerIndex);
- mRender.onActionDown(x, y);
- mActivePointerId = ev.getPointerId(newPointerIndex);
- }
- break;
- }
- }
-
- return ret;
- }
-
- private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
- @Override
- public boolean onScale(ScaleGestureDetector detector) {
- mRender.onActionScale(detector.getScaleFactor());
- return true;
- }
- }
-}
-
-
diff --git a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/shaderstest.rs b/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/shaderstest.rs
deleted file mode 100644
index 735f6b9..0000000
--- a/tests/RenderScriptTests/ShadersTest/src/com/android/shaderstest/shaderstest.rs
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright (C) 2011 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.
-
-#pragma version(1)
-
-#pragma rs java_package_name(com.android.shaderstest)
-
-#include "rs_graphics.rsh"
-
-rs_program_vertex gPVBackground;
-rs_program_fragment gPFBackground;
-
-typedef struct VignetteConstants_s {
- float size;
- float feather;
- float width;
- float height;
-} VignetteConstants;
-VignetteConstants *gFSVignetteConstants;
-rs_program_fragment gPFVignette;
-
-rs_allocation gTMesh;
-
-rs_sampler gLinear;
-rs_sampler gNearest;
-
-rs_program_store gPFSBackground;
-
-rs_allocation gScreenDepth;
-rs_allocation gScreen;
-
-typedef struct MeshInfo {
- rs_mesh mMesh;
- int mNumIndexSets;
- float3 bBoxMin;
- float3 bBoxMax;
-} MeshInfo_t;
-MeshInfo_t *gMeshes;
-
-static float3 gLookAt;
-
-static float gRotateX;
-static float gRotateY;
-static float gZoom;
-
-static float gLastX;
-static float gLastY;
-
-static float3 toFloat3(float x, float y, float z) {
- float3 f;
- f.x = x;
- f.y = y;
- f.z = z;
- return f;
-}
-
-void onActionDown(float x, float y) {
- gLastX = x;
- gLastY = y;
-}
-
-void onActionScale(float scale) {
-
- gZoom *= 1.0f / scale;
- gZoom = max(0.1f, min(gZoom, 500.0f));
-}
-
-void onActionMove(float x, float y) {
- float dx = gLastX - x;
- float dy = gLastY - y;
-
- if (fabs(dy) <= 2.0f) {
- dy = 0.0f;
- }
- if (fabs(dx) <= 2.0f) {
- dx = 0.0f;
- }
-
- gRotateY -= dx;
- if (gRotateY > 360) {
- gRotateY -= 360;
- }
- if (gRotateY < 0) {
- gRotateY += 360;
- }
-
- gRotateX -= dy;
- gRotateX = min(gRotateX, 80.0f);
- gRotateX = max(gRotateX, -80.0f);
-
- gLastX = x;
- gLastY = y;
-}
-
-void init() {
- gRotateX = 0.0f;
- gRotateY = 0.0f;
- gZoom = 50.0f;
- gLookAt = 0.0f;
-}
-
-void updateMeshInfo() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- float minX, minY, minZ, maxX, maxY, maxZ;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgMeshComputeBoundingBox(info->mMesh,
- &minX, &minY, &minZ,
- &maxX, &maxY, &maxZ);
- info->bBoxMin = toFloat3(minX, minY, minZ);
- info->bBoxMax = toFloat3(maxX, maxY, maxZ);
- gLookAt += (info->bBoxMin + info->bBoxMax)*0.5f;
- }
- gLookAt = gLookAt / (float)size;
-}
-
-static void renderAllMeshes() {
- rs_allocation allMeshes = rsGetAllocation(gMeshes);
- int size = rsAllocationGetDimX(allMeshes);
- gLookAt = 0.0f;
- for (int i = 0; i < size; i++) {
- MeshInfo_t *info = (MeshInfo_t*)rsGetElementAt(allMeshes, i);
- rsgDrawMesh(info->mMesh);
- }
-}
-
-static void renderOffscreen() {
- rsgBindProgramVertex(gPVBackground);
- rs_matrix4x4 proj;
- float aspect = (float) rsAllocationGetDimX(gScreen) / (float) rsAllocationGetDimY(gScreen);
- rsMatrixLoadPerspective(&proj, 30.0f, aspect, 1.0f, 1000.0f);
- rsgProgramVertexLoadProjectionMatrix(&proj);
-
- rsgBindProgramFragment(gPFBackground);
- rsgBindTexture(gPFBackground, 0, gTMesh);
-
- rs_matrix4x4 matrix;
-
- rsMatrixLoadIdentity(&matrix);
- rsMatrixTranslate(&matrix, gLookAt.x, gLookAt.y, gLookAt.z - gZoom);
- rsMatrixRotate(&matrix, gRotateX, 1.0f, 0.0f, 0.0f);
- rsMatrixRotate(&matrix, gRotateY, 0.0f, 1.0f, 0.0f);
- rsgProgramVertexLoadModelMatrix(&matrix);
-
- renderAllMeshes();
-}
-
-static void drawOffscreenResult(int posX, int posY, float width, float height) {
- // display the result d
- rs_matrix4x4 proj, matrix;
- rsMatrixLoadOrtho(&proj, 0, width, height, 0, -500, 500);
- rsgProgramVertexLoadProjectionMatrix(&proj);
- rsMatrixLoadIdentity(&matrix);
- rsgProgramVertexLoadModelMatrix(&matrix);
- float startX = posX, startY = posY;
- rsgDrawQuadTexCoords(startX, startY, 0, 0, 1,
- startX, startY + height, 0, 0, 0,
- startX + width, startY + height, 0, 1, 0,
- startX + width, startY, 0, 1, 1);
-}
-
-int root(void) {
- gFSVignetteConstants->size = 0.58f * 0.58f;
- gFSVignetteConstants->feather = 0.2f;
- gFSVignetteConstants->width = (float) rsAllocationGetDimX(gScreen);
- gFSVignetteConstants->height = (float) rsAllocationGetDimY(gScreen);
-
- rsgBindProgramStore(gPFSBackground);
-
- // Render scene to fullscreenbuffer
- rsgBindColorTarget(gScreen, 0);
- rsgBindDepthTarget(gScreenDepth);
- rsgClearDepth(1.0f);
- rsgClearColor(1.0f, 1.0f, 1.0f, 0.0f);
- renderOffscreen();
-
- // Render on screen
- rsgClearAllRenderTargets();
- rsgClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- rsgClearDepth(1.0f);
-
- rsgBindProgramFragment(gPFVignette);
- rsgBindTexture(gPFVignette, 0, gScreen);
- drawOffscreenResult(0, 0, rsgGetWidth(), rsgGetHeight());
-
- return 0;
-}
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index e4738f5..5ad3379 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -1095,13 +1095,6 @@
analyze_image(imageName, imageInfo, grayscaleTolerance, rgbPalette, alphaPalette,
&paletteEntries, &hasTransparency, &color_type, outRows);
- // If the image is a 9-patch, we need to preserve it as a ARGB file to make
- // sure the pixels will not be pre-dithered/clamped until we decide they are
- if (imageInfo.is9Patch && (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)) {
- color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- }
-
if (kIsDebug) {
switch (color_type) {
case PNG_COLOR_TYPE_PALETTE:
@@ -1180,18 +1173,11 @@
}
for (int i = 0; i < chunk_count; i++) {
- unknowns[i].location = PNG_HAVE_PLTE;
+ unknowns[i].location = PNG_HAVE_IHDR;
}
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
chunk_names, chunk_count);
png_set_unknown_chunks(write_ptr, write_info, unknowns, chunk_count);
-#if PNG_LIBPNG_VER < 10600
- /* Deal with unknown chunk location bug in 1.5.x and earlier */
- png_set_unknown_chunk_location(write_ptr, write_info, 0, PNG_HAVE_PLTE);
- if (imageInfo.haveLayoutBounds) {
- png_set_unknown_chunk_location(write_ptr, write_info, 1, PNG_HAVE_PLTE);
- }
-#endif
}
diff --git a/tools/layoutlib/bridge/src/android/os/ServiceManager.java b/tools/layoutlib/bridge/src/android/os/ServiceManager.java
index 6a68ee2..549074d 100644
--- a/tools/layoutlib/bridge/src/android/os/ServiceManager.java
+++ b/tools/layoutlib/bridge/src/android/os/ServiceManager.java
@@ -51,8 +51,10 @@
/**
* Return a list of all currently running services.
+ * @return an array of all currently running services, or <code>null</code> in
+ * case of an exception
*/
- public static String[] listServices() throws RemoteException {
+ public static String[] listServices() {
// actual implementation returns null sometimes, so it's ok
// to return null instead of an empty list.
return null;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
index 27751eb..4625de2 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePackageManager.java
@@ -97,11 +97,26 @@
}
@Override
+ public int[] getPackageGids(String packageName, int flags) throws NameNotFoundException {
+ return new int[0];
+ }
+
+ @Override
+ public int getPackageUid(String packageName, int flags) throws NameNotFoundException {
+ return 0;
+ }
+
+ @Override
public int getPackageUidAsUser(String packageName, int userHandle) throws NameNotFoundException {
return 0;
}
@Override
+ public int getPackageUidAsUser(String packageName, int flags, int userHandle) throws NameNotFoundException {
+ return 0;
+ }
+
+ @Override
public PermissionInfo getPermissionInfo(String name, int flags) throws NameNotFoundException {
return null;
}