Loading AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ <activity android:name=".InstallStaging" android:exported="false" /> <activity android:name=".DeleteStagedFileOnResult" android:exported="false" /> <activity android:name=".PackageInstallerActivity" android:exported="false" /> Loading src/com/android/packageinstaller/DeleteStagedFileOnResult.java 0 → 100644 +50 −0 Original line number Diff line number Diff line /* * Copyright 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.packageinstaller; import android.annotation.Nullable; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import java.io.File; /** * Trampoline activity. Calls PackageInstallerActivity and deletes staged install file onResult. */ public class DeleteStagedFileOnResult extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { Intent installIntent = new Intent(getIntent()); installIntent.setClass(this, PackageInstallerActivity.class); installIntent.setFlags(installIntent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT); startActivityForResult(installIntent, 0); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { File sourceFile = new File(getIntent().getData().getPath()); sourceFile.delete(); setResult(resultCode, data); finish(); } } src/com/android/packageinstaller/InstallStaging.java +22 −33 Original line number Diff line number Diff line Loading @@ -74,25 +74,10 @@ public class InstallStaging extends Activity { }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { setResult(resultCode, data); if (mStagedFile != null) { mStagedFile.delete(); } // This is executed before onResume but after the mStagingTask completed, hence no need // to deal with the task. finish(); } @Override protected void onResume() { super.onResume(); // In some cases onResume might be called even if onActivityResult finished the activity. if (!isFinishing()) { // This is the first onResume in a single life of the activity if (mStagingTask == null) { // File does not exist, or became invalid Loading @@ -110,7 +95,6 @@ public class InstallStaging extends Activity { mStagingTask.execute(getIntent().getData()); } } } @Override protected void onSaveInstanceState(Bundle outState) { Loading Loading @@ -210,12 +194,17 @@ public class InstallStaging extends Activity { if (success) { // Now start the installation again from a file Intent installIntent = new Intent(getIntent()); installIntent.setClass(InstallStaging.this, PackageInstallerActivity.class); installIntent.setClass(InstallStaging.this, DeleteStagedFileOnResult.class); installIntent.setData(Uri.fromFile(mStagedFile)); installIntent .setFlags(installIntent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT); if (installIntent.getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) { installIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); } installIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivityForResult(installIntent, 0); startActivity(installIntent); InstallStaging.this.finish(); } else { showError(); } Loading Loading
AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ <activity android:name=".InstallStaging" android:exported="false" /> <activity android:name=".DeleteStagedFileOnResult" android:exported="false" /> <activity android:name=".PackageInstallerActivity" android:exported="false" /> Loading
src/com/android/packageinstaller/DeleteStagedFileOnResult.java 0 → 100644 +50 −0 Original line number Diff line number Diff line /* * Copyright 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.packageinstaller; import android.annotation.Nullable; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import java.io.File; /** * Trampoline activity. Calls PackageInstallerActivity and deletes staged install file onResult. */ public class DeleteStagedFileOnResult extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { Intent installIntent = new Intent(getIntent()); installIntent.setClass(this, PackageInstallerActivity.class); installIntent.setFlags(installIntent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT); startActivityForResult(installIntent, 0); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { File sourceFile = new File(getIntent().getData().getPath()); sourceFile.delete(); setResult(resultCode, data); finish(); } }
src/com/android/packageinstaller/InstallStaging.java +22 −33 Original line number Diff line number Diff line Loading @@ -74,25 +74,10 @@ public class InstallStaging extends Activity { }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { setResult(resultCode, data); if (mStagedFile != null) { mStagedFile.delete(); } // This is executed before onResume but after the mStagingTask completed, hence no need // to deal with the task. finish(); } @Override protected void onResume() { super.onResume(); // In some cases onResume might be called even if onActivityResult finished the activity. if (!isFinishing()) { // This is the first onResume in a single life of the activity if (mStagingTask == null) { // File does not exist, or became invalid Loading @@ -110,7 +95,6 @@ public class InstallStaging extends Activity { mStagingTask.execute(getIntent().getData()); } } } @Override protected void onSaveInstanceState(Bundle outState) { Loading Loading @@ -210,12 +194,17 @@ public class InstallStaging extends Activity { if (success) { // Now start the installation again from a file Intent installIntent = new Intent(getIntent()); installIntent.setClass(InstallStaging.this, PackageInstallerActivity.class); installIntent.setClass(InstallStaging.this, DeleteStagedFileOnResult.class); installIntent.setData(Uri.fromFile(mStagedFile)); installIntent .setFlags(installIntent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT); if (installIntent.getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) { installIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); } installIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivityForResult(installIntent, 0); startActivity(installIntent); InstallStaging.this.finish(); } else { showError(); } Loading