Merge "Fix crash when selecting AppInfo for uninstalled app from Recents."
This commit is contained in:
@@ -29,6 +29,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
@@ -164,6 +165,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private Preference mMemoryPreference;
|
private Preference mMemoryPreference;
|
||||||
|
|
||||||
private boolean mDisableAfterUninstall;
|
private boolean mDisableAfterUninstall;
|
||||||
|
private boolean mListeningToPackageRemove;
|
||||||
|
private boolean mUninstallRequested;
|
||||||
|
|
||||||
// Used for updating notification preference.
|
// Used for updating notification preference.
|
||||||
private final NotificationBackend mBackend = new NotificationBackend();
|
private final NotificationBackend mBackend = new NotificationBackend();
|
||||||
|
|
||||||
@@ -336,6 +340,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
if (mFinishing) {
|
if (mFinishing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
stopListeningToPackageRemove();
|
||||||
mState.requestSize(mPackageName, mUserId);
|
mState.requestSize(mPackageName, mUserId);
|
||||||
AppItem app = new AppItem(mAppEntry.info.uid);
|
AppItem app = new AppItem(mAppEntry.info.uid);
|
||||||
app.addUid(mAppEntry.info.uid);
|
app.addUid(mAppEntry.info.uid);
|
||||||
@@ -352,12 +357,16 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
getLoaderManager().destroyLoader(LOADER_CHART_DATA);
|
getLoaderManager().destroyLoader(LOADER_CHART_DATA);
|
||||||
|
if (!mFinishing && !mUninstallRequested) {
|
||||||
|
startListeningToPackageRemove();
|
||||||
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
TrafficStats.closeQuietly(mStatsSession);
|
TrafficStats.closeQuietly(mStatsSession);
|
||||||
|
stopListeningToPackageRemove();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,21 +497,22 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == REQUEST_UNINSTALL) {
|
switch (requestCode) {
|
||||||
if (mDisableAfterUninstall) {
|
case REQUEST_UNINSTALL:
|
||||||
mDisableAfterUninstall = false;
|
if (mDisableAfterUninstall) {
|
||||||
new DisableChanger(this, mAppEntry.info,
|
mDisableAfterUninstall = false;
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
new DisableChanger(this, mAppEntry.info,
|
||||||
.execute((Object)null);
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
||||||
}
|
.execute((Object)null);
|
||||||
if (!refreshUi()) {
|
}
|
||||||
setIntentAndFinish(true, true);
|
// continue with following operations
|
||||||
}
|
case REQUEST_REMOVE_DEVICE_ADMIN:
|
||||||
}
|
if (!refreshUi()) {
|
||||||
if (requestCode == REQUEST_REMOVE_DEVICE_ADMIN) {
|
setIntentAndFinish(true, true);
|
||||||
if (!refreshUi()) {
|
} else {
|
||||||
setIntentAndFinish(true, true);
|
mUninstallRequested = false;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,6 +690,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
|
private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
|
||||||
|
mUninstallRequested = true;
|
||||||
// Create new intent to launch Uninstaller activity
|
// Create new intent to launch Uninstaller activity
|
||||||
Uri packageURI = Uri.parse("package:"+packageName);
|
Uri packageURI = Uri.parse("package:"+packageName);
|
||||||
Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
|
Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
|
||||||
@@ -769,6 +780,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
String packageName = mAppEntry.info.packageName;
|
String packageName = mAppEntry.info.packageName;
|
||||||
if (v == mUninstallButton) {
|
if (v == mUninstallButton) {
|
||||||
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
|
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
|
||||||
|
mUninstallRequested = true;
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
|
Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
|
||||||
uninstallDAIntent.putExtra(DeviceAdminAdd.EXTRA_DEVICE_ADMIN_PACKAGE_NAME,
|
uninstallDAIntent.putExtra(DeviceAdminAdd.EXTRA_DEVICE_ADMIN_PACKAGE_NAME,
|
||||||
@@ -1238,4 +1250,33 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mPermissionsPreference.setSummary(summary);
|
mPermissionsPreference.setSummary(summary);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void startListeningToPackageRemove() {
|
||||||
|
if (mListeningToPackageRemove) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mListeningToPackageRemove = true;
|
||||||
|
final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_REMOVED);
|
||||||
|
filter.addDataScheme("package");
|
||||||
|
getContext().registerReceiver(mPackageRemovedReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopListeningToPackageRemove() {
|
||||||
|
if (!mListeningToPackageRemove) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mListeningToPackageRemove = false;
|
||||||
|
getContext().unregisterReceiver(mPackageRemovedReceiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final BroadcastReceiver mPackageRemovedReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
if (!mFinishing && mAppEntry.info.packageName.equals(packageName)) {
|
||||||
|
getActivity().finishAndRemoveTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user