-
Notifications
You must be signed in to change notification settings - Fork 0
Request to Merge #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: parent20290
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,6 +384,38 @@ public static int getAppIconId(final String packageName) { | |
} | ||
} | ||
|
||
|
||
/** | ||
* Return true if this is the first ever time that the application is installed on the device. | ||
* | ||
* @return true if this is the first ever time that the application is installed on the device. | ||
*/ | ||
public static boolean isFirstTimeInstall(){ | ||
try { | ||
Long firstInstallTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).firstInstallTime; | ||
Long lastUpdateTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).lastUpdateTime; | ||
return firstInstallTime == lastUpdateTime; | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
Comment on lines
+394
to
+400
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant calls to getPackageManager() and getPackageInfo(). Tell me moreIn both 'isFirstTimeInstall' and 'isAppUpgraded' methods, you're calling getPackageManager() and getPackageInfo() twice to get the firstInstallTime and lastUpdateTime. This is redundant and could impact performance. Consider retrieving the PackageInfo object once and then accessing both times from it. This will make the code more efficient. |
||
} | ||
|
||
/** | ||
* Return true if app was previously installed and this one is an update/upgrade to that one, returns false if this is a fresh installation and not an update/upgrade. | ||
* | ||
* @return true if app was previously installed and this one is an update/upgrade to that one, returns false if this is a fresh installation and not an update/upgrade. | ||
*/ | ||
public static boolean isAppUpgraded(){ | ||
try { | ||
Long firstInstallTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).firstInstallTime; | ||
Long lastUpdateTime = Utils.getApp().getPackageManager().getPackageInfo(this.getAppPackageName(), 0).lastUpdateTime; | ||
return firstInstallTime != lastUpdateTime; | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
Comment on lines
+409
to
+415
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add logging for exceptions in isAppUpgraded() method. Tell me moreIn the |
||
} | ||
|
||
|
||
/** | ||
* Return the application's package name. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add logging to exception handling in isFirstTimeInstall().
Tell me more
In the
isFirstTimeInstall()
method, you're catching a general Exception, but not logging any information about it. Consider adding a log statement to capture the exception details for debugging purposes. For example:Log.e("AppUtils", "Error checking first time install", e);