Merge "Track getxattr API change"

am: c4c4a1e76e

Change-Id: I66059536d5dfb0999743656f095d557ddf25ff70
This commit is contained in:
Yi Kong
2016-08-29 08:05:05 +00:00
committed by android-build-merger
2 changed files with 4 additions and 6 deletions

View File

@@ -323,9 +323,8 @@ public final class SELinuxMMAC {
*/ */
public static boolean isRestoreconNeeded(File file) { public static boolean isRestoreconNeeded(File file) {
try { try {
final byte[] buf = new byte[20]; final byte[] buf = Os.getxattr(file.getAbsolutePath(), XATTR_SEAPP_HASH);
final int len = Os.getxattr(file.getAbsolutePath(), XATTR_SEAPP_HASH, buf); if ((buf.length == 20) && Arrays.equals(SEAPP_CONTEXTS_HASH, buf)) {
if ((len == 20) && Arrays.equals(SEAPP_CONTEXTS_HASH, buf)) {
return false; return false;
} }
} catch (ErrnoException e) { } catch (ErrnoException e) {

View File

@@ -2958,9 +2958,8 @@ public class UserManagerService extends IUserManager.Stub {
*/ */
private static int getSerialNumber(File file) throws IOException { private static int getSerialNumber(File file) throws IOException {
try { try {
final byte[] buf = new byte[256]; final byte[] buf = Os.getxattr(file.getAbsolutePath(), XATTR_SERIAL);
final int len = Os.getxattr(file.getAbsolutePath(), XATTR_SERIAL, buf); final String serial = new String(buf);
final String serial = new String(buf, 0, len);
try { try {
return Integer.parseInt(serial); return Integer.parseInt(serial);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {