android.content.pm.PackageUserState Java Examples
The following examples show how to use
android.content.pm.PackageUserState.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApkTargetMapping.java From GPT with Apache License 2.0 | 5 votes |
/** * generateReceiverInfo * * @param p PackageParser.Package * @param pi PackageInfo * @param flags flags */ private void generateReceiverInfo(PackageParser.Package p, PackageInfo pi, int flags) { PackageUserState state = new PackageUserState(); if ((flags & PackageManager.GET_RECEIVERS) != 0) { int N = p.receivers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.receivers.get(i).info.enabled) num++; } pi.receivers = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.receivers.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers[j++] = PackageParser.generateActivityInfo(p.receivers.get(i), flags, state, 0); // try { // pi.receivers[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, // "generateActivityInfo", p.receivers.get(i), flags, state, 0); // } catch (Exception e) { // e.printStackTrace(); // } } } } } }
Example #2
Source File: ApkTargetMapping.java From GPT with Apache License 2.0 | 5 votes |
/** * generateProviderInfo * * @param p PackageParser.Package * @param pi PackageInfo * @param flags flags */ private void generateProviderInfo(PackageParser.Package p, PackageInfo pi, int flags) { PackageUserState state = new PackageUserState(); if ((flags & PackageManager.GET_PROVIDERS) != 0) { int N = p.providers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers = new ProviderInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.providers.get(i).info.enabled) num++; } pi.providers = new ProviderInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Provider provider = p.providers.get(i); if (provider.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers[j++] = PackageParser.generateProviderInfo(p.providers.get(i), flags, state, 0); // try { // pi.providers[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generateProviderInfo", // p.providers.get(i), flags, state, 0); // } catch (Exception e) { // e.printStackTrace(); // } } } } } }
Example #3
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void setSuspended(boolean suspended, String suspendingPackage, String dialogMessage, PersistableBundle appExtras, PersistableBundle launcherExtras, int userId) { final PackageUserState existingUserState = modifyUserState(userId); existingUserState.suspended = suspended; existingUserState.suspendingPackage = suspended ? suspendingPackage : null; existingUserState.dialogMessage = suspended ? dialogMessage : null; existingUserState.suspendedAppExtras = suspended ? appExtras : null; existingUserState.suspendedLauncherExtras = suspended ? launcherExtras : null; }
Example #4
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void setUserState(int userId, long ceDataInode, int enabled, boolean installed, boolean stopped, boolean notLaunched, boolean hidden, boolean suspended, String suspendingPackage, String dialogMessage, PersistableBundle suspendedAppExtras, PersistableBundle suspendedLauncherExtras, boolean instantApp, boolean virtualPreload, String lastDisableAppCaller, ArraySet<String> enabledComponents, ArraySet<String> disabledComponents, int domainVerifState, int linkGeneration, int installReason, String harmfulAppWarning) { PackageUserState state = modifyUserState(userId); state.ceDataInode = ceDataInode; state.enabled = enabled; state.installed = installed; state.stopped = stopped; state.notLaunched = notLaunched; state.hidden = hidden; state.suspended = suspended; state.suspendingPackage = suspendingPackage; state.dialogMessage = dialogMessage; state.suspendedAppExtras = suspendedAppExtras; state.suspendedLauncherExtras = suspendedLauncherExtras; state.lastDisableAppCaller = lastDisableAppCaller; state.enabledComponents = enabledComponents; state.disabledComponents = disabledComponents; state.domainVerificationStatus = domainVerifState; state.appLinkGeneration = linkGeneration; state.installReason = installReason; state.instantApp = instantApp; state.virtualPreload = virtualPreload; state.harmfulAppWarning = harmfulAppWarning; }
Example #5
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
PackageUserState modifyUserStateComponents(int userId, boolean disabled, boolean enabled) { PackageUserState state = modifyUserState(userId); if (disabled && state.disabledComponents == null) { state.disabledComponents = new ArraySet<String>(1); } if (enabled && state.enabledComponents == null) { state.enabledComponents = new ArraySet<String>(1); } return state; }
Example #6
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
boolean enableComponentLPw(String componentClassName, int userId) { PackageUserState state = modifyUserStateComponents(userId, false, true); boolean changed = state.disabledComponents != null ? state.disabledComponents.remove(componentClassName) : false; changed |= state.enabledComponents.add(componentClassName); return changed; }
Example #7
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
boolean disableComponentLPw(String componentClassName, int userId) { PackageUserState state = modifyUserStateComponents(userId, true, false); boolean changed = state.enabledComponents != null ? state.enabledComponents.remove(componentClassName) : false; changed |= state.disabledComponents.add(componentClassName); return changed; }
Example #8
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
boolean restoreComponentLPw(String componentClassName, int userId) { PackageUserState state = modifyUserStateComponents(userId, true, true); boolean changed = state.disabledComponents != null ? state.disabledComponents.remove(componentClassName) : false; changed |= state.enabledComponents != null ? state.enabledComponents.remove(componentClassName) : false; return changed; }
Example #9
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
int getCurrentEnabledStateLPr(String componentName, int userId) { PackageUserState state = readUserState(userId); if (state.enabledComponents != null && state.enabledComponents.contains(componentName)) { return COMPONENT_ENABLED_STATE_ENABLED; } else if (state.disabledComponents != null && state.disabledComponents.contains(componentName)) { return COMPONENT_ENABLED_STATE_DISABLED; } else { return COMPONENT_ENABLED_STATE_DEFAULT; } }
Example #10
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public PackageUserState readUserState(int userId) { PackageUserState state = userState.get(userId); if (state == null) { return DEFAULT_USER_STATE; } state.categoryHint = categoryHint; return state; }
Example #11
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void setDomainVerificationStatusForUser(final int status, int generation, int userId) { PackageUserState state = modifyUserState(userId); state.domainVerificationStatus = status; if (status == PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) { state.appLinkGeneration = generation; } }
Example #12
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
protected void writeUsersInfoToProto(ProtoOutputStream proto, long fieldId) { int count = userState.size(); for (int i = 0; i < count; i++) { final long userToken = proto.start(fieldId); final int userId = userState.keyAt(i); final PackageUserState state = userState.valueAt(i); proto.write(PackageProto.UserInfoProto.ID, userId); final int installType; if (state.instantApp) { installType = PackageProto.UserInfoProto.INSTANT_APP_INSTALL; } else if (state.installed) { installType = PackageProto.UserInfoProto.FULL_APP_INSTALL; } else { installType = PackageProto.UserInfoProto.NOT_INSTALLED_FOR_USER; } proto.write(PackageProto.UserInfoProto.INSTALL_TYPE, installType); proto.write(PackageProto.UserInfoProto.IS_HIDDEN, state.hidden); proto.write(PackageProto.UserInfoProto.IS_SUSPENDED, state.suspended); if (state.suspended) { proto.write(PackageProto.UserInfoProto.SUSPENDING_PACKAGE, state.suspendingPackage); } proto.write(PackageProto.UserInfoProto.IS_STOPPED, state.stopped); proto.write(PackageProto.UserInfoProto.IS_LAUNCHED, !state.notLaunched); proto.write(PackageProto.UserInfoProto.ENABLED_STATE, state.enabled); proto.write( PackageProto.UserInfoProto.LAST_DISABLED_APP_CALLER, state.lastDisableAppCaller); proto.end(userToken); } }
Example #13
Source File: ApkTargetMapping.java From GPT with Apache License 2.0 | 5 votes |
/** * generateServiceInfo * * @param p PackageParser.Package * @param pi PackageInfo * @param flags flags */ private void generateServiceInfo(PackageParser.Package p, PackageInfo pi, int flags) { PackageUserState state = new PackageUserState(); if ((flags & PackageManager.GET_SERVICES) != 0) { int N = p.services.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services = new ServiceInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.services.get(i).info.enabled) num++; } pi.services = new ServiceInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Service service = p.services.get(i); if (service.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services[j++] = PackageParser.generateServiceInfo(p.services.get(i), flags, state, 0); // try { // pi.services[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generateServiceInfo", // p.services.get(i), flags, state, 0); // } catch (Exception e) { // e.printStackTrace(); // } } } } } }
Example #14
Source File: ApkTargetMapping.java From GPT with Apache License 2.0 | 5 votes |
/** * generateActivityInfo * * @param p PackageParser.Package * @param pi PackageInfo * @param flags flags */ private void generateActivityInfo(PackageParser.Package p, PackageInfo pi, int flags) { PackageUserState state = new PackageUserState(); if ((flags & PackageManager.GET_ACTIVITIES) != 0) { int N = p.activities.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.activities.get(i).info.enabled) num++; } pi.activities = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.activities.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities[j++] = PackageParser.generateActivityInfo(activity, flags, state, 0); // try { // pi.activities[j++] = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generateActivityInfo", // activity, flags, state, 0); // } catch (Exception e) { // e.printStackTrace(); // } } } } } }
Example #15
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
long getDomainVerificationStatusForUser(int userId) { PackageUserState state = readUserState(userId); long result = (long) state.appLinkGeneration; result |= ((long) state.domainVerificationStatus) << 32; return result; }
Example #16
Source File: ApkTargetMapping.java From GPT with Apache License 2.0 | 4 votes |
/** * getPackageArchiveInfo * * @param parser android.content.pm.PackageParser * @param pkg PackageParser.Package * @param archiveFilePath archiveFilePath * @param flags flags * @return PackageInfo */ public PackageInfo getPackageArchiveInfo(android.content.pm.PackageParser parser, PackageParser.Package pkg, String archiveFilePath, int flags) { PackageInfo packageInfo = null; if ((flags & PackageManager.GET_SIGNATURES) != 0) { // 2.3 4.0 4.1 4.2 4.4 parser.collectCertificates(pkg, 0); // 5.0 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { parser.collectManifestDigest(pkg); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // 4.2 4.3 4.4 5.0 6.0 PackageUserState state = new PackageUserState(); //packageInfo = PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); try { // 这里使用反射。因为 permission 参数 在 5.0 5.1 6.0 上参数不同,但是我们传入的为 null packageInfo = JavaCalls.callStaticMethodOrThrow(PackageParser.class, "generatePackageInfo", pkg, null, flags, 0L, 0L, null, state); } catch (Exception e) { if (Constants.DEBUG) { e.printStackTrace(); } String methodInfo = JavaCalls .getMethodToString(JavaCalls.getMethodFromClass(PackageParser.class, "generatePackageInfo")); if (methodInfo == null) { methodInfo = ""; } throw new RuntimeException("generatePackageInfo get exception, " + methodInfo, e); } } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // 4.1 packageInfo = PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, false, 0); } else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { // 2.3 4.0 packageInfo = PackageParser.generatePackageInfo(pkg, null, flags, 0, 0); } return packageInfo; }
Example #17
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
String getHarmfulAppWarning(int userId) { PackageUserState userState = readUserState(userId); return userState.harmfulAppWarning; }
Example #18
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void setHarmfulAppWarning(int userId, String harmfulAppWarning) { PackageUserState userState = modifyUserState(userId); userState.harmfulAppWarning = harmfulAppWarning; }
Example #19
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** Only use for testing. Do NOT use in production code. */ @VisibleForTesting SparseArray<PackageUserState> getUserState() { return userState; }
Example #20
Source File: PackageSettingBase.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
void setEnabled(int state, int userId, String callingPackage) { PackageUserState st = modifyUserState(userId); st.enabled = state; st.lastDisableAppCaller = callingPackage; }