Skip to content

Commit

Permalink
Add UI support for APIs 26 and 27 (Android 8.0 and 8.1 Oreo)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanchon committed Feb 25, 2019
1 parent d497127 commit b04e078
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 0 deletions.
1 change: 1 addition & 0 deletions bulk-patch-builder/build-all
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ build_all() {

build_one sigspoof-ui-global-4.1-6.0 "$tmp_dir"/sigspoof-core__fs/{1[6-9],2[1-3]}-*
build_one sigspoof-ui-global-7.0-7.1 "$tmp_dir"/sigspoof-core__fs/2[4-5]-*
build_one sigspoof-ui-global-8.0-8.1 "$tmp_dir"/sigspoof-core__fs/2[6-7]-*

rm -rf "$tmp_dir"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
* Copyright (C) 2015 Marvin W <https://github.com/mar-v-in>
* Copyright (C) 2016 Lanchon <https://github.com/Lanchon>
*
* This is Marvin's work converted to DexPatcher patches by Lanchon.
*
* https://gerrit.omnirom.org/#/c/14898/
* https://gerrit.omnirom.org/#/c/14899/
*
* 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.settings.development;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v14.preference.PreferenceFragment;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.TwoStatePreference;
import android.util.Log;

import com.android.settings.Utils;

import lanchon.dexpatcher.annotation.*;

@DexEdit(contentOnly = true)
public class DevelopmentSettings extends PreferenceFragment {

// SwitchPreference Hooks

@DexIgnore private final ArrayList<SwitchPreference> mResetSwitchPrefs = new ArrayList<SwitchPreference>();
@DexIgnore void updateSwitchPreference(SwitchPreference switchPreference, boolean value) { throw null; }

// CheckBoxPreference Hooks

@DexIgnore private final ArrayList<CheckBoxPreference> mResetCbPrefs = new ArrayList<CheckBoxPreference>();
@DexIgnore void updateCheckBox(CheckBoxPreference checkBox, boolean value) { throw null; }

// TwoStatePreference Interface

@DexAdd
private boolean useSwitchPreference() {
return Build.VERSION.SDK_INT >= 22; // Build.VERSION_CODES.LOLLIPOP_MR1
}

@DexAdd
private TwoStatePreference createTwoStatePreference(Context context) {
if (useSwitchPreference()) {
return new SwitchPreference(context);
} else {
return new CheckBoxPreference(context);
}
}

@DexAdd
private boolean mResetTwoStatePrefsAdd(TwoStatePreference preference) {
if (useSwitchPreference()) {
return mResetSwitchPrefs.add((SwitchPreference) preference);
} else {
return mResetCbPrefs.add((CheckBoxPreference) preference);
}
}

@DexAdd
private void updateTwoStatePreference(TwoStatePreference preference, boolean value) {
if (useSwitchPreference()) {
updateSwitchPreference((SwitchPreference) preference, value);
} else {
updateCheckBox((CheckBoxPreference) preference, value);
}
}

@DexAdd
static class FakeSignatureGlobalUI {

static final String DEBUG_APPLICATIONS_CATEGORY_KEY = "debug_applications_category";

static final String SETTING_SECURE_KEY = "allow_fake_signature_global";

static final String SETTING_TITLE =
"Allow signature spoofing";
static final String SETTING_SUMMARY =
//"Allow apps to bypass security systems by pretending to be a different app";
//"Allow apps to spoof information about their publisher";
"Allow apps to impersonate other apps";
static final String SETTING_WARNING =
//"Allowing apps to bypass security systems can lead to serious security and privacy problems! " +
//"Check that only benign apps use the corresponding permission when this is active.";
"Allowing apps to impersonate other apps has security and privacy implications. " +
"Malicious apps can use this functionality to access the private data of other apps.\n\n" +
"Make sure that you trust all installed apps that use the 'FAKE_PACKAGE_SIGNATURE' " +
"permission before enabling this setting.";

}

@DexIgnore private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();

@DexAdd private TwoStatePreference mAllowFakeSignatureGlobal;
@DexAdd /* private */ Dialog mAllowFakeSignatureGlobalDialog;

@DexIgnore
private DevelopmentSettings() { throw null; }

@DexIgnore
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { throw null; }

@DexAppend
@Override
public void onCreate(Bundle icicle) {
try {
PreferenceGroup pg = (PreferenceGroup) findPreference(
FakeSignatureGlobalUI.DEBUG_APPLICATIONS_CATEGORY_KEY);
if (pg != null) {
TwoStatePreference p = createTwoStatePreference(pg.getContext());
p.setKey(FakeSignatureGlobalUI.SETTING_SECURE_KEY);
p.setTitle(FakeSignatureGlobalUI.SETTING_TITLE);
p.setSummary(FakeSignatureGlobalUI.SETTING_SUMMARY);
p.setPersistent(false);
mResetTwoStatePrefsAdd(p);
mAllPrefs.add(p);
//pg.setOrderingAsAdded(true);
pg.addPreference(p);
mAllowFakeSignatureGlobal = p;
} else {
Log.e("DevelopmentSettings_FakeSignatureGlobalUI", "cannot find 'applications' preference category");
}
} catch (Throwable t) {
Log.e("DevelopmentSettings_FakeSignatureGlobalUI", "onCreate exception", t);
}
}

@DexAppend
private void updateAllOptions() {
if (mAllowFakeSignatureGlobal != null) {
updateAllowFakeSignatureGlobalOption();
}
}

@DexAdd
/* private */ void updateAllowFakeSignatureGlobalOption() {
boolean value = Settings.Secure.getInt(getActivity().getContentResolver(),
FakeSignatureGlobalUI.SETTING_SECURE_KEY, 0) != 0;
updateTwoStatePreference(mAllowFakeSignatureGlobal, value);
}

@DexWrap
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (Utils.isMonkeyRunning()) {
return false;
}
if (mAllowFakeSignatureGlobal != null) {
if (preference == mAllowFakeSignatureGlobal) {
writeAllowFakeSignatureGlobalOption();
return false;
}
}
return onPreferenceTreeClick(preference);
}

@DexAdd
private void writeAllowFakeSignatureGlobalOption() {
if (mAllowFakeSignatureGlobal.isChecked()) {
if (mAllowFakeSignatureGlobalDialog != null) {
dismissDialogs();
}
@DexAdd
class Listener implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
Settings.Secure.putInt(getActivity().getContentResolver(),
FakeSignatureGlobalUI.SETTING_SECURE_KEY, 1);
}
//updateAllowFakeSignatureGlobalOption(); // handled by onDismiss(...)
}
@Override
public void onDismiss(DialogInterface dialog) {
updateAllowFakeSignatureGlobalOption();
mAllowFakeSignatureGlobalDialog = null;
}
}
Listener listener = new Listener();
mAllowFakeSignatureGlobalDialog = new AlertDialog.Builder(getActivity())
.setMessage(FakeSignatureGlobalUI.SETTING_WARNING)
.setTitle(FakeSignatureGlobalUI.SETTING_TITLE)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setPositiveButton(android.R.string.yes, listener)
.setNegativeButton(android.R.string.no, listener)
.create();
mAllowFakeSignatureGlobalDialog.setOnDismissListener(listener);
mAllowFakeSignatureGlobalDialog.show();
} else {
Settings.Secure.putInt(getActivity().getContentResolver(),
FakeSignatureGlobalUI.SETTING_SECURE_KEY, 0);
updateAllowFakeSignatureGlobalOption();
}
}

@DexAppend
private void dismissDialogs() {
if (mAllowFakeSignatureGlobalDialog != null) {
mAllowFakeSignatureGlobalDialog.dismiss();
mAllowFakeSignatureGlobalDialog = null;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2015 Marvin W <https://github.com/mar-v-in>
* Copyright (C) 2016 Lanchon <https://github.com/Lanchon>
*
* This is Marvin's work converted to DexPatcher patches by Lanchon.
*
* https://gerrit.omnirom.org/#/c/14898/
* https://gerrit.omnirom.org/#/c/14899/
*
* 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.server.pm;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageParser;
import android.provider.Settings;

import lanchon.dexpatcher.annotation.*;

@DexEdit
class GeneratePackageInfoHook {

@DexAdd
static class FakeSignatureGlobalUI {
static final String SECURE_SETTING = "allow_fake_signature_global";
}

@DexReplace
private static boolean getGlobalEnable(PackageInfo pi, Context context, PackageParser.Package p, int flags, int userId) {
return Settings.Secure.getInt(context.getContentResolver(),
FakeSignatureGlobalUI.SECURE_SETTING, 0) != 0;
}

}
60 changes: 60 additions & 0 deletions patches/bulk-patch-builder.log
Original file line number Diff line number Diff line change
Expand Up @@ -1260,3 +1260,63 @@ info: dry run due to '--dry-run' option
********* BUILT AGAINST: 24-7.0-cm-14.0-20161011-UNOFFICIAL-hammerheadcaf-nyyu_tk__sigspoof-hook-7.0-8.1__sigspoof-core


********* BUILD: sigspoof-ui-global-8.0-8.1

****** build: sigspoof-ui-global-8.0-8.1
****** against: 26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core

>>> target directory: /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core
>>> build patch: services.jar
>>> build patch: Settings.apk

*** apply fileset patch (dry-run)
>>> apply patch: services.jar
>>> dexpatcher --api-level 26 --verbose --dry-run --multi-dex /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar.dex
DexPatcher version 1.6.2 by Lanchon (https://dexpatcher.github.io/)
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar'
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar.dex'
info: type 'com.android.server.pm.GeneratePackageInfoHook': method '<init>():void': (GeneratePackageInfoHook.java:33): implicit ignore of trivial default constructor
info: dry run due to '--dry-run' option
0 error(s), 0 warning(s)
>>> apply patch: Settings.apk
>>> dexpatcher --api-level 26 --verbose --dry-run --multi-dex /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk.dex
DexPatcher version 1.6.2 by Lanchon (https://dexpatcher.github.io/)
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk'
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk.dex'
info: dry run due to '--dry-run' option
0 error(s), 0 warning(s)

*** patch-fileset: success
*** build-patch: success

****** build: sigspoof-ui-global-8.0-8.1
****** against: 27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core

>>> target directory: /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core
>>> build patch: services.jar
>>> build patch: Settings.apk

*** apply fileset patch (dry-run)
>>> apply patch: services.jar
>>> dexpatcher --api-level 27 --verbose --dry-run --multi-dex /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar.dex
DexPatcher version 1.6.2 by Lanchon (https://dexpatcher.github.io/)
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar'
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/services.jar.dex'
info: type 'com.android.server.pm.GeneratePackageInfoHook': method '<init>():void': (GeneratePackageInfoHook.java:33): implicit ignore of trivial default constructor
info: dry run due to '--dry-run' option
0 error(s), 0 warning(s)
>>> apply patch: Settings.apk
>>> dexpatcher --api-level 27 --verbose --dry-run --multi-dex /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk /home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk.dex
DexPatcher version 1.6.2 by Lanchon (https://dexpatcher.github.io/)
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-core__fs/27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk'
info: read '/home/rod/android/haystack/git/bulk-patch-builder/../patches/tmp.$$$/sigspoof-ui-global-8.0-8.1/sigspoof-ui-global-8.0-8.1__27-8.1-lineage-15.1-20180109-UNOFFICIAL-falcon-carlosarriaga__sigspoof-hook-7.0-8.1__sigspoof-core/Settings.apk.dex'
info: dry run due to '--dry-run' option
0 error(s), 0 warning(s)

*** patch-fileset: success
*** build-patch: success

********* PUBLISH: sigspoof-ui-global-8.0-8.1
********* BUILT AGAINST: 26-8.0-lineage-15.0-20170915-UNOFFICIAL-falcon-allstargaurav__sigspoof-hook-7.0-8.1__sigspoof-core


Binary file not shown.
Binary file not shown.

0 comments on commit b04e078

Please sign in to comment.