Skip to content

Commit

Permalink
UPDATE: Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
oasisfeng committed Jul 22, 2019
1 parent 9c34c41 commit 7cf4932
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 24 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ dependencies {
implementation project(':biometric')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"
implementation 'androidx.lifecycle:lifecycle-common-java8:2.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<string name="action_freeze">冻结</string>
<string name="action_unfreeze">解除冻结</string>
<string name="action_shortcut">创建“解冻并启动”快捷方式</string>
<string name="action_greenify">委托绿色守护自动冻结</string>
<string name="action_greenify">委托“绿色守护”自动冻结</string>
<string name="action_app_settings">应用设置</string>
<string name="action_remove">移除分身</string>
<string name="action_uninstall">卸载</string>
Expand Down Expand Up @@ -144,8 +144,8 @@
<string name="pref_launch_shortcut_prefix_title">应用启动快捷方式的名称前缀</string>
<string name="pref_show_admin_message_title">在操作限制界面中显示提示信息</string>
<string name="pref_show_admin_message_summary">在系统弹出的“不允许执行此操作”对话框中显示针对性的提示信息。</string>
<string name="pref_preserve_app_ops">为解冻的应用恢复 App-Ops</string>
<string name="pref_preserve_app_ops_description">Android 系统不会为冻结的应用保留已设置的 App-Ops(权限限制,例如“后台限制”、“显示在其它应用的上层”),炼妖壶可以为其提供恢复。</string>
<string name="pref_preserve_app_ops">为解冻的应用恢复 App Ops</string>
<string name="pref_preserve_app_ops_description">Android 系统不会为冻结的应用保留已设置的 App Ops(权限限制,例如“后台限制”、“显示在其它应用的上层”),炼妖壶可以为其提供恢复。</string>
<string name="pref_preserve_app_ops_adb_footnote">\n\n(需要执行 ADB 指令,仅在首次开启时)</string>
<string name="prompt_adb_app_ops_command">请在 ADB 命令行执行以下指令:\n\n</string>
<string name="action_copy">复制至剪贴板</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ the sandbox environment. Island never collect data related to your privacy, plea

<string name="pref_general_header">General</string>
<string name="pref_launch_shortcut_prefix_title">Launch shortcut prefix</string>
<string name="pref_show_admin_message_title">Extra info in "Action not allowed" dialog</string>
<string name="pref_show_admin_message_title">Extra info in \"Action not allowed\" dialog</string>
<string name="pref_show_admin_message_summary">Show Island-specific extra information in the \"Action not allowed\" system dialog.</string>
<string name="pref_preserve_app_ops">Preserve App-Ops for frozen apps</string>
<string name="pref_preserve_app_ops_description">Android system does not preserve the App-Ops (permission override) settings (e.g. \"background restriction\", \"show above other apps\") for frozen apps, let Island do that for you.</string>
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

buildscript {
ext.kotlin_version = '1.3.40'
ext.kotlin_coroutine_version = '1.3.0-M2'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0-beta05'
classpath 'com.android.tools.build:gradle:3.5.0-rc01'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand Down
8 changes: 4 additions & 4 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ android {
dependencies {
implementation project(':shared')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1'
implementation 'androidx.core:core:1.0.1' // ShortcutShuttle
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
implementation 'androidx.core:core:1.0.2' // ShortcutShuttle
implementation "androidx.core:core-ktx:1.0.2"

androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.util.Log;
import android.util.Pair;
import android.view.View;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.Toast;

Expand Down Expand Up @@ -276,7 +277,9 @@ private void performInstall(final Uri uri, final CharSequence app_description, f

final String progress_text = getString(mUpdateOrInstall == null ? R.string.progress_dialog_cloning : mUpdateOrInstall
? R.string.progress_dialog_updating : R.string.progress_dialog_installing, mCallerAppLabel.get(), app_description);
mProgressDialog = Dialogs.buildProgress(this, progress_text).indeterminate().nonCancelable().start();
try {
mProgressDialog = Dialogs.buildProgress(this, progress_text).indeterminate().nonCancelable().start();
} catch (final WindowManager.BadTokenException ignored) {} // Activity may no longer visible.
}

private void fallbackToSystemPackageInstaller(final String reason, final @Nullable Exception e) {
Expand Down
30 changes: 16 additions & 14 deletions shared/src/main/java/com/oasisfeng/island/appops/AppOpsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.util.Log;

import com.oasisfeng.island.util.Hacks;
import com.oasisfeng.island.util.OwnerUser;
import com.oasisfeng.island.util.ProfileUser;

import java.util.Arrays;
Expand All @@ -25,19 +26,20 @@

private static final String PREFS_NAME = "app_ops";

/** @return whether anything is saved. False will be returned for failure */
@ProfileUser @RequiresPermission(GET_APP_OPS_STATS)
public static boolean saveAppOps(final Context context, final String pkg) throws PackageManager.NameNotFoundException {
final List<Hacks.AppOpsManager.PackageOps> list = new AppOpsCompat(context)
.getOpsForPackage(context.getPackageManager().getPackageUid(pkg, MATCH_DISABLED_COMPONENTS), pkg, null);
final SharedPreferences.Editor store = getDeviceProtectedSharedPreferences(context).edit();
@OwnerUser @ProfileUser @RequiresPermission(GET_APP_OPS_STATS)
public static void saveAppOps(final Context context, final String pkg) throws PackageManager.NameNotFoundException {
final SharedPreferences store = getDeviceProtectedSharedPreferences(context); // As early as possible since the async loading takes time.

final int uid = context.getPackageManager().getPackageUid(pkg, MATCH_DISABLED_COMPONENTS);
final List<Hacks.AppOpsManager.PackageOps> list = new AppOpsCompat(context).getOpsForPackage(uid, pkg, null);
final String flat_pkg_ops = list == null || list.isEmpty() ? null : list.stream().filter(ops -> pkg.equals(ops.getPackageName()))
.flatMap(ops -> ops.getOps().stream()).filter(entry -> ! isDefaultMode(entry.getOp(), entry.getMode())).map(entry -> entry.getOp() + ":" + entry.getMode())
.collect(Collectors.joining(","));
if (flat_pkg_ops == null || flat_pkg_ops.isEmpty()) store.remove(pkg).apply();
else store.putString(pkg, flat_pkg_ops).apply();
Log.d(TAG, "App ops saved for " + pkg + ": " + flat_pkg_ops);
return true;
.flatMap(ops -> ops.getOps().stream()).filter(entry -> ! isDefaultMode(entry.getOp(), entry.getMode()))
.map(entry -> entry.getOp() + ":" + entry.getMode()).collect(Collectors.joining(","));

if (flat_pkg_ops != null && ! flat_pkg_ops.isEmpty()) {
store.edit().putString(pkg, flat_pkg_ops).apply();
Log.d(TAG, "App-ops saved for " + pkg + ": " + flat_pkg_ops);
} else store.edit().remove(pkg).apply();
}

private static boolean isDefaultMode(final int op, final int mode) { // DO NOT pass in OpEntry as parameter, which causes disaster after R8. (as of AS 3.5 Beta 5)
Expand All @@ -54,8 +56,8 @@ private static boolean isDefaultMode(final int op, final int mode) { // DO NOT p
final int mode = Integer.parseInt(splits[1].substring(0, 1));
app_ops.setMode(op, uid, pkg, mode);
});
Log.d(TAG, "App ops restored for " + pkg + ": " + pkg_ops);
return false;
Log.d(TAG, "App-ops restored for " + pkg + ": " + pkg_ops);
return true;
}

private static SharedPreferences getDeviceProtectedSharedPreferences(final Context context) {
Expand Down

0 comments on commit 7cf4932

Please sign in to comment.