Loading packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java +61 −38 Original line number Original line Diff line number Diff line Loading @@ -41,6 +41,15 @@ import java.util.List; public class InstallSuccess extends AlertActivity { public class InstallSuccess extends AlertActivity { private static final String LOG_TAG = InstallSuccess.class.getSimpleName(); private static final String LOG_TAG = InstallSuccess.class.getSimpleName(); @Nullable private PackageUtil.AppSnippet mAppSnippet; @Nullable private String mAppPackageName; @Nullable private Intent mLaunchIntent; @Override @Override protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); Loading @@ -55,40 +64,55 @@ public class InstallSuccess extends AlertActivity { Intent intent = getIntent(); Intent intent = getIntent(); ApplicationInfo appInfo = ApplicationInfo appInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO); intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO); mAppPackageName = appInfo.packageName; Uri packageURI = intent.getData(); Uri packageURI = intent.getData(); // Set header icon and title // Set header icon and title PackageUtil.AppSnippet as; PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager(); if ("package".equals(packageURI.getScheme())) { if ("package".equals(packageURI.getScheme())) { as = new PackageUtil.AppSnippet(pm.getApplicationLabel(appInfo), mAppSnippet = new PackageUtil.AppSnippet(pm.getApplicationLabel(appInfo), pm.getApplicationIcon(appInfo)); pm.getApplicationIcon(appInfo)); } else { } else { File sourceFile = new File(packageURI.getPath()); File sourceFile = new File(packageURI.getPath()); as = PackageUtil.getAppSnippet(this, appInfo, sourceFile); mAppSnippet = PackageUtil.getAppSnippet(this, appInfo, sourceFile); } mLaunchIntent = getPackageManager().getLaunchIntentForPackage(mAppPackageName); bindUi(); } } } mAlert.setIcon(as.icon); @Override mAlert.setTitle(as.label); protected void onResume() { super.onResume(); bindUi(); } private void bindUi() { if (mAppSnippet == null) { return; } mAlert.setIcon(mAppSnippet.icon); mAlert.setTitle(mAppSnippet.label); mAlert.setView(R.layout.install_content_view); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null, mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null, null); null); mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done), mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done), (ignored, ignored2) -> { (ignored, ignored2) -> { if (appInfo.packageName != null) { if (mAppPackageName != null) { Log.i(LOG_TAG, "Finished installing " + appInfo.packageName); Log.i(LOG_TAG, "Finished installing " + mAppPackageName); } } finish(); finish(); }, null); }, null); setupAlert(); setupAlert(); requireViewById(R.id.install_success).setVisibility(View.VISIBLE); requireViewById(R.id.install_success).setVisibility(View.VISIBLE); // Enable or disable "launch" button // Enable or disable "launch" button Intent launchIntent = getPackageManager().getLaunchIntentForPackage( appInfo.packageName); boolean enabled = false; boolean enabled = false; if (launchIntent != null) { if (mLaunchIntent != null) { List<ResolveInfo> list = getPackageManager().queryIntentActivities(launchIntent, List<ResolveInfo> list = getPackageManager().queryIntentActivities(mLaunchIntent, 0); 0); if (list != null && list.size() > 0) { if (list != null && list.size() > 0) { enabled = true; enabled = true; Loading @@ -99,7 +123,7 @@ public class InstallSuccess extends AlertActivity { if (enabled) { if (enabled) { launchButton.setOnClickListener(view -> { launchButton.setOnClickListener(view -> { try { try { startActivity(launchIntent); startActivity(mLaunchIntent); } catch (ActivityNotFoundException | SecurityException e) { } catch (ActivityNotFoundException | SecurityException e) { Log.e(LOG_TAG, "Could not start activity", e); Log.e(LOG_TAG, "Could not start activity", e); } } Loading @@ -110,4 +134,3 @@ public class InstallSuccess extends AlertActivity { } } } } } } } Loading
packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java +61 −38 Original line number Original line Diff line number Diff line Loading @@ -41,6 +41,15 @@ import java.util.List; public class InstallSuccess extends AlertActivity { public class InstallSuccess extends AlertActivity { private static final String LOG_TAG = InstallSuccess.class.getSimpleName(); private static final String LOG_TAG = InstallSuccess.class.getSimpleName(); @Nullable private PackageUtil.AppSnippet mAppSnippet; @Nullable private String mAppPackageName; @Nullable private Intent mLaunchIntent; @Override @Override protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); Loading @@ -55,40 +64,55 @@ public class InstallSuccess extends AlertActivity { Intent intent = getIntent(); Intent intent = getIntent(); ApplicationInfo appInfo = ApplicationInfo appInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO); intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO); mAppPackageName = appInfo.packageName; Uri packageURI = intent.getData(); Uri packageURI = intent.getData(); // Set header icon and title // Set header icon and title PackageUtil.AppSnippet as; PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager(); if ("package".equals(packageURI.getScheme())) { if ("package".equals(packageURI.getScheme())) { as = new PackageUtil.AppSnippet(pm.getApplicationLabel(appInfo), mAppSnippet = new PackageUtil.AppSnippet(pm.getApplicationLabel(appInfo), pm.getApplicationIcon(appInfo)); pm.getApplicationIcon(appInfo)); } else { } else { File sourceFile = new File(packageURI.getPath()); File sourceFile = new File(packageURI.getPath()); as = PackageUtil.getAppSnippet(this, appInfo, sourceFile); mAppSnippet = PackageUtil.getAppSnippet(this, appInfo, sourceFile); } mLaunchIntent = getPackageManager().getLaunchIntentForPackage(mAppPackageName); bindUi(); } } } mAlert.setIcon(as.icon); @Override mAlert.setTitle(as.label); protected void onResume() { super.onResume(); bindUi(); } private void bindUi() { if (mAppSnippet == null) { return; } mAlert.setIcon(mAppSnippet.icon); mAlert.setTitle(mAppSnippet.label); mAlert.setView(R.layout.install_content_view); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null, mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null, null); null); mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done), mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done), (ignored, ignored2) -> { (ignored, ignored2) -> { if (appInfo.packageName != null) { if (mAppPackageName != null) { Log.i(LOG_TAG, "Finished installing " + appInfo.packageName); Log.i(LOG_TAG, "Finished installing " + mAppPackageName); } } finish(); finish(); }, null); }, null); setupAlert(); setupAlert(); requireViewById(R.id.install_success).setVisibility(View.VISIBLE); requireViewById(R.id.install_success).setVisibility(View.VISIBLE); // Enable or disable "launch" button // Enable or disable "launch" button Intent launchIntent = getPackageManager().getLaunchIntentForPackage( appInfo.packageName); boolean enabled = false; boolean enabled = false; if (launchIntent != null) { if (mLaunchIntent != null) { List<ResolveInfo> list = getPackageManager().queryIntentActivities(launchIntent, List<ResolveInfo> list = getPackageManager().queryIntentActivities(mLaunchIntent, 0); 0); if (list != null && list.size() > 0) { if (list != null && list.size() > 0) { enabled = true; enabled = true; Loading @@ -99,7 +123,7 @@ public class InstallSuccess extends AlertActivity { if (enabled) { if (enabled) { launchButton.setOnClickListener(view -> { launchButton.setOnClickListener(view -> { try { try { startActivity(launchIntent); startActivity(mLaunchIntent); } catch (ActivityNotFoundException | SecurityException e) { } catch (ActivityNotFoundException | SecurityException e) { Log.e(LOG_TAG, "Could not start activity", e); Log.e(LOG_TAG, "Could not start activity", e); } } Loading @@ -110,4 +134,3 @@ public class InstallSuccess extends AlertActivity { } } } } } } }