-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Iurii Makhno
committed
Mar 9, 2022
1 parent
2f2bb4b
commit 9666988
Showing
130 changed files
with
7,257 additions
and
1,725 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Source-code for java/com/android/tools/build/bundletool/archive/dex/classes.dex | ||
which is used to build APKs with build-mode ARCHIVE. |
119 changes: 119 additions & 0 deletions
119
archive/com/google/android/archive/ReactivateActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright (C) 2021 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.google.android.archive; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.content.ActivityNotFoundException; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
import android.net.Uri; | ||
|
||
/** Activity that triggers the reactivation of an app through the app store. */ | ||
public class ReactivateActivity extends Activity implements DialogInterface.OnClickListener { | ||
|
||
public static final String STORE_PACKAGE_NAME = "com.android.vending"; | ||
|
||
private boolean processingError; | ||
|
||
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
// Ensures we don't try to send another intent immediately after the first one failed, instead | ||
// an error dialog is shown. | ||
if (processingError) { | ||
return; | ||
} | ||
Intent intent = new Intent(); | ||
intent.setAction("com.google.android.STORE_ARCHIVE"); | ||
intent.setPackage(STORE_PACKAGE_NAME); | ||
try { | ||
startActivityForResult(intent, /* flags= */ 0); | ||
} catch (ActivityNotFoundException e) { | ||
// We handle this case in onActivityResult, because a RESULT_CANCELED is emitted. | ||
} | ||
} | ||
|
||
/** Returns true if the targeted Store is installed and enabled. */ | ||
private boolean isStoreInstalled() { | ||
try { | ||
return getPackageManager().getApplicationInfo(STORE_PACKAGE_NAME, 0).enabled; | ||
} catch (NameNotFoundException e) { | ||
return false; | ||
} | ||
} | ||
|
||
private AlertDialog buildErrorDialog() { | ||
AlertDialog.Builder dialog = | ||
new AlertDialog.Builder(this) | ||
.setTitle("Installation failed") | ||
.setCancelable(false) | ||
.setNeutralButton("Close", this) | ||
.setMessage( | ||
String.format( | ||
"The app %s is currently archived and must be reinstalled from an" | ||
+ " official app store.", | ||
getAppName())); | ||
|
||
if (isStoreInstalled()) { | ||
dialog.setPositiveButton("Reinstall", this); | ||
} | ||
|
||
return dialog.create(); | ||
} | ||
|
||
private String getAppName() { | ||
return getApplicationInfo().loadLabel(getPackageManager()).toString(); | ||
} | ||
|
||
@Override | ||
public void onClick(DialogInterface ignored, int buttonType) { | ||
processingError = false; | ||
switch (buttonType) { | ||
case DialogInterface.BUTTON_POSITIVE: | ||
openStorePageForApp(); | ||
break; | ||
case DialogInterface.BUTTON_NEUTRAL: | ||
default: | ||
// Nothing specific, just close the app. | ||
finish(); | ||
break; | ||
} | ||
} | ||
|
||
private void openStorePageForApp() { | ||
Intent intent = | ||
new Intent(Intent.ACTION_VIEW) | ||
.setPackage(STORE_PACKAGE_NAME) | ||
.setData(Uri.parse(String.format("market://details?id=%s", getPackageName()))); | ||
|
||
startActivity(intent); | ||
} | ||
|
||
@Override | ||
public void onActivityResult(int ignored1, int resultCode, Intent ignored2) { | ||
if (resultCode == Activity.RESULT_CANCELED) { | ||
processingError = true; | ||
buildErrorDialog().show(); | ||
} else { | ||
// At this point the reactivation has completed and the app should be restarted immediately, | ||
// if there is some delay here we don't want to show an empty activity. | ||
finish(); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
archive/com/google/android/archive/UpdateBroadcastReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2021 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.google.android.archive; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import java.io.File; | ||
|
||
/** Clears up the app's cache once it has been archived. */ | ||
public class UpdateBroadcastReceiver extends BroadcastReceiver { | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
if (intent.getAction().equals(Intent.ACTION_MY_PACKAGE_REPLACED)) { | ||
deleteDir(context.getCacheDir()); | ||
} | ||
} | ||
|
||
private static void deleteDir(File dir) { | ||
File[] contents = dir.listFiles(); | ||
if (contents != null) { | ||
for (File file : contents) { | ||
deleteDir(file); | ||
} | ||
} | ||
dir.delete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
release_version = 1.8.2 | ||
release_version = 1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.