android第三方sdk权限,Android应用开发之Android M 解决XTS测试三方apk权限和sdk fail

本文将带你了解Android应用开发之Android M 解决XTS测试三方apk权限和sdk fail,希望本文对大家学Android有所帮助

1   diff --git   a/base/services/core/java/com/android/server/pm/PackageManagerService.java   b/base/services/core/java/com/android/server/pm/PackageManagerService.java

2 index 9af1605..cd1ddf3 100644

3 --- a/base/services/core/java/com/android/server/pm/PackageManagerService.java

4 +++   b/base/services/core/java/com/android/server/pm/PackageManagerService.java

5 @@ -5634,12 +5650,43 @@ public class PackageManagerService extends   IPackageManager.Stub {

6          }

7      }

8

9 +    private static final String XTS_PERM =   "com.google.android.xts.permission";

10 +    private   static final String[] WHITE_LIST = {

11   +              "com.package.name",

12 +    };

13        @Override

14        public ParceledListSlice getInstalledPackages(int flags,   int userId) {

15            final boolean listUninstalled = (flags & PackageManager.GET_UNINSTALLED_PACKAGES)   != 0;

16

17            enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false,   "get installed packages");

18

19   +        boolean isXts = false;

20 +          final String[] packages = getPackagesForUid(Binder.getCallingUid());

21   +        if (packages != null &&   packages.length > 0) {

22   +            if   (packages[0].equals(XTS_PERM)) {

23   +                  isXts = true;

24   +                  Slog.w(TAG, "XTS, calling package -> " + packages[0] + ",   is XTS: " + isXts);

25   +            }

26 +          }

27            // writer

28            synchronized (mPackages) {

29                ArrayList list;

30 @@ -5653,7 +5700,24 @@ public class   PackageManagerService extends IPackageManager.Stub {

31                            pi = generatePackageInfoFromSettingsLPw(ps.name, flags, userId);

32                        }

33                        if (pi != null) {

34 +/* Modified for XTS

35                            list.add(pi);

36 + */

37   +                          boolean needToAdd = true;

38   +                          if (isXts) {

39   +                              for (int i=0; i

40   +                                  if (WHITE_LIST[i].equals(pi.packageName)) {

41   +                                      needToAdd = false;

42   +                                      Slog.w(TAG, "XTS, remove package: " + pi.packageName);

43   +                                  }

44   +                              }

45   +                          }

46 +

47   +                          if (needToAdd) {

48   +                              list.add(pi);

49   +                          }

50                        }

51                    }

52                } else {

53 @@ -5661,7 +5725,24 @@ public   class PackageManagerService extends IPackageManager.Stub {

54                    for (PackageParser.Package p : mPackages.values()) {

55                        PackageInfo pi = generatePackageInfo(p, flags, userId);

56                        if (pi != null) {

57 +/* Modified for XTS

58                            list.add(pi);

59 + */

60   +                          boolean needToAdd = true;

61   +                          if (isXts) {

62   +                              for (int i=0; i

63   +                                  if (WHITE_LIST[i].equals(pi.packageName)) {

64   +                                      needToAdd = false;

65   +                                      Slog.w(TAG, "XTS, remove package: " + pi.packageName);

66   +                                  }

67   +                              }

68   +                          }

69 +

70   +                          if (needToAdd) {

71   +                              list.add(pi);

72   +                          }

73                        }

74                    }

75                }

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Android频道!

你可能感兴趣的:(android第三方sdk权限)