Merge "Add internal implementation for notifyPackageUse" into oc-mr1-dev

This commit is contained in:
TreeHugger Robot
2017-09-05 16:28:13 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 9 deletions

View File

@@ -378,4 +378,9 @@ public abstract class PackageManagerInternal {
* associated with an instant app. It may be kept after the instant app has been uninstalled. * associated with an instant app. It may be kept after the instant app has been uninstalled.
*/ */
public abstract boolean hasInstantApplicationMetadata(String packageName, int userId); public abstract boolean hasInstantApplicationMetadata(String packageName, int userId);
/**
* Updates a package last used time.
*/
public abstract void notifyPackageUse(String packageName, int reason);
} }

View File

@@ -3588,10 +3588,8 @@ public class ActivityManagerService extends IActivityManager.Stub
} }
void notifyPackageUse(String packageName, int reason) { void notifyPackageUse(String packageName, int reason) {
IPackageManager pm = AppGlobals.getPackageManager(); synchronized(this) {
try { getPackageManagerInternalLocked().notifyPackageUse(packageName, reason);
pm.notifyPackageUse(packageName, reason);
} catch (RemoteException e) {
} }
} }

View File

@@ -9844,13 +9844,17 @@ public class PackageManagerService extends IPackageManager.Stub
return; return;
} }
} }
notifyPackageUseLocked(packageName, reason);
}
}
private void notifyPackageUseLocked(String packageName, int reason) {
final PackageParser.Package p = mPackages.get(packageName); final PackageParser.Package p = mPackages.get(packageName);
if (p == null) { if (p == null) {
return; return;
} }
p.mLastPackageUsageTimeInMills[reason] = System.currentTimeMillis(); p.mLastPackageUsageTimeInMills[reason] = System.currentTimeMillis();
} }
}
@Override @Override
public void notifyDexLoad(String loadingPackageName, List<String> classLoaderNames, public void notifyDexLoad(String loadingPackageName, List<String> classLoaderNames,
@@ -25502,6 +25506,13 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
return mInstantAppRegistry.hasInstantApplicationMetadataLPr(packageName, userId); return mInstantAppRegistry.hasInstantApplicationMetadataLPr(packageName, userId);
} }
} }
@Override
public void notifyPackageUse(String packageName, int reason) {
synchronized (mPackages) {
PackageManagerService.this.notifyPackageUseLocked(packageName, reason);
}
}
} }
@Override @Override